Files
codex-security/.github/workflows/test-quality.yml
T
4f1ad92130 test(ci): qualify parallel runners on balanced shards (#1860)
* test(ci): balance test shards by recorded duration

* test(ci): compare weighted shards across Bun runner modes

* test(ci): require complete runner diagnostic shard reports

* test(ci): align Linux diagnostic ripgrep setup

* test: qualify changes to CI runner tooling

* test: close native configuration fixture before preflight reply

---------

Co-authored-by: mldangelo-oai <269034524+mldangelo-oai@users.noreply.github.com>
Co-authored-by: Codex <codex@users.noreply.github.com>
2026-10-23 11:32:09 +08:00

195 lines
7.4 KiB
YAML

name: test-quality
on:
workflow_call:
inputs:
native-artifacts-ready:
description: Use the native artifacts already built by the caller in this run.
type: boolean
default: false
workflow_dispatch:
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
runner:
needs: native
if: ${{ !cancelled() && (inputs.native-artifacts-ready || needs.native.result == 'success') }}
name: ${{ matrix.target.os }} / ${{ matrix.mode.name }} / 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 }}
strategy:
fail-fast: false
matrix:
# Every mode uses the same production shard count and timing snapshot.
target:
- { os: ubuntu-latest, shard: 1, count: 3 }
- { os: ubuntu-latest, shard: 2, count: 3 }
- { os: ubuntu-latest, shard: 3, count: 3 }
- { os: macos-latest, shard: 1, count: 3 }
- { os: macos-latest, shard: 2, count: 3 }
- { os: macos-latest, shard: 3, count: 3 }
- { os: windows-latest, shard: 1, count: 7 }
- { os: windows-latest, shard: 2, count: 7 }
- { os: windows-latest, shard: 3, count: 7 }
- { os: windows-latest, shard: 4, count: 7 }
- { os: windows-latest, shard: 5, count: 7 }
- { os: windows-latest, shard: 6, count: 7 }
- { os: windows-latest, shard: 7, count: 7 }
mode:
- { name: baseline, args: "" }
- { name: isolated, args: --isolate }
- { name: parallel, args: --parallel=2 }
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@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.12"
- name: Prepare native runtime
uses: ./.github/actions/download-native
- &actions-setup-node
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: "22.13.0"
- name: Set up pnpm
uses: ./.github/actions/setup-tools
with:
setup-node: false
cache-dependency-path: |
sdk/typescript/pnpm-lock.yaml
plugins/codex-security/mcp-app/pnpm-lock.yaml
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with:
# Includes the isolated spawnSync fix from oven-sh/bun#44581.
bun-version: "1.4.3"
- name: Install dependencies
run: |
pnpm --dir sdk/typescript install --frozen-lockfile
pnpm --dir plugins/codex-security/mcp-app install --frozen-lockfile
- 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: Build bundled plugin
run: pnpm --dir sdk/typescript run build:plugin
- name: Install ripgrep
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install --yes ripgrep
- name: Test runner mode
working-directory: sdk/typescript
env:
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 ${{ matrix.target.shard }}/${{ matrix.target.count }} ${{ matrix.mode.args }} --seed=${{ env.CODEX_SECURITY_PROPERTY_SEED }} --reporter-outfile=reports/runner-${{ matrix.target.os }}-${{ matrix.mode.name }}-${{ matrix.target.shard }}.xml
- name: Upload runner report
if: always()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: runner-${{ matrix.target.os }}-${{ matrix.mode.name }}-${{ matrix.target.shard }}
overwrite: true
path: sdk/typescript/reports/runner-*.xml
if-no-files-found: error
retention-days: 14
compare:
name: Runner inventory and timing
if: always() && !cancelled()
needs: [runner]
runs-on: ubuntu-latest
steps:
- *actions-checkout
- *actions-setup-node
- &github-actions-setup-tools
uses: ./.github/actions/setup-tools
with:
setup-node: false
- 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
shards=3
if [[ "$os" == windows-latest ]]; then shards=7; fi
for mode in baseline isolated parallel; do
reports=(reports/runner-"$os"-"$mode"-*.xml)
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
for mode in isolated parallel; do
node --experimental-strip-types sdk/typescript/scripts/compare-test-reports.mts "reports/runner-$os-baseline-*.xml" "reports/runner-$os-$mode-*.xml" >> "$GITHUB_STEP_SUMMARY" || comparison_status=1
done
done
exit "$comparison_status"
mutation:
name: Pure-module mutation trial
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- *actions-checkout
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
# Stryker 10's Babel 8 requires Node 22.18+ or 24.11+.
node-version: "24.15.0"
- *github-actions-setup-tools
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with:
bun-version: "1.3.14"
- name: Install dependencies
run: pnpm --dir sdk/typescript install --frozen-lockfile
- 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