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

Add go.mod support #47

Merged
merged 1 commit into from
Oct 27, 2023
Merged

Add go.mod support #47

merged 1 commit into from
Oct 27, 2023

Conversation

andyfeller
Copy link
Contributor

@andyfeller andyfeller commented Oct 26, 2023

Fixes #46

These changes add go_version_file input to define path to go.mod or go.work file containing the Go version to use.

Testing

go.mod

module github.com/tinyfists/gh-nonsense

go 1.20

Original using default input value

  • Workflow

        steps:
          - uses: actions/checkout@v3
          - uses: cli/gh-extension-precompile@v1
  • Workflow run

    Setup go version spec 1.18
    Attempting to download 1.18...
    matching 1.18...
    Acquiring 1.18.10 from https://github.com/actions/go-versions/releases/download/1.18.10-3890634278/go-1.18.10-linux-x64.tar.gz
    Extracting Go...
    

New using go.mod input value

  • Workflow

          - uses: cli/gh-extension-precompile@andyfeller/46-go-mod-support
            with:
              go_version_file: go.mod
  • Workflow run

    Run actions/setup-go@v3
    Setup go version spec 1.20
    Found in cache @ /opt/hostedtoolcache/go/1.20.10/x64
    Added go to the path
    Successfully set up Go version 1.20
    go version go1.20.10 linux/amd64
    

New using both go_version and go_version_file with go_version of 1.19 being used

  • Workflow

          - uses: cli/gh-extension-precompile@andyfeller/46-go-mod-support
            with:
              go_version: 1.19
              go_version_file: go.mod
  • Workflow run

    Run actions/setup-go@v3
    Warning: Both go-version and go-version-file inputs are specified, only go-version will be used
    Setup go version spec 1.19
    Found in cache @ /opt/hostedtoolcache/go/1.19.[13](https://github.com/tinyfists/gh-nonsense-internal/actions/runs/6659389467/job/18098346598#step:3:15)/x64
    Added go to the path
    Successfully set up Go version 1.19
    go version go1.19.13 linux/amd64
    

New using default input values, resulting in 1.18 being used

  • Workflow

        steps:
          - uses: actions/checkout@v3
          - uses: cli/gh-extension-precompile@andyfeller/46-go-mod-support
  • Workflow run

    Run actions/setup-go@v3
    Setup go version spec 1.18
    Attempting to download 1.18...
    matching 1.18...
    Acquiring 1.18.10 from https://github.com/actions/go-versions/releases/download/1.18.10-38[9](https://github.com/tinyfists/gh-nonsense-internal/actions/runs/6659398809/job/18098374871#step:3:11)0634278/go-1.18.[10](https://github.com/tinyfists/gh-nonsense-internal/actions/runs/6659398809/job/18098374871#step:3:12)-linux-x64.tar.gz
    Extracting Go...
    

These changes add `go_version_file` input to define path to `go.mod` or
`go.work` file containing the Go version to use.
@andyfeller andyfeller requested a review from a team as a code owner October 26, 2023 20:21
@andyfeller andyfeller requested a review from samcoe October 26, 2023 20:21
@andyfeller andyfeller enabled auto-merge October 26, 2023 20:31
@andyfeller
Copy link
Contributor Author

As an aside, I would really like to see a future breaking change where these inputs matched the ones used by actions/setup-go 😬

@andyfeller andyfeller self-assigned this Oct 27, 2023
Copy link
Contributor

@samcoe samcoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. Thanks for adding the code comment. My only question is do you think it makes sense to move the go_version determination logic into a determine_go_version step similar to determine_token?

I am unsure if adding another step would add significant time to running this action, but if it does then I think it is best left as is. I will leave it up to you to decide. No strong opinion.

@andyfeller andyfeller merged commit b0da21c into trunk Oct 27, 2023
@andyfeller
Copy link
Contributor Author

This looks good to me. Thanks for adding the code comment. My only question is do you think it makes sense to move the go_version determination logic into a determine_go_version step similar to determine_token?

I am unsure if adding another step would add significant time to running this action, but if it does then I think it is best left as is. I will leave it up to you to decide. No strong opinion.

That is a really good question 🤔 I will have to experiment with that and iterate. As this is how I personally solved this before, it would take me a bit of time to re-engineer a solution, so I lean on a working solution now with shipping improvements later.

@andyfeller andyfeller deleted the andyfeller/46-go-mod-support branch October 27, 2023 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow setting Go version from go.mod file
2 participants