Development

Prerequisites#

Build#

git clone https://gitlab.com/gitlab-org/ci-cd/runner-tools/glci
cd glci
make build    # same identity as a `go build` in the clone; see below
make docker   # required: builds glci:local image

The glci:local Docker image contains the mock server binary and should match the CLI binary’s build commit. Nothing checks this up front. glci picks the first image it finds (see how the image is resolved) and does not compare it with the binary. A mismatch that breaks the run makes preparation fail within about 30 seconds, with an error that names the image and the binary’s version. The auto-restart on version mismatch compares the CLI process with the running daemon process, not with the image. Always re-run make docker after pulling new changes or switching branches.

The build embeds the git commit hash via linker flags so the daemon can detect version mismatches:

make build    # builds ./glci with embedded commit hash
make install  # installs to $GOPATH/bin with embedded commit hash

A plain go build inside the clone also knows its commit, because the Go toolchain embeds the Git revision, with local changes marked -dirty. So it behaves like make build. Only a build with no Git information (-buildvcs=false, or a copy of the source without .git) is a dev build with no identity. If both the CLI and daemon are such builds, glci prints a warning on each invocation because it cannot check that they match. The release version is never passed by linker flags. glci reads it from the module version or from the release tarball (see pkg/version), so no release step has to bump it.

A working tree that differs from HEAD in any way is stamped <sha>-dirty — the check is git status --porcelain, so untracked files count too. glci treats a -dirty stamp as unpublished and skips the commit-tagged image entirely: it never probes or pulls a -dirty tag, and uses the glci:local you built from the same tree instead of silently trusting the CI image for <sha>, which would not contain your changes.

Project structure#

glci/
├── cmd/glci/           # CLI entry point and subcommands
├── pkg/
│   ├── config/         # YAML parsing (offline + API-assisted), inputs, matrix expansion
│   ├── daemon/         # Background daemon: server, client, executor, eventbus,
│   │                   #   transport, crash recovery, execution state, registry
│   ├── enginestub/     # Test support: keeps unit tests off real container engines
│   ├── gitutil/        # Git helper utilities (diff, clean env)
│   ├── glciconfig/     # Config file parsing: ~/.glci/config.toml + .glciconfig.toml
│   ├── history/        # Pipeline persistence (~/.glci/projects/{key}/pipelines/)
│   ├── logparse/       # Trace output parsing: strip timestamps, colorize sections
│   ├── mockserver/     # Mock GitLab API, git HTTP, artifacts, cache, auth
│   ├── muxproto/       # Binary protocol for docker exec transport
│   ├── netguard/       # Test support: keeps unit tests off the real network
│   ├── pipeline/       # Pipeline graph rendering (ANSI, JSON, watch mode)
│   ├── planner/        # Execution plan: stages, DAG, filtering, auto-deps
│   ├── redact/         # Secret masking and mask-then-truncate excerpts of upstream text
│   ├── rules/          # rules: if: expression evaluation (boolean, regex, variables)
│   ├── runner/         # gitlab-runner integration: job spec JSON, config.toml generation
│   ├── scheduler/      # Concurrent job dispatch, DAG-aware, resource groups
│   ├── slug/           # GitLab's CI slug algorithm, shared by variables/ and runner/
│   ├── tui/            # Interactive TUI (bubbletea): app, graph, log viewer
│   ├── varexpand/      # $VAR / ${VAR} expansion, shared by variables/ and runner/
│   ├── variables/      # CI variable generation, API fetch, context simulation
│   └── version/        # Build-time version metadata
├── e2e/                # End-to-end and compatibility tests
│   └── testdata/       # Test fixtures (comprehensive CI config, golden fixtures)
├── docs/plan/          # Planning and sprint documents
└── Makefile

Test#

Unit tests require no Docker and no network access:

make test             # run all unit tests
make test-v           # verbose output
go test ./pkg/...     # run unit tests for a specific package subtree
go test ./pkg/config/ # run tests for a single package

Unit tests never touch a real container engine, even when your shell points at one through DOCKER_HOST, a Docker context or a Podman connection. Every test binary that links pkg/daemon (today pkg/daemon and cmd/glci) calls os.Exit(enginestub.Main(m)) from its TestMain. enginestub.Main puts stub docker and podman binaries first on PATH, and each stub records its call and fails the way an unreachable engine would. It also sets DOCKER_HOST and CONTAINER_HOST to an endpoint nothing listens on, sets DOCKER_CONFIG to an empty directory and CONTAINERS_CONF and PODMAN_CONNECTIONS_CONF to an empty file, and unsets DOCKER_CONTEXT, CONTAINER_CONNECTION, CONTAINER_SSHKEY, DOCKER_CERT_PATH and DOCKER_TLS_VERIFY. GLCI_DAEMON_SOCK points at a socket nothing listens on, so a CLI test can’t reach a daemon you have running. A test that needs other values sets them with t.Setenv. A test that runs a shell with its own PATH builds it with Stub.SystemPath instead of naming /usr/bin:/bin, which may hold a real docker. A guard test in pkg/enginestub fails when a package whose tests link pkg/daemon has no enginestub.Main call. A test that needs a real engine belongs behind the e2e build tag. The stubs are shell scripts, so these two packages’ unit tests refuse to run on Windows, which glci doesn’t support.

Unit tests don’t reach gitlab.com or any other remote host either. A test that needs a GitLab response serves it from an httptest.Server. If the test needs a real response, record it under the package’s testdata/. The pkg/config offline-parser tests parse real projects’ pipelines, and one of those pipelines has an absolute include: remote: URL. Their fixture server sends every request to the test server, whatever host the URL names. It serves <host>/<path> (the query string is ignored) from testdata/remote/<host>/<path>. When no recording exists, it fails the test and names the file to record.

pkg/netguard enforces this for the packages most likely to dial a host named in test input: pkg/config, pkg/daemon and cmd/glci. Each calls netguard.Install() from its TestMain and runs netguard.Check as a guard test. Install covers two routes:

A test that slips through fails at once with unit tests must not reach the real network, so a gitlab.com rate limit can’t make it fail at random. The guard doesn’t stop an IP-address dial through a transport the test built itself, or the network use of child processes such as git and glab. pkg/config also stubs the glab credential helper, so no pkg/config test runs glab. Other packages follow the rule by convention. A test that has to talk to a live GitLab belongs behind the e2e build tag, in the external tier.

Lint:

go vet ./...

Test tiers#

Tests are organized into tiers of increasing scope. Each tier is a separate Make target with no overlap between targets.

Tier 0: Unit tests (always run)#

make test       # no Docker, no network

Tier 1: Parse and golden tests#

make test-e2e-parse    # parse comprehensive pipeline fixture (~1m18s)
make test-e2e-golden   # compare pipeline JSON against golden fixtures (~1m20s)

These validate CI config parsing and pipeline structure without running any containers.

Tier 2: TUI tests#

make test-tui          # TUI and CLI rendering tests (~2m14s)

Tier 3: Integration tests#

These run real pipelines with Docker containers:

make test-integration              # stateless pipeline execution (~7m, Docker required)
                                   #   includes TestE2E_Submodule* — real submodule checkouts
make test-integration-light        # artifact CLI, CLI commands, daemon logs (~1m27s, no Docker)
make test-integration-cli          # CLI functional tests: lint, jobs, doctor, history (~1m)
make test-integration-cli-daemon   # CLI daemon-dependent tests: run, ps, log, registry (~3m, Docker)
make test-integration-docker       # Docker infra, DinD, containerized pipelines (~7m, Docker)
make test-integration-registry     # Registry push/pull/mirror tests (~7m, Docker)
make test-integration-lifecycle    # Crash recovery, force stop, daemon lifecycle (~7m, Docker)
make test-e2e-simulate             # Simulate comprehensive pipeline (~5m, Docker)

There is no local target for Podman. End-to-end Podman coverage lives only in CI, as the test:podman job: it starts rootful Podman in a privileged container on the DinD daemon, brings up the Docker-compatible API socket, and runs a one-job pipeline through it. The job is allow_failure: true for now, so a red test:podman does not block a pipeline — read its log rather than trusting the overall status. To reproduce a Podman issue locally, point glci at your own Podman ([docker] engine = "podman" in ~/.glci/config.toml) and run the normal integration targets.

Tier 4: Comprehensive compatibility#

make test-e2e-comprehensive          # full compat run (~4m, Docker, requires glci:local)
make test-e2e-comprehensive-release  # release pipeline compat (~3m, Docker)

These targets require the glci:local Docker image. Build with make docker first.

Tier 5: External (network required)#

make test-e2e-external   # real external repos (~50m, Docker + network)

Only run when explicitly needed. These clone external repositories and run full pipelines.

What to run for your changes#

Changed areaRun
Anything in pkg/make test
CLI commands (cobra)make test + make test-integration-cli + make test-integration-cli-daemon
TUImake test + make test-tui
Config parsing, rules, plannermake test + make test-e2e-parse
Pipeline JSON, when/allow_failuremake test + make test-e2e-golden
Mock server, scheduler, DAGmake test + make test-e2e-simulate
Pipeline execution, daemonmake test + make test-integration
Docker executor, DinDmake test + make test-integration-docker
Registry, push-throughmake test + make test-integration-registry
Daemon lifecycle, recoverymake test + make test-integration-lifecycle
Broad or uncertainmake test + make test-e2e-comprehensive

Override the timeout for long-running tests:

make test-e2e-comprehensive COMPAT_TIMEOUT=30m

Tail daemon logs during tests#

E2e tests run isolated daemon instances with their own GLCI_HOME. To tail the active test daemon’s log:

make test-logs

This finds the most recent daemon.log under .glci-compat-*/ or .glci-e2e-*/ and tails it.

Golden fixture updates#

If you change pipeline JSON output or parsing behavior, golden fixtures may need updating:

make golden-update    # regenerate golden fixtures from the GitLab API (network required)

Then verify the diff makes sense before committing.

Adding comprehensive test fixtures#

When adding a new CI keyword, runner config field, or mock server capability:

  1. Add a job exercising it to e2e/testdata/comprehensive/ci/jobs.yml
  2. Update the parse test (compat_pipeline_test.go)
  3. Update the full-run test (compat_test.go)
  4. Update all three golden fixtures in e2e/testdata/golden/comprehensive/*.json
  5. Rebuild glci:local with make docker
  6. Run make test-e2e-comprehensive

Some features need repository content that a fixture directory inside glci’s own repository cannot carry. Git submodules are the example: a gitlink cannot be committed under e2e/testdata/. The harness builds that content when it creates the project’s single commit. LocalSubmodules on compatProject (in e2e/compat_test.go) attaches the submodules that the comprehensive submodules jobs check out.

Key dependencies#

glci prefers external libraries over reimplementing. Key dependencies (see go.mod):

LibraryPurpose
cobraCLI framework
yaml.v3YAML parsing
BurntSushi/tomlTOML config files
bubbletea / bubbles / lipglossInteractive TUI
go-containerregistryOCI registry implementation
testifyTest assertions
fsnotifyFile watching
schollz/progressbarProgress bars
mattn/go-isattyTTY detection
gofrs/flockAdvisory inter-process file locking (serializes daemon spawns and bare repo cache access)
stdlib net/httpHTTP routing (no framework)

Development plan#

Development is organized in incremental sprints documented in docs/plan/. Each sprint has a dedicated design document covering the problem, approach, and implementation details.

Architecture and design decisions are documented in ARCHITECTURE.md.

Git hooks#

Install a pre-push hook that runs a quick lint pipeline before each push:

make install-hooks

This installs a pre-push hook that runs glci run -p precheck.

Release process#

Releases are automated via Make:

make release              # bump minor version, generate changelog, tag, push
make release BUMP=patch   # bump patch version instead
make release BUMP=major   # bump major version

This generates a changelog from GitLab merge request labels, commits it, creates a git tag, and pushes.

Changelog generation#

CHANGELOG.md is generated by git-cliff from cliff.toml and is never edited by hand — run make regenerate_changelog instead. The per-release pages under site/content/changelog/ are derived from it by scripts/generate-changelog-pages.sh, which preserves any hand-written <!-- NOTABLE:START --> block.

Each release lists its sections in a fixed order:

  1. Community contributions
  2. New features
  3. Bug fixes
  4. Maintenance
  5. Other changes

Crediting community contributions#

Merge requests labelled Community contribution on GitLab get their own section at the top of the release, rendered from the merge request title and linked to the merge request, with a credit to its author:

### Community contributions
- feat: add Podman container-engine support alongside Docker [!141](https://gitlab.com/gitlab-org/ci-cd/runner-tools/glci/-/merge_requests/141) — thanks [@paramah](https://gitlab.com/paramah)!

The label is the only thing that drives this, so a community merge request must carry the Community contribution label before it is merged — the changelog reads the label off the merge request, and an unlabelled contribution is credited to nobody.

Mechanically:

Demo recordings#

The home page features terminal demo videos recorded with VHS. Tape files (recording scripts) live in demos/tapes/, numbered in display order:

demos/
├── tapes/
│   ├── 01-lint.tape          # CI Lint
│   ├── 02-run.tape           # Run Pipeline
│   ├── 03-context.tape       # Context Simulation
│   ├── 04-artifacts.tape     # Artifact Download
│   ├── 05-registry.tape      # Local Docker Registry
│   ├── 06-pages.tape         # Pages Preview
│   └── 07-tui.tape           # Interactive TUI
├── output/                   # Generated mp4 files
└── project/                  # Demo project with .gitlab-ci.yml

Prerequisites#

Make targets#

make demos           # build only changed demos + copy to site/static/demos/
make demos-rebuild   # clean all + rebuild everything
make demos-clean     # delete all generated mp4s

Adding a new demo#

  1. Create demos/tapes/NN-name.tape following the existing tape format (same Set Theme, Set FontSize 36, Set Width 2400, Set Height 1200)
  2. Set the output path: Output ../output/NN-name.mp4
  3. If the demo needs a custom CI config, add it to demos/project/ (e.g. .gitlab-ci.registry.yml)
  4. Add a tab button and video panel in site/layouts/home.html
  5. Run make demos to record and copy to site/static/demos/

Tape conventions#

All tapes share identical settings for visual consistency:

Playback speed varies per demo (Set PlaybackSpeed). The site JS also applies 1.5× playback on videos, so the effective speed is PlaybackSpeed × 1.5.

Rebuilding a single demo#

cd demos/project
vhs ../../demos/tapes/01-lint.tape
cp ../output/01-lint.mp4 ../../site/static/demos/

License#

MIT

Esc