Files

260 lines
11 KiB
YAML

name: test-quality
on:
workflow_call:
inputs:
compare-layouts: &compare-layouts
description: Run the full SDK shard-layout comparison
type: boolean
default: true
native-artifacts-ready:
description: Use the native artifacts already built by the caller in this run.
type: boolean
default: false
workflow_dispatch:
inputs:
compare-layouts: *compare-layouts
schedule:
- cron: "23 9 * * 1"
permissions:
contents: read
concurrency:
group: test-quality-${{ github.ref }}
cancel-in-progress: true
env:
CODEX_SECURITY_INTEGRATION: "0"
CODEX_SECURITY_ALLOW_MACHINE_POLICY_TEST: "false"
jobs:
native:
if: ${{ !inputs.native-artifacts-ready }}
uses: ./.github/workflows/native-artifacts.yml
with:
reuse-verified: ${{ !inputs.compare-layouts }}
runner:
needs: native
if: ${{ !cancelled() && inputs.compare-layouts && (inputs.native-artifacts-ready || needs.native.result == 'success') }}
name: ${{ matrix.target.os }} / ${{ matrix.target.mode }} / shard-${{ matrix.target.shard }}
runs-on: ${{ matrix.target.os }}
timeout-minutes: ${{ matrix.target.os == 'windows-latest' && 90 || 30 }}
env:
CODEX_SECURITY_PROPERTY_SEED: ${{ github.event_name == 'pull_request' && 1 || github.run_number }}
SHARD: ${{ matrix.target.shard }}/${{ matrix.target.count }}
REPORT_ID: ${{ matrix.target.os }}-${{ matrix.target.mode }}-${{ matrix.target.shard }}
strategy:
fail-fast: false
matrix:
# Compare the previous layout with the expanded production layout.
target:
- { os: ubuntu-latest, shard: 1, count: 3, mode: baseline }
- { os: ubuntu-latest, shard: 2, count: 3, mode: baseline }
- { os: ubuntu-latest, shard: 3, count: 3, mode: baseline }
- { os: macos-latest, shard: 1, count: 3, mode: baseline }
- { os: macos-latest, shard: 2, count: 3, mode: baseline }
- { os: macos-latest, shard: 3, count: 3, mode: baseline }
- { os: windows-latest, shard: 1, count: 7, mode: baseline }
- { os: windows-latest, shard: 2, count: 7, mode: baseline }
- { os: windows-latest, shard: 3, count: 7, mode: baseline }
- { os: windows-latest, shard: 4, count: 7, mode: baseline }
- { os: windows-latest, shard: 5, count: 7, mode: baseline }
- { os: windows-latest, shard: 6, count: 7, mode: baseline }
- { os: windows-latest, shard: 7, count: 7, mode: baseline }
- { os: ubuntu-latest, shard: 1, count: 6, mode: expanded }
- { os: ubuntu-latest, shard: 2, count: 6, mode: expanded }
- { os: ubuntu-latest, shard: 3, count: 6, mode: expanded }
- { os: ubuntu-latest, shard: 4, count: 6, mode: expanded }
- { os: ubuntu-latest, shard: 5, count: 6, mode: expanded }
- { os: ubuntu-latest, shard: 6, count: 6, mode: expanded }
- { os: macos-latest, shard: 1, count: 6, mode: expanded }
- { os: macos-latest, shard: 2, count: 6, mode: expanded }
- { os: macos-latest, shard: 3, count: 6, mode: expanded }
- { os: macos-latest, shard: 4, count: 6, mode: expanded }
- { os: macos-latest, shard: 5, count: 6, mode: expanded }
- { os: macos-latest, shard: 6, count: 6, mode: expanded }
- { os: windows-latest, shard: 1, count: 14, mode: expanded }
- { os: windows-latest, shard: 2, count: 14, mode: expanded }
- { os: windows-latest, shard: 3, count: 14, mode: expanded }
- { os: windows-latest, shard: 4, count: 14, mode: expanded }
- { os: windows-latest, shard: 5, count: 14, mode: expanded }
- { os: windows-latest, shard: 6, count: 14, mode: expanded }
- { os: windows-latest, shard: 7, count: 14, mode: expanded }
- { os: windows-latest, shard: 8, count: 14, mode: expanded }
- { os: windows-latest, shard: 9, count: 14, mode: expanded }
- { os: windows-latest, shard: 10, count: 14, mode: expanded }
- { os: windows-latest, shard: 11, count: 14, mode: expanded }
- { os: windows-latest, shard: 12, count: 14, mode: expanded }
- { os: windows-latest, shard: 13, count: 14, mode: expanded }
- { os: windows-latest, shard: 14, count: 14, mode: expanded }
steps:
- &actions-checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Python
if: runner.os == 'Windows'
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: "3.12"
- &download-native
name: Prepare native runtime
uses: ./.github/actions/download-native
- &set-up-plugin-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
- &set-up-bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with:
bun-version: "1.3.14"
- &install-plugin-dependencies
name: Install dependencies
shell: bash
run: |
pnpm --dir sdk/typescript install --frozen-lockfile
pnpm --dir plugins/codex-security/mcp-app install --frozen-lockfile
- &prepare-windows-test-root
name: Prepare private Windows test root
if: runner.os == 'Windows'
id: windows-temp
shell: pwsh
run: ./sdk/typescript/scripts/prepare-windows-test-root.ps1
- &build-plugin
name: Build bundled plugin
run: pnpm --dir sdk/typescript run build:plugin
- name: Install ripgrep
if: runner.os == 'Linux'
run: .github/scripts/install-ripgrep.sh
- name: Test shard layout
working-directory: sdk/typescript
env: &test-temp
TEMP: ${{ steps.windows-temp.outputs.path || runner.temp }}
TMP: ${{ steps.windows-temp.outputs.path || runner.temp }}
TMPDIR: ${{ steps.windows-temp.outputs.path || runner.temp }}
run: node --experimental-strip-types scripts/run-ci-tests.mts ${{ env.SHARD }} ${{ runner.os == 'Linux' && '--coverage --coverage-reporter=lcov' || '' }} --coverage-dir=reports/coverage-${{ env.REPORT_ID }} --seed=${{ env.CODEX_SECURITY_PROPERTY_SEED }} --reporter-outfile=reports/runner-${{ env.REPORT_ID }}.xml
- &upload-runner-report
name: Upload runner report
if: always()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: runner-${{ env.REPORT_ID }}
overwrite: true
path: sdk/typescript/reports/
if-no-files-found: error
retention-days: 14
properties:
needs: native
if: ${{ !cancelled() && !inputs.compare-layouts && (inputs.native-artifacts-ready || needs.native.result == 'success') }}
name: ${{ matrix.os }} / rotating properties
runs-on: ${{ matrix.os }}
timeout-minutes: 20
env:
CODEX_SECURITY_PROPERTY_SEED: ${{ github.run_number }}
CODEX_SECURITY_TEST_TIMEOUT_MS: ${{ matrix.os == 'windows-latest' && '120000' || '30000' }}
REPORT_ID: ${{ matrix.os }}-properties
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- *actions-checkout
- *download-native
- *set-up-plugin-tools
- *set-up-bun
- *install-plugin-dependencies
- *build-plugin
- *prepare-windows-test-root
- name: Test rotating properties
working-directory: sdk/typescript
shell: bash
env: *test-temp
run: |
git grep -lzF 'support/property' -- 'tests-ts/*.test.ts' > "$RUNNER_TEMP/property-tests"
mkdir -p reports
xargs -0 bun test --timeout="$CODEX_SECURITY_TEST_TIMEOUT_MS" --seed="$CODEX_SECURITY_PROPERTY_SEED" --reporter=junit --reporter-outfile=reports/properties.xml < "$RUNNER_TEMP/property-tests"
- *upload-runner-report
compare:
name: Runner inventory and timing
if: always() && !cancelled() && inputs.compare-layouts
needs: [runner]
runs-on: ubuntu-latest
steps:
- *actions-checkout
- name: Set up TypeScript tools
uses: ./.github/actions/setup-tools
- &install-sdk-dependencies
name: Install dependencies
run: pnpm --dir sdk/typescript install --frozen-lockfile
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
pattern: runner-*
merge-multiple: true
path: reports
- name: Compare inventories and outcomes
shell: bash
run: |
comparison_status=0
shopt -s nullglob
for os in ubuntu-latest macos-latest windows-latest; do
for mode in baseline expanded; do
shards=3
if [[ "$os" == windows-latest ]]; then shards=7; fi
reports=(reports/runner-"$os"-"$mode"-*.xml)
if [[ "$mode" == expanded ]]; then
shards=$((shards * 2))
expanded_reports=("${reports[@]}")
else
baseline_reports=("${reports[@]}")
fi
if (( ${#reports[@]} != shards )); then
echo "Expected $shards reports for $os/$mode, found ${#reports[@]}" >&2
comparison_status=1
fi
for ((shard=1; shard<=shards; shard++)); do
report="reports/runner-$os-$mode-$shard.xml"
if [[ ! -f "$report" ]]; then
echo "Missing shard report: $report" >&2
comparison_status=1
fi
done
done
node --experimental-strip-types sdk/typescript/scripts/compare-test-reports.mts "${baseline_reports[@]}" -- "${expanded_reports[@]}" >> "$GITHUB_STEP_SUMMARY" || comparison_status=1
done
exit "$comparison_status"
mutation:
name: Pure-module mutation trial
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- *actions-checkout
- uses: ./.github/actions/setup-tools
with:
# Stryker 10's Babel 8 requires Node 22.18+ or 24.11+.
node-version: "24.15.0"
cache-dependency-path: |
sdk/typescript/pnpm-lock.yaml
sdk/mutation/pnpm-lock.yaml
- *set-up-bun
- *install-sdk-dependencies
- name: Run mutation trial
run: pnpm --dir sdk/typescript run test:mutation
- name: Upload mutation report
if: always()
continue-on-error: true
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: mutation-report
overwrite: true
path: sdk/typescript/reports/mutation/
if-no-files-found: warn
retention-days: 14