actions / setup-go

Set up your GitHub Actions workflow with a specific version of Go
MIT License
1.39k stars 512 forks source link

Fail to cache with go version 1.23 #498

Open linglingye001 opened 3 weeks ago

linglingye001 commented 3 weeks ago

Description: We have upgraded the go version of our project to 1.23 and updated the golangci-lint as well. But the log output Cache not found which made golangci-lint fail.

Setup go version spec 1.23.0
Attempting to download 1.23.0...
matching 1.23.0...
Acquiring 1.23.0 from https://github.com/actions/go-versions/releases/download/1.23.0-103[8](https://github.com/Azure/AppConfiguration-KubernetesProvider/actions/runs/10519320181/job/29146495024#step:3:9)0775229/go-1.23.0-linux-x64.tar.gz
Extracting Go...
/usr/bin/tar xz --warning=no-unknown-keyword --overwrite -C /home/runner/work/_temp/bf173660-517d-4d7[9](https://github.com/Azure/AppConfiguration-KubernetesProvider/actions/runs/10519320181/job/29146495024#step:3:10)-8823-26a5e905efc1 -f /home/runner/work/_temp/c8[11](https://github.com/Azure/AppConfiguration-KubernetesProvider/actions/runs/10519320181/job/29146495024#step:3:12)b549-7eec-4ea2-8c26-73b4bee40ebc
Successfully extracted go to /home/runner/work/_temp/bf173660-517d-4d79-8823-26a5e905efc1
Adding to the cache ...
Successfully cached go to /opt/hostedtoolcache/go/1.23.0/x64
Added go to the path
Successfully set up Go version 1.23.0
/opt/hostedtoolcache/go/1.23.0/x64/bin/go env GOMODCACHE
/opt/hostedtoolcache/go/1.23.0/x64/bin/go env GOCACHE
/home/runner/go/pkg/mod
/home/runner/.cache/go-build
Cache is not found
go version go1.23.0 linux/amd64

Action version: Specify the action version setup-go@v5

Platform: Ubuntu

Runner type: Hosted

Tools version:

1.23.0

linglingye001 commented 3 weeks ago

With go version 1.22.6, the cache restored successfully. I’m not sure if this is related to the Go version. Thanks

priya-kinthali commented 3 weeks ago

Hello @linglingye001 👋, Thank you for reporting this. We will investigate the issue and get back to you as soon as we have updates.

remyleone commented 2 weeks ago

I got a similar problem and I also see that even if the cache is marked as found by the action many packages are still downloaded :( I'm not sure the cache is working properly by default

andreigorgan commented 2 weeks ago

I also had a similar issue with V5 , go version 1.23 . Here are some logs (debug mode):

...
2024-08-27T12:10:00.9630701Z ../../../../.cache/go-build/54/
2024-08-27T12:10:00.9631864Z Cache Size: ~0 MB (58214 B)
2024-08-27T12:10:00.9635096Z [command]/usr/bin/tar -xf /home/runner/actions-runner/_work/_temp/47ac88a3-544a-4172-8835-ebd0ed8b2ffd/cache.tzst -P -C /home/runner/actions-runner/_work/<repository_name>/<repository_name> --use-compress-program unzstd
2024-08-27T12:10:00.9637846Z /usr/bin/tar: ../../../../go/pkg/mod/golang.org/x/telemetry/config@v0.29.0/doc.go: Cannot open: File exists
2024-08-27T12:10:00.9639625Z /usr/bin/tar: ../../../../go/pkg/mod/golang.org/x/telemetry/config@v0.29.0/LICENSE: Cannot open: File exists
2024-08-27T12:10:00.9641358Z /usr/bin/tar: ../../../../go/pkg/mod/golang.org/x/telemetry/config@v0.29.0/config.json: Cannot open: File exists
2024-08-27T12:10:00.9643051Z /usr/bin/tar: ../../../../go/pkg/mod/golang.org/x/telemetry/config@v0.29.0/go.mod: Cannot open: File exists
2024-08-27T12:10:00.9644483Z /usr/bin/tar: Exiting with failure status due to previous errors
2024-08-27T12:10:00.9672705Z ##[warning]Failed to restore: "/usr/bin/tar" failed with error: The process '/usr/bin/tar' failed with exit code 2
2024-08-27T12:10:00.9680769Z Cache is not found
2024-08-27T12:10:00.9693251Z ##[add-matcher]/home/runner/actions-runner/_work/_actions/actions/setup-go/v5/matchers.json
2024-08-27T12:10:00.9704908Z ##[debug]Added matchers: 'go'. Problem matchers scan action output for known warning or error strings and report these inline.
2024-08-27T12:10:00.9706337Z go version go1.23.0 linux/amd64

The configuration i used is:

      - uses: actions/setup-go@v5
        with:
          go-version-file: 'go.mod'
          cache-dependency-path: go.sum
galdor commented 1 week ago

It seems we are having the same issue. The only way to make builds pass is to delete the cache manually and restart the job.

gowridurgad commented 1 week ago

Hi @linglingye001, We've upgraded go and golangci-lint to the latest versions (Go: 1.23, golangci-lint: v1.60.3) and Successfully executed the workflow without encountering any errors. Here's a screenshot for your reference. To help us further investigate the issue, Could you please attach link to the build or public repository to reproduce the issue ?

Screenshot 2024-09-04 at 5 19 49 PM
muzimuzhi commented 1 week ago

I observed the warning

Warning: Failed to restore: "/usr/bin/tar" failed with error: The process '/usr/bin/tar' failed with exit code 2

in a job run in https://github.com/ayoisaiah/f2, 4 days ago. But now it disappeared in runs since 2 days ago.

The no-warning job run was 1 commit ahead, which updates go dependencies, see https://github.com/ayoisaiah/f2/compare/5865461f50db4c15345c93a1d3458308f22972da...560fe309926b3d476428eb926889e5c4c24dc4d6.

datbth commented 6 days ago

I'm also facing this issue with Go 1.23.
And my errors also point to go/pkg/mod/golang.org/x/telemetry/config
image (by the way, is it the new telemetry feature introduced since go 1.23?)

Then, I tried cache: false and use @actions/cache directly:

    - uses: actions/setup-go@v5
      with:
        go-version: '1.23.0'
        cache: false

    - name: Get Go ENVs
      id: go_envs
      shell: bash
      run: |
        echo "GOMODCACHE=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT"
        echo "GOCACHE=$(go env GOCACHE)" >> "$GITHUB_OUTPUT"

    - uses: actions/cache@v4
      with:
        key: v1-go-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
        restore-keys: |
          v1-go-${{ runner.os }}-
        path: |
          ${{ steps.go_envs.outputs.GOMODCACHE }}
          ${{ steps.go_envs.outputs.GOCACHE }}

It failed similarly: image

Then I tried cleaning modcache before calling (restoring) @actions/cache:

    - uses: actions/setup-go@v5
      with:
        go-version: '1.23.0'
        cache: false

    - name: Get Go ENVs
      id: go_envs
      shell: bash
      run: |
        echo "GOMODCACHE=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT"
        echo "GOCACHE=$(go env GOCACHE)" >> "$GITHUB_OUTPUT"

    - shell: bash
      run: |
        go clean -modcache

    - uses: actions/cache@v4
      with:
        key: v1-go-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
        restore-keys: |
          v1-go-${{ runner.os }}-
        path: |
          ${{ steps.go_envs.outputs.GOMODCACHE }}
          ${{ steps.go_envs.outputs.GOCACHE }}

It also failed: image

Then I tried using rm -rf instead of go clean and, interestingly, it threw permission denied: image

I could sudo rm -rf instead, but then it still failed when restoring cache: image

sudo chmod -R 0777 also failed: image

However, cleaning both -modcache and -cache somehow worked: image

which is weird to me because the error is pointing to GOMODCACHE (go/pkg/mod).

Edit: I ran my workflow another time and this time it failed :crying_cat_face: (even when cleaning both -modcache and -cache): image

p/s I would like to note that this issue happens when restoring cache, while @gowridurgad ran a workflow that had no cache yet.

gowridurgad commented 3 days ago

Hi @muzimuzhi, @datbth, The issue you're facing during cache restoration is due to the telemetry update in Go 1.23.0. This update includes files (config.json, go.mod, LICENSE, doc.go) that already exist in the golang.org/x/telemetry directory, causing conflicts. When restoring the cache, these existing files prevent the tar command from completing successfully, resulting in "File exists" errors.

We have observed that the error related to extracting telemetry files is not present in Go version 1.23.1. Attached a screenshot for your reference This suggests that the issue might have been resolved in the newer release. We recommend updating your workflow to use Go version 1.23.1 as follows:

- name: Set up Go
  uses: actions/setup-go@v5
  with:
    go-version: 1.23.1

If you continue to experience issues, please let us know.

Screenshot 2024-09-10 at 4 46 11 PM
datbth commented 2 days ago

I just tried a few workflows with 1.23.1 and it is working fine so far.

Still find it quite weird that removing the whole modcache directory did not work.

But anyway, I'm good for now. Thank you!