-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (49 loc) · 1.57 KB
/
go-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
name: Lint Code
on:
workflow_call:
jobs:
prebuild:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 2
- id: push_commit_msg
if: github.event_name == 'push'
run: echo ::set-output name=push_msg::$(git log --format=%B -n 1 HEAD)
- id: pull_commit_msg
if: github.event_name == 'pull_request'
run: echo ::set-output name=pull_msg::$(git log --format=%B -n 1 HEAD^2)
outputs:
commit_msg: $( [ -z "${{ steps.pull_commit_msg.outputs.pull_msg }}" ] && echo "${{ steps.push_commit_msg.outputs.push_msg }}" || echo "${{ steps.pull_commit_msg.outputs.pull_msg }}" )
lint:
needs:
- prebuild
strategy:
matrix:
go-version:
- 1.18.x
- 1.19.x
platform:
- ubuntu-latest
runs-on: ${{ matrix.platform }}
if: ${{ !contains(needs.prebuild.outputs.commit_msg, '[ci nolint]') }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go${{ matrix.go-version }}-
- run: go mod download
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v4.0.0
with:
version: v1.46.2
skip-cache: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}