Skip to content

Commit 9b77d24

Browse files
committed
ci: add golangci-lint job
Taken from runc. Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent afa9f8f commit 9b77d24

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

.github/workflows/validate.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: validate
2+
on:
3+
push:
4+
tags:
5+
- v*
6+
branches:
7+
- main
8+
- release-*
9+
pull_request:
10+
env:
11+
GO_VERSION: 1.24
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
lint:
17+
timeout-minutes: 30
18+
permissions:
19+
contents: read
20+
pull-requests: read
21+
checks: write # to allow the action to annotate code in the PR.
22+
runs-on: ubuntu-24.04
23+
steps:
24+
- uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 2
27+
- uses: actions/setup-go@v5
28+
with:
29+
go-version: "${{ env.GO_VERSION }}"
30+
- uses: golangci/golangci-lint-action@v6
31+
with:
32+
version: v1.64
33+
# Extra linters, only checking new code from a pull request.
34+
- name: lint-extra
35+
if: github.event_name == 'pull_request'
36+
run: |
37+
golangci-lint run --config .golangci-extra.yml --new-from-rev=HEAD~1
38+

.golangci-extra.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This is golangci-lint config file which is used to check NEW code in
2+
# github PRs only (see lint-extra in .github/workflows/validate.yml).
3+
#
4+
# For the default linter config, see .golangci.yml. This config should
5+
# only enable additional linters not enabled in the default config.
6+
7+
linters:
8+
disable-all: true
9+
enable:
10+
- godot
11+
- revive
12+

.golangci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# For documentation, see https://golangci-lint.run/usage/configuration/
2+
3+
linters:
4+
enable:
5+
- gofumpt
6+
- errorlint
7+
- unconvert
8+
- unparam
9+
10+
linters-settings:
11+
govet:
12+
enable:
13+
- nilness

0 commit comments

Comments
 (0)