Skip to content

Cache the gitleaks download so a GitHub outage can't fail the build - #662

Merged
coopernetes merged 1 commit into
mainfrom
chore/gitleaks-download-cache
Sep 14, 2026
Merged

coopernetes merged 1 commit into
mainfrom
chore/gitleaks-download-cache

Conversation

@coopernetes

Copy link
Copy Markdown
Member

fogwall-core downloads the gitleaks binary into build/generated-resources at build time and packs it into the jar. gradle clean — which every image build and every fresh CI runner does — wipes that, so the binary is re-downloaded from GitHub's release CDN on every build. Nothing caches it: the Docker cache mounts and setup-gradle cover ~/.gradle (deps), not the project build dir. A transient 504 from that CDN recently failed both the image build and the e2e job.

What changed

downloadGitleaks gains an optional, CI-owned cache and a retry:

  • If GITLEAKS_CACHE_DIR points somewhere, a binary already there is reused and a freshly downloaded one is written back, keyed by version (gitleaks_<version>_<target>) so a bump never serves a stale binary.
  • If it is unset — a laptop, a fresh clone — the layer is skipped and the task downloads straight to the resource classpath exactly as before.
  • The download retries a few times, so a flaky fetch is a slow build rather than a red one.

The cache dir is deliberately outside anything Gradle manages, so it can't disturb the build cache or the setup-gradle action's save/restore.

CI populates it: the Dockerfile mounts /gitleaks-cache as a BuildKit cache and sets GITLEAKS_CACHE_DIR for the image build; the four gradle-on-runner jobs (build, e2e, compose smoke, playwright) restore ~/.cache/gitleaks with actions/cache keyed on the gitleaks version.

Testing

Ran downloadGitleaks locally in all three modes: unset (downloads, leaves ~/.gradle untouched), cache set + empty (downloads and populates), cache set + populated (restores, no download).

🤖 Generated with Claude Code

fogwall-core downloads the gitleaks binary into build/generated-resources at
build time, and `gradle clean` — which every image build and fresh CI runner
does — wipes it, so it re-downloads from GitHub's release CDN on every build.
A transient 504 from that CDN recently failed the image build and the e2e job.

downloadGitleaks now reuses a binary from an optional cache directory
(GITLEAKS_CACHE_DIR) and writes a freshly downloaded one back to it, keyed by
version so a bump never serves a stale binary. The directory is deliberately
outside anything Gradle manages, so it can't disturb the build cache or the
setup-gradle action; when the variable is unset — a laptop, a fresh clone — the
task downloads exactly as before. The download also retries a few times, so a
flaky fetch is a slow build rather than a red one.

CI populates the cache: the Dockerfile mounts it as a BuildKit cache, and the
gradle jobs restore it with actions/cache keyed on the gitleaks version.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coopernetes
coopernetes force-pushed the chore/gitleaks-download-cache branch from 59f5af8 to 051d609 Compare September 14, 2026 16:38
@coopernetes
coopernetes merged commit 77bb0e6 into main Sep 14, 2026
23 checks passed
@coopernetes
coopernetes deleted the chore/gitleaks-download-cache branch September 14, 2026 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant