-
Notifications
You must be signed in to change notification settings - Fork 13
54 lines (52 loc) · 1.76 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
name: Go Lint
# Trigger the workflow on pull requests and direct pushes to any branch
on:
push:
paths:
- '**.go'
pull_request:
types: [ opened, synchronize ]
paths:
- '**.go'
jobs:
lint:
name: golangci-lint
runs-on: ubuntu-latest
# Pull requests from the same repository won't trigger this checks as they were already triggered by the push
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
steps:
- name: Setup Go environment
uses: actions/setup-go@v5
with:
go-version: '^1.21'
- name: Clone the code
uses: actions/checkout@v4
- name: Cache go dependencies
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Generate necessary files
run: make generate
shell: bash
- name: Run linter
uses: golangci/golangci-lint-action@v3
with:
version: latest # Always uses the latest patch version.
only-new-issues: true # Show only new issues if it's a pull request
skip-pkg-cache: true
skip-build-cache: true
args: --timeout=5m
- name: Report failure
if: failure() && github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: actions-cool/issues-helper@v3
with:
actions: 'create-issue'
token: ${{ secrets.GITHUB_TOKEN }}
title: 🐛 Lint failed for ${{ github.sha }}
body: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
labels: bug