Skip to content

Commit cb97b14

Browse files
committed
ci/gha: convert lint-extra from a job to a step
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]>
1 parent e7d12c7 commit cb97b14

File tree

2 files changed

+7
-22
lines changed

2 files changed

+7
-22
lines changed

.github/workflows/validate.yml

+6-21
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,8 @@ jobs:
1616
runs-on: ubuntu-20.04
1717
steps:
1818
- uses: actions/checkout@v3
19-
- uses: actions/setup-go@v3
20-
with:
21-
go-version: "${{ env.GO_VERSION }}"
22-
- name: install deps
23-
run: |
24-
sudo apt -q update
25-
sudo apt -q install libseccomp-dev
26-
- uses: golangci/golangci-lint-action@v3
2719
with:
28-
version: v1.45
29-
30-
lint-extra:
31-
# Extra linters, only checking new code from pull requests.
32-
if: github.event_name == 'pull_request'
33-
runs-on: ubuntu-20.04
34-
permissions:
35-
contents: read
36-
steps:
37-
- uses: actions/checkout@v3
20+
fetch-depth: 2
3821
- uses: actions/setup-go@v3
3922
with:
4023
go-version: "${{ env.GO_VERSION }}"
@@ -44,10 +27,12 @@ jobs:
4427
sudo apt -q install libseccomp-dev
4528
- uses: golangci/golangci-lint-action@v3
4629
with:
47-
only-new-issues: true
48-
args: --config .golangci-extra.yml
4930
version: v1.45
50-
31+
# Extra linters, only checking new code from a pull request.
32+
- name: lint-extra
33+
if: github.event_name == 'pull_request'
34+
run: |
35+
golangci-lint run --config .golangci-extra.yml --new-from-rev=HEAD~1 --out-format=github-actions
5136
5237
compile-buildtags:
5338
runs-on: ubuntu-20.04

.golangci-extra.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This is golangci-lint config file which is used to check new code in
2-
# github PRs only (see lint-extra job in .github/workflows/validate.yml).
2+
# github PRs only (see lint-extra in .github/workflows/validate.yml).
33
#
44
# For the default linter config, see .golangci.yml. This config should
55
# only enable additional linters not enabled in the default config.

0 commit comments

Comments
 (0)