-
-
Notifications
You must be signed in to change notification settings - Fork 152
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
Feature request: run linter a few times #449
Comments
Actually you don't need to use the action on second run. You can call jobs:
lint:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: "${{ env.GO_VERSION }}"
- name: install deps
run: |
sudo apt -q update
sudo apt -q install libseccomp-dev
- uses: golangci/golangci-lint-action@v3
with:
version: "${{ env.LINT_VERSION }}"
# Extra linters, only checking new code from pull requests.
- run: golangci-lint --config .golangci-extra.yml --new-from-rev=origin/${{ github.base_ref }} --out-format=github-actions |
Awesome, thanks, let me check this |
OTOH it would still be nice to have something like |
For some reason it's not working (quoting https://github.com/opencontainers/runc/runs/6017736006?check_suite_focus=true):
I also see that the implementation of golangci-lint-action/src/run.ts Lines 22 to 75 in c675eb7
I guess I can use |
There is no need to parallelize lint and lint-extra jobs, and they only differ with the arguments to golangci-lint. Given that the longest time spent in these jobs is installing libseccomp-dev, and that the second linter run can probably benefit a lot from caching, it makes sense to merge them. Move lint-extra from a separate job to a step in lint job. The implementation is motivated by [1] and relies on the fact that the last commit being fetched is the merge commit. So, we need to set fetch-depth to 2 to be able to see the diff of the merge commit -- and this is what golangci-lint is using. [1] golangci/golangci-lint-action#449 (comment) Signed-off-by: Kir Kolyshkin <[email protected]>
OK, made it working, see opencontainers/runc#3457 It should, you need to have something like jobs:
lint:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 2 # So we can do git diff HEAD~1
- uses: actions/setup-go@v3
with:
go-version: "${{ env.GO_VERSION }}"
- name: install deps
run: |
sudo apt -q update
sudo apt -q install libseccomp-dev
- uses: golangci/golangci-lint-action@v3
with:
version: v1.45
# Extra linters, only checking new code from a pull request.
- run: golangci-lint run --config .golangci-extra.yml --new-from-rev=HEAD~1 --out-format=github-actions This relies on the fact that the last commit being fetched is the merge commit (somehow created by github) which shows the full diff for the PR. |
There is no need to parallelize lint and lint-extra jobs, and they only differ with the arguments to golangci-lint. Given that the longest time spent in these jobs is installing libseccomp-dev, and that the second linter run can probably benefit a lot from caching, it makes sense to merge them. Move lint-extra from a separate job to a step in lint job. The implementation is motivated by [1] and relies on the fact that the last commit being fetched is the merge commit. So, we need to set fetch-depth to 2 to be able to see the diff of the merge commit -- and this is what golangci-lint is using. [1] golangci/golangci-lint-action#449 (comment) Signed-off-by: Kir Kolyshkin <[email protected]> (cherry picked from commit fa83a17) Signed-off-by: Kir Kolyshkin <[email protected]>
There is no need to parallelize lint and lint-extra jobs, and they only differ with the arguments to golangci-lint. Given that the longest time spent in these jobs is installing libseccomp-dev, and that the second linter run can probably benefit a lot from caching, it makes sense to merge them. Move lint-extra from a separate job to a step in lint job. The implementation is motivated by [1] and relies on the fact that the last commit being fetched is the merge commit. So, we need to set fetch-depth to 2 to be able to see the diff of the merge commit -- and this is what golangci-lint is using. [1] golangci/golangci-lint-action#449 (comment) Signed-off-by: Kir Kolyshkin <[email protected]> (cherry picked from commit fa83a17) Signed-off-by: Kir Kolyshkin <[email protected]>
There is no need to parallelize lint and lint-extra jobs, and they only differ with the arguments to golangci-lint. Given that the longest time spent in these jobs is installing libseccomp-dev, and that the second linter run can probably benefit a lot from caching, it makes sense to merge them. Move lint-extra from a separate job to a step in lint job. The implementation is motivated by [1] and relies on the fact that the last commit being fetched is the merge commit. So, we need to set fetch-depth to 2 to be able to see the diff of the merge commit -- and this is what golangci-lint is using. [1] golangci/golangci-lint-action#449 (comment) Signed-off-by: Kir Kolyshkin <[email protected]> (cherry picked from commit fa83a17) Signed-off-by: Kir Kolyshkin <[email protected]>
There is no need to parallelize lint and lint-extra jobs, and they only differ with the arguments to golangci-lint. Given that the longest time spent in these jobs is installing libseccomp-dev, and that the second linter run can probably benefit a lot from caching, it makes sense to merge them. Move lint-extra from a separate job to a step in lint job. The implementation is motivated by [1] and relies on the fact that the last commit being fetched is the merge commit. So, we need to set fetch-depth to 2 to be able to see the diff of the merge commit -- and this is what golangci-lint is using. [1] golangci/golangci-lint-action#449 (comment) Signed-off-by: Kir Kolyshkin <[email protected]> (cherry picked from commit fa83a17) Signed-off-by: Kir Kolyshkin <[email protected]>
There is no need to parallelize lint and lint-extra jobs, and they only differ with the arguments to golangci-lint. Given that the longest time spent in these jobs is installing libseccomp-dev, and that the second linter run can probably benefit a lot from caching, it makes sense to merge them. Move lint-extra from a separate job to a step in lint job. The implementation is motivated by [1] and relies on the fact that the last commit being fetched is the merge commit. So, we need to set fetch-depth to 2 to be able to see the diff of the merge commit -- and this is what golangci-lint is using. [1] golangci/golangci-lint-action#449 (comment) Signed-off-by: Kir Kolyshkin <[email protected]> (cherry picked from commit fa83a17) Signed-off-by: Kir Kolyshkin <[email protected]>
There is no need to parallelize lint and lint-extra jobs, and they only differ with the arguments to golangci-lint. Given that the longest time spent in these jobs is installing libseccomp-dev, and that the second linter run can probably benefit a lot from caching, it makes sense to merge them. Move lint-extra from a separate job to a step in lint job. The implementation is motivated by [1] and relies on the fact that the last commit being fetched is the merge commit. So, we need to set fetch-depth to 2 to be able to see the diff of the merge commit -- and this is what golangci-lint is using. [1] golangci/golangci-lint-action#449 (comment) Signed-off-by: Kir Kolyshkin <[email protected]> (cherry picked from commit fa83a17) Signed-off-by: Kir Kolyshkin <[email protected]>
There is no need to parallelize lint and lint-extra jobs, and they only differ with the arguments to golangci-lint. Given that the longest time spent in these jobs is installing libseccomp-dev, and that the second linter run can probably benefit a lot from caching, it makes sense to merge them. Move lint-extra from a separate job to a step in lint job. The implementation is motivated by [1] and relies on the fact that the last commit being fetched is the merge commit. So, we need to set fetch-depth to 2 to be able to see the diff of the merge commit -- and this is what golangci-lint is using. [1] golangci/golangci-lint-action#449 (comment) Signed-off-by: Kir Kolyshkin <[email protected]> (cherry picked from commit fa83a17) Signed-off-by: Kir Kolyshkin <[email protected]>
There is no need to parallelize lint and lint-extra jobs, and they only differ with the arguments to golangci-lint. Given that the longest time spent in these jobs is installing libseccomp-dev, and that the second linter run can probably benefit a lot from caching, it makes sense to merge them. Move lint-extra from a separate job to a step in lint job. The implementation is motivated by [1] and relies on the fact that the last commit being fetched is the merge commit. So, we need to set fetch-depth to 2 to be able to see the diff of the merge commit -- and this is what golangci-lint is using. [1] golangci/golangci-lint-action#449 (comment) Signed-off-by: Kir Kolyshkin <[email protected]> (cherry picked from commit fa83a17) Signed-off-by: Kir Kolyshkin <[email protected]>
In my repository (https://github.com/opencontainers/runc) I use two distinct linter configs:
The first config is used everywhere (on main and release branches, as well as for PRs)
The second config is
only-new-issues: true
)if: github.event_name == 'pull_request'
)The idea behind this setup is simple: since we have a pretty big codebase, we can't possibly modify it to satisfy some more stricter and/or opinionated linters (such as
godot
,revive
,gocritic
, ordupl
), nor it makes sense to do so -- but we can impose stricter standards for the newly added code.Now, the GHA CI implementation (with the
.golangci-extra.yml
file with extra linters) looks like this:All this works, except that since I use
golangci/golangci-lint-action
twice, it actually downloads and installs golangci-lint twice (for example, see the log at https://github.com/opencontainers/runc/runs/5982042602?check_suite_focus=true.** Proposal ** modify the action to detect that it is being used for the second time, and skip the second, redundant golangci-lint setup.
The text was updated successfully, but these errors were encountered: