Browse Source

ci: stop workflows from sharing and emptying the Go cache

Six workflows keyed the setup-go cache on service/go.mod, so they all
shared one cache key. build-buf and the javascript leg of CodeQL set up Go
without building anything, and saved a near-empty cache under that key.
Because a cache key is never overwritten, every later run restored the
empty cache and downloaded and compiled everything from scratch.

Disable the cache in build-buf, only set up Go for the CodeQL go leg, and
key the remaining caches on go.sum plus the workflow file, as each
workflow builds different artifacts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jamesread 21 hours ago
parent
commit
1cc079382f

+ 4 - 1
.github/workflows/build-and-release.yml

@@ -98,7 +98,10 @@ jobs:
         with:
         with:
           go-version-file: 'service/go.mod'
           go-version-file: 'service/go.mod'
           cache: true
           cache: true
-          cache-dependency-path: 'service/go.mod'
+          # Keyed per workflow, as each builds different artifacts.
+          cache-dependency-path: |
+            service/go.sum
+            .github/workflows/build-and-release.yml
 
 
       - name: Print go version
       - name: Print go version
         run: go version
         run: go version

+ 2 - 2
.github/workflows/build-buf.yml

@@ -24,8 +24,8 @@ jobs:
         uses: actions/setup-go@v5
         uses: actions/setup-go@v5
         with:
         with:
           go-version-file: 'service/go.mod'
           go-version-file: 'service/go.mod'
-          cache: true
-          cache-dependency-path: 'service/go.mod'
+          # buf does not build Go code; a cache saved here would be empty.
+          cache: false
 
 
       - uses: bufbuild/buf-action@v1.1.0
       - uses: bufbuild/buf-action@v1.1.0
         with:
         with:

+ 5 - 1
.github/workflows/codeql-analysis.yml

@@ -53,11 +53,15 @@ jobs:
         uses: actions/checkout@v4
         uses: actions/checkout@v4
 
 
       - name: Setup Go
       - name: Setup Go
+        if: matrix.language == 'go'
         uses: actions/setup-go@v5
         uses: actions/setup-go@v5
         with:
         with:
           go-version-file: 'service/go.mod'
           go-version-file: 'service/go.mod'
           cache: true
           cache: true
-          cache-dependency-path: 'service/go.mod'
+          # Keyed per workflow, as each builds different artifacts.
+          cache-dependency-path: |
+            service/go.sum
+            .github/workflows/codeql-analysis.yml
 
 
       - name: Setup Node
       - name: Setup Node
         if: matrix.language == 'javascript'
         if: matrix.language == 'javascript'

+ 4 - 1
.github/workflows/codestyle.yml

@@ -34,7 +34,10 @@ jobs:
         with:
         with:
           go-version-file: 'service/go.mod'
           go-version-file: 'service/go.mod'
           cache: true
           cache: true
-          cache-dependency-path: 'service/go.mod'
+          # Keyed per workflow, as each builds different artifacts.
+          cache-dependency-path: |
+            service/go.sum
+            .github/workflows/codestyle.yml
 
 
       - name: Print go version
       - name: Print go version
         run: go version
         run: go version

+ 4 - 1
.github/workflows/race.yml

@@ -30,7 +30,10 @@ jobs:
         with:
         with:
           go-version-file: 'service/go.mod'
           go-version-file: 'service/go.mod'
           cache: true
           cache: true
-          cache-dependency-path: 'service/go.mod'
+          # Keyed per workflow, as each builds different artifacts.
+          cache-dependency-path: |
+            service/go.sum
+            .github/workflows/race.yml
 
 
       - name: Run race detector
       - name: Run race detector
         run: make -wC service unittests-race
         run: make -wC service unittests-race