File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,31 +2,43 @@ name: Go Tests
22
33on :
44 push :
5- branches : [ main, master ]
5+ branches : [ main ]
66 pull_request :
7- branches : [ main, master ]
7+ branches : [ main ]
88
99jobs :
1010 test :
11- name : Test
1211 runs-on : ubuntu-latest
13-
12+ permissions :
13+ contents : read
1414 steps :
15- - name : Checkout code
16- uses : actions/checkout@v3
15+ - uses : actions/checkout@v4
1716
18- - name : Set up Go
19- uses : actions/setup-go@v4
20- with :
21- go-version : ' 1.24'
22-
23- - name : Get dependencies
24- run : go mod download
17+ - name : Set up Go
18+ uses : actions/setup-go@v5
19+ with :
20+ go-version : ' 1.24'
2521
26- - name : Run tests
27- run : go test -v ./... -coverprofile=coverage.txt
22+ - name : Check formatting
23+ run : |
24+ UNFORMATTED=$(gofmt -s -l .)
25+ if [ -n "$UNFORMATTED" ]; then
26+ echo "::error::The following files are not formatted:"
27+ echo "$UNFORMATTED"
28+ echo ""
29+ echo "Run locally: gofmt -s -w ."
30+ exit 1
31+ fi
2832
29- - name : Upload results to Codecov
30- uses : codecov/codecov-action@v5
31- with :
32- token : ${{ secrets.CODECOV_TOKEN }}
33+ - name : Vet
34+ run : go vet ./...
35+
36+ - name : Test
37+ run : go test -race -coverprofile=coverage.txt -covermode=atomic ./...
38+
39+ - name : Upload coverage to Codecov
40+ uses : codecov/codecov-action@v5
41+ with :
42+ file : ./coverage.txt
43+ token : ${{ secrets.CODECOV_TOKEN }}
44+ fail_ci_if_error : false
You can’t perform that action at this time.
0 commit comments