From aa875339b54f2c34264e52c0261049c015a8d91a Mon Sep 17 00:00:00 2001 From: Stephen Adamson Date: Thu, 25 Jun 2026 12:57:15 +0100 Subject: [PATCH] ci: add race detector, govulncheck, and frontend quality jobs Three parallel jobs: - test: existing Go tests (unchanged) - race: Go tests with -race flag (catches data races) - quality: govulncheck + svelte-check + eslint/prettier (no PG needed) Race job has its own PG service container so all three can run in parallel. --- .gitea/workflows/backend-tests.yaml | 69 -------------- .gitea/workflows/ci.yaml | 142 ++++++++++++++++++++++++++++ 2 files changed, 142 insertions(+), 69 deletions(-) delete mode 100644 .gitea/workflows/backend-tests.yaml create mode 100644 .gitea/workflows/ci.yaml diff --git a/.gitea/workflows/backend-tests.yaml b/.gitea/workflows/backend-tests.yaml deleted file mode 100644 index e108ce3..0000000 --- a/.gitea/workflows/backend-tests.yaml +++ /dev/null @@ -1,69 +0,0 @@ -name: Backend Tests -description: Runs Go tests with PostgreSQL for all backend packages. -on: - push: - branches: - - main - - develop - pull_request: - -jobs: - test: - runs-on: ubuntu-latest - defaults: - run: - shell: sh - services: - postgres: - image: postgres:16-alpine - env: - POSTGRES_USER: myuser - POSTGRES_PASSWORD: mypassword - POSTGRES_DB: mydb - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version: "1.25" - cache: false - - - name: Install system deps - run: apk add --no-cache postgresql-client - - - name: Wait for PostgreSQL - run: | - for i in $(seq 1 30); do - pg_isready -h postgres -U myuser && break - sleep 1 - done - - - name: Create test databases - run: | - PGPASSWORD=mypassword psql -h postgres -U myuser -d mydb -c "CREATE DATABASE crussell_test_db;" 2>/dev/null || true - - - name: Build - working-directory: backend - run: go build ./... - - - name: Vet - working-directory: backend - run: go vet ./... - - - name: Test (all packages) - working-directory: backend - run: go test -tags "test,dev" -count=1 -v -timeout 180s ./... - env: - POSTGRES_HOST: postgres - TEST_DB_HOST: postgres - PGUSER: myuser - PGPASSWORD: mypassword - PGDATABASE: mydb diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml new file mode 100644 index 0000000..1d1cc04 --- /dev/null +++ b/.gitea/workflows/ci.yaml @@ -0,0 +1,142 @@ +name: Backend CI +description: Runs Go tests, race detection, linting, and frontend quality checks. +on: + push: + branches: + - main + - develop + pull_request: + +env: + POSTGRES_USER: myuser + POSTGRES_PASSWORD: mypassword + POSTGRES_DB: mydb + +jobs: + test: + name: Tests + runs-on: ubuntu-latest + defaults: + run: + shell: sh + services: + postgres: + image: postgres:16-alpine + env: + POSTGRES_USER: myuser + POSTGRES_PASSWORD: mypassword + POSTGRES_DB: mydb + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version: "1.25" + cache: false + + - run: apk add --no-cache postgresql-client + + - run: | + for i in $(seq 1 30); do + pg_isready -h postgres -U myuser && break + sleep 1 + done + + - run: PGPASSWORD=mypassword psql -h postgres -U myuser -d mydb -c "CREATE DATABASE crussell_test_db;" 2>/dev/null || true + + - run: go build ./... + working-directory: backend + + - run: go vet ./... + working-directory: backend + + - name: Test + working-directory: backend + run: go test -tags "test,dev" -count=1 -v -timeout 180s ./... + env: + POSTGRES_HOST: postgres + TEST_DB_HOST: postgres + + race: + name: Race detector + runs-on: ubuntu-latest + defaults: + run: + shell: sh + services: + postgres: + image: postgres:16-alpine + env: + POSTGRES_USER: myuser + POSTGRES_PASSWORD: mypassword + POSTGRES_DB: mydb + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version: "1.25" + cache: false + + - run: apk add --no-cache postgresql-client + + - run: | + for i in $(seq 1 30); do + pg_isready -h postgres -U myuser && break + sleep 1 + done + + - run: PGPASSWORD=mypassword psql -h postgres -U myuser -d mydb -c "CREATE DATABASE crussell_test_db;" 2>/dev/null || true + + - name: Test with race detector + working-directory: backend + run: go test -tags "test,dev" -race -count=1 -timeout 300s ./... + env: + POSTGRES_HOST: postgres + TEST_DB_HOST: postgres + + quality: + name: Lint & vulns + runs-on: ubuntu-latest + defaults: + run: + shell: sh + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version: "1.25" + cache: false + + - name: Go vulnerability scan + working-directory: backend + run: | + go install golang.org/x/vuln/cmd/govulncheck@latest + govulncheck ./... + + - uses: actions/setup-node@v4 + with: + node-version: "22" + + - name: Frontend type check + working-directory: frontend + run: | + npm ci + npm run check + + - name: Frontend lint + working-directory: frontend + run: npm run lint