Skip to content

Commit 1a6c912

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 of two reasons: 1. actions/checkout should be run _before actions/setup-go. 2. There's no top-level go.sum file. The first problem is easy to fix. As for the second one, 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 29394de commit 1a6c912

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

.github/workflows/test.yml

+10-2
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,20 @@ jobs:
1111
run:
1212
shell: bash
1313
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
- name: Find go.sum files
17+
id: gosum
18+
shell: bash
19+
run: |
20+
echo 'files<<EOF' >> "$GITHUB_OUTPUT"
21+
git ls-files '*/go.sum' >> "$GITHUB_OUTPUT"
22+
echo 'EOF' >> "$GITHUB_OUTPUT"
1423
- name: Install Go
1524
uses: actions/setup-go@v5
1625
with:
1726
go-version: ${{ matrix.go-version }}
18-
- name: Checkout code
19-
uses: actions/checkout@v4
27+
cache-dependency-path: ${{ steps.gosum.outputs.files }}
2028
- name: Set PACKAGES env
2129
if: ${{ matrix.go-version == '1.18.x' }}
2230
run: |

0 commit comments

Comments
 (0)