ci: split test.yml into test-web.yml + test-go.yml, run on dev pushes
Operator wants CI to run on dev pushes (not just PR-to-main) but path-scoped so Go-only diffs don't run web tests and vice versa. The old test.yml ran everything on PR-to-main only; the new shape is two focused workflows that each path-filter their own scope. - test-web.yml — paths: web/**. Runs npm ci + npm run check + vitest. Drops the npm run build step (vitest doesn't need the bundle; the go:embed placeholder lives in web/build/index.html and never needs the test job to rebuild it). - test-go.yml — paths: **/*.go, go.mod, go.sum, sqlc.yaml, internal/**, cmd/**. Runs go vet + golangci-lint + go test -short -race. Both trigger on push to dev/main and PR to main. Tag pushes are not covered — release.yml owns the tag-build path and tests have already passed by the time a tag lands. Drops the gomod-detect guard from test.yml — go.mod has been present since M1 and is required for any Go file to exist anyway.
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
name: test-go
|
||||
|
||||
# Go server: vet + golangci-lint + short race tests. Runs on push to
|
||||
# dev/main and PRs to main, scoped to Go-side files only — web-only or
|
||||
# Flutter-only diffs don't trigger this workflow.
|
||||
#
|
||||
# Integration tests needing Postgres/ffmpeg run locally via docker-compose;
|
||||
# they should guard with testing.Short() so this short-mode run skips them.
|
||||
#
|
||||
# `web/build/` has a committed placeholder index.html so go:embed succeeds
|
||||
# without needing the SPA to be freshly built. Real builds happen in
|
||||
# release.yml (container) and locally during dev.
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [dev, main]
|
||||
paths:
|
||||
- '**/*.go'
|
||||
- 'go.mod'
|
||||
- 'go.sum'
|
||||
- 'sqlc.yaml'
|
||||
- 'internal/**'
|
||||
- 'cmd/**'
|
||||
- '.forgejo/workflows/test-go.yml'
|
||||
pull_request:
|
||||
branches: [main]
|
||||
paths:
|
||||
- '**/*.go'
|
||||
- 'go.mod'
|
||||
- 'go.sum'
|
||||
- 'sqlc.yaml'
|
||||
- 'internal/**'
|
||||
- 'cmd/**'
|
||||
- '.forgejo/workflows/test-go.yml'
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: go-ci
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Toolchain versions
|
||||
run: |
|
||||
go version
|
||||
golangci-lint --version
|
||||
|
||||
- name: go vet
|
||||
run: go vet ./...
|
||||
|
||||
- name: golangci-lint
|
||||
run: golangci-lint run ./...
|
||||
|
||||
- name: go test (short, race)
|
||||
run: go test -short -race ./...
|
||||
@@ -0,0 +1,45 @@
|
||||
name: test-web
|
||||
|
||||
# Web SPA: vitest + svelte-check. Runs on push to dev/main and PRs to
|
||||
# main, scoped to web/** changes only — Go-only or Flutter-only diffs
|
||||
# don't trigger this workflow.
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [dev, main]
|
||||
paths:
|
||||
- 'web/**'
|
||||
- '.forgejo/workflows/test-web.yml'
|
||||
pull_request:
|
||||
branches: [main]
|
||||
paths:
|
||||
- 'web/**'
|
||||
- '.forgejo/workflows/test-web.yml'
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: go-ci
|
||||
|
||||
defaults:
|
||||
run:
|
||||
working-directory: web
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '22'
|
||||
cache: 'npm'
|
||||
cache-dependency-path: web/package-lock.json
|
||||
|
||||
- name: Install deps
|
||||
run: npm ci
|
||||
|
||||
- name: Type-check + svelte-check
|
||||
run: npm run check
|
||||
|
||||
- name: Vitest
|
||||
run: npm test
|
||||
@@ -1,75 +0,0 @@
|
||||
name: test
|
||||
|
||||
# Lint + short unit tests. Integration tests needing Postgres/ffmpeg run
|
||||
# locally via docker-compose; they should guard with testing.Short().
|
||||
|
||||
on:
|
||||
# PRs against main are the gate. Direct pushes to dev no longer trigger
|
||||
# CI on their own — opening a PR fires the pull_request event and gates
|
||||
# the merge. Avoids the duplicate push+pull_request runs we were
|
||||
# accumulating on every PR commit.
|
||||
#
|
||||
# paths-ignore skips this workflow when only Flutter-client files change;
|
||||
# the Flutter workflow (.forgejo/workflows/flutter.yml) handles those.
|
||||
pull_request:
|
||||
branches: [main]
|
||||
paths-ignore:
|
||||
- 'flutter_client/**'
|
||||
- 'docs/**'
|
||||
- '**/*.md'
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: go-ci
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '22'
|
||||
cache: 'npm'
|
||||
cache-dependency-path: web/package-lock.json
|
||||
|
||||
- name: Install web deps
|
||||
working-directory: web
|
||||
run: npm ci
|
||||
|
||||
- name: Web build (populates web/build/ for go:embed)
|
||||
working-directory: web
|
||||
run: npm run build
|
||||
|
||||
- name: Web test (vitest)
|
||||
working-directory: web
|
||||
run: npm test
|
||||
|
||||
- name: Detect Go project
|
||||
id: gomod
|
||||
shell: bash
|
||||
run: |
|
||||
if [ -f go.mod ]; then
|
||||
echo "present=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "present=false" >> "$GITHUB_OUTPUT"
|
||||
echo "::notice::No go.mod yet — Go steps will be skipped until the skeleton lands"
|
||||
fi
|
||||
|
||||
- name: Toolchain versions
|
||||
if: steps.gomod.outputs.present == 'true'
|
||||
run: |
|
||||
go version
|
||||
golangci-lint --version
|
||||
|
||||
- name: go vet
|
||||
if: steps.gomod.outputs.present == 'true'
|
||||
run: go vet ./...
|
||||
|
||||
- name: golangci-lint
|
||||
if: steps.gomod.outputs.present == 'true'
|
||||
run: golangci-lint run ./...
|
||||
|
||||
- name: go test (short, race)
|
||||
if: steps.gomod.outputs.present == 'true'
|
||||
run: go test -short -race ./...
|
||||
Reference in New Issue
Block a user