-
Notifications
You must be signed in to change notification settings - Fork 97
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
Consolidate lint steps in GitHub Actions #231
Conversation
416604d
to
8cb492c
Compare
@bgentry Was seeing lint jobs take almost ten minutes to run — totally nuts. This change fixes that as far as I can tell. |
469fa22
to
27ee4dd
Compare
Where are you seeing this? this latest master run shows ~40 seconds. |
I would actually like to get this working, and based on the docs it seems we merely need to add a
I'm not seeing anything like this from the latest run on If you can point me to wherever you saw evidence of this being super slow, I'm happy to debug—I've gotten pretty skilled with Actions from work stuff. |
Like with running Go tests, the lints for each separate Go module must be running separately. This is currently being accomplished in CI by giving each Go module its own lint job using golangci-lint's GitHub Action. Unfortunately, this is really not working out well. Although the lints themselves are all very fast to run (just a couple seconds), the post run step where it saves it cache is quite slow, about two minutes, and that's happening for each of the lint steps, making the entire lint job take almost _ten minutes_ to run. I think what might've been happening is that each lint job was overwriting the last job's cache, which is why each post run step seemed to be doing so much work. I didn't validate this hypothesis, but it seems like a strong possibility. Here, try to hack around the problem by having the main lint job fetch golangci-lint, but then only run `--help`, and then do the real linting as a separate step (one that doesn't use the GitHub Action) that calls into our `make lint` target to run lints for each Go module. A downside is that it may not annotate lint problems on the GitHub PR, which is something that theoretically happened before, although it never seemed to work for me. This might not be that bad though because it could as a side effect improve the log output, which is terrible for the GitHub Action step because it doesn't include files or line numbers. Also, I notice that the lints/tests in `Makefile` had been commented out for `./cmd/river` for some reason (maybe something I did during the driver refactor and forgot to fix), so I uncommented them. [1] golangci/golangci-lint-action#271
27ee4dd
to
e486e60
Compare
Ah yeah, that could be. I have to say though that I have it enabled it in another repo, and IMO it's not that great — you get failures in there, but you still have to scroll through pages of diff trying to zero in on them. Not hard against it, but the CLI output is easier to track down in my experience.
Cool. It may not be happening in
I think some of the step timing on those might be retrospectively wrong. Each one is showing two of the lint post actions as 2+ minutes, but I think all of them basically where. Take a look at the total run time of each, and they're all over > 9 minutes, which is what I was experiencing yesterday. |
Ah yeah, good point — it does seem like the golangci-lint step was doing roughly the right thing despite the duration. (Although I was watching them at the time and they really did take 2+ min each, so who knows what's going on. A GitHub Actions bug wouldn't surprise me.)
Yeah, I looked through a lot of their conf, and it really does seem like there's only one of these actions meant to be used per job. golangci/golangci-lint-action#271 has a few other ideas on how to handle multiple directories, but this is the one approach out of those that seemed to work well for me. SG if you want to take a look though. |
I had a bad run of this here. I even cancelled the workflow while it was sitting inexplicably on one of these steps, and it kept going for many minutes longer (through multiple post-cache steps with the same issue). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine as a temporary measure until I have time to look into how to fix this more cleanly
Awesome. Spoke with @bgentry about this on Slack, and we may end up reverting most of this, but it gets us faster build in the interim while we're chasing down a few other high priority items. |
Like with running Go tests, the lints for each separate Go module must
be running separately. This is currently being accomplished in CI by
giving each Go module its own lint job using golangci-lint's GitHub
Action.
Unfortunately, this is really not working out well. Although the lints
themselves are all very fast to run (just a couple seconds), the post
run step where it saves it cache is quite slow, about two minutes, and
that's happening for each of the lint steps, making the entire lint job
take almost ten minutes to run.
I think what might've been happening is that each lint job was
overwriting the last job's cache, which is why each post run step seemed
to be doing so much work. I didn't validate this hypothesis, but it
seems like a strong possibility.
Here, try to hack around the problem by having the main lint job fetch
golangci-lint, but then only run
--help
, and then do the real lintingas a separate step (one that doesn't use the GitHub Action) that calls
into our
make lint
target to run lints for each Go module.A downside is that it may not annotate lint problems on the GitHub PR,
which is something that theoretically happened before, although it never
seemed to work for me. This might not be that bad though because it
could as a side effect improve the log output, which is terrible for the
GitHub Action step because it doesn't include files or line numbers.
Also, I notice that the lints/tests in
Makefile
had been commented outfor
./cmd/river
for some reason (maybe something I did during thedriver refactor and forgot to fix), so I uncommented them.
[1] golangci/golangci-lint-action#271