ci: cache elc binary + Docker layers, asset changes from 42min to ~5min
Deploy marketing to Cloud Run / deploy (push) Has been cancelled

- deploy.yaml: restore elc from GCS (gs://neuron-ci-cache) keyed on
  source SHA; only compile on cache miss, then upload for future runs
- Dockerfile.stage: pre-compile el_runtime.o as its own layer so the
  expensive object is cached when only main.c changes between runs
- build-stage.sh: add --cache-from/--cache-to pointing at Artifact
  Registry so apt-get + compilation layers survive across cold builds
This commit is contained in:
Will Anderson
2026-05-02 17:30:18 -05:00
parent 2e73fce3b3
commit a185b8ae69
3 changed files with 32 additions and 3 deletions
+23 -1
View File
@@ -79,7 +79,27 @@ jobs:
sudo apt-get update -qq
sudo apt-get install -y --no-install-recommends build-essential libcurl4-openssl-dev libssl-dev
- name: Build elc fresh on the runner
- name: Restore elc binary from GCS cache
id: elc-cache
run: |
set -euo pipefail
# Cache key = SHA256 of both source files that produce elc
ELC_SRC_HASH=$(cat "$EL_HOME/dist/platform/elc.c" "$EL_HOME/el-compiler/runtime/el_runtime.c" | sha256sum | cut -c1-16)
CACHE_OBJ="gs://neuron-ci-cache/elc/linux-amd64/${ELC_SRC_HASH}/elc"
echo "elc_cache_key=${ELC_SRC_HASH}" >> "$GITHUB_OUTPUT"
echo "elc_cache_obj=${CACHE_OBJ}" >> "$GITHUB_OUTPUT"
if gsutil -q stat "$CACHE_OBJ" 2>/dev/null; then
echo "Cache hit: ${CACHE_OBJ}"
gsutil cp "$CACHE_OBJ" "$EL_HOME/dist/platform/elc"
chmod +x "$EL_HOME/dist/platform/elc"
echo "cache_hit=true" >> "$GITHUB_OUTPUT"
else
echo "Cache miss for key ${ELC_SRC_HASH}"
echo "cache_hit=false" >> "$GITHUB_OUTPUT"
fi
- name: Build elc (cache miss only)
if: steps.elc-cache.outputs.cache_hit != 'true'
run: |
set -euo pipefail
# The committed dist/platform/elc is arm64 from Will's mac. We
@@ -93,6 +113,8 @@ jobs:
-lcurl -lpthread -ldl -lm -lssl -lcrypto
file dist/platform/elc
ls -la dist/platform/elc
# Upload to GCS cache for future runs
gsutil cp dist/platform/elc "${{ steps.elc-cache.outputs.elc_cache_obj }}" || true
- name: Compute image tag
id: tag