Files
memos/.github/workflows/backend-tests.yml
T
boojack dcf08b5911 chore(ci): share Go and web setup through composite actions
Add .github/actions/setup-go (Go version from go.mod) and
.github/actions/setup-web (pnpm from web/package.json, Node 24,
frozen install), and use them in every workflow that installed the
toolchains by hand. Drop the per-workflow version env vars and the
redundant pnpm store cache steps that duplicated setup-node's cache.
2026-10-27 20:22:30 +08:00

89 lines
2.4 KiB
YAML

name: Backend Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
paths:
- "go.mod"
- "go.sum"
- "**.go"
- ".golangci.yaml"
- ".github/actions/setup-go/**"
- ".github/workflows/backend-tests.yml"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
static-checks:
name: Static Checks
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup Go
uses: ./.github/actions/setup-go
- name: Verify go.mod is tidy
run: |
go mod tidy
git diff --exit-code
- name: Verify go fix
run: go fix -diff ./...
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.14.0
args: --timeout=3m
tests:
name: Tests (${{ matrix.test-group }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test-group: [store, server, internal, other]
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup Go
uses: ./.github/actions/setup-go
- name: Run tests
run: |
case "${{ matrix.test-group }}" in
store)
# Run store tests for all drivers (sqlite, mysql, postgres)
DRIVER= go test -v -coverprofile=coverage.out -covermode=atomic ./store/...
;;
server)
# Includes ./server/test, which boots the real server via
# server.NewServer and smokes every router it mounts.
go test -v -race -coverprofile=coverage.out -covermode=atomic ./server/...
;;
internal)
go test -v -race -coverprofile=coverage.out -covermode=atomic ./internal/...
;;
other)
go test -v -race -coverprofile=coverage.out -covermode=atomic \
./cmd/... ./core/... ./markdown/... ./filter/... ./provider/... ./proto/...
;;
esac
env:
DRIVER: sqlite
- name: Upload coverage
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: codecov/codecov-action@v5
with:
files: ./coverage.out
flags: ${{ matrix.test-group }}
fail_ci_if_error: false