name: node-ci on: push: branches: [main] pull_request: types: [opened, edited, reopened, synchronize] permissions: contents: read concurrency: # Metadata edits must not cancel source checks for the same pull request. group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}${{ github.event_name == 'pull_request' && github.event.action == 'edited' && github.event.changes.base == null && '-metadata' || '' }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: classify-changes: name: classify changes if: github.event_name != 'pull_request' || github.event.action != 'edited' || github.event.changes.base != null runs-on: ubuntu-latest timeout-minutes: 10 outputs: container-validate: ${{ steps.scope.outputs.container-validate }} test-quality: ${{ steps.scope.outputs.test-quality }} workflow-quality: ${{ steps.scope.outputs.workflow-quality }} steps: - name: Checkout pull request for change classification if: github.event_name == 'pull_request' && github.event.changes.base == null uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 2 persist-credentials: false - name: Select additional checks id: scope shell: bash env: EVENT_NAME: ${{ github.event_name }} BASE_CHANGED: ${{ github.event.changes.base != null }} run: | set -euo pipefail container_validate=false if [[ "$EVENT_NAME" == "push" ]]; then container_validate=true fi test_quality=false workflow_quality=false if [[ "$EVENT_NAME" == "push" || "$BASE_CHANGED" == "true" ]]; then workflow_quality=true fi if [[ "$EVENT_NAME" == "pull_request" && "$BASE_CHANGED" == "true" ]]; then container_validate=true test_quality=true fi if [[ "$EVENT_NAME" == "pull_request" && "$BASE_CHANGED" != "true" ]]; then changed_files="$(mktemp)" trap 'rm -f "$changed_files"' EXIT git diff --no-renames --name-only -z HEAD^1 HEAD > "$changed_files" while IFS= read -r -d '' path; do case "$path" in .github/workflows/* | .github/actions/* | .github/actionlint.yaml | .github/zizmor.yml | \ .github/scripts/release-progress.mjs | .github/scripts/test_release_progress.mjs | \ sdk/typescript/scripts/release-pr.mjs | docker/verify-container-compose.sh) workflow_quality=true ;; esac case "$path" in .dockerignore | .github/workflows/native-*.yml | \ .github/actions/download-native/* | Dockerfile | \ Dockerfile.dockerignore | compose.yaml | compose.apparmor.yaml | \ compose.runner.yaml | docker/* | \ plugins/codex-security/* | sdk/typescript/* | \ .github/workflows/container-ci.yml | .github/workflows/container-release.yml | \ .github/workflows/container-validate.yml) container_validate=true ;; .github/workflows/node-ci.yml | .github/actions/setup-tools/*) container_validate=true test_quality=true ;; .github/workflows/test-quality.yml) test_quality=true ;; esac done < "$changed_files" fi printf 'container-validate=%s\n' "$container_validate" >> "$GITHUB_OUTPUT" printf 'test-quality=%s\n' "$test_quality" >> "$GITHUB_OUTPUT" printf 'workflow-quality=%s\n' "$workflow_quality" >> "$GITHUB_OUTPUT" workflow-quality: needs: classify-changes if: needs.classify-changes.outputs.workflow-quality == 'true' uses: ./.github/workflows/workflow-quality.yml static-checks: name: typecheck and formatting needs: classify-changes runs-on: ubuntu-latest timeout-minutes: 20 permissions: contents: read packages: read steps: - name: Checkout repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 2 persist-credentials: false - &set-up-typescript-tools name: Set up TypeScript tools uses: ./.github/actions/setup-tools with: cache-dependency-path: | sdk/typescript/pnpm-lock.yaml plugins/codex-security/mcp-app/pnpm-lock.yaml - &install-dependencies name: Install dependencies run: | pnpm --dir sdk/typescript install --frozen-lockfile pnpm --dir plugins/codex-security/mcp-app install --frozen-lockfile - name: Check devcontainer dependency cooldown env: GH_TOKEN: ${{ github.token }} run: node --experimental-strip-types sdk/typescript/scripts/check-devcontainer-cooldown.mts - name: Typecheck run: pnpm --dir sdk/typescript run types - name: Check formatting run: pnpm --dir sdk/typescript run format - name: Check MCP formatting run: pnpm --dir plugins/codex-security/mcp-app exec prettier --check "**/*.{cjs,cts,js,jsx,mjs,mts,ts,tsx}" native: needs: classify-changes uses: ./.github/workflows/native-artifacts.yml container-validate: needs: [classify-changes, native] if: needs.classify-changes.outputs.container-validate == 'true' uses: ./.github/workflows/container-validate.yml test-quality: needs: [classify-changes, native] if: needs.classify-changes.outputs.test-quality == 'true' uses: ./.github/workflows/test-quality.yml with: native-artifacts-ready: true package: name: build and check package needs: [classify-changes, native] runs-on: ubuntu-latest timeout-minutes: 20 steps: - &checkout-repository name: Checkout repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: Check plugin source boundary run: node sdk/typescript/scripts/check-plugin-source.mjs - &download-native name: Prepare native runtime uses: ./.github/actions/download-native - *set-up-typescript-tools - *install-dependencies - name: Audit production dependencies run: pnpm --dir sdk/typescript run audit:prod - name: Pack working-directory: sdk/typescript run: pnpm pack --pack-destination ../../dist - name: Inspect archive contents working-directory: sdk/typescript run: node scripts/check-package.mjs ../../dist/*.tgz ../../plugins/codex-security/plugin-files.json - name: Upload package for this commit uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: package-${{ github.sha }} overwrite: true path: dist/*.tgz if-no-files-found: error retention-days: 7 test: name: tests / ${{ matrix.os }} / shard-${{ matrix.shard }} needs: [classify-changes, package] runs-on: ${{ matrix.os }} timeout-minutes: 20 strategy: fail-fast: false matrix: os: [ubuntu-latest, macos-latest] shard: [1, 2, 3] steps: - *checkout-repository - *download-native - *set-up-typescript-tools - &set-up-bun name: Set up Bun uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2 with: bun-version: "1.3.14" - *install-dependencies - &download-package-for-this-commit name: Download package for this commit uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: name: package-${{ github.sha }} path: dist - name: Restore bundled plugin run: tar -xzf dist/*.tgz --strip-components=1 -C sdk/typescript package/_bundled_plugin - name: Install ripgrep if: matrix.os == 'ubuntu-latest' run: | sudo apt-get update sudo apt-get install --yes ripgrep - name: Test working-directory: sdk/typescript env: TEMP: ${{ runner.temp }} TMP: ${{ runner.temp }} TMPDIR: ${{ runner.temp }} CODEX_SECURITY_ALLOW_MACHINE_POLICY_TEST: "false" run: node --experimental-strip-types scripts/run-ci-tests.mts ${{ matrix.shard }}/3 ${{ matrix.os == 'ubuntu-latest' && '--coverage --coverage-reporter=text --coverage-reporter=lcov' || '' }} - name: Upload test reports if: always() continue-on-error: true uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: bun-${{ runner.os }}-${{ matrix.shard }} overwrite: true path: | sdk/typescript/reports/junit-*.xml sdk/typescript/coverage/lcov.info plugins/codex-security/mcp-app/reports/junit.xml if-no-files-found: warn retention-days: 14 compatibility: name: installed package / ${{ matrix.os }} / node-${{ matrix.node }} needs: [classify-changes, package] runs-on: ${{ matrix.os }} timeout-minutes: 20 strategy: fail-fast: false matrix: os: [ubuntu-latest] node: ["22.13.0", "24.0.0", "24", "26.0.0", "26"] include: - os: macos-latest node: "22.13.0" steps: - *checkout-repository - &set-up-node-js name: Set up Node.js id: node uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: ${{ matrix.node }} cache: npm cache-dependency-path: sdk/typescript/pnpm-lock.yaml - &resolve-npm-cache name: Resolve npm download cache id: npm-cache if: steps.node.outputs.cache-hit != 'true' shell: bash env: PRIMARY_CACHE_KEY: ${{ steps.node.outputs.cache-primary-key }} run: | echo "path=$(npm config get cache)" >> "$GITHUB_OUTPUT" echo "restore-prefix=${PRIMARY_CACHE_KEY%-*}-" >> "$GITHUB_OUTPUT" - &restore-npm-cache name: Restore previous npm downloads if: steps.node.outputs.cache-hit != 'true' uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: ${{ steps.npm-cache.outputs.path }} key: ${{ steps.node.outputs.cache-primary-key }} restore-keys: ${{ steps.npm-cache.outputs.restore-prefix }} - *download-package-for-this-commit - name: Inspect installed package working-directory: sdk/typescript run: node scripts/check-package.mjs ../../dist/*.tgz - name: Check Action against the release candidate if: matrix.os == 'ubuntu-latest' && matrix.node == '24' uses: ./.github/actions/check-action-candidate mcp: name: MCP app tests needs: [classify-changes, package] runs-on: ubuntu-latest timeout-minutes: 20 steps: - *checkout-repository - &set-up-mcp-tools name: Set up TypeScript tools uses: ./.github/actions/setup-tools with: cache-dependency-path: plugins/codex-security/mcp-app/pnpm-lock.yaml - name: Install dependencies run: pnpm --dir plugins/codex-security/mcp-app install --frozen-lockfile - name: Install ripgrep run: | sudo apt-get update sudo apt-get install --yes ripgrep - *download-package-for-this-commit - name: Restore bundled plugin run: tar -xzf dist/*.tgz --strip-components=1 -C sdk/typescript package/_bundled_plugin - name: Test MCP app run: pnpm --dir plugins/codex-security/mcp-app run test:mcp - name: Upload MCP test reports if: always() continue-on-error: true uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: mcp-test-reports overwrite: true path: plugins/codex-security/mcp-app/reports/junit.xml if-no-files-found: warn retention-days: 14 plugin-host: name: standalone plugin / ${{ matrix.os }} needs: classify-changes runs-on: ${{ matrix.os }} timeout-minutes: 20 strategy: fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] steps: - name: Checkout plugin source without the SDK uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false sparse-checkout: | plugins/codex-security .github/actions/setup-tools - *set-up-mcp-tools - name: Install plugin dependencies run: pnpm --dir plugins/codex-security/mcp-app install --frozen-lockfile - name: Build and test the standalone host runtime run: node --experimental-strip-types --test plugins/codex-security/mcp-app/scripts/test_host_build.mts plugin-source: name: plugin source contracts / ${{ matrix.os }} / python-${{ matrix.python }} needs: classify-changes runs-on: ${{ matrix.os }} timeout-minutes: 30 strategy: fail-fast: false matrix: include: - os: ubuntu-latest python: "3.10" markers: "" - os: ubuntu-latest python: "3.12" markers: "" - os: ubuntu-latest python: "3.14" markers: "" - os: macos-latest python: "3.12" markers: cross_platform or native_macos - os: windows-latest python: "3.12" markers: cross_platform or native_windows steps: - *checkout-repository - name: Set up Node.js if: matrix.os == 'ubuntu-latest' && matrix.python == '3.12' uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: "22.13.0" - name: Set up pnpm if: matrix.os == 'ubuntu-latest' && matrix.python == '3.12' uses: ./.github/actions/setup-tools with: setup-node: false compile: true cache-dependency-path: | sdk/typescript/pnpm-lock.yaml plugins/codex-security/mcp-app/pnpm-lock.yaml - name: Install plugin dependencies if: matrix.os == 'ubuntu-latest' && matrix.python == '3.12' run: pnpm --dir plugins/codex-security/mcp-app install --frozen-lockfile - name: Set up Python uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: python-version: ${{ matrix.python }} cache: pip cache-dependency-path: plugins/codex-security/requirements-test.txt - name: Install Python test dependencies run: python -m pip install --disable-pip-version-check --no-input -r plugins/codex-security/requirements-test.txt - name: Install ripgrep if: runner.os == 'Linux' run: | sudo apt-get update sudo apt-get install --yes ripgrep - name: Check plugin source compatibility if: matrix.os == 'ubuntu-latest' && matrix.python == '3.12' run: | python -m ruff check --config plugins/codex-security/pyproject.toml plugins/codex-security python -m ruff format --check --config plugins/codex-security/pyproject.toml plugins/codex-security node .github/scripts/check_plugin_source_compatibility.mjs - name: Test source compatibility checker if: matrix.os == 'ubuntu-latest' && matrix.python == '3.12' run: node --test .github/scripts/test_check_plugin_source_compatibility.mjs - name: Prepare private Windows test root if: runner.os == 'Windows' id: windows-temp shell: pwsh run: ./sdk/typescript/scripts/prepare-windows-test-root.ps1 - name: Test Python source contracts shell: bash env: PYTEST_MARKERS: ${{ matrix.markers }} WINDOWS_TEST_ROOT: ${{ steps.windows-temp.outputs.path }} run: | if [ -n "$WINDOWS_TEST_ROOT" ]; then export TEMP="$WINDOWS_TEST_ROOT" TMP="$WINDOWS_TEST_ROOT" TMPDIR="$WINDOWS_TEST_ROOT" fi python -m pytest plugins/codex-security/tests -m "$PYTEST_MARKERS" -q -n 4 --dist worksteal --max-worker-restart 0 --durations=30 --junitxml=reports/python.xml - name: Require native platform coverage if: runner.os != 'Linux' run: python -c "import pathlib, xml.etree.ElementTree as ET; assert not any(ET.parse(report).findall('.//testcase/skipped') for report in pathlib.Path('reports').glob('python*.xml')), 'Native platform tests must run without skips'" - name: Upload Python test reports if: always() continue-on-error: true uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: python-test-reports-${{ matrix.os }}-${{ matrix.python }} overwrite: true path: reports/python*.xml if-no-files-found: warn retention-days: 14 - name: Set up Node.js for triage evals if: matrix.os == 'ubuntu-latest' && matrix.python == '3.12' uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: "24.15.0" - name: Set up triage eval dependencies and host runtime if: matrix.os == 'ubuntu-latest' && matrix.python == '3.12' run: pnpm --dir evals/triage-finding run setup - name: Test deterministic triage eval contracts if: matrix.os == 'ubuntu-latest' && matrix.python == '3.12' working-directory: evals/triage-finding run: node --run test:deterministic - name: Test secret discovery eval contracts if: matrix.os == 'ubuntu-latest' && matrix.python == '3.12' run: node --experimental-strip-types --test evals/secret-discovery/test_*.mts - name: Test workflow routing eval contracts if: matrix.os == 'ubuntu-latest' && matrix.python == '3.12' run: node --experimental-strip-types --test evals/workflow-routing/test_*.mts required-test: # Skipped metadata jobs must not satisfy required source-check contexts. name: ${{ github.event_name == 'pull_request' && github.event.action == 'edited' && github.event.changes.base == null && 'metadata / ' || '' }}${{ matrix.os }} / node-22 needs: [ classify-changes, workflow-quality, static-checks, package, test, compatibility, mcp, plugin-host, plugin-source, container-validate, ] if: &source-aggregate always() && (github.event_name != 'pull_request' || github.event.action != 'edited' || github.event.changes.base != null) runs-on: ubuntu-latest strategy: fail-fast: false matrix: os: [ubuntu-latest, macos-latest] steps: - name: Require selected workflow checks if: needs.classify-changes.outputs.workflow-quality == 'true' && needs.workflow-quality.result != 'success' run: exit 1 - name: Require every Unix coverage job if: needs.classify-changes.result != 'success' || (needs.static-checks.result != 'success' || needs.package.result != 'success' || needs.test.result != 'success' || needs.compatibility.result != 'success' || needs.mcp.result != 'success' || needs.plugin-host.result != 'success' || needs.plugin-source.result != 'success') run: exit 1 - name: Require selected container coverage if: needs.classify-changes.outputs.container-validate == 'true' && needs.container-validate.result != 'success' run: exit 1 windows-test: name: windows-latest / node-22 / tests-${{ matrix.shard }} needs: [classify-changes, package] runs-on: windows-latest timeout-minutes: 40 strategy: fail-fast: false matrix: shard: [1, 2, 3, 4, 5, 6, 7] steps: - *checkout-repository - &set-up-python name: Set up Python uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: python-version: "3.12" - *download-native - name: Set up Node.js uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: "22.13.0" - name: Set up pnpm uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 with: package_json_file: package.json - *set-up-bun - *install-dependencies - *download-package-for-this-commit - name: Restore bundled plugin shell: bash run: tar -xzf dist/*.tgz --strip-components=1 -C sdk/typescript package/_bundled_plugin - name: Prepare private Windows test root id: windows-temp shell: pwsh run: ./sdk/typescript/scripts/prepare-windows-test-root.ps1 - name: Test shard ${{ matrix.shard }} env: TEMP: ${{ steps.windows-temp.outputs.path }} TMP: ${{ steps.windows-temp.outputs.path }} TMPDIR: ${{ steps.windows-temp.outputs.path }} CODEX_SECURITY_ALLOW_MACHINE_POLICY_TEST: "false" run: node --experimental-strip-types sdk/typescript/scripts/run-ci-tests.mts ${{ matrix.shard }}/7 --seed=${{ github.run_number }} - name: Upload Windows test reports if: always() continue-on-error: true uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: bun-Windows-${{ matrix.shard }} overwrite: true path: sdk/typescript/reports/junit-*.xml if-no-files-found: warn retention-days: 14 - name: Test machine-wide PowerShell policy if: matrix.shard == 3 && runner.environment == 'github-hosted' timeout-minutes: 7 working-directory: sdk/typescript env: TEMP: ${{ steps.windows-temp.outputs.path }} TMP: ${{ steps.windows-temp.outputs.path }} TMPDIR: ${{ steps.windows-temp.outputs.path }} CODEX_SECURITY_ALLOW_MACHINE_POLICY_TEST: "true" run: bun test --timeout 360000 ./tests-ts/windows-machine-policy.test.ts windows-verify: name: windows-latest / node-${{ matrix.node == '22.13.0' && '22' || matrix.node }} / verify needs: [classify-changes, package] runs-on: windows-latest timeout-minutes: 20 strategy: &windows-node-strategy fail-fast: false matrix: node: ["22.13.0", "24"] steps: - *checkout-repository - *set-up-python - *set-up-node-js - *resolve-npm-cache - *restore-npm-cache - *download-package-for-this-commit - name: Inspect installed package working-directory: sdk/typescript shell: bash run: node scripts/check-package.mjs ../../dist/*.tgz windows: name: ${{ github.event_name == 'pull_request' && github.event.action == 'edited' && github.event.changes.base == null && 'metadata / ' || '' }}windows-latest / node-${{ matrix.node == '22.13.0' && '22' || matrix.node }} runs-on: ubuntu-latest if: *source-aggregate needs: [ classify-changes, static-checks, plugin-host, plugin-source, windows-test, windows-verify, ] strategy: *windows-node-strategy steps: - name: Require every Windows coverage job if: needs.classify-changes.result != 'success' || (needs.static-checks.result != 'success' || needs.plugin-host.result != 'success' || needs.plugin-source.result != 'success' || needs.windows-test.result != 'success' || needs.windows-verify.result != 'success') run: exit 1