name: Championship CI/CD on: push: branches: [ main, develop ] # Docs-only: skip full championship suite (saves minutes; avoids noise). paths-ignore: - '**.md' - 'docs/**' - 'LICENSE*' - '.gitignore' pull_request: branches: [ main ] env: NODE_VERSION: '22.x' BUN_VERSION: '1.3.13' jobs: # Security Check security: name: Security Audit runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - name: Setup Node.js uses: actions/setup-node@v7 with: node-version: ${{ env.NODE_VERSION }} cache: 'npm' - name: Install dependencies run: npm ci - name: NPM Audit run: npm audit --audit-level=moderate --omit=dev - name: Check for secrets uses: trufflesecurity/trufflehog@31ce31ee1abbcc7dc8eee5764c17121c3044c8b2 with: path: ./ base: ${{ github.event.repository.default_branch }} # Primary Test Suite — Bun # Windows runs the full suite in the `windows` job below (its own steps: TEMP # setup, packed-tarball install, faf auto). test: name: Bun Test Suite runs-on: ${{ matrix.os }} strategy: # A red macOS leg must not cancel ubuntu: the TAF receipt comes from ubuntu's run. fail-fast: false matrix: os: [ubuntu-latest, macos-latest] steps: - uses: actions/checkout@v7 - name: Setup Bun uses: oven-sh/setup-bun@v2 with: bun-version: ${{ env.BUN_VERSION }} - name: Setup Node.js uses: actions/setup-node@v7 with: node-version: ${{ env.NODE_VERSION }} cache: 'npm' - name: Install dependencies run: npm ci - name: Lint code run: npm run lint continue-on-error: true # lint surfaces issues, doesn't block tests/build - name: Build TypeScript run: npm run build - name: Run tests (bun) shell: bash # -o pipefail: tee must not hide a red run run: bun test --timeout=120000 2>&1 | tee test-output.txt # The TAF job prints its receipt from this run's output: one run, one receipt. - name: Keep the test output for the receipt uses: actions/upload-artifact@v6 if: "!cancelled() && matrix.os == 'ubuntu-latest'" with: name: test-output path: test-output.txt - name: Test CLI functionality run: | node dist/cli.js --help node dist/cli.js --version - name: Test project detection shell: bash run: | node dist/cli.js init --force --output test.faf ls -la test.faf head -10 test.faf node dist/cli.js score test.faf node dist/cli.js check test.faf - name: Upload build artifacts uses: actions/upload-artifact@v6 if: matrix.os == 'ubuntu-latest' with: name: dist-files path: dist/ # Node Smoke Test — npx users still work. The low end of this matrix IS the # engines.node floor (scripts/check-engines.mjs gates it). node-compat: name: Node Smoke Test runs-on: ubuntu-latest strategy: matrix: node: [22.x, 24.x] steps: - uses: actions/checkout@v7 - name: Setup Bun uses: oven-sh/setup-bun@v2 with: bun-version: ${{ env.BUN_VERSION }} - name: Setup Node.js ${{ matrix.node }} uses: actions/setup-node@v7 with: node-version: ${{ matrix.node }} cache: 'npm' - name: Install dependencies run: npm ci - name: Build TypeScript run: npm run build - name: CLI smoke test run: | node dist/cli.js --version node dist/cli.js --help node dist/cli.js init --force --output test.faf node dist/cli.js score test.faf node dist/cli.js check test.faf # Pack-and-install smoke test — catches the v6.3.0 class of bug where # the local build works but the published tarball crashes for end users. # Tests the actual user experience: `npm install -g ` + `faf info`. - name: Packed-tarball smoke test run: | set -euo pipefail TARBALL_DIR=$(mktemp -d) npm pack --pack-destination "$TARBALL_DIR" >/dev/null TARBALL=$(ls "$TARBALL_DIR"/faf-cli-*.tgz | head -1) echo "::group::Tarball contents" tar -tzf "$TARBALL" | sed -n '1,20p' echo "::endgroup::" # Install globally from the tarball into a fresh prefix INSTALL_PREFIX=$(mktemp -d) npm install --prefix "$INSTALL_PREFIX" --no-save --no-audit --no-fund "$TARBALL" # Run the binary from that fresh install — this is what users get BIN="$INSTALL_PREFIX/node_modules/.bin/faf" # Assert --version matches package.json (catches stale hardcoded VERSION constants) EXPECTED=$(node -p "require('./package.json').version") ACTUAL=$("$BIN" --version) if [ "$EXPECTED" != "$ACTUAL" ]; then echo "::error::Version mismatch from packed tarball — expected '$EXPECTED', got '$ACTUAL'" exit 1 fi echo "✓ faf --version: $ACTUAL" echo "::group::faf info" "$BIN" info echo "::endgroup::" # Windows — a real pre-ship gate. Builds on Windows, runs the CLI, installs the # packed tarball as a user would, runs `faf auto` on this repo (real Windows # paths), and runs the full test suite. windows: name: Windows (Node ${{ matrix.node }}) runs-on: windows-latest # A green run takes ~3 min. The suite has hung here (2026-10-04: 47 min and # ~2 h) with every test inside its 2-min limit, so the process outlives the # tests. Fail fast instead of holding the runner for GitHub's 6 h default. timeout-minutes: 15 strategy: matrix: node: [22.x, 24.x] defaults: run: shell: bash steps: - uses: actions/checkout@v7 # The runner's default TEMP is an 8.3 short path (C:\Users\RUNNER~1\...). # faf prints real paths (runneradmin), so tests comparing against tmpdir() # would differ by name only. RUNNER_TEMP has no short alias. - name: Use a temp folder without a short-name alias run: | echo "TEMP=$RUNNER_TEMP" >> "$GITHUB_ENV" echo "TMP=$RUNNER_TEMP" >> "$GITHUB_ENV" - name: Setup Bun uses: oven-sh/setup-bun@v2 with: bun-version: ${{ env.BUN_VERSION }} - name: Setup Node.js ${{ matrix.node }} uses: actions/setup-node@v7 with: node-version: ${{ matrix.node }} cache: 'npm' - name: Install dependencies run: npm ci - name: Build TypeScript run: npm run build - name: CLI smoke test run: | set -euo pipefail node dist/cli.js --version node dist/cli.js --help > /dev/null node dist/cli.js init --force --output test.faf node dist/cli.js score test.faf node dist/cli.js check test.faf - name: Packed-tarball install run: | set -euo pipefail TARBALL_DIR=$(mktemp -d) npm pack --pack-destination "$TARBALL_DIR" > /dev/null TARBALL=$(ls "$TARBALL_DIR"/faf-cli-*.tgz | head -1) INSTALL_PREFIX=$(mktemp -d) npm install --prefix "$INSTALL_PREFIX" --no-save --no-audit --no-fund "$TARBALL" EXPECTED=$(node -p "require('./package.json').version") ACTUAL=$("$INSTALL_PREFIX/node_modules/.bin/faf" --version) if [ "$EXPECTED" != "$ACTUAL" ]; then echo "::error::Version mismatch from packed tarball on Windows — expected '$EXPECTED', got '$ACTUAL'" exit 1 fi echo "✓ faf --version on Windows: $ACTUAL" # What a Windows user runs, from the installed package, in a clean folder FAF="$INSTALL_PREFIX/node_modules/.bin/faf" USER_DIR=$(mktemp -d) cd "$USER_DIR" echo '{"name":"smoke-app","version":"1.0.0"}' > package.json "$FAF" init > /dev/null "$FAF" auto > /dev/null "$FAF" score > /dev/null "$FAF" card init --name "Smoke App" --domain example.com \ --description "A smoke test for the business card." --set-version 1.0.0 \ --package smoke-app --kind cli --skill "Run: Runs the smoke test." < /dev/null > /dev/null "$FAF" cards < /dev/null > /dev/null for f in project.faf agent.fafa .well-known/ai-catalog.json .well-known/ard.json; do [ -f "$f" ] || { echo "::error::$f missing after the Windows user path"; exit 1; } done echo "✓ init, auto, score, card init, cards from the packed tarball" - name: faf auto on this repo (real Windows paths) run: | set -euo pipefail cp project.faf project.faf.orig node dist/cli.js auto node dist/cli.js score mv project.faf.orig project.faf # A green run takes ~2.5 min. On Windows a child process sometimes never # exits (mostly Node 24): a test ends exactly at its limit, or the whole run # stalls. That is timing, not a failing test, so the PR job doesn't wait for # it: the tests that start the CLI as a child run in the Windows nightly # (about 4am Atlanta, no time pressure), and a release waits for that run. # Here a stall retries once and then warns; a failing test fails at once. - name: Full test suite (child-process tests run nightly) timeout-minutes: 12 env: FAF_WINDOWS_PR: '1' run: | for attempt in 1 2; do set +e timeout 300 bun test --timeout=120000 code=$? set -e if [ "$code" -ne 124 ]; then exit "$code"; fi echo "::warning::Windows test run stalled (attempt $attempt of 2): timing, not a failing test" done echo "::warning::Windows run stalled twice. Not a test failure; the Windows nightly must be green before a release." # Package managers — the packed tarball must install and run under npm, pnpm # and bun. 8.0.0 shipped a file: dependency that npm resolved inside faf-cli # but pnpm resolved from the consumer's root (ERR_PNPM_LINKED_PKG_DIR_NOT_FOUND). package-managers: name: Install with ${{ matrix.manager }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: manager: [npm, pnpm, bun] steps: - uses: actions/checkout@v7 - name: Setup Bun uses: oven-sh/setup-bun@v2 with: bun-version: ${{ env.BUN_VERSION }} - name: Setup Node.js uses: actions/setup-node@v7 with: node-version: ${{ env.NODE_VERSION }} cache: 'npm' - name: Install dependencies run: npm ci - name: Build and pack run: | set -euo pipefail npm run build PACK_DIR=$(mktemp -d) npm pack --pack-destination "$PACK_DIR" >/dev/null echo "TARBALL=$(ls "$PACK_DIR"/faf-cli-*.tgz | head -1)" >> "$GITHUB_ENV" echo "EXPECTED=$(node -p "require('./package.json').version")" >> "$GITHUB_ENV" - name: Install the tarball with ${{ matrix.manager }} run: | set -euo pipefail CONSUMER=$(mktemp -d) echo "CONSUMER=$CONSUMER" >> "$GITHUB_ENV" cd "$CONSUMER" echo '{"name":"consumer","version":"1.0.0","private":true}' > package.json case "${{ matrix.manager }}" in npm) npm install --no-audit --no-fund "$TARBALL" ;; pnpm) npx --yes pnpm@10 add "$TARBALL" ;; bun) bun add "$TARBALL" ;; esac - name: Kernel resolves from faf-cli, bin runs, faf score works run: | set -euo pipefail cd "$CONSUMER" # Resolve the kernel the way faf-cli does at runtime: from faf-cli's own folder. node -e "const fs=require('fs'),path=require('path');const dir=path.dirname(fs.realpathSync('node_modules/faf-cli/package.json'));require(require.resolve('faf-scoring-kernel',{paths:[dir]}));console.log('✓ faf-scoring-kernel resolves from faf-cli')" ACTUAL=$(node_modules/.bin/faf --version) if [ "$EXPECTED" != "$ACTUAL" ]; then echo "::error::${{ matrix.manager }}: faf --version printed '$ACTUAL', expected '$EXPECTED'" exit 1 fi echo "✓ faf --version: $ACTUAL" printf 'faf_version: "3.0"\nproject:\n name: consumer\n goal: Check faf-cli installs with every package manager\n main_language: TypeScript\n' > project.faf OUT=$(node_modules/.bin/faf score project.faf) echo "$OUT" echo "$OUT" | grep -qE '[0-9]+%' || { echo "::error::${{ matrix.manager }}: faf score printed no score"; exit 1; } # TAF recipes — `faf taf setup` for Rust, Java (Maven, Gradle) and .NET, run # for real. For each fixture (2 passing, 1 failing, 1 skipped), faf writes the # recipe; prove-recipe.mjs checks its setup steps are the ones below, runs its # run steps, and reads the report with faf-taf-git's parser (the version faf # pins). The receipt's counts must match the runner's own summary line. taf-recipes: name: taf setup recipe (${{ matrix.lang }}) runs-on: ubuntu-latest strategy: fail-fast: false matrix: lang: [rust, maven, gradle, dotnet] steps: - uses: actions/checkout@v7 - name: Setup Bun uses: oven-sh/setup-bun@v2 with: bun-version: ${{ env.BUN_VERSION }} - name: Setup Node.js uses: actions/setup-node@v7 with: node-version: ${{ env.NODE_VERSION }} cache: 'npm' - name: Install dependencies run: npm ci - name: Build run: npm run build # The toolchain steps the recipe writes, with the same inputs # (prove-recipe.mjs fails when they differ). - if: matrix.lang == 'rust' uses: dtolnay/rust-toolchain@stable - if: matrix.lang == 'rust' uses: taiki-e/install-action@v2 with: tool: cargo-nextest@0.9.151 - if: matrix.lang == 'maven' uses: actions/setup-java@v6 with: distribution: temurin java-version: '21' cache: maven - if: matrix.lang == 'gradle' uses: actions/setup-java@v6 with: distribution: temurin java-version: '21' - if: matrix.lang == 'gradle' uses: gradle/actions/setup-gradle@v6 with: gradle-version: '9.8.2' - if: matrix.lang == 'dotnet' uses: actions/setup-dotnet@v6 with: dotnet-version: '10.0.x' - name: faf taf setup on the fixture run: | set -euo pipefail PROJECT="$RUNNER_TEMP/taf-${{ matrix.lang }}" cp -R "tests/fixtures/taf-setup/${{ matrix.lang }}" "$PROJECT" git -C "$PROJECT" init -q -b main (cd "$PROJECT" && node "$GITHUB_WORKSPACE/dist/cli.js" taf setup --write) cat "$PROJECT/.github/workflows/taf.yml" echo "PROJECT=$PROJECT" >> "$GITHUB_ENV" - name: faf-taf-git's parser, the version faf pins run: | set -euo pipefail VERSION=$(grep -oE "Wolfe-Jam/faf-taf-git@v[0-9.]+" src/commands/taf.ts | head -1 | sed 's/.*@v//') TAF_GIT="$RUNNER_TEMP/faf-taf-git" mkdir -p "$TAF_GIT" npm install --prefix "$TAF_GIT" --no-save --no-audit --no-fund "faf-taf-git@$VERSION" echo "TAF_GIT=$TAF_GIT/node_modules/faf-taf-git" >> "$GITHUB_ENV" - name: Run the recipe and check the receipt run: node tests/fixtures/taf-setup/prove-recipe.mjs "${{ matrix.lang }}" "$PROJECT" "$TAF_GIT" # Code Quality quality: name: Code Quality runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - name: Setup Node.js uses: actions/setup-node@v7 with: node-version: ${{ env.NODE_VERSION }} cache: 'npm' - name: Install dependencies run: npm ci - name: Engine floor gate run: npm run check:engines # HARD gate — engines.node floor == lowest Node in the ci.yml and release.yml matrices - name: Lint run: npm run lint continue-on-error: true # lint surfaces issues, doesn't gate the badge - name: Format Check run: npm run format -- --check continue-on-error: true # TAF - Testing Activity Feed taf: name: TAF Receipt runs-on: ubuntu-latest needs: test # !cancelled(): runs when the tests fail too, so a red run gets a FAILED receipt # instead of a gap. The receipt is the test job's own run (ubuntu), not a second one. if: "!cancelled() && github.event_name == 'push' && github.ref == 'refs/heads/main'" permissions: contents: write steps: - uses: actions/checkout@v7 with: token: ${{ secrets.GITHUB_TOKEN }} - name: Get the test output uses: actions/download-artifact@v7 with: name: test-output path: /tmp - name: Generate TAF Receipt uses: Wolfe-Jam/faf-taf-git@v2.6.0 with: test-output-file: /tmp/test-output.txt auto-commit: 'true' commit-message: 'chore(taf): update .taf receipt [skip ci]' target-branch: taf-receipts # Championship Status status: name: Championship Status runs-on: ubuntu-latest needs: [security, test, node-compat, windows, package-managers, taf-recipes, quality] if: always() steps: - name: Check results run: | echo "FAF CLI Championship CI/CD" echo "---" failed=0 if [ "${{ needs.security.result }}" != "success" ]; then echo "FAIL Security: ${{ needs.security.result }}" failed=1 else echo "PASS Security" fi if [ "${{ needs.test.result }}" != "success" ]; then echo "FAIL Bun Tests: ${{ needs.test.result }}" failed=1 else echo "PASS Bun Tests: all platforms" fi if [ "${{ needs.node-compat.result }}" != "success" ]; then echo "FAIL Node Compat: ${{ needs.node-compat.result }}" failed=1 else echo "PASS Node Compat: 22.x, 24.x" fi if [ "${{ needs.windows.result }}" != "success" ]; then echo "FAIL Windows: ${{ needs.windows.result }}" failed=1 else echo "PASS Windows: 22.x, 24.x" fi if [ "${{ needs.package-managers.result }}" != "success" ]; then echo "FAIL Package managers: ${{ needs.package-managers.result }}" failed=1 else echo "PASS Package managers: npm, pnpm, bun" fi if [ "${{ needs.taf-recipes.result }}" != "success" ]; then echo "FAIL taf setup recipes: ${{ needs.taf-recipes.result }}" failed=1 else echo "PASS taf setup recipes: rust, maven, gradle, dotnet" fi if [ "${{ needs.quality.result }}" != "success" ]; then echo "FAIL Quality: ${{ needs.quality.result }}" failed=1 else echo "PASS Quality" fi echo "---" if [ "$failed" -eq 1 ]; then echo "CI FAILED" exit 1 fi echo "PODIUM READY"