Skip to content

Commit 93ff9fe

Browse files
Copilothsluoyz
andcommitted
Add GitHub Actions CI workflow for automated testing and building
Co-authored-by: hsluoyz <3787410+hsluoyz@users.noreply.github.com>
1 parent 5233252 commit 93ff9fe

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

.github/workflows/ci.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
branches: [ main, master ]
8+
9+
jobs:
10+
test:
11+
name: Test
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
go-version: ['1.19', '1.20', '1.21']
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Go
22+
uses: actions/setup-go@v5
23+
with:
24+
go-version: ${{ matrix.go-version }}
25+
26+
- name: Download dependencies
27+
run: go mod download
28+
29+
- name: Verify dependencies
30+
run: go mod verify
31+
32+
- name: Run go vet
33+
run: go vet ./...
34+
35+
- name: Run go fmt
36+
run: |
37+
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then
38+
echo "Please run 'go fmt ./...'"
39+
gofmt -s -l .
40+
exit 1
41+
fi
42+
43+
- name: Run tests
44+
run: go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...
45+
46+
- name: Upload coverage
47+
uses: codecov/codecov-action@v4
48+
with:
49+
file: ./coverage.txt
50+
flags: unittests
51+
52+
build:
53+
name: Build
54+
runs-on: ubuntu-latest
55+
56+
steps:
57+
- name: Checkout code
58+
uses: actions/checkout@v4
59+
60+
- name: Set up Go
61+
uses: actions/setup-go@v5
62+
with:
63+
go-version: '1.21'
64+
65+
- name: Build
66+
run: go build -v ./...

0 commit comments

Comments
 (0)