-
Notifications
You must be signed in to change notification settings - Fork 29
65 lines (57 loc) · 1.5 KB
/
ci-test-go.yaml
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
name: ci-test-golang
on:
push:
branches:
- "*"
pull_request:
branches:
- "master"
# Allows for manual triggers using the `gh` CLI.
workflow_dispatch:
env:
GO_VERSION: "1.22"
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Install dependencies
run: go mod download
- name: Run go vet
run: go vet ./...
- name: Run go test
run: go test ./... -json > test-results.json
- name: Publish test results
uses: actions/upload-artifact@v4
with:
name: go-results
path: test-results.json
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Verify go mod tidy has been run
run: |
set -e
go mod tidy
if [ ! -z "$(git status --porcelain go.mod go.sum)" ]; then
>&2 echo "Running go mod tidy modified go.mod and/or go.sum"
exit 1
fi
- name: Verify gofumpt has been run
run: |
set -e
go install mvdan.cc/gofumpt@latest
gofumpt -l -w .
if [ ! -z "$(git status --porcelain .)" ]; then
>&2 echo "Running gofumpt modified source code"
exit 1
fi