116 lines
4.1 KiB
YAML
116 lines
4.1 KiB
YAML
# Kit template — copy to .gitea/workflows/ci.yml and fill placeholders.
|
|
# Pin @v1 (or @v1.1 once post_build_command is tagged on infra/ci-workflows).
|
|
# Never a branch. Path filter + changes job stay local (repo-specific).
|
|
#
|
|
# node-ci phases: lint → extra_check (NO dist) → build → post_build (MAY use dist).
|
|
# Do not put check:bundle / Playwright / anything that needs dist/ in extra_check.
|
|
#
|
|
# If tests still use Testcontainers, the workflow's Postgres/Redis services may sit
|
|
# idle — prefer extending infra/ci-workflows over forking steps.
|
|
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main, master]
|
|
paths:
|
|
- "api/**"
|
|
- "web/**"
|
|
- "tests/**"
|
|
- "MyApp.sln"
|
|
- ".gitea/workflows/**"
|
|
pull_request:
|
|
branches: [main, master]
|
|
paths:
|
|
- "api/**"
|
|
- "web/**"
|
|
- "tests/**"
|
|
- "MyApp.sln"
|
|
- ".gitea/workflows/**"
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
# Stays local: repo-specific path map; needs fetch-depth: 0.
|
|
# Keep actions/checkout@v4 here until builtin:checkout is proven with fetch-depth: 0.
|
|
changes:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
backend: ${{ steps.filter.outputs.backend }}
|
|
frontend: ${{ steps.filter.outputs.frontend }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- id: filter
|
|
name: Detect stack changes
|
|
run: |
|
|
set -euo pipefail
|
|
backend=false
|
|
frontend=false
|
|
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
|
backend=true
|
|
frontend=true
|
|
else
|
|
if [ "${{ github.event_name }}" = "pull_request" ]; then
|
|
base="${{ github.event.pull_request.base.sha }}"
|
|
else
|
|
base="${{ github.event.before }}"
|
|
fi
|
|
if [ -z "${base:-}" ] || [ "$base" = "0000000000000000000000000000000000000000" ]; then
|
|
backend=true
|
|
frontend=true
|
|
else
|
|
files="$(git diff --name-only "$base" "${{ github.sha }}")"
|
|
printf '%s\n' "$files"
|
|
if printf '%s\n' "$files" | grep -qE '^(api/|tests/|MyApp\.sln|\.gitea/workflows/)'; then
|
|
backend=true
|
|
fi
|
|
if printf '%s\n' "$files" | grep -qE '^(web/|\.gitea/workflows/)'; then
|
|
frontend=true
|
|
fi
|
|
fi
|
|
fi
|
|
echo "backend=${backend}" >> "$GITHUB_OUTPUT"
|
|
echo "frontend=${frontend}" >> "$GITHUB_OUTPUT"
|
|
|
|
backend:
|
|
needs: changes
|
|
if: needs.changes.outputs.backend == 'true'
|
|
uses: infra/ci-workflows/.gitea/workflows/dotnet8-ci.yml@v1
|
|
with:
|
|
working_directory: .
|
|
solution: MyApp.sln
|
|
postgres_db: myapp_test
|
|
# Prefer split projects: isolated (InMemory) first, then service-backed.
|
|
# If unit + integration share one .csproj, omit isolated_test_projects and
|
|
# list that project only under test_projects.
|
|
isolated_test_projects: |
|
|
tests/MyApp.UnitTests/MyApp.UnitTests.csproj
|
|
test_projects: |
|
|
tests/MyApp.IntegrationTests/MyApp.IntegrationTests.csproj
|
|
test_env: |
|
|
Auth__ApiKey=ci-test-api-key-at-least-32-bytes-long!!
|
|
|
|
frontend:
|
|
needs: changes
|
|
if: needs.changes.outputs.frontend == 'true'
|
|
# Use @v1.1 once infra/ci-workflows tags post_build_command; until then keep
|
|
# post-dist steps inside build_command after `npx vite build`.
|
|
uses: infra/ci-workflows/.gitea/workflows/node-ci.yml@v1
|
|
with:
|
|
working_directory: web
|
|
node_version: "22"
|
|
# Typecheck once here; build must not re-run tsc / vue-tsc.
|
|
lint_command: npm run lint && npm run typecheck
|
|
# Pre-dist only (audit, unit tests, source checks).
|
|
extra_check_command: npm audit --audit-level=high && npm run test -- --run --coverage
|
|
build_command: npx vite build
|
|
# Needs dist/ — bundle budget, Playwright, etc. (requires node-ci @v1.1+)
|
|
post_build_command: npm run check:bundle && npx playwright install --with-deps chromium && npx playwright test
|
|
build_env: |
|
|
VITE_API_BASE_URL=http://localhost:5067
|
|
VITE_RELEASE=ci
|
|
VITE_ENVIRONMENT=ci
|
|
CI=true
|
|
artifact_path: dist
|