-
Notifications
You must be signed in to change notification settings - Fork 3
175 lines (146 loc) · 4.81 KB
/
pr-main.yaml
File metadata and controls
175 lines (146 loc) · 4.81 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
---
name: "PR → main: CI Tests and Linting"
on:
merge_group:
pull_request:
types: [opened, reopened, synchronize]
branches:
- main
jobs:
ci-test-go:
runs-on: ubuntu-24.04
permissions:
contents: read
pull-requests: read
checks: write
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: 0
- name: Configure env for toolchain ignore
shell: bash
run: echo "GOTOOLCHAIN=local" >> "$GITHUB_ENV"
- name: Setup golang
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with:
go-version-file: go.mod
- name: Set env vars
run: |
gomodcache="$(go env GOMODCACHE)"
gocache="$(go env GOCACHE)"
goroot="$(go env GOROOT)"
{
echo "GOMODCACHE=${gomodcache}"
echo "GOCACHE=${gocache}"
echo "GOROOT=${goroot}"
} >> "$GITHUB_ENV"
- name: Cache Go modules and build cache
uses: actions/cache@v4
with:
path: |
${{ env.GOMODCACHE }}
${{ env.GOCACHE }}
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum', '**/go.work.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Setup asdf
uses: asdf-vm/actions/install@1902764435ca0dd2f3388eea723a4f92a4eb8302 # v4.0.0
- name: Setup task
uses: arduino/setup-task@b91d5d2c96a56797b48ac1e0e89220bf64044611 # v2.0.0
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Generate code
run: go generate ./...
- name: Run Go Tests
run: task go:test
- name: Archive code coverage results
uses: actions/upload-artifact@v4
with:
name: code-coverage
path: coverage.txt
ci-lint-go:
runs-on: ubuntu-24.04
permissions:
contents: read
pull-requests: read
checks: write
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: 0
- name: Configure env for toolchain ignore
shell: bash
run: echo "GOTOOLCHAIN=local" >> "$GITHUB_ENV"
- name: Setup golang
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with:
go-version-file: go.mod
- name: Set env vars
run: |
gomodcache="$(go env GOMODCACHE)"
gocache="$(go env GOCACHE)"
goroot="$(go env GOROOT)"
{
echo "GOMODCACHE=${gomodcache}"
echo "GOCACHE=${gocache}"
echo "GOROOT=${goroot}"
} >> "$GITHUB_ENV"
- name: Cache Go modules and build cache
uses: actions/cache@v4
with:
path: |
${{ env.GOMODCACHE }}
${{ env.GOCACHE }}
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum', '**/go.work.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Setup asdf
uses: asdf-vm/actions/install@1902764435ca0dd2f3388eea723a4f92a4eb8302 # v4.0.0
- name: Setup task
uses: arduino/setup-task@b91d5d2c96a56797b48ac1e0e89220bf64044611 # v2.0.0
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Generate code
run: go generate ./...
- name: Run golangci-lint
run: task go:lint
gen-coverage-report:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: 0
- name: Setup golang
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with:
go-version-file: go.mod
- name: Set env vars
run: |
gomodcache="$(go env GOMODCACHE)"
gocache="$(go env GOCACHE)"
goroot="$(go env GOROOT)"
{
echo "GOMODCACHE=${gomodcache}"
echo "GOCACHE=${gocache}"
echo "GOROOT=${goroot}"
} >> "$GITHUB_ENV"
- name: Cache Go modules and build cache
uses: actions/cache@v4
with:
path: |
${{ env.GOMODCACHE }}
${{ env.GOCACHE }}
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum', '**/go.work.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: generate test coverage
run: go test -fullpath -mod=readonly -count 1 -shuffle=on -coverprofile=./coverage.txt -covermode=atomic -coverpkg=./... ./...
- name: check test coverage
uses: vladopajic/go-test-coverage@d4177aaab9307eb783516275d495c01254da2fb9 # v2.16.0
with:
config: ./.testcoverage.yaml