tests: use proper context in test + add pull request workflow
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user