Files
memos/.github/workflows/backend-tests.yml
T

90 lines
2.4 KiB
YAML

name: Backend Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
paths:
- "go.mod"
- "go.sum"
- "**.go"
- "store/migration/**"
- ".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 all database targets (SQLite, MySQL, MariaDB, PostgreSQL).
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