From b86edba2c0e81e802a98d35f8a399bb356edc67b 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 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 --- .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 9ead5e0..dd3660f 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 }} - name: Set PACKAGES env if: ${{ matrix.go-version == '1.18.x' }} run: |