name: ZitPlane P05 CI Verification # Manual only. Docker socket is accessible to CI; do not enable untrusted PR triggers. on: workflow_dispatch: permissions: contents: read jobs: account: name: Account Portal reproducible build runs-on: ubuntu-latest container: node:22-bookworm timeout-minutes: 25 steps: - uses: actions/checkout@v4 with: github-server-url: https://dev.ivib.cc - name: Preflight source, npm lock and OIDC guard contracts run: | set -eu node --version npm --version python3 --version python3 tests/ci/source_contract.py - name: Account Portal npm ci, TypeScript and Next.js build working-directory: users/ui run: | set -eu npm ci --no-audit --no-fund npm run typecheck npm run build echo ZITPLANE_ACCOUNT_BUILD_PASS - name: Negative account API and protected page smoke (no real login) working-directory: users/ui run: | set -eu export AUTH_SECRET="$(node -e "process.stdout.write(require('node:crypto').randomBytes(48).toString('base64url'))")" export AUTH_URL=https://localhost:3001 export AUTH_TRUST_HOST=true export ZITADEL_ISSUER=https://zitadel-ci.invalid export ZITADEL_CLIENT_ID=disposable-negative-only export ZITADEL_CLIENT_SECRET=disposable-negative-only npm run start -- -p 3001 > /tmp/zitplane-account-server.log 2>&1 & server_pid=$! trap 'kill "$server_pid" 2>/dev/null || true' EXIT python3 ../../tests/ci/account_negative.py echo ZITPLANE_ACCOUNT_NEGATIVE_ACCESS_PASS login: name: Upstream Login V2 frozen workspace build runs-on: ubuntu-latest container: node:22-bookworm timeout-minutes: 45 env: NX_NO_CLOUD: "true" NX_DAEMON: "false" CI: "true" steps: - uses: actions/checkout@v4 with: github-server-url: https://dev.ivib.cc - name: Prepare pinned pnpm and frozen workspace working-directory: auth/ui/v2 run: | set -eu corepack enable corepack prepare pnpm@10.30.3 --activate pnpm --version pnpm install --frozen-lockfile echo ZITPLANE_LOGIN_FROZEN_INSTALL_PASS - name: Build ZITADEL proto, client and Login V2 working-directory: auth/ui/v2 run: | set -eu # Upstream build expects a transient .env to remove from standalone output. # No real token or credential is injected; source snapshots are untouched. : > apps/login/.env trap 'rm -f apps/login/.env' EXIT pnpm exec nx run @zitadel/login:build --skip-nx-cache test -f apps/login/.next/standalone/apps/login/server.js echo ZITPLANE_LOGIN_BUILD_PASS - name: Run upstream Login V2 unit suite working-directory: auth/ui/v2 run: | set -eu pnpm --filter @zitadel/login run test-unit echo ZITPLANE_LOGIN_UNIT_PASS security: name: Account and Login dependency security triage runs-on: ubuntu-latest container: node:22-bookworm timeout-minutes: 25 steps: - uses: actions/checkout@v4 with: github-server-url: https://dev.ivib.cc - name: Account production dependency advisories (high and critical) working-directory: users/ui run: | set -eu npm audit --omit=dev --audit-level=high echo ZITPLANE_ACCOUNT_ADVISORY_GATE_PASS # Advisory collection is non-mutating; tolerate moderate-only exit 1, # but require valid JSON and preserve the HIGH/CRITICAL gate above. npm audit --omit=dev --json > /tmp/zitplane-npm-audit.json || true python3 ../../tests/ci/advisory_triage.py npm /tmp/zitplane-npm-audit.json - name: Login workspace production dependency advisories (high and critical) working-directory: auth/ui/v2 run: | set -eu corepack enable corepack prepare pnpm@10.30.3 --activate pnpm audit --prod --audit-level high echo ZITPLANE_LOGIN_ADVISORY_GATE_PASS pnpm audit --prod --json > /tmp/zitplane-pnpm-audit.json || true python3 ../../../tests/ci/advisory_triage.py pnpm /tmp/zitplane-pnpm-audit.json backend: name: Disposable ZITADEL Docker and OIDC discovery runs-on: ubuntu-latest container: node:22-alpine timeout-minutes: 35 steps: # Alpine does not include Git. Checkout's API-archive fallback is not # reliable on Gitea; install Git before invoking actions/checkout. - name: Install Git before checkout (Alpine runner prerequisite) run: apk add --no-cache git - uses: actions/checkout@v4 with: github-server-url: https://dev.ivib.cc - name: Docker runner capability and prior backend contracts run: | set -eu apk add --no-cache python3 docker-cli docker-cli-compose git docker --version docker compose version docker info --format 'Docker driver={{.Driver}}' python3 -m unittest discover -s tests -p test_backend_dev.py -v # The P02 Compose has a literal network name and loopback port. # Refuse to attach to an existing network belonging to a different run. if docker network inspect zitplane-backend-dev-internal >/dev/null 2>&1; then echo '::error::CI local network already exists; refusing to touch another stack' exit 1 fi project="zitplane-p05-${GITHUB_RUN_ID:-0}" if docker ps -a --filter "label=com.docker.compose.project=$project" -q | grep -q .; then echo '::error::Disposable CI project already exists; refusing takeover' exit 1 fi echo ZITPLANE_DOCKER_PREFLIGHT_PASS - name: Start disposable backend and verify OIDC discovery/JWKS run: | set -eu project="zitplane-p05-${GITHUB_RUN_ID:-0}" python3 core/backend/zitadel/dev.py init docker compose --env-file .env -p "$project" -f deployment/docker/compose.backend.dev.yaml config --quiet # Cleanup is allowed only after the preflight confirmed the network was absent. touch .p05-ci-started docker compose --env-file .env -p "$project" -f deployment/docker/compose.backend.dev.yaml up -d --wait docker compose --env-file .env -p "$project" -f deployment/docker/compose.backend.dev.yaml ps # The disposable Postgres volume must retain independently written data # after a database-container restart; this is NOT a production migration. docker compose --env-file .env -p "$project" -f deployment/docker/compose.backend.dev.yaml \ exec -T postgres psql -U zitadel -d postgres -v ON_ERROR_STOP=1 \ -c 'CREATE TABLE IF NOT EXISTS public.zitplane_ci_persist(marker text PRIMARY KEY)' docker compose --env-file .env -p "$project" -f deployment/docker/compose.backend.dev.yaml \ exec -T postgres psql -U zitadel -d postgres -v ON_ERROR_STOP=1 \ -c "INSERT INTO public.zitplane_ci_persist(marker) VALUES ('p05-$project') ON CONFLICT DO NOTHING" docker compose --env-file .env -p "$project" -f deployment/docker/compose.backend.dev.yaml restart postgres docker compose --env-file .env -p "$project" -f deployment/docker/compose.backend.dev.yaml up -d --wait marker="$(docker compose --env-file .env -p "$project" -f deployment/docker/compose.backend.dev.yaml \ exec -T postgres psql -U zitadel -d postgres -tAc 'SELECT marker FROM public.zitplane_ci_persist LIMIT 1')" test "$marker" = "p05-$project" echo ZITPLANE_POSTGRES_RESTART_PERSISTENCE_PASS docker run --rm --network zitplane-backend-dev-internal \ -e ZITPLANE_CI_PROXY=http://proxy \ python:3.12-alpine python -c "$(cat tests/ci/oidc_discovery.py)" echo ZITPLANE_DOCKER_DISCOVERY_PASS echo '::warning::OIDC interactive callback, MFA and Account Portal session E2E require a future disposable-client integration gate; NOT VERIFIED.' - name: Always remove only P05 disposable Docker state if: always() run: | set +e cleanup_rc=0 if [ -f .p05-ci-started ] && [ -f .env ]; then project="zitplane-p05-${GITHUB_RUN_ID:-0}" docker compose --env-file .env -p "$project" -f deployment/docker/compose.backend.dev.yaml down -v --remove-orphans || cleanup_rc=1 fi rm -f .env .p05-ci-started if [ "$cleanup_rc" -ne 0 ]; then echo '::error::Disposable Docker cleanup failed; operator must inspect exact CI-owned resources' exit 1 fi echo ZITPLANE_DISPOSABLE_CLEANUP_COMPLETE