1+ name : Test
2+
3+ on :
4+ push :
5+ branches : [ main, develop ]
6+ pull_request :
7+ branches : [ main, develop ]
8+
9+ jobs :
10+ test :
11+ name : Test
12+ runs-on : ubuntu-latest
13+
14+ strategy :
15+ matrix :
16+ go-version : ['1.21', '1.22', '1.23']
17+
18+ steps :
19+ - name : Checkout code
20+ uses : actions/checkout@v4
21+
22+ - name : Set up Go
23+ uses : actions/setup-go@v5
24+ with :
25+ go-version : ${{ matrix.go-version }}
26+
27+ - name : Cache Go modules
28+ uses : actions/cache@v4
29+ with :
30+ path : |
31+ ~/.cache/go-build
32+ ~/go/pkg/mod
33+ key : ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
34+ restore-keys : |
35+ ${{ runner.os }}-go-${{ matrix.go-version }}-
36+
37+ - name : Download dependencies
38+ run : go mod download
39+
40+ - name : Verify dependencies
41+ run : go mod verify
42+
43+ - name : Run go vet
44+ run : go vet ./...
45+
46+ - name : Run go fmt
47+ run : |
48+ if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then
49+ echo "The following files are not formatted:"
50+ gofmt -s -l .
51+ exit 1
52+ fi
53+
54+ - name : Run tests
55+ run : go test -v -race -coverprofile=coverage.out ./...
56+
57+ - name : Run tests with short mode
58+ run : go test -v -short ./...
59+
60+ - name : Upload coverage to Codecov
61+ uses : codecov/codecov-action@v4
62+ with :
63+ file : ./coverage.out
64+ flags : unittests
65+ name : codecov-umbrella
66+ fail_ci_if_error : false
67+
68+ - name : Generate coverage report
69+ run : go tool cover -html=coverage.out -o coverage.html
70+
71+ - name : Upload coverage report
72+ uses : actions/upload-artifact@v4
73+ with :
74+ name : coverage-report-go${{ matrix.go-version }}
75+ path : coverage.html
76+
77+ test-build :
78+ name : Test Build
79+ runs-on : ubuntu-latest
80+ needs : test
81+
82+ steps :
83+ - name : Checkout code
84+ uses : actions/checkout@v4
85+
86+ - name : Set up Go
87+ uses : actions/setup-go@v5
88+ with :
89+ go-version : ' 1.23'
90+
91+ - name : Download dependencies
92+ run : go mod download
93+
94+ - name : Build
95+ run : go build -v -o commit ./cmd/commit-msg
96+
97+ - name : Verify binary
98+ run : ./commit --help || true
0 commit comments