actions / setup-go

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

Error with no go.sum file #427

Closed faisal-memon closed 1 year ago

faisal-memon commented 1 year ago

Description: After upgrading from 4.0 to 4.1 we see the below failure:

Restore cache failed: Dependencies file is not found in /home/runner/work/helm-charts/helm-charts. Supported file pattern: go.sum

We don't have a go.sum file.

Action version: setup-go@4.1.0

Platform:

Runner type:

Tools version: Go 1.21

Repro steps:
Run setup-go without a go.sum

Expected behavior: For it to work ok as go.sum is not needed if there are no dependancies

Actual behavior: Failure

faisal-memon commented 1 year ago

you can see our failed github action here: https://github.com/spiffe/helm-charts/actions/runs/6219786000

dsame commented 1 year ago

Thank you @faisal-memon , we are starting to investigate the problem.

dsame commented 1 year ago

Hello @faisal-memon ,

This is expected behaviour, and it is the same for both v4.0 and v4.1

I went through the history all actions runs in the repo and was not able to discover any runs that had used setup-go@v4.0, the first occurrence of setup-go step is in run#22 and it already was using v4.1 and produced the same warning.

In order to get rid of the annoying message please add cache: false input:

      - name: Setup go
        uses: actions/setup-go@v4.1.0
        with:
          cache: false

did it help?

faisal-memon commented 1 year ago

Thanks @dsame Confirmed error goes away with the suggested change.

dpurbosakti commented 11 months ago

Hello @faisal-memon ,

This is expected behaviour, and it is the same for both v4.0 and v4.1

I went through the history all actions runs in the repo and was not able to discover any runs that had used setup-go@v4.0, the first occurrence of setup-go step is in run#22 and it already was using v4.1 and produced the same warning.

In order to get rid of the annoying message please add cache: false input:

      - name: Setup go
        uses: actions/setup-go@v4.1.0
        with:
          cache: false

did it help?

got the same problem and it fixed with this solution

alexaandru commented 9 months ago

For anyone else ending up here (and for those that used the cache: false as a solution): there is a better way to get this working than disabling the cache (which just makes your jobs slower): give it the path to your go.sum file(s), as shown here: https://github.com/actions/setup-go/blob/6c1fd22b67f7a7c42ad9a45c0f4197434035e429/docs/adrs/0000-caching-dependencies.md#example-of-real-use-cases in short, add:

cache-dependency-path: "**/go.sum"

FWIW, a better solution would be for this action to infer the path of go.sum from the go.mod file, and not just to assume it is in the project root, particularly when go.mod is NOT there (i.e. if I give it go-version-file: foo/bar/go.mod it should look for foo/bar/go.sum not for ./go.sum).

remyleone commented 3 months ago

I would also suggest to ensure that checkout is performed BEFORE invoking setup-go. Otherwise, the setup-go step won't find the go.sum if the checkout is not performed.