-
Notifications
You must be signed in to change notification settings - Fork 3
82 lines (72 loc) · 1.96 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
name: golangci-lint
on:
push:
branches:
- main
- next/cicd
pull_request:
branches:
- main
- "release/*.*.*"
paths:
- "go.mod"
- "go.sum"
- "**.go"
env:
GO_VERSION: '1.23'
jobs:
lint-and-test:
# Only run if push to main or not previously run in a pull request
if: |
github.event_name == 'push' &&
(
github.event.pull_request.head.repo.full_name != github.repository ||
github.event.pull_request.merged != true
) ||
github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
check-latest: true
cache: false
# Cache Go modules to improve build time.
- name: Cache Go Modules
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
# Verify go.mod and go.sum are tidy.
- name: Verify go.mod is tidy
run: |
go mod tidy -go=${{ env.GO_VERSION }}
git diff --exit-code go.sum
git diff --exit-code go.mod
# Due to poor unit testing, we comment out it.
#
# Run unit tests.
# - name: Run unit tests
# run: |
# go test ./... -v -race -coverprofile=coverage.out
# env:
# GOFLAGS: "-mod=readonly"
# Upload code coverage report.
# - name: Upload Coverage Report
# uses: actions/upload-artifact@v3
# with:
# name: coverage-report
# path: coverage.out
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.61.0
args: --verbose --timeout=3m
skip-cache: true