tests: use proper context in test + add pull request workflow

This commit is contained in:
Stevan Freeborn
2026-01-12 17:59:46 -06:00
parent a9e49906e0
commit 54865ba64c
3 changed files with 48 additions and 7 deletions
+39
View File
@@ -0,0 +1,39 @@
name: Pull Request
on:
pull_request:
branches:
- main
jobs:
test-and-lint:
name: Test, Format & Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: "1.25"
cache: true
- name: Check formatting
run: |
# Fails if any files are not formatted correctly
if [ -n "$(gofmt -l .)" ]; then
echo "Go code is not formatted:"
gofmt -d .
exit 1
fi
- name: Run go vet
run: go vet ./...
- name: Run linter
uses: golangci/golangci-lint-action@v9
with:
version: latest
- name: Run tests
run: go test -v ./... -coverprofile=coverage.out
- name Generate coverage report
run: go tool cover -html=coverage.out -o coverage.html
- name: Upload test coverage
uses: actions/upload-artifact@v6
with:
name: coverage.html