Files
promptfoo--promptfoo/.github/workflows/tusk-test-runner-vitest-unit-tests.yml
T
wehub-resource-sync 0d3cb498a3
Deploy local.promptfoo.app / Deploy to Cloudflare Pages (push) Waiting to run
Test and Publish Multi-arch Docker Image / test (push) Waiting to run
Test and Publish Multi-arch Docker Image / build-docker-and-push-digests (map[digest-suffix:linux-amd64 platform:linux/amd64 runner:ubuntu-latest]) (push) Blocked by required conditions
Test and Publish Multi-arch Docker Image / build-docker-and-push-digests (map[digest-suffix:linux-arm64 platform:linux/arm64 runner:ubuntu-24.04-arm]) (push) Blocked by required conditions
Test and Publish Multi-arch Docker Image / merge-docker-digests (push) Blocked by required conditions
Test and Publish Multi-arch Docker Image / Attest Multi-arch Image (push) Blocked by required conditions
CI / Shell Format Check (push) Waiting to run
CI / Check Ruby (3.4) (push) Waiting to run
CI / CI Config (push) Waiting to run
CI / Test on Node ${{ matrix.node }} and ${{ matrix.os }}${{ matrix.shard && format(' (shard {0}/3)', matrix.shard) || '' }} (push) Blocked by required conditions
CI / Build on Node ${{ matrix.node }} (push) Blocked by required conditions
CI / Style Check (push) Waiting to run
CI / Generate Assets (push) Waiting to run
CI / Check Python (3.14) (push) Waiting to run
CI / Check Python (3.9) (push) Waiting to run
CI / Build Docs (push) Waiting to run
CI / Code Scan Action (push) Waiting to run
CI / Site tests (push) Waiting to run
CI / webui tests (push) Waiting to run
CI / Run Integration Tests (push) Waiting to run
CI / Run Smoke Tests (push) Waiting to run
CI / Go Tests (push) Waiting to run
CI / Share Test (push) Waiting to run
CI / Redteam (Production API) (push) Waiting to run
CI / Redteam (Staging API) (push) Waiting to run
CI / GitHub Actions Lint (push) Waiting to run
CI / Check Ruby (3.0) (push) Waiting to run
release-please / release-please (push) Waiting to run
release-please / build (push) Blocked by required conditions
release-please / publish-npm (push) Blocked by required conditions
release-please / publish-npm-backfill (push) Waiting to run
release-please / docker (push) Blocked by required conditions
release-please / publish-code-scan-action (push) Blocked by required conditions
release-please / attest-code-scan-action (push) Blocked by required conditions
Validate Renovate Config / Validate Renovate Configuration (push) Waiting to run
chore: import upstream snapshot with attribution
2026-07-13 13:24:08 +08:00

113 lines
3.7 KiB
YAML

name: Tusk Test Runner - Vitest unit tests (test directory)
# Required for Tusk
permissions:
contents: read
on:
workflow_dispatch:
inputs:
runId:
description: 'Tusk Run ID'
required: true
tuskUrl:
description: 'Tusk server URL'
required: true
commitSha:
description: 'Commit SHA to checkout'
required: true
runnerIndexes:
description: 'Runner indexes'
required: false
default: '["1"]'
jobs:
test-action:
name: Tusk Test Runner
runs-on: ubuntu-latest
timeout-minutes: 10
env:
PROMPTFOO_DISABLE_TELEMETRY: 1
# Required for test parallelization where available, do not remove.
strategy:
matrix:
runnerIndex: ${{ fromJson(github.event.inputs.runnerIndexes) }}
steps:
- name: Checkout
id: checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
with:
ref: ${{ github.event.inputs.commitSha }} # Required for Tusk to access files for the commit being tested
- name: Use Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
with:
node-version-file: '.nvmrc'
cache: 'npm'
# Node 24 ships with npm 11.6.2 which has a lockfile compatibility bug (npm/cli#8669).
# Pinned exact (not @latest): npm 12.0.0 blocks postinstall scripts not covered by
# allowScripts, which silently skips e.g. the Playwright browser download.
- name: Upgrade npm
run: npm install -g npm@11.18.0
- name: Install Dependencies
run: |
npm ci
- name: Start runner
id: test-action
uses: Use-Tusk/test-runner@c83efabca725843d6cdb5d3e9c4083baf7c8282e # v1
# See https://github.com/Use-Tusk/test-runner for full details and examples.
with:
# Required for the test runner, do not remove this input
runId: ${{ github.event.inputs.runId }}
# Required for the test runner, do not remove this input
tuskUrl: ${{ github.event.inputs.tuskUrl }}
# Required for the test runner, do not remove this input
commitSha: ${{ github.event.inputs.commitSha }}
# Your Tusk auth token. It is recommended to add it to your repo's secrets.
# Please adapt the secret name accordingly if you have named it differently.
authToken: ${{ secrets.TUSK_AUTH_TOKEN }}
testFramework: 'vitest'
testFileRegex: '^test/.*\.test\.(js|ts|tsx)$'
# Format with Biome (JS/TS/JSON) and Prettier (CSS/MD/YAML), then lint
lintScript: |
FILE="{{file}}"
# Validate no shell metacharacters in file path
if [[ "$FILE" =~ [\;\|\&\$\`\<\>\(\)] ]]; then
echo "Error: Invalid characters in file path: $FILE"
exit 1
fi
EXT="${FILE##*.}"
# Format based on file extension (use -- to prevent flag injection)
case "$EXT" in
js|jsx|mjs|cjs|ts|tsx|json)
npx @biomejs/biome check --write -- "$FILE"
;;
css|scss|html|md|mdc|mdx|yaml|yml)
npx prettier --write -- "$FILE"
;;
*)
echo "Skipping unsupported file type: $FILE"
;;
esac
testScript: 'npx vitest run {{file}} --reporter=verbose'
coverageScript: 'npx vitest run {{testFilePaths}} --coverage --coverage.reporter=json-summary --coverage.reporter=json'
# Required for test parallelization where available, do not remove.
runnerIndex: ${{ matrix.runnerIndex }}