Speed up CI pipeline: split tool setup, cache Go modules/build #76
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
keyop-go/nfq_forwarder!76
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "issue35_speed_up_ci_pipeline"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #35 (in-repo portion - see comment on the ticket for suggested follow-up changes to the external CI image, which need to happen in that project separately)
Investigation
Pulled the actual trace logs for a recent lint job (pipeline 392, job 1074) and build job to find where the time actually goes, rather than guessing:
apt-get update && apt-get install -y libpam0g-dev yamllint iptables: ~6-7 seconds.go install github.com/goreleaser/goreleaser/v2@latest+go install github.com/zricethezav/gitleaks/v8@latest(both run unconditionally by the old combinedsetupMakefile target, regardless of which the calling target actually needed): ~2 minutes of a ~2.5 minute job - by far the dominant cost. Neither tool is baked into the CI image, so each downloads and compiles a large dependency tree from scratch on every single run, and - worse - every job installed both tools even though lint only ever needs gitleaks and build/package/release only ever need goreleaser..goreleaser.yaml's build matrix is already minimal (linux/amd64only) - no wasted cross-compilation there.Fix (this MR - no external changes needed)
setupintosetup-goreleaser/setup-gitleaks.build/package/releasenow depend only onsetup-goreleaser;check-secrets(lint's only caller of either) depends only onsetup-gitleaks.setupitself is kept as a combined convenience alias but nothing depends on it any more. This halves the wasted-install cost per job today, and bothcommand -vguards already become free no-ops the moment the image gains these tools (no further Makefile change needed then).GOPATH/GOCACHEnow point under$CI_PROJECT_DIRwith acache:block (keyed ongo.sum's content, so a dependency bump gets a fresh cache automatically) persisting the module download cache and build cache between pipeline runs - repeatedgo install/go build/go test/golangci-lintinvocations across pipelines can now reuse work instead of starting cold every time.apt-get install libpam0g-dev yamllint iptablesstep defensive (checks each one first viacommand -v/accheader probe, only installs what's actually missing) - today this still installs all three since the image doesn't have them, but it self-shrinks to a no-op automatically once it does, with no further.gitlab-ci.ymledit needed.Suggested follow-up in the external image (posting the same detail as a comment on #35 for tracking)
The real fix for the ~2-minute dominant cost is baking pinned versions of
goreleaserandgitleaksdirectly intoregistry.keyop.co.uk/keyop/docker/golang-ci(and ideallylibpam0g-dev/yamllint/iptablestoo, closing out the smaller remaining cost) - see the ticket comment for specifics. I don't have access to that project to make the change myself.Testing
make lint/make testboth clean locally;make -n build/make -n package/make -n check-secretsdry-runs confirm each target now only pulls in the one tool it actually needs..gitlab-ci.ymlvalidated withyamllintand a plain YAML parse.Docs
Added a
CLAUDE.mdDesign notes bullet with the full timing breakdown and reasoning, and a Known Issues entry tracking the pending external image update.requested review from @danny
assigned to @claude
mentioned in issue #35
LGTM
approved this merge request
aborted the automatic merge because the source branch was updated. Learn more.
added 1 commit
1fc8dc0e- Fix PATH after GOPATH override so go install'd tools are actually foundCompare with previous version
added 1 commit
daa6aefc- Exclude the Go module cache from yamllint's scanCompare with previous version
added 1 commit
c4dbec21- Document the PATH and yamllint follow-up fixes for issue #35Compare with previous version
mentioned in commit
8432b95b7a