From 5dae738067414d235ee386abd690faf1a8da9ff4 Mon Sep 17 00:00:00 2001 From: Daniel Hiltgen Date: Mon, 8 Dec 2025 09:48:49 -0800 Subject: [PATCH] CI: use vendor base commit in cache keys (#13348) Prevent CGO from accidentally reusing old object files from the cache across vendor updates --- .github/workflows/release.yaml | 17 ++++++++++++++--- .github/workflows/test.yaml | 9 +++++++-- Makefile.sync | 8 ++++++-- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 8c3b3120..b4b9602b 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -16,13 +16,15 @@ jobs: outputs: GOFLAGS: ${{ steps.goflags.outputs.GOFLAGS }} VERSION: ${{ steps.goflags.outputs.VERSION }} + vendorsha: ${{ steps.changes.outputs.vendorsha }} steps: - uses: actions/checkout@v4 - name: Set environment id: goflags run: | - echo GOFLAGS="'-ldflags=-w -s \"-X=github.com/ollama/ollama/version.Version=${GITHUB_REF_NAME#v}\" \"-X=github.com/ollama/ollama/server.mode=release\"'" >>$GITHUB_OUTPUT - echo VERSION="${GITHUB_REF_NAME#v}" >>$GITHUB_OUTPUT + echo GOFLAGS="'-ldflags=-w -s \"-X=github.com/ollama/ollama/version.Version=${GITHUB_REF_NAME#v}\" \"-X=github.com/ollama/ollama/server.mode=release\"'" | tee -a $GITHUB_OUTPUT + echo VERSION="${GITHUB_REF_NAME#v}" | tee -a $GITHUB_OUTPUT + echo vendorsha=$(make -f Makefile.sync print-base) | tee -a $GITHUB_OUTPUT darwin-build: runs-on: macos-14-xlarge @@ -53,6 +55,9 @@ jobs: - uses: actions/setup-go@v5 with: go-version-file: go.mod + cache-dependency-path: | + go.sum + Makefile.sync - run: | ./scripts/build_darwin.sh - name: Log build results @@ -185,7 +190,7 @@ jobs: - uses: actions/cache@v4 with: path: ${{ github.workspace }}\.ccache - key: ccache-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.preset }} + key: ccache-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.preset }}-${{ needs.setup-environment.outputs.vendorsha }} - name: Build target "${{ matrix.preset }}" run: | Import-Module 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\Microsoft.VisualStudio.DevShell.dll' @@ -249,6 +254,9 @@ jobs: - uses: actions/setup-go@v5 with: go-version-file: go.mod + cache-dependency-path: | + go.sum + Makefile.sync - name: Verify gcc is actually clang run: | $ErrorActionPreference='Continue' @@ -302,6 +310,9 @@ jobs: - uses: actions/setup-go@v5 with: go-version-file: go.mod + cache-dependency-path: | + go.sum + Makefile.sync - uses: actions/download-artifact@v4 with: pattern: depends-windows* diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 08a0a714..b614d2f0 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -22,6 +22,7 @@ jobs: runs-on: ubuntu-latest outputs: changed: ${{ steps.changes.outputs.changed }} + vendorsha: ${{ steps.changes.outputs.vendorsha }} steps: - uses: actions/checkout@v4 with: @@ -37,6 +38,7 @@ jobs: } echo changed=$(changed 'llama/llama.cpp/**/*' 'ml/backend/ggml/ggml/**/*') | tee -a $GITHUB_OUTPUT + echo vendorsha=$(make -f Makefile.sync print-base) | tee -a $GITHUB_OUTPUT linux: needs: [changes] @@ -83,7 +85,7 @@ jobs: - uses: actions/cache@v4 with: path: /github/home/.cache/ccache - key: ccache-${{ runner.os }}-${{ runner.arch }}-${{ matrix.preset }} + key: ccache-${{ runner.os }}-${{ runner.arch }}-${{ matrix.preset }}-${{ needs.changes.outputs.vendorsha }} - run: | cmake --preset ${{ matrix.preset }} ${{ matrix.flags }} cmake --build --preset ${{ matrix.preset }} --parallel @@ -178,7 +180,7 @@ jobs: - uses: actions/cache@v4 with: path: ${{ github.workspace }}\.ccache - key: ccache-${{ runner.os }}-${{ runner.arch }}-${{ matrix.preset }} + key: ccache-${{ runner.os }}-${{ runner.arch }}-${{ matrix.preset }}-${{ needs.changes.outputs.vendorsha }} - run: | Import-Module 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\Microsoft.VisualStudio.DevShell.dll' Enter-VsDevShell -VsInstallPath 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise' -SkipAutomaticLocation -DevCmdArguments '-arch=x64 -no_logo' @@ -206,6 +208,9 @@ jobs: - uses: actions/setup-go@v5 with: go-version-file: 'go.mod' + cache-dependency-path: | + go.sum + Makefile.sync - uses: actions/setup-node@v4 with: node-version: '20' diff --git a/Makefile.sync b/Makefile.sync index 4991ad84..a485d6f2 100644 --- a/Makefile.sync +++ b/Makefile.sync @@ -57,7 +57,7 @@ checkout: $(WORKDIR) $(WORKDIR): git clone $(UPSTREAM) $(WORKDIR) -.PHONE: format-patches +.PHONY: format-patches format-patches: llama/patches git -C $(WORKDIR) format-patch \ --no-signature \ @@ -66,7 +66,11 @@ format-patches: llama/patches -o $(realpath $<) \ $(FETCH_HEAD) -.PHONE: clean +.PHONY: clean clean: checkout @git -C $(WORKDIR) am --abort || true $(RM) llama/patches/.*.patched + +.PHONY: print-base +print-base: + @echo $(FETCH_HEAD) \ No newline at end of file