Skip to content

Commit b86edba

Browse files
committed
ci: add path to go.sum to actions/setup-go
I just noticed that actions/setup-go complains about the missing go.sum file: > Restore cache failed: Dependencies file is not found in /home/runner/work/sys/sys. Supported file pattern: go.sum Apparently this happens because there's no top-level go.sum file. Documentation[1] suggests using a wild card in such cases, but using neither "*/go.sum" nor "**/go.sum" works, as not all modules have go.sum, and so it fails with the following error: > Restore cache failed: Some specified paths were not resolved, unable to cache dependencies. Alas, we have to add an extra step to list the available go.sum files. The alternative would be listing them all, which is maintainers' nightmare. (The contents of these files are used as an input when calculating the cache checksum, essentially meaning if any of these files are changed, the cache will be invalidated.) [1]: https://github.com/actions/setup-go/blob/main/README.md#caching-dependency-files-and-build-outputs Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent bcbc034 commit b86edba

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Diff for: .github/workflows/test.yml

+10-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,20 @@ jobs:
88
platform: [ubuntu-20.04, ubuntu-22.04, ubuntu-24.04, windows-latest, macos-12, macos-14]
99
runs-on: ${{ matrix.platform }}
1010
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
- name: Find go.sum files
14+
id: gosum
15+
shell: bash
16+
run: |
17+
echo 'files<<EOF' >> "$GITHUB_OUTPUT"
18+
git ls-files '*/go.sum' >> "$GITHUB_OUTPUT"
19+
echo 'EOF' >> "$GITHUB_OUTPUT"
1120
- name: Install Go
1221
uses: actions/setup-go@v5
1322
with:
1423
go-version: ${{ matrix.go-version }}
15-
- name: Checkout code
16-
uses: actions/checkout@v4
24+
cache-dependency-path: ${{ steps.gosum.outputs.files }}
1725
- name: Set PACKAGES env
1826
if: ${{ matrix.go-version == '1.18.x' }}
1927
run: |

0 commit comments

Comments
 (0)