Commit bf572be5
bf572be576e3Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
ci: cache build/test-results across CI runs
Each test rebuilds its parse→analyze→codegen→cc→link→run chain on every CI invocation; the per-test fork-exec cost adds up enough that Windows takes ~2x the Linux/macOS wall time.
Cache build/test-results keyed on the hash of every file that affects
a test outcome (test/, compiler sources, runtime sources, Makefile).
On hit, refresh .ok mtimes so make's incremental tracking skips them
through the stamp dependency that make all just touched. Any input
change misses the cache and reruns every test; no restore-keys
fallback, since a partial-match restore + mtime touch would risk
trusting stale .ok files ([[test-ok-stale]]).
Expected to help most on CI retries of the same commit (flaky-test reruns) and docs-only PRs. Per-PR effect for normal compiler/test work is limited because any change to test/ or the compiler invalidates the whole cache. We'll see if it pays for itself.
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- bf572be576e3
- Parent
- 2a8d002f5436
.github/workflows/ci.ymlmodifiedView file
if: runner.os == 'macOS' run: echo "/opt/homebrew/opt/coreutils/libexec/gnubin" >> "$GITHUB_PATH" # When every input the test result depends on is unchanged # (test/, compiler source, runtime source, Makefile), the # prior run's `.ok` stamps are still valid. Pulling them down # lets `make test` short-circuit each test via mtime tracking. # The hash key is the sole invalidator — any change to any # input file misses the cache and reruns every test. See # the post-build `touch` step for why mtimes need a refresh. - name: Restore test-results cache uses: actions/cache@v4 with: path: build/test-results key: tests-${{ matrix.os }}-${{ matrix.cc }}-${{ hashFiles('test/**', 'spinel_parse.c', 'spinel_analyze.rb', 'spinel_codegen.rb', 'compiler_helpers.rb', 'node_table_loader.rb', 'lib/**', 'Makefile') }} - name: Fetch libprism sources run: make deps - name: Build (parse + regexp + codegen) run: make -j$(getconf _NPROCESSORS_ONLN) LTO=0 all # `make all` just touched the compiler-binary stamps that every # `.ok` depends on, so without this refresh, make would treat # every cached `.ok` as stale and rerun each test. The cache # key already covers every input that affects the test outcome, # so bumping mtimes here is safe. - name: Refresh test-results mtimes run: | if [ -d build/test-results ]; then find build/test-results -name '*.ok' -exec touch {} + fi - name: Run tests # OPT=-O0 cuts cc time per test (each .rb compiles its own # generated C with $(CFLAGS) -Werror). Type-checking still make --version | head -1 sccache --version # See the posix job for the cache contract. Windows is the # biggest beneficiary because its per-test fork-exec cost # dwarfs the cache-restore step. - name: Restore test-results cache uses: actions/cache@v4 with: path: build/test-results key: tests-windows-mingw-gcc-${{ hashFiles('test/**', 'spinel_parse.c', 'spinel_analyze.rb', 'spinel_codegen.rb', 'compiler_helpers.rb', 'node_table_loader.rb', 'lib/**', 'Makefile') }} - name: Fetch libprism sources run: make deps - name: Build (parse + regexp + codegen) run: make -j$(nproc) LTO=0 all - name: Refresh test-results mtimes run: | if [ -d build/test-results ]; then find build/test-results -name '*.ok' -exec touch {} + fi - name: Run tests run: make -j$(nproc) test OPT=-O0