Skip to content

Commit

Permalink
ci: add path to go.sum to actions/setup-go
Browse files Browse the repository at this point in the history
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 <kolyshkin@gmail.com>
  • Loading branch information
kolyshkin committed Sep 21, 2024
1 parent bcbc034 commit d3128cb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ jobs:
platform: [ubuntu-20.04, ubuntu-22.04, ubuntu-24.04, windows-latest, macos-12, macos-14]
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- id: gosum
run: echo files=$(git ls-files '*/go.sum') >> $GITHUB_OUTPUT
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v4
cache-dependency-path: ${{ steps.gosum.outputs.files }}
- name: Set PACKAGES env
if: ${{ matrix.go-version == '1.18.x' }}
run: |
Expand Down

0 comments on commit d3128cb

Please sign in to comment.