Skip to content

TSJS Performance Gate / tsjs-pr-31658474971 / pull-request #6

TSJS Performance Gate / tsjs-pr-31658474971 / pull-request

TSJS Performance Gate / tsjs-pr-31658474971 / pull-request #6

name: "TSJS Performance Gate"
run-name: >-
TSJS Performance Gate / ${{ inputs.evidence_id || format('tsjs-pr-{0}', github.run_id) }} / ${{ inputs.mode || 'pull-request' }}
permissions:
contents: read
on:
pull_request:
paths:
- ".github/workflows/tsjs-performance-gate.yml"
- ".tool-versions"
- "Cargo.toml"
- "Cargo.lock"
- "crates/trusted-server-core/**"
- "crates/trusted-server-core/src/auction/**"
- "crates/trusted-server-integration-tests/Cargo.toml"
- "crates/trusted-server-integration-tests/browser/**"
- "crates/trusted-server-integration-tests/src/bin/generate-tsjs-prospective-fixture.rs"
- "crates/trusted-server-js/**"
- "scripts/validate-tsjs-performance-evidence.mjs"
workflow_dispatch:
inputs:
evidence_id:
description: Unique identifier bound to the uploaded evidence
required: true
type: string
mode:
description: Cutover side measured by this run
required: true
type: choice
options:
- preswitch
- postswitch
workflow_call:
inputs:
evidence_id:
description: Unique identifier bound to the uploaded evidence
required: true
type: string
mode:
description: Cutover side measured by this run (preswitch or postswitch)
required: true
type: string
env:
TSJS_PERF_MACHINE_CLASS: github-hosted:ubuntu-24.04
TSJS_PERF_RUNNER_IMAGE: ubuntu-24.04
TSJS_PERF_WORKFLOW_NAME: TSJS Performance Gate
TSJS_PERF_WORKFLOW_FILE: .github/workflows/tsjs-performance-gate.yml
jobs:
measure:
name: measure ${{ inputs.mode || 'pull-request' }} (${{ inputs.evidence_id || format('tsjs-pr-{0}', github.run_id) }})
runs-on: ubuntu-24.04
timeout-minutes: 35
env:
TSJS_EVIDENCE_ID: ${{ inputs.evidence_id || format('tsjs-pr-{0}', github.run_id) }}
TSJS_PERF_MODE: ${{ inputs.mode || 'pull-request' }}
TSJS_PERF_ARTIFACT_NAME: tsjs-performance-${{ inputs.evidence_id || format('tsjs-pr-{0}', github.run_id) }}
TSJS_PERF_OUTPUT: crates/trusted-server-integration-tests/browser/test-results/tsjs-performance-${{ inputs.mode || 'pull-request' }}.json
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Validate immutable measurement inputs
shell: bash
run: |
test "$TSJS_PERF_MODE" = preswitch || test "$TSJS_PERF_MODE" = postswitch || test "$TSJS_PERF_MODE" = pull-request
[[ "$TSJS_EVIDENCE_ID" =~ ^[A-Za-z0-9][A-Za-z0-9._-]{7,127}$ ]]
- name: Read repository toolchain pins
id: toolchains
shell: bash
run: |
node_version="$(awk '$1 == "nodejs" { print $2 }' .tool-versions)"
rust_version="$(awk '$1 == "rust" { print $2 }' .tool-versions)"
test -n "$node_version"
test -n "$rust_version"
echo "node=$node_version" >> "$GITHUB_OUTPUT"
echo "rust=$rust_version" >> "$GITHUB_OUTPUT"
- name: Set up pinned Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ steps.toolchains.outputs.node }}
cache: npm
cache-dependency-path: |
crates/trusted-server-js/lib/package-lock.json
crates/trusted-server-integration-tests/browser/package-lock.json
- name: Set up pinned Rust for the generated controller fixture
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ steps.toolchains.outputs.rust }}
cache-shared-key: cargo-${{ runner.os }}-tsjs-performance
- name: Verify installed toolchain pins
shell: bash
run: |
test "$(node --version)" = "v24.12.0"
test "$(npm --version)" = "11.6.2"
test "$(rustc --version | awk '{ print $2 }')" = "1.95.0"
- name: Build the real TSJS artifacts once
working-directory: crates/trusted-server-js/lib
run: |
npm ci
npm run build
npm run check:bundle
- name: Build the exact current main artifacts
shell: bash
run: |
git fetch origin main
main_sha="$(git rev-parse origin/main)"
main_root="$RUNNER_TEMP/tsjs-performance-main"
[[ "$main_sha" =~ ^[0-9a-f]{40}$ ]]
test "$(git cat-file -t "$main_sha")" = commit
git worktree add --detach "$main_root" "$main_sha"
npm --prefix "$main_root/crates/trusted-server-js/lib" ci
npm --prefix "$main_root/crates/trusted-server-js/lib" run build
echo "TSJS_PERF_MAIN_SHA=$main_sha" >> "$GITHUB_ENV"
echo "TSJS_PERF_MAIN_ROOT=$main_root" >> "$GITHUB_ENV"
- name: Install the lockfile-pinned Chromium setup
working-directory: crates/trusted-server-integration-tests/browser
run: |
npm ci
node -e 'const version = require("@playwright/test/package.json").version; if (version !== "1.58.2") throw new Error("unexpected Playwright " + version)'
npx playwright install --with-deps chromium
- name: Run the complete TSJS performance sample exactly once
working-directory: crates/trusted-server-integration-tests/browser
env:
CI: "true"
GITHUB_SHA: ${{ github.sha }}
run: |
config_file="$RUNNER_TEMP/tsjs-performance-playwright.config.mjs"
printf "%s\n" \
"export default {" \
" testDir: process.cwd()," \
" timeout: 30000," \
" retries: 0," \
" workers: 1," \
" use: { headless: true }," \
" projects: [{ name: 'chromium', use: { browserName: 'chromium' } }]," \
" reporter: [['list']]," \
" outputDir: './test-results'" \
"};" > "$config_file"
npx playwright test \
tests/shared/tsjs-performance.spec.ts \
--config="$config_file" \
--project=chromium \
--workers=1
- name: Validate the generated evidence before upload
if: always()
run: >-
node scripts/validate-tsjs-performance-evidence.mjs
--file "$TSJS_PERF_OUTPUT"
--evidence-id "$TSJS_EVIDENCE_ID"
--head-sha "${{ github.sha }}"
--main-sha "$TSJS_PERF_MAIN_SHA"
--mode "$TSJS_PERF_MODE"
- name: Upload immutable TSJS performance evidence
if: always()
uses: actions/upload-artifact@v4
with:
name: ${{ env.TSJS_PERF_ARTIFACT_NAME }}
path: ${{ env.TSJS_PERF_OUTPUT }}
if-no-files-found: error
retention-days: 30