Add a staticcheck step to the lint job of the Test workflow, and fix reported diagnostics.
63 lines
1.4 KiB
YAML
63 lines
1.4 KiB
YAML
name: Test
|
|
on:
|
|
# Manual trigger
|
|
workflow_dispatch:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
lint:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check out code
|
|
uses: actions/checkout@v4
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: "^1.23"
|
|
- name: Check formatting
|
|
run: |
|
|
unformatted=$(gofmt -l .)
|
|
if [ -n "$unformatted" ]; then
|
|
echo "The following files are not properly formatted:"
|
|
echo "$unformatted"
|
|
exit 1
|
|
fi
|
|
echo "All Go files are properly formatted"
|
|
- name: Run Go vet
|
|
run: go vet ./...
|
|
- name: Run staticcheck
|
|
uses: dominikh/staticcheck-action@v1
|
|
with:
|
|
version: "latest"
|
|
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
go: ["1.23", "1.24", "1.25.0-rc.3"]
|
|
steps:
|
|
- name: Check out code
|
|
uses: actions/checkout@v4
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: ${{ matrix.go }}
|
|
- name: Test
|
|
run: go test -v ./...
|
|
|
|
race-test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check out code
|
|
uses: actions/checkout@v4
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: "1.24"
|
|
- name: Test with -race
|
|
run: go test -v -race ./...
|