Skip to content

Commit 4cee1f3

Browse files
committed
Add CI
1 parent 9759ea6 commit 4cee1f3

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

.github/workflows/ci.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
go-version: ["1.20", "1.24"]
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Set up Go
21+
uses: actions/setup-go@v4
22+
with:
23+
go-version: ${{ matrix.go-version }}
24+
25+
- name: Cache Go modules
26+
uses: actions/cache@v3
27+
with:
28+
path: ~/go/pkg/mod
29+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
30+
restore-keys: |
31+
${{ runner.os }}-go-
32+
33+
- name: Download dependencies
34+
run: go mod download
35+
36+
- name: Verify dependencies
37+
run: go mod verify
38+
39+
- name: Run tests
40+
run: go test -v ./...
41+
42+
- name: Check formatting
43+
run: |
44+
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then
45+
echo "Code is not formatted properly:"
46+
gofmt -s -l .
47+
exit 1
48+
fi
49+
50+
- name: Run go vet
51+
run: go vet ./...
52+
53+
- name: Run staticcheck
54+
uses: dominikh/staticcheck-action@v1
55+
with:
56+
version: "latest"

0 commit comments

Comments
 (0)