-
Notifications
You must be signed in to change notification settings - Fork 8
97 lines (84 loc) · 2.12 KB
/
go_ci.yaml
File metadata and controls
97 lines (84 loc) · 2.12 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
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
85
86
87
88
89
90
91
92
93
94
95
96
97
name: go-ci
on:
release:
types: [created]
pull_request:
push:
branches:
- main
paths:
- 'go/**'
- '.github/workflows/go_ci.yaml'
workflow_call:
permissions:
contents: read
pull-requests: read
jobs:
changes:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
outputs:
go: ${{ steps.filter.outputs.go }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
go:
- 'go/**'
- '.github/workflows/go_ci.yaml'
lint-go:
needs: [changes]
if: |
always() &&
(github.event_name != 'pull_request' || needs.changes.outputs.go == 'true')
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: go fmt
uses: Jerome1337/gofmt-action@v1.0.5
with:
gofmt-path: './go'
gofmt-flags: '-l -d'
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.22
- name: Verify dependencies
run: go mod verify
working-directory: go
- name: Build
run: go build -v ./...
working-directory: go
- name: Run go vet
run: go vet ./...
working-directory: go
- name: Install staticcheck
run: go install honnef.co/go/tools/cmd/staticcheck@latest
working-directory: go
- name: Run staticcheck
run: staticcheck ./...
working-directory: go
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
working-directory: go
version: v1.60
go-ci-status:
if: always()
needs: [changes, lint-go]
runs-on: ubuntu-latest
steps:
- name: Check result
run: |
result="${{ needs.lint-go.result }}"
if [[ "$result" == "success" || "$result" == "skipped" ]]; then
echo "go-ci passed (lint-go: $result)"
else
echo "go-ci failed (lint-go: $result)"
exit 1
fi