ci: add go lint and race test workflow (#187)

This commit is contained in:
BBQ
2026-03-05 11:25:33 +08:00
committed by GitHub
parent 387ac50030
commit 3feb03aca7
192 changed files with 2245 additions and 2028 deletions
+69
View File
@@ -0,0 +1,69 @@
name: Go CI
on:
push:
branches: ["main"]
paths:
- "**/*.go"
- "go.mod"
- "go.sum"
- ".golangci.yml"
- "db/queries/**/*.sql"
- "db/migrations/**/*.sql"
- ".github/workflows/go-ci.yml"
pull_request:
branches: ["main"]
paths:
- "**/*.go"
- "go.mod"
- "go.sum"
- ".golangci.yml"
- "db/queries/**/*.sql"
- "db/migrations/**/*.sql"
- ".github/workflows/go-ci.yml"
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.10.1
only-new-issues: true
test:
name: Test
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Run tests
run: go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...
- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: go-coverage
path: coverage.txt
if-no-files-found: error