diff --git a/.github/actions/prepare-git-compatibility/action.yml b/.github/actions/prepare-git-compatibility/action.yml index 058d31a064c7..310154bfd479 100644 --- a/.github/actions/prepare-git-compatibility/action.yml +++ b/.github/actions/prepare-git-compatibility/action.yml @@ -4,13 +4,25 @@ description: Restore or build the pinned Linux Git binary for the compatibility runs: using: composite steps: + # Same scope as install-node-dependencies: a binary linked on a newer image's glibc fails on an older one. + - name: Resolve Git cache scope + id: git-cache-scope + shell: bash + run: | + scope="${ImageOS:-$RUNNER_OS}" + if [ -r /etc/os-release ]; then + . /etc/os-release + scope="${ID:-linux}-${VERSION_ID:-unknown}" + fi + echo "scope=$scope" >> "$GITHUB_OUTPUT" + # The default-branch warmer shares this key across PRs; a PR save is private to its merge ref. # Cache eviction remains possible, so keep the checksum-verified cold build below. - name: Cache baseline Git build uses: actions/cache@v5 with: path: ~/.cache/orca-git-compat/git-2.25.5 - key: git-compat-baseline-${{ runner.os }}-${{ runner.arch }}-2.25.5 + key: git-compat-baseline-${{ runner.os }}-${{ steps.git-cache-scope.outputs.scope }}-${{ runner.arch }}-2.25.5 # Finish the CPU-heavy build before any timed compatibility lanes start. - name: Build the baseline Git binary diff --git a/config/scripts/git-binary-compatibility-workflow.test.mjs b/config/scripts/git-binary-compatibility-workflow.test.mjs index c03c7973f6a8..ce8dd3687798 100644 --- a/config/scripts/git-binary-compatibility-workflow.test.mjs +++ b/config/scripts/git-binary-compatibility-workflow.test.mjs @@ -60,8 +60,14 @@ describe('Git binary compatibility PR gate', () => { // in whichever boundary case is running rather than as a slow build. expect(steps[matrixIndex].run).not.toContain('make -C') expect(baselineSteps[cacheIndex].with.path).toBe(BASELINE_DIR) + // Why the OS release in the key: a baseline linked against a newer image's glibc + // fails to load on an older runner while ubuntu-latest rolls over gradually. + const scopeIndex = names.indexOf('Resolve Git cache scope') + expect(scopeIndex).toBeGreaterThanOrEqual(0) + expect(scopeIndex).toBeLessThan(cacheIndex) + expect(baselineSteps[scopeIndex].run).toContain('. /etc/os-release') expect(baselineSteps[cacheIndex].with.key).toBe( - 'git-compat-baseline-${{ runner.os }}-${{ runner.arch }}-2.25.5' + 'git-compat-baseline-${{ runner.os }}-${{ steps.git-cache-scope.outputs.scope }}-${{ runner.arch }}-2.25.5' ) })