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

make it possible to set the GOOS / GOARCH #742

Closed
3 tasks done
marten-seemann opened this issue May 6, 2023 · 4 comments
Closed
3 tasks done

make it possible to set the GOOS / GOARCH #742

marten-seemann opened this issue May 6, 2023 · 4 comments
Labels
question Further information is requested

Comments

@marten-seemann
Copy link

marten-seemann commented May 6, 2023

Welcome

  • Yes, I understand that the GitHub action repository is not the repository of golangci-lint itself.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've included all information below (version, config, etc).

Description of the problem

I have a lot of platform-specific in quic-go. So far, I've been running golangci-lint on Ubuntu, thus only the code for Linux has been linted.

I discovered that in the terminal, it's easily possible to run golangci-lint for other platforms as well:

GOOS=<x> GOARCH=<y> golangci-lint run .

As you might be able to expected, the code for the other platforms was not properly linted. I therefore would like to run golangci-lint using multiple platforms on CI. As far as I can see, there's no way to set the GOOS / GOARCH as a config flag.

As a workaround, this is how you could achieve the same result:

- name: Set GOOS environment variable
  run: echo "GOOS=windows" >> $GITHUB_ENV
- name: golangci-lint (Linux)
  uses: golangci/golangci-lint-action@v3
  with:
     version: v1.52.2

I suggest adding config flags to make this more accessible:

- name: golangci-lint (Linux)
  uses: golangci/golangci-lint-action@v3
  with:
     goos: "windows"
     goarch: "i386"
     version: v1.52.2

Does this make sense?

Version of golangci-lint

v1.52.2

Version of the GitHub Action

v3

Workflow file

see above

Go version

1.20

Code example or link to a public repository

https://github.com/quic-go/quic-go/blob/22d6b0e626c56f311ff05705042d8caf506e5919/.github/workflows/lint.yml#L24-L35

@ldez
Copy link
Member

ldez commented Jun 12, 2023

I think a better solution is to use an OS matrix:

jobs:

  golangci-lint:
    name: Linter
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]

    steps:
// ...

@ldez ldez added the question Further information is requested label Jun 12, 2023
@marten-seemann
Copy link
Author

Not really. You pay the cost of booting the VM, checking out the code, setting up Go, for a linting fast that just takes a few seconds.

It also means that you can only lint the code for the 3 platforms that GH actions is offering. I need to support FreeBSD, among others, so this doesn’t work at all.

@ldez
Copy link
Member

ldez commented Jun 12, 2023

When the binary is built, it is built for a GOOS/ARCH tuple, some elements of the std or dependencies can be missing.

The basic core can work because it's related to Go tooling, but I cannot provide any warranty about the behavior when playing with GOOS/ARCH to run golangci-lint.

In this context adding options to play with GOOS/ARCH seems risky.

@ldez
Copy link
Member

ldez commented Jun 12, 2023

I think your current approach based on env vars is the best approach to handle your use case.

https://github.com/quic-go/quic-go/blob/e1bcedc78cfea33b47d46349e9219e45d4c74b6c/.github/workflows/lint.yml#LL42C10-L42C10

For other users: I recommend NOT doing that as explain here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants