name: CI on: push: branches: - dev - next - main pull_request: branches: - dev - next - main workflow_dispatch: permissions: contents: read concurrency: group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true jobs: plan: name: Plan if: github.repository == '21nCo/superfunctions' runs-on: ubuntu-latest outputs: base_ref: ${{ steps.plan.outputs.base_ref }} changed_files_count: ${{ steps.plan.outputs.changed_files_count }} run_js: ${{ steps.plan.outputs.run_js }} full_js: ${{ steps.plan.outputs.full_js }} has_js_build: ${{ steps.plan.outputs.has_js_build }} has_js_test: ${{ steps.plan.outputs.has_js_test }} has_js_lint: ${{ steps.plan.outputs.has_js_lint }} has_js_typecheck: ${{ steps.plan.outputs.has_js_typecheck }} js_build_filters: ${{ steps.plan.outputs.js_build_filters }} js_test_filters: ${{ steps.plan.outputs.js_test_filters }} js_lint_filters: ${{ steps.plan.outputs.js_lint_filters }} js_typecheck_filters: ${{ steps.plan.outputs.js_typecheck_filters }} run_devfn: ${{ steps.plan.outputs.run_devfn }} devfn_test_filters: ${{ steps.plan.outputs.devfn_test_filters }} run_python: ${{ steps.plan.outputs.run_python }} full_python: ${{ steps.plan.outputs.full_python }} python_matrix: ${{ steps.plan.outputs.python_matrix }} run_mcpfn: ${{ steps.plan.outputs.run_mcpfn }} mcpfn_only: ${{ steps.plan.outputs.mcpfn_only }} steps: - name: Checkout uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: fetch-depth: 0 - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: "20" - name: Refresh common target branches run: | git fetch --no-tags --depth=1 origin dev || true git fetch --no-tags --depth=1 origin next || true git fetch --no-tags --depth=1 origin main || true - name: Verify CI planner run: node --test scripts/ci-plan.test.mjs # The standalone-script list (SFNS-307) must match turbo.json's global inputs and no package may use a script on # it. These checks need no Turbo, so every pull request runs them, whatever the plan selects. The file's Turbo # task-hash tests need an installed Turbo and run with `node --test scripts/turbo-cache-config.test.mjs`. - name: Verify standalone script list run: | node --test --test-name-pattern="^standalone list: " scripts/turbo-cache-config.test.mjs - name: Verify UIFn docs CLI resolution run: node --test scripts/uifn-docs-cli-resolution.test.mjs - name: Verify UIFn registry KMS signer run: node --test scripts/sign-uifn-registry-kms.test.mjs - name: Nested package-lock.json files are not tracked run: | node --test scripts/verify-package-lockfiles.test.mjs node scripts/verify-package-lockfiles.mjs # Ownership manifests (SFNS-122) with public semantics: superfunctions.owners.json must list every top-level path, # root file, release slug and Python project, and every workflow outside the shared list carries the repository # guard (SFNS-123). This job is guarded, so it never runs on 21nCo/super-functions.next; next runs # `node scripts/verify-owners.mjs --repo next` from its own CI (live next check deferred to SFNS-160). - name: Ownership manifest matches the tree env: OWNERS_REPO: public run: | node --test scripts/owners.test.mjs scripts/verify-owners.test.mjs node scripts/verify-owners.mjs --repo "$OWNERS_REPO" # The dev-push notifier (SFNS-126): trigger, repository guard, environment, token permissions and payload. - name: Verify next sync notifier workflow run: node --test scripts/notify-next-sync-workflow.test.mjs - name: Build CI plan id: plan run: node scripts/ci-plan.mjs # uifn-version-bump-retarget.yml reruns this job when a PR is edited, which is how a PR retargeted to dev gets it. uifn-version-bump: name: UIFn version bump if: github.repository == '21nCo/superfunctions' && (github.event_name == 'pull_request' && github.base_ref == 'dev') runs-on: ubuntu-latest steps: # The PR merge ref, which holds the checker even for a branch made before it, with every branch's history. - name: Checkout uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: fetch-depth: 0 persist-credentials: false # Payload base.sha is stale after a push and the merge ref can predate the base tip, so judge a merge of exactly the base tip B and head.sha. - name: Merge the PR head into the base branch tip run: | B=$(git rev-parse "origin/${{ github.base_ref }}") H="${{ github.event.pull_request.head.sha }}" git merge-base --is-ancestor "${{ github.event.pull_request.base.sha }}" "$B" || { echo "::error::base ${{ github.event.pull_request.base.sha }} is not on ${{ github.base_ref }} at $B"; exit 1; } if [ "$(git rev-parse HEAD^1 HEAD^2 | tr '\n' ' ')" != "$B $H " ]; then git checkout -q --detach "$B" && git -c user.name=ci -c user.email=ci@localhost merge -q --no-ff --no-edit "$H" || { echo "::error::cannot merge head $H into ${{ github.base_ref }} at $B"; exit 1; } fi echo "UIFN_BASE=$B" >> "$GITHUB_ENV" - name: Setup Node.js uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 with: node-version: "20" cache: "npm" # The checker resolves tsconfigs with the repository's TypeScript. - name: Install dependencies run: npm ci --ignore-scripts - name: Verify version bump checker run: node --test scripts/verify-uifn-version-bump.test.mjs - name: Require version bump and changelog entry for shipped uifn changes run: node scripts/verify-uifn-version-bump.mjs --base "$UIFN_BASE" - name: Report uifn changes since last published tags run: node scripts/verify-uifn-version-bump.mjs --since-published --head "$UIFN_BASE" javascript: name: JavaScript needs: plan if: github.repository == '21nCo/superfunctions' && (needs.plan.outputs.run_js == 'true' && needs.plan.outputs.mcpfn_only != 'true') runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: fetch-depth: 0 - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: "22" cache: "npm" - name: Install dependencies run: npm ci --ignore-scripts - name: Build trusted esbuild native binding run: npm rebuild esbuild - name: Build trusted SQLite native binding run: npm rebuild better-sqlite3 - name: Ensure Rollup native package run: node scripts/ci-install-rollup-native.mjs - name: Install Rust WASM target run: rustup target add wasm32-unknown-unknown - name: Show plan run: | echo "base: ${{ needs.plan.outputs.base_ref }}" echo "changed files: ${{ needs.plan.outputs.changed_files_count }}" echo "full js: ${{ needs.plan.outputs.full_js }}" echo "build filters: ${{ needs.plan.outputs.js_build_filters }}" echo "test filters: ${{ needs.plan.outputs.js_test_filters }}" echo "lint filters: ${{ needs.plan.outputs.js_lint_filters }}" echo "typecheck filters: ${{ needs.plan.outputs.js_typecheck_filters }}" echo "devfn tests (DevFn tests job): ${{ needs.plan.outputs.devfn_test_filters }}" - name: Build if: needs.plan.outputs.has_js_build == 'true' run: | if [ "${{ needs.plan.outputs.full_js }}" = "true" ]; then ./node_modules/.bin/turbo run build else ./node_modules/.bin/turbo run build ${{ needs.plan.outputs.js_build_filters }} fi - name: Typecheck if: needs.plan.outputs.has_js_typecheck == 'true' run: | if [ "${{ needs.plan.outputs.full_js }}" = "true" ]; then ./node_modules/.bin/turbo run typecheck else ./node_modules/.bin/turbo run typecheck ${{ needs.plan.outputs.js_typecheck_filters }} fi # Avoid oversubscribing hosted runners with many concurrent Vitest pools. The filters exclude every DevFn # package, even on a full run: the DevFn tests job runs those. - name: Test if: needs.plan.outputs.has_js_test == 'true' run: ./node_modules/.bin/turbo run test --concurrency=2 ${{ needs.plan.outputs.js_test_filters }} - name: Lint if: needs.plan.outputs.has_js_lint == 'true' run: | if [ "${{ needs.plan.outputs.full_js }}" = "true" ]; then ./node_modules/.bin/turbo run lint else ./node_modules/.bin/turbo run lint ${{ needs.plan.outputs.js_lint_filters }} fi # DevFn's real-process tests (SFNS-293) run one package at a time, apart from every other package's tests. The plan # selects the DevFn part of the JavaScript test selection: a full run selects every DevFn package. Like the JavaScript # job it skips McpFn-only changes. Build and typecheck of DevFn packages stay in the JavaScript job. devfn: name: DevFn tests needs: plan if: github.repository == '21nCo/superfunctions' && (needs.plan.outputs.run_devfn == 'true' && needs.plan.outputs.mcpfn_only != 'true') runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: fetch-depth: 0 - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: "22" cache: "npm" - name: Install dependencies run: npm ci --ignore-scripts - name: Build trusted esbuild native binding run: npm rebuild esbuild - name: Build trusted SQLite native binding run: npm rebuild better-sqlite3 - name: Ensure Rollup native package run: node scripts/ci-install-rollup-native.mjs - name: Install Rust WASM target run: rustup target add wasm32-unknown-unknown - name: Show plan run: | echo "base: ${{ needs.plan.outputs.base_ref }}" echo "full js: ${{ needs.plan.outputs.full_js }}" echo "devfn test filters: ${{ needs.plan.outputs.devfn_test_filters }}" - name: Test run: ./node_modules/.bin/turbo run test --concurrency=1 ${{ needs.plan.outputs.devfn_test_filters }} mcpfn-node20: name: McpFn Node 20 compatibility needs: plan if: github.repository == '21nCo/superfunctions' && (needs.plan.outputs.run_mcpfn == 'true') runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: "20" cache: "npm" - name: Install dependencies run: npm ci --ignore-scripts # Only the build tool needs its installation hook in this compatibility lane. - name: Build trusted esbuild binary run: npm rebuild esbuild - name: Ensure Rollup native package run: node scripts/ci-install-rollup-native.mjs - name: Build compatibility targets and dependencies run: ./node_modules/.bin/turbo run build --filter='@mcpfn/testing...' --filter='@mcpfn/cli...' - name: Check transport-neutral client, testing, and CLI on Node 20 run: | npm run typecheck --workspace=@mcpfn/client --workspace=@mcpfn/testing --workspace=@mcpfn/cli npm test --workspace=@mcpfn/client --workspace=@mcpfn/testing --workspace=@mcpfn/cli # Leak guard (SFNS-125): the public tree holds only what superfunctions.owners.json allows (top-level paths, # release entries, Python projects, workspace packages) and imports or depends on no *fn package that is neither a # public workspace package nor pinned in scripts/public-boundary.allow.json. Guarded, so it never runs on next. public-boundary: name: Public boundary if: github.repository == '21nCo/superfunctions' runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: persist-credentials: false - name: Setup Node.js uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 with: node-version: "22" cache: "npm" # Imports are read with the installed parsers (typescript, svelte, parse5, MDX) and Python's ast module. - name: Setup Python uses: actions/setup-python@v5 with: python-version: "3.12" - name: Install dependencies run: npm ci --ignore-scripts - name: Verify public boundary checker run: node --test scripts/verify-public-boundary.test.mjs - name: Public tree stays inside the public manifest run: node scripts/verify-public-boundary.mjs # Release target resolution (release-packages.json plus a repository overlay) on the runtimes the publish # workflows use, and the root workspace globs against the explicit list they replaced (SFNS-123). The promotion # script's temp-repository tests need git-filter-repo; PROMOTE_REQUIRE_FILTER_REPO turns their skip into a failure. release-scripts: name: Release scripts if: github.repository == '21nCo/superfunctions' runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: fetch-depth: 0 persist-credentials: false - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: "22" - name: Setup Python uses: actions/setup-python@v5 with: python-version: "3.12" - name: Workspace globs and npm release targets run: node --test scripts/workspaces.test.mjs scripts/resolve-release-tag.test.mjs - name: Release owner and CI gates (SFNS-124) run: node --test scripts/assert-release-owner.test.mjs scripts/assert-release-ci.test.mjs scripts/release-gate-workflows.test.mjs - name: Python release targets run: | python -m pip install --only-binary=:all: packaging==25.0 python -m unittest discover -s scripts -p test_python_release.py -v - name: Promotion script (SFNS-127) run: | python -m pip install --only-binary=:all: git-filter-repo==2.47.0 git filter-repo --version PROMOTE_REQUIRE_FILTER_REPO=1 node --test scripts/promote.test.mjs python: name: Python package (${{ matrix.package.path }}) needs: plan if: github.repository == '21nCo/superfunctions' && (needs.plan.outputs.run_python == 'true' && needs.plan.outputs.mcpfn_only != 'true') runs-on: ubuntu-latest strategy: fail-fast: false matrix: package: ${{ fromJson(needs.plan.outputs.python_matrix) }} steps: - name: Checkout uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: fetch-depth: 0 - name: Setup Python uses: actions/setup-python@v5 with: python-version: "3.11" cache: "pip" cache-dependency-path: | **/pyproject.toml - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: "20" - name: Upgrade pip run: "python -m pip install --only-binary=:all: pip==26.0.1 build==1.4.4" - name: Check package run: node scripts/ci-run-python-package.mjs "${{ matrix.package.path }}" python-result: name: Python needs: [plan, python] if: github.repository == '21nCo/superfunctions' && (always()) runs-on: ubuntu-latest steps: - name: Require every planned Python package check to pass env: PLAN_RESULT: ${{ needs.plan.result }} PYTHON_RESULT: ${{ needs.python.result }} run: | echo "plan: ${PLAN_RESULT}, python packages: ${PYTHON_RESULT}" if [ "${PLAN_RESULT}" != "success" ]; then echo "The CI plan did not succeed." >&2 exit 1 fi case "${PYTHON_RESULT}" in success|skipped) ;; *) echo "A Python package check ended ${PYTHON_RESULT}." >&2 exit 1 ;; esac mcpfn: name: McpFn release gate needs: plan if: github.repository == '21nCo/superfunctions' && (needs.plan.outputs.run_mcpfn == 'true') runs-on: ubuntu-24.04 # Playwright 1.59 does not support ubuntu-latest (26.04) steps: - name: Checkout uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: fetch-depth: 0 - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: "22" cache: "npm" - name: Install dependencies run: npm ci --ignore-scripts - name: Build trusted esbuild native binding run: npm rebuild esbuild - name: Build trusted SQLite native binding run: npm rebuild better-sqlite3 - name: Ensure Rollup native package run: node scripts/ci-install-rollup-native.mjs - name: Install Chromium for McpFn auth tests run: ./node_modules/.bin/playwright install --with-deps chromium - name: Run McpFn release gate run: npm run gate:mcpfn-release env: MCPFN_ARTIFACT_DIR: artifacts/mcpfn - name: Upload McpFn regression artifacts if: always() uses: actions/upload-artifact@v4 with: name: mcpfn-regression-${{ github.run_id }}-${{ github.run_attempt }} path: artifacts/mcpfn if-no-files-found: warn retention-days: 14 mcpfn-node18-cjs: name: McpFn Node 18 CommonJS needs: plan if: github.repository == '21nCo/superfunctions' && (needs.plan.outputs.run_mcpfn == 'true') runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: "18.20.8" cache: "npm" - name: Install dependencies run: npm ci --ignore-scripts - name: Build trusted esbuild native binding run: npm rebuild esbuild - name: Ensure Rollup native package run: node scripts/ci-install-rollup-native.mjs - name: Build CommonJS dependency chain run: | npm run build --workspace @superfunctions/observability npm run build --workspace @superfunctions/db npm run build --workspace @superfunctions/oauth-storage npm run build --workspace @superfunctions/oauth-core npm run build --workspace @mcpfn/core npm run build --workspace @mcpfn/client - name: Require supported CommonJS entry points run: node -e 'for (const name of ["@superfunctions/oauth-core", "@mcpfn/core", "@mcpfn/client"]) { const loaded = require(name); if (!Object.keys(loaded).length) throw new Error(name + " has no CommonJS exports"); }'