-
Notifications
You must be signed in to change notification settings - Fork 8
58 lines (48 loc) · 1.24 KB
/
Copy pathlint-and-format.yml
File metadata and controls
58 lines (48 loc) · 1.24 KB
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
name: Lint and Format
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
permissions:
contents: read
jobs:
lint:
name: Lint and Format Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: true
- name: Install dependencies
run: |
go mod download
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
- name: Run gofmt
run: |
# Check if gofmt reports any formatting issues
if [ -n "$(gofmt -l .)" ]; then
echo "The following files need formatting:"
gofmt -l .
echo ""
echo "Please run 'gofmt -w .' to format your code"
exit 1
fi
- name: Run go vet
run: go vet ./...
- name: Run golangci-lint
run: golangci-lint run --timeout=5m
- name: Run go mod tidy check
run: |
go mod tidy
if [ -n "$(git status --porcelain)" ]; then
echo "go mod tidy produced changes:"
git diff
echo ""
echo "Please run 'go mod tidy' and commit the changes"
exit 1
fi