Skip to content

Commit 682a2a0

Browse files
hyperpolymathclaude
andcommitted
perf(hypatia-scan): cache built scanner keyed on Hypatia HEAD + shallow clone
The reusable rebuilds Hypatia from source on every run; the full clone and `mix escript.build` dominate wall-clock, so even a trivial Dependabot bump triggers a full neurosymbolic build. Resolve Hypatia's HEAD SHA and key a build cache on it, so a fresh clone+build happens only when Hypatia actually changes; otherwise the prebuilt escript is restored and the existing [ ! -d ]/[ ! -f ] guards short-circuit. Also cache Hex/Mix and shallow-clone. No change to scan behaviour: correctness is preserved by the exact-SHA build-cache key (no restore-keys, which could leave a stale scanner in place and analyse with old rules). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 426368b commit 682a2a0

1 file changed

Lines changed: 34 additions & 1 deletion

File tree

.github/workflows/hypatia-scan-reusable.yml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,43 @@ jobs:
111111
elixir-version: '1.18'
112112
otp-version: '27'
113113

114+
# --- Hypatia build caching (perf) ---------------------------------------
115+
# The scanner is rebuilt from source on every run; the clone and
116+
# `mix escript.build` dominate wall-clock (a full neurosymbolic build on
117+
# every push, including trivial Dependabot bumps). Key the build cache on
118+
# Hypatia's HEAD so a fresh clone+build happens ONLY when Hypatia actually
119+
# changes; otherwise the prebuilt escript is restored and the clone/build
120+
# steps short-circuit on their existing `[ ! -d ]` / `[ ! -f ]` guards.
121+
- name: Resolve Hypatia version
122+
id: hypatia_ref
123+
run: echo "sha=$(git ls-remote https://github.com/hyperpolymath/hypatia.git HEAD | cut -f1)" >> "$GITHUB_OUTPUT"
124+
125+
- name: Cache Hex/Mix package cache
126+
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v4
127+
with:
128+
path: |
129+
~/.hex
130+
~/.mix
131+
~/.cache/hex
132+
key: hypatia-hexmix-${{ runner.os }}-otp27-elixir1.18-${{ steps.hypatia_ref.outputs.sha }}
133+
restore-keys: |
134+
hypatia-hexmix-${{ runner.os }}-otp27-elixir1.18-
135+
136+
- name: Cache built Hypatia scanner
137+
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v4
138+
with:
139+
path: ~/hypatia
140+
# Exact-SHA key, NO restore-keys on purpose: an exact match guarantees
141+
# we run the scanner built from that Hypatia commit. A partial (restore-
142+
# keys) hit would leave a STALE ~/hypatia in place, the `[ ! -d ]` guard
143+
# would then skip the re-clone, and the repo would be analysed with old
144+
# rules. On a miss we simply re-clone+rebuild that commit.
145+
key: hypatia-build-${{ runner.os }}-otp27-elixir1.18-${{ steps.hypatia_ref.outputs.sha }}
146+
114147
- name: Clone Hypatia
115148
run: |
116149
if [ ! -d "$HOME/hypatia" ]; then
117-
git clone https://github.com/hyperpolymath/hypatia.git "$HOME/hypatia"
150+
git clone --depth 1 https://github.com/hyperpolymath/hypatia.git "$HOME/hypatia"
118151
fi
119152
120153
- name: Build Hypatia scanner (if needed)

0 commit comments

Comments
 (0)