# CI checks for the API, run on PRs touching api/ and manually via dispatch name: ๐Ÿšฆ API CI on: pull_request: paths: - 'api/**' - 'awesome-privacy.yml' - '.github/workflows/ci-api.yml' workflow_dispatch: permissions: contents: read concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: lint: name: ๐Ÿ›ก๏ธ Lint runs-on: ubuntu-latest defaults: run: working-directory: api steps: - uses: actions/checkout@v6 with: persist-credentials: false - uses: oven-sh/setup-bun@v2 with: bun-version: 1.3.10 - run: bun install --frozen-lockfile - run: bun run lint format: name: ๐Ÿ’… Format runs-on: ubuntu-latest defaults: run: working-directory: api steps: - uses: actions/checkout@v6 with: persist-credentials: false - uses: oven-sh/setup-bun@v2 with: bun-version: 1.3.10 - run: bun install --frozen-lockfile - run: bun run format:check typecheck: name: ๐Ÿงฉ Typecheck runs-on: ubuntu-latest defaults: run: working-directory: api steps: - uses: actions/checkout@v6 with: persist-credentials: false - uses: oven-sh/setup-bun@v2 with: bun-version: 1.3.10 - run: bun install --frozen-lockfile - run: bun run build:data - run: bun run typecheck test: name: ๐Ÿงช Test runs-on: ubuntu-latest defaults: run: working-directory: api steps: - uses: actions/checkout@v6 with: persist-credentials: false - uses: oven-sh/setup-bun@v2 with: bun-version: 1.3.10 - run: bun install --frozen-lockfile - run: bun run build:data - run: bun run test build: name: ๐Ÿ—๏ธ Build runs-on: ubuntu-latest defaults: run: working-directory: api steps: - uses: actions/checkout@v6 with: persist-credentials: false - uses: oven-sh/setup-bun@v2 with: bun-version: 1.3.10 - run: bun install --frozen-lockfile - run: bun run build - name: Verify bundle output run: test -f dist/index.workers.js || { echo "โŒ worker bundle not produced"; exit 1; } smoke: name: ๐Ÿ’จ Smoke Test runs-on: ubuntu-latest defaults: run: working-directory: api steps: - uses: actions/checkout@v6 with: persist-credentials: false - uses: oven-sh/setup-bun@v2 with: bun-version: 1.3.10 - run: bun install --frozen-lockfile - run: bun run smoke docker-smoke: name: ๐Ÿณ Docker Smoke runs-on: ubuntu-latest outputs: result: ${{ steps.run.outcome }} defaults: run: working-directory: api steps: - uses: actions/checkout@v6 with: persist-credentials: false - name: Build and run container id: run continue-on-error: true run: bash tests/docker-smoke.sh timeout-minutes: 10 dependency-review: name: ๐Ÿ”’ Dependency Audit runs-on: ubuntu-latest if: github.event_name == 'pull_request' steps: - uses: actions/checkout@v6 with: persist-credentials: false - uses: actions/dependency-review-action@v5 with: fail-on-severity: moderate secret-scan: name: ๐Ÿ”‘ Secret Scan runs-on: ubuntu-latest if: github.event_name == 'pull_request' steps: - uses: actions/checkout@v6 with: fetch-depth: 0 persist-credentials: false - name: Scan PR diff for secrets uses: trufflesecurity/trufflehog@v3.95.5 with: base: ${{ github.event.pull_request.base.sha }} head: ${{ github.event.pull_request.head.sha }} extra_args: --only-verified # Renders a markdown table of every check at the end summary: name: ๐Ÿ“‹ Summary runs-on: ubuntu-latest if: always() continue-on-error: true needs: - lint - format - typecheck - test - build - smoke - docker-smoke - dependency-review - secret-scan steps: - name: Render summary env: NEEDS: ${{ toJSON(needs) }} run: | label() { case "$1" in lint) echo "๐Ÿ›ก๏ธ Lint" ;; format) echo "๐Ÿ’… Format" ;; typecheck) echo "๐Ÿงฉ Typecheck" ;; test) echo "๐Ÿงช Test" ;; build) echo "๐Ÿ—๏ธ Build" ;; smoke) echo "๐Ÿ’จ Smoke Test" ;; docker-smoke) echo "๐Ÿณ Docker Smoke" ;; dependency-review) echo "๐Ÿ”’ Dependency Audit" ;; secret-scan) echo "๐Ÿ”‘ Secret Scan" ;; *) echo "$1" ;; esac } status() { case "$1" in success) echo "โœ… Passed" ;; skipped) echo "โญ๏ธ Skipped" ;; cancelled) echo "๐Ÿšซ Cancelled" ;; failure) [ "$2" = docker-smoke ] && echo "โš ๏ธ Warnings" || echo "โŒ Failed" ;; *) echo "โ” $1" ;; esac } { echo "## API CI Summary" echo "" echo "| Check | Status |" echo "|-------|--------|" } >> "$GITHUB_STEP_SUMMARY" for job in $(echo "$NEEDS" | jq -r 'keys[]'); do result=$(echo "$NEEDS" | jq -r --arg j "$job" '.[$j].result') if [ "$job" = docker-smoke ]; then result=$(echo "$NEEDS" | jq -r '."docker-smoke".outputs.result // "skipped"') fi echo "| $(label "$job") | $(status "$result" "$job") |" >> "$GITHUB_STEP_SUMMARY" done