From 649e3beaab61e781e06bb48289629b02ab5e6819 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Fri, 20 Sep 2024 17:46:46 -0700 Subject: [PATCH] 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 --- .github/workflows/test.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 185549c..e7d7372 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,12 +8,20 @@ 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 + - name: Find go.sum files + id: gosum + shell: bash + run: | + echo 'files<> "$GITHUB_OUTPUT" + git ls-files '*/go.sum' >> "$GITHUB_OUTPUT" + echo 'EOF' >> "$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 }} - if: ${{ matrix.go-version == '1.18.x' }} run: | # This corresponds with the list in Makefile:1, but omits the "userns"