-
Notifications
You must be signed in to change notification settings - Fork 25
64 lines (63 loc) · 1.84 KB
/
backend-sanity-checks.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
55
56
57
58
59
60
61
62
63
64
name: backend-sanity-checks
on:
push:
paths:
- "**.go"
- ".github/workflows/backend-sanity-checks.yml"
jobs:
go-vet:
name: Go Vet
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "1.21.x"
- name: Run go vet
run: go vet ./... > govetresult.json
- name: Upload Go test results
uses: actions/upload-artifact@v3
with:
name: go-vet-results
path: govetresult.json
go-fmt:
name: Go fmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "1.21.x"
- name: Run go fmt
id: run-go-fmt
run: |
go fmt ./... >> gofmtresult.json
# [ -s <filename> ] returns true is file exists and size is greater than zero
echo "gofmt_needed=$(if [ -s gofmtresult.json ];then echo "true"; else echo "false"; fi)" >> $GITHUB_OUTPUT
- name: Check if any files need to be formatted with go fmt
if: steps.run-go-fmt.outputs.gofmt_needed == 'true'
run: |
echo "go fmt needs to be run on the following files:"
cat gofmtresult.json
exit 1
go-test:
name: Go Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "1.21.x"
- name: Install dependencies
run: |
go install gotest.tools/gotestsum@latest
- name: Run Tests
run: gotestsum --format testname --jsonfile testresult.json -- -v ./...
- name: Upload Go test results
uses: actions/upload-artifact@v3
with:
name: go-test-results
path: testresult.json