@@ -2,23 +2,24 @@ name: Test App
2
2
3
3
on :
4
4
push :
5
- branches : ["*", "!release/*", "!nightly"]
6
5
paths : ["cmd/**", "internal/**", "server/**", "test/**", "main.go", "go.mod", "go.sum"]
6
+ branches-ignore : ["release/*", "nightly"]
7
7
tags-ignore : ["v*"]
8
8
pull_request :
9
- branches : ["*", "!release/*", "!nightly"]
10
9
paths : ["cmd/**", "internal/**", "server/**", "test/**", "main.go", "go.mod", "go.sum"]
10
+ branches-ignore : ["release/*", "nightly"]
11
11
12
12
env :
13
13
REPORT_DIR : " /tmp/test-reports"
14
14
15
15
jobs :
16
16
test_app :
17
- name : Test App on ${{ matrix.os }}
17
+ name : Test Go on ${{ matrix.os }}
18
18
runs-on : ${{ matrix.os }}
19
19
strategy :
20
+ fail-fast : false
20
21
matrix :
21
- os : [windows-latest, ubuntu-latest, macos-latest]
22
+ os : [ubuntu-latest, macos-latest]
22
23
23
24
steps :
24
25
- uses : actions/checkout@v4
27
28
uses : actions/setup-go@v5
28
29
with :
29
30
go-version-file : go.mod
31
+ cache : false # https://github.com/actions/setup-go/issues/483
30
32
31
- - name : Print the Go version
32
- run : go version
33
+ - id : go-vars
34
+ name : Get Go variables for cache
35
+ run : |
36
+ echo "GOCACHE=$(go env GOCACHE)" >> "$GITHUB_OUTPUT"
37
+ echo "GOMODCACHE=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT"
38
+
39
+ - name : Cache go modules
40
+ uses : actions/cache@v4
41
+ with :
42
+ path : |
43
+ ${{ steps.go-vars.outputs.GOCACHE }}
44
+ ${{ steps.go-vars.outputs.GOMODCACHE }}
45
+ key : go-test-${{ runner.os }}-${{ hashFiles('**/go.mod') }}
46
+ restore-keys : |
47
+ go-test-${{ runner.os }}
33
48
34
49
- name : Install tools
35
50
run : go install gotest.tools/gotestsum@latest
@@ -40,18 +55,16 @@ jobs:
40
55
- name : Run tests
41
56
run : |
42
57
mkdir -p $REPORT_DIR
43
- gotestsum \
44
- --junitfile $REPORT_DIR/unit-tests.xml \
45
- --jsonfile $REPORT_DIR/unit-tests.json \
46
- -- -coverprofile=$REPORT_DIR/coverage.out ./...
58
+ gotestsum --junitfile $REPORT_DIR/unit-tests.xml --jsonfile $REPORT_DIR/unit-tests.json -- -coverprofile=$REPORT_DIR/coverage.out ./...
47
59
48
60
- name : Upload test results
49
61
uses : actions/upload-artifact@v4
50
62
with :
51
- name : Go-Test-Results
63
+ name : Go-Test-Results-${{ runner.os }}
52
64
path : ${{ env.REPORT_DIR }}
53
65
54
- - name : Upload coverage to Codecov
66
+ - if : matrix.os == 'ubuntu-latest'
67
+ name : Upload coverage to Codecov
55
68
uses : codecov/codecov-action@v4
56
69
with :
57
70
flags : go
0 commit comments