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

staticcheck doesn't create GitHub Annotations #910

Closed
marten-seemann opened this issue Jan 15, 2021 · 5 comments
Closed

staticcheck doesn't create GitHub Annotations #910

marten-seemann opened this issue Jan 15, 2021 · 5 comments
Labels
upstream Issues that are caused by a dependency

Comments

@marten-seemann
Copy link

I'm looking for a way to have staticcheck create annotations on PRs, something like this:
image
Running staticcheck in golangci-lint produces such annotations, but the standalone version doesn't.

I created a minimal working example in

The GitHub Actions workflow is the following:

on: [push, pull_request]
jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-go@v2
        with:
          go-version: "1.15.x"
      - run: go get honnef.co/go/tools/cmd/staticcheck
      - run: staticcheck ./...

It does find the problem in my code (if you look at the linter output), but the PR is not annotated: https://github.com/marten-seemann/linter-test/pull/2/files

@marten-seemann marten-seemann added the needs-triage Newly filed issue that needs triage label Jan 15, 2021
@marten-seemann marten-seemann changed the title staticcheck doesn't trigger a GitHub Annotation staticcheck doesn't create GitHub Annotations Jan 15, 2021
@dominikh dominikh added started Issues we've started working on and removed needs-triage Newly filed issue that needs triage labels Jan 16, 2021
@dominikh
Copy link
Owner

It works for me when using the following action instead:

on: [push, pull_request]
jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-go@v1
        with:
          go-version: "1.15.x"
      - run: go get honnef.co/go/tools/cmd/staticcheck
      - run: $(go env GOPATH)/bin/staticcheck ./...

The only relevant difference is that it's using setup-go@v1 instead of v2. (It also has to call the staticcheck binary directly, as setup-go@v1 didn't add $GOPATH/bin to the PATH, but that should not be important.)

So, to me, this looks like a regression in the setup-go action. Looking at the difference between v1 and v2, the pattern they use to match output has changed from ^([^:]*: )?((.:)?[^:]*):(\\d+)(:(\\d+))?: (.*)$ to ^\\s*(\\.{0,2}[\\/\\\\].+\\.go):(?:(\\d+):(\\d+):)? (.*) (\ are escaped because the expressions are stored in JSON strings)

And indeed, the new pattern doesn't match our output. I'll try and file an issue with the setup-go people.

@dominikh
Copy link
Owner

I have sent actions/setup-go#98

@dominikh dominikh added the upstream Issues that are caused by a dependency label Jan 16, 2021
@mvdan
Copy link
Sponsor Contributor

mvdan commented Jan 16, 2021

Wow, very nice digging!

@dominikh
Copy link
Owner

Lacking any progress whatsoever in actions/setup-go, I now recommend using https://github.com/WillAbides/setup-go-faster instead, which is faster and has sensible problem matchers.

@dominikh
Copy link
Owner

dominikh commented Jun 2, 2021

I am going to close this. Upstream is being upstream, and setup-go-faster is a better alternative that works correctly.

We'll mention it when we publish our article on running Staticcheck in CI.

@dominikh dominikh closed this as completed Jun 2, 2021
@dominikh dominikh removed the started Issues we've started working on label Oct 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream Issues that are caused by a dependency
Projects
None yet
Development

No branches or pull requests

3 participants