f7da091467
Create a new documentation file to provide guidance for using reusable GitLab CI templates in Unbound Software projects. Detail the repository overview, architecture, release pipeline workflow, key environment variables, and common usage patterns. Also, update `.gitignore` to exclude the CLAUDE directory from version control.
3.9 KiB
3.9 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Repository Overview
This is a collection of reusable GitLab CI templates for Unbound Software projects. These templates are designed to be included in other projects' .gitlab-ci.yml files to provide standardized CI/CD workflows.
Architecture
Template Files
- Defaults.gitlab-ci.yml: Default retry configuration for all jobs (handles runner failures, timeouts, etc.)
- Pre-Commit-Go.gitlab-ci.yml: Pre-commit job for Go projects using
unbound/pre-commitDocker image - Pre-Commit-Node.gitlab-ci.yml: Pre-commit job for Node.js projects using
unbound/pre-commit-nodeDocker image - Release.gitlab-ci.yml: Automated release management using git-cliff for changelog generation and version bumping
Release Pipeline Workflow
The Release template implements a sophisticated automated release workflow:
- unbound_release_preconditions_failed: Validates that
UNBOUND_RELEASE_TOKENis set - unbound_release_changelog: Generates changelog using git-cliff and bumps version
- unbound_release_handle_mr: Creates or updates a "next-release" branch and merge request with CHANGELOG.md and .version file
- unbound_release_prepare_release: Prepares release artifacts (CHANGES.md, VERSION)
- unbound_release_create_release: Creates GitLab release (when
UNBOUND_RELEASE_TAG_ONLY != "true") - unbound_release_tag: Creates git tag only (when
UNBOUND_RELEASE_TAG_ONLY == "true")
Key Environment Variables
UNBOUND_RELEASE_TOKEN: Personal/Project/Group Access Token with API access (required for release pipeline)UNBOUND_RELEASE_TAG_ONLY: Set to "true" to only create tags without full releasesCI_DEFAULT_BRANCH: The default branch (usually "main") where releases are createdGOPRIVATE: Set togitlab.com/unboundsoftwarein Go pre-commit template for private Go modulesPRE_COMMIT_HOME: Cache directory for pre-commit hooks
Docker Images
All images use SHA256 pinning for reproducibility and security:
unbound/pre-commit:v0.3.5- Go pre-commit environmentunbound/pre-commit-node:v0.0.23- Node.js pre-commit environmentorhunp/git-cliff:2.10.1- Changelog generation toolamd64/alpine:3.22.2- Lightweight base for shell scripts
Modifying Templates
When editing templates:
- Ensure Docker image references include both version tags and SHA256 digests
- Test changes by including the modified template in a test project's
.gitlab-ci.yml - Release pipeline jobs should maintain backward compatibility or increment major version
- Pre-commit templates should cache
PRE_COMMIT_HOMEfor performance
Common Patterns
Including Templates in Projects
Projects typically include these templates in their .gitlab-ci.yml:
include:
- project: 'unboundsoftware/ci-templates'
ref: main
file: 'Defaults.gitlab-ci.yml'
- project: 'unboundsoftware/ci-templates'
ref: main
file: 'Pre-Commit-Go.gitlab-ci.yml'
- project: 'unboundsoftware/ci-templates'
ref: main
file: 'Release.gitlab-ci.yml'
Version Management
- Version bumping follows conventional commits via git-cliff
.versionfile stores current version as JSON:{"version":"1.2.3"}CHANGELOG.mdis automatically maintained with full historyCHANGES.mdcontains only the latest/unreleased changes
Authentication
- Pre-commit Go template uses GitLab CI token for private Go module access via
.netrc - Release jobs use
UNBOUND_RELEASE_TOKENfor API operations (creating MRs, releases, tags)
Testing Changes
Since this repository contains templates only (no executable code), testing requires:
- Create a test project or use an existing project
- Point the include reference to your branch:
ref: your-feature-branch - Trigger the relevant pipeline in the consuming project
- Verify job behavior and outputs