Skip to content

Commit c0d17fd

Browse files
authored
Merge pull request #11 from tstromberg/main
add github CI
2 parents 4aad25c + 8b4a9b7 commit c0d17fd

3 files changed

Lines changed: 653 additions & 25 deletions

File tree

.github/workflows/lint.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
lint:
11+
name: Lint
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Go
19+
uses: actions/setup-go@v5
20+
with:
21+
go-version: 'stable'
22+
cache: true
23+
24+
- name: Download dependencies
25+
run: go mod download
26+
27+
- name: Set up Python
28+
uses: actions/setup-python@v5
29+
with:
30+
python-version: '3.x'
31+
32+
- name: Run make lint
33+
run: make lint

.github/workflows/test.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
name: Test
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Go
19+
uses: actions/setup-go@v5
20+
with:
21+
go-version: 'stable'
22+
cache: true
23+
24+
- name: Download dependencies
25+
run: go mod download
26+
27+
- name: Run go fmt
28+
run: |
29+
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then
30+
echo "The following files are not formatted:"
31+
gofmt -s -l .
32+
exit 1
33+
fi
34+
35+
- name: Run go vet
36+
run: go vet ./...
37+
38+
- name: Run tests with coverage
39+
run: go test -race -coverprofile=coverage.out -covermode=atomic ./...
40+
41+
- name: Check coverage
42+
run: |
43+
coverage=$(go tool cover -func=coverage.out | grep total | awk '{print $3}' | sed 's/%//')
44+
echo "Total coverage: ${coverage}%"
45+
46+
# Set minimum coverage threshold (adjust as needed)
47+
min_coverage=70
48+
49+
if (( $(echo "$coverage < $min_coverage" | bc -l) )); then
50+
echo "Coverage ${coverage}% is below minimum threshold of ${min_coverage}%"
51+
exit 1
52+
fi
53+
54+
echo "Coverage check passed: ${coverage}% >= ${min_coverage}%"
55+
56+
- name: Upload coverage to Codecov
57+
uses: codecov/codecov-action@v4
58+
with:
59+
file: ./coverage.out
60+
flags: unittests
61+
name: codecov-umbrella
62+
fail_ci_if_error: false

0 commit comments

Comments
 (0)