Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to run tests with latest golang version #455

Closed
2 of 5 tasks
fredmaggiowski opened this issue Feb 7, 2024 · 12 comments
Closed
2 of 5 tasks

How to run tests with latest golang version #455

fredmaggiowski opened this issue Feb 7, 2024 · 12 comments
Assignees
Labels
bug Something isn't working

Comments

@fredmaggiowski
Copy link

Description:

Hi, I can't find a way to make my action run against the latest golang version available.

I want to run tests against stable golang releases but also verify that newer golang version do not provide harm to my codebase, for this reason I've setup my action to run on a version matrix and then have a "special job" that I want to run tests on the very latest golang release.

This is my setup:

      - name: Use golang ${{ matrix.go_version }}
        uses: actions/setup-go@v5
        with:
          check-latest: true

What I'd expect from this is that used golang version would be something > go1.22, instead I see golang 1.20 is being used.

Even adding cache: false makes my action run with golang 1.20

I understand this might not be a bug but just me not understanding the doc, but how am I supposed to reach my goal?

Action version:

actions/setup-go@v5

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Tools version:

Repro steps:

Action current configuration on main branch:

https://github.com/rond-authz/rond/blob/07099709a5968c4617c9342716b64d9e077b38f7/.github/workflows/test.yml#L53-L55

PR where I'm trying to fix the behavior:

https://github.com/rond-authz/rond/pull/320/files

Action result showing golang 1.20 is being used:

https://github.com/rond-authz/rond/actions/runs/7816281593/job/21321451154?pr=320#step:3:9

Screenshot 2024-02-07 alle 15 33 02

Expected behavior:

My test-latest job should run with the latest golang release avilable

Actual behavior:

not the latest is being used, regardless of the cache (apparently)

@fredmaggiowski fredmaggiowski added bug Something isn't working needs triage labels Feb 7, 2024
@spencerschrock
Copy link

I believe you're confusing two caches: the tool cache vs the build/package cache, which the argument is for README link.

It sounds like what you want are the stable and oldstable aliases, which are mentioned in the README here.

@fredmaggiowski
Copy link
Author

ok got it thanks, so being everything sourced from go-versions I assume using stable will give me go1.22 since is currently the latest "stable" version

https://github.com/actions/go-versions/blob/c0555276f6ee861abbf6bc35c752c8547fcbb86e/versions-manifest.json#L3

What if I want to test with versions that are not yet stable? For instance, once we have the first rc for go1.23, use it to make sure my codebase will not have issues

@aparnajyothi-y
Copy link

Hello @spencerschrock, Thank you for creating the issue and we will look into it :)

@aparnajyothi-y
Copy link

Hello @spencerschrock, Thank you once again for creating this issue
If we want to test with versions of Go that are not yet stable, you can specify the exact version in the with.go-version field of your workflow file. This field supports the 1.x syntax, so you can use 1.23.x to test with the latest release of Go 1.23, including any release candidates. Please refere this document

The actions/setup-go action is designed to download and set up a Go environment of any version specified in the go-version input of the action. The action uses the official Go downloads, which include both stable and unstable versions.
However, the actions/setup-go action only supports versions that are available in the go-versions repository.
However, it's important to note that using non-stable versions may lead to potential instability in your workflows, as they may have not been fully tested or may contain bugs. The best practice is to use stable versions for production code.

@gaby
Copy link

gaby commented Feb 10, 2024

@fredmaggiowski This is what I use:

steps:
  - uses: actions/checkout@v4
  - uses: actions/setup-go@v5
    with:
      go-version: 'stable'
      check-latest: true
  - run: go run hello.go

@aparnajyothi-y
Copy link

Hello @spencerschrock, Please confirm that the above clarification is helpful to proceed to close the issue.

@spencerschrock
Copy link

I'm not the issue author, I'm assuming you meant @fredmaggiowski

@fredmaggiowski
Copy link
Author

I'm not the issue author, I'm assuming you meant @fredmaggiowski

I guess you are right lol

Hello @spencerschrock, Please confirm that the above clarification is helpful to proceed to close the issue.

Yes @aparnajyothi-y sorry for the delay, I had a few busy weeks; i'm verifying it later today and come back at you asap :)

@fredmaggiowski
Copy link
Author

fredmaggiowski commented Feb 21, 2024

@fredmaggiowski This is what I use:

steps:
  - uses: actions/checkout@v4
  - uses: actions/setup-go@v5
    with:
      go-version: 'stable'
      check-latest: true
  - run: go run hello.go

@gaby It seems to work, thanks!

https://github.com/rond-authz/rond/actions/runs/7986038478/job/21805633813?pr=323#step:3:11

image

@tamird
Copy link

tamird commented Jul 16, 2024

Hello @spencerschrock, Thank you once again for creating this issue If we want to test with versions of Go that are not yet stable, you can specify the exact version in the with.go-version field of your workflow file. This field supports the 1.x syntax, so you can use 1.23.x to test with the latest release of Go 1.23, including any release candidates. Please refere this document

Hi @aparnajyothi-y. It seems that the manifest doesn't include any non-stable versions. Neither betas nor release candidates. Is that still meant to be a supported use case? See petermattis/goid#50 where I tried unsuccessfully to add go1.23rc2 to the matrix.

@nikicat
Copy link

nikicat commented Aug 13, 2024

Hello, how can I build with go 1.23rc2?

@nikicat
Copy link

nikicat commented Aug 13, 2024

Figured it out: just specify go-version: 1.23.0-rc.2 instead of 1.23rc2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants