-
Notifications
You must be signed in to change notification settings - Fork 16
84 lines (82 loc) · 2.19 KB
/
lint.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: Lint
# This workflow is run on every pull request and push to master
# The `golangci` will pass without running if no *.{go, mod, sum} files have been changed.
on:
pull_request:
paths:
- "**.go"
- "go.mod"
- "go.sum"
push:
branches:
- main
- "release/*"
paths:
- "**.go"
- "go.mod"
- "go.sum"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
golangci:
env:
GOLANGCI_LINT_VERSION: v1.59.1
name: golangci-lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.22
check-latest: true
- uses: technote-space/[email protected]
id: git_diff
with:
PATTERNS: |
**/**.go
go.mod
go.sum
# install golangci-lint
- run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}
- name: run go linters (long)
if: env.GIT_DIFF
id: lint_long
run: |
make lint
env:
GIT_DIFF: ${{ env.GIT_DIFF }}
- uses: technote-space/[email protected]
if: steps.lint_long.outcome == 'skipped'
with:
PATTERNS: |
**/**.go
go.mod
go.sum
- name: run go linters (short)
if: steps.lint_long.outcome == 'skipped' && env.GIT_DIFF
run: |
make lint
env:
GIT_DIFF: ${{ env.GIT_DIFF }}
LINT_DIFF: 1
# Use --check or --exit-code when available (Go 1.19?)
# https://github.com/golang/go/issues/27005
tidy:
runs-on: ubuntu-latest
name: tidy
steps:
- uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: 1.22
check-latest: true
- run: |
go mod tidy
CHANGES_IN_REPO=$(git status --porcelain)
if [[ -n "$CHANGES_IN_REPO" ]]; then
echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:"
git status && git --no-pager diff
exit 1
fi