chore: add testbox workflows and scripts (#4071)
Needed to trigger Blacksmith Testbox workflows.
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
# Blacksmith Testboxes
|
||||
|
||||
Use Testboxes to validate changes in CI-like runners instead of running tests locally.
|
||||
|
||||
Always run `blacksmith testbox` commands from the repository root:
|
||||
|
||||
```bash
|
||||
cd "$(git rev-parse --show-toplevel)"
|
||||
```
|
||||
|
||||
## PR checks Testbox
|
||||
|
||||
The Linux PR Testbox covers the normal Linux PR checks: format, lint, typecheck, exports, unit test shards, webapp e2e, Linux CLI e2e, and SDK compatibility checks.
|
||||
|
||||
Warm it up:
|
||||
|
||||
```bash
|
||||
blacksmith testbox warmup pr-testbox.yml --idle-timeout 60
|
||||
```
|
||||
|
||||
Run the PR checks against your current working tree:
|
||||
|
||||
```bash
|
||||
blacksmith testbox run --id <linux-testbox-id> "scripts/test-pr-check.sh"
|
||||
```
|
||||
|
||||
## Windows PR checks Testbox
|
||||
|
||||
The Windows PR Testbox covers the Windows CLI v3 e2e matrix row.
|
||||
|
||||
Warm it up:
|
||||
|
||||
```bash
|
||||
blacksmith testbox warmup pr-testbox-windows.yml --idle-timeout 60
|
||||
```
|
||||
|
||||
Run the Windows checks against your current working tree:
|
||||
|
||||
```bash
|
||||
blacksmith testbox run --id <windows-testbox-id> "pwsh -NoProfile -ExecutionPolicy Bypass -File scripts/test-pr-check-windows.ps1"
|
||||
```
|
||||
|
||||
## Running both
|
||||
|
||||
```bash
|
||||
linux_id=<linux-testbox-id>
|
||||
windows_id=<windows-testbox-id>
|
||||
|
||||
blacksmith testbox run --id "$linux_id" "scripts/test-pr-check.sh"
|
||||
blacksmith testbox run --id "$windows_id" "pwsh -NoProfile -ExecutionPolicy Bypass -File scripts/test-pr-check-windows.ps1"
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
- The workflow files must be merged before GitHub can dispatch them via `workflow_dispatch`.
|
||||
- `blacksmith testbox run` syncs your local tracked and unignored files before running the command.
|
||||
- If you change dependency manifests, the scripts run `pnpm install` again inside the Testbox.
|
||||
- The Linux Testbox intentionally does not cover the Windows CLI row; use the Windows Testbox for that.
|
||||
- Stop Testboxes when you are finished:
|
||||
|
||||
```bash
|
||||
blacksmith testbox stop --id <testbox-id>
|
||||
```
|
||||
@@ -0,0 +1,74 @@
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
Set-Location (git rev-parse --show-toplevel)
|
||||
|
||||
function Start-Section {
|
||||
param([Parameter(Mandatory = $true)][string]$Title)
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "::group::$Title"
|
||||
}
|
||||
|
||||
function Stop-Section {
|
||||
Write-Host "::endgroup::"
|
||||
}
|
||||
|
||||
function Invoke-Native {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)][string]$Command,
|
||||
[Parameter(ValueFromRemainingArguments = $true)][string[]]$Arguments
|
||||
)
|
||||
|
||||
& $Command @Arguments
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Command failed with exit code ${LASTEXITCODE}: $Command $($Arguments -join ' ')"
|
||||
}
|
||||
}
|
||||
|
||||
function Invoke-Section {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)][string]$Title,
|
||||
[Parameter(Mandatory = $true)][scriptblock]$ScriptBlock
|
||||
)
|
||||
|
||||
Start-Section $Title
|
||||
try {
|
||||
& $ScriptBlock
|
||||
} finally {
|
||||
Stop-Section
|
||||
}
|
||||
}
|
||||
|
||||
Invoke-Section "Install CLI dependencies" {
|
||||
Invoke-Native pnpm install --frozen-lockfile --filter trigger.dev...
|
||||
}
|
||||
|
||||
Invoke-Section "Generate Prisma client" {
|
||||
Invoke-Native pnpm run generate
|
||||
}
|
||||
|
||||
Invoke-Section "Build CLI monorepo dependencies" {
|
||||
Invoke-Native pnpm run build --filter trigger.dev^...
|
||||
}
|
||||
|
||||
Invoke-Section "Build worker template files" {
|
||||
Invoke-Native pnpm --filter trigger.dev run --if-present build:workers
|
||||
}
|
||||
|
||||
Invoke-Section "Enable corepack" {
|
||||
Invoke-Native corepack enable
|
||||
}
|
||||
|
||||
Invoke-Section "CLI v3 E2E tests (npm)" {
|
||||
$env:LOG = "debug"
|
||||
$env:PM = "npm"
|
||||
Invoke-Native pnpm --filter trigger.dev run test:e2e
|
||||
}
|
||||
|
||||
Invoke-Section "CLI v3 E2E tests (pnpm)" {
|
||||
$env:LOG = "debug"
|
||||
$env:PM = "pnpm"
|
||||
Invoke-Native pnpm --filter trigger.dev run test:e2e
|
||||
}
|
||||
|
||||
Write-Host "Windows PR checks completed."
|
||||
Executable
+171
@@ -0,0 +1,171 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
cd "$(git rev-parse --show-toplevel)"
|
||||
|
||||
section() {
|
||||
local title="$1"
|
||||
echo ""
|
||||
echo "::group::${title}"
|
||||
}
|
||||
|
||||
end_section() {
|
||||
echo "::endgroup::"
|
||||
}
|
||||
|
||||
run_section() {
|
||||
local title="$1"
|
||||
shift
|
||||
section "$title"
|
||||
|
||||
local status=0
|
||||
if bash -euo pipefail -c '"$@"' bash "$@"; then
|
||||
status=0
|
||||
else
|
||||
status=$?
|
||||
fi
|
||||
|
||||
end_section
|
||||
return "${status}"
|
||||
}
|
||||
|
||||
find_node_bin() {
|
||||
local version_prefix="$1"
|
||||
|
||||
if [[ ! -d /opt/hostedtoolcache/node ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
find /opt/hostedtoolcache/node -maxdepth 3 -type d -path "*/${version_prefix}*/x64/bin" 2>/dev/null | sort -V | tail -n 1
|
||||
}
|
||||
|
||||
with_node() {
|
||||
local node_bin="$1"
|
||||
shift
|
||||
|
||||
if [[ -n "${node_bin}" ]]; then
|
||||
PATH="${node_bin}:${PATH}" "$@"
|
||||
else
|
||||
"$@"
|
||||
fi
|
||||
}
|
||||
|
||||
run_webapp_unit_tests() {
|
||||
for shard in {1..10}; do
|
||||
echo "Running webapp unit test shard ${shard}/10"
|
||||
SHARD_INDEX="${shard}" SHARD_TOTAL="10" pnpm run test:webapp --reporter=default --shard="${shard}/10" --passWithNoTests
|
||||
done
|
||||
}
|
||||
|
||||
run_package_unit_tests() {
|
||||
for shard in {1..3}; do
|
||||
echo "Running package unit test shard ${shard}/3"
|
||||
SHARD_INDEX="${shard}" SHARD_TOTAL="3" pnpm run test:packages --reporter=default --shard="${shard}/3" --passWithNoTests
|
||||
done
|
||||
}
|
||||
|
||||
run_internal_unit_tests() {
|
||||
for shard in {1..12}; do
|
||||
echo "Running internal unit test shard ${shard}/12"
|
||||
SHARD_INDEX="${shard}" SHARD_TOTAL="12" pnpm run test:internal --reporter=default --shard="${shard}/12" --passWithNoTests
|
||||
done
|
||||
}
|
||||
|
||||
run_webapp_e2e_tests() {
|
||||
pnpm run build --filter webapp
|
||||
(cd apps/webapp && WEBAPP_TEST_VERBOSE="1" pnpm exec vitest run --config vitest.e2e.config.ts --reporter=default)
|
||||
}
|
||||
|
||||
run_cli_e2e_tests() {
|
||||
pnpm run build --filter trigger.dev^...
|
||||
pnpm --filter trigger.dev run --if-present build:workers
|
||||
corepack enable
|
||||
|
||||
LOG=debug PM=npm pnpm --filter trigger.dev run test:e2e
|
||||
LOG=debug PM=pnpm pnpm --filter trigger.dev run test:e2e
|
||||
|
||||
echo "Skipped the PR workflow's Windows CLI matrix row; this Testbox is Linux only."
|
||||
}
|
||||
|
||||
run_sdk_node_compat_tests() {
|
||||
local node_bin="$1"
|
||||
local label="$2"
|
||||
|
||||
with_node "${node_bin}" node --version
|
||||
with_node "${node_bin}" pnpm install --frozen-lockfile
|
||||
with_node "${node_bin}" pnpm run generate
|
||||
with_node "${node_bin}" pnpm run build --filter '@trigger.dev/sdk^...'
|
||||
with_node "${node_bin}" pnpm run build --filter '@trigger.dev/sdk'
|
||||
with_node "${node_bin}" pnpm --filter @internal/sdk-compat-tests test
|
||||
|
||||
echo "Completed SDK Node compatibility checks for ${label}."
|
||||
}
|
||||
|
||||
run_sdk_runtime_compat_tests() {
|
||||
local node20_bin="$1"
|
||||
|
||||
with_node "${node20_bin}" pnpm run build --filter '@trigger.dev/sdk^...'
|
||||
with_node "${node20_bin}" pnpm run build --filter '@trigger.dev/sdk'
|
||||
|
||||
(cd internal-packages/sdk-compat-tests/src/fixtures/bun && bun run test.ts)
|
||||
|
||||
(
|
||||
cd internal-packages/sdk-compat-tests/src/fixtures/deno
|
||||
if [[ ! -e node_modules && ! -L node_modules ]]; then
|
||||
ln -s ../../../../../node_modules node_modules
|
||||
fi
|
||||
deno run --allow-read --allow-env --allow-sys test.ts
|
||||
)
|
||||
|
||||
(
|
||||
cd internal-packages/sdk-compat-tests/src/fixtures/cloudflare-worker
|
||||
pnpm install
|
||||
npx wrangler deploy --dry-run --outdir dist
|
||||
)
|
||||
}
|
||||
|
||||
export -f find_node_bin
|
||||
export -f with_node
|
||||
export -f run_webapp_unit_tests
|
||||
export -f run_package_unit_tests
|
||||
export -f run_internal_unit_tests
|
||||
export -f run_webapp_e2e_tests
|
||||
export -f run_cli_e2e_tests
|
||||
export -f run_sdk_node_compat_tests
|
||||
export -f run_sdk_runtime_compat_tests
|
||||
|
||||
export DATABASE_URL="${DATABASE_URL:-postgresql://postgres:postgres@localhost:5432/postgres}"
|
||||
export DIRECT_URL="${DIRECT_URL:-postgresql://postgres:postgres@localhost:5432/postgres}"
|
||||
export SESSION_SECRET="${SESSION_SECRET:-secret}"
|
||||
export MAGIC_LINK_SECRET="${MAGIC_LINK_SECRET:-secret}"
|
||||
export ENCRYPTION_KEY="${ENCRYPTION_KEY:-dummy-encryption-keeeey-32-bytes}"
|
||||
export DEPLOY_REGISTRY_HOST="${DEPLOY_REGISTRY_HOST:-docker.io}"
|
||||
export CLICKHOUSE_URL="${CLICKHOUSE_URL:-http://default:password@localhost:8123}"
|
||||
export NODE_OPTIONS="${NODE_OPTIONS:---max-old-space-size=8192}"
|
||||
|
||||
NODE20_BIN="${NODE20_BIN:-$(find_node_bin 20.20)}"
|
||||
NODE22_BIN="${NODE22_BIN:-$(find_node_bin 22.12)}"
|
||||
|
||||
run_section "Install dependencies" pnpm install --frozen-lockfile
|
||||
run_section "Generate Prisma client" pnpm run generate
|
||||
|
||||
run_section "Format check" pnpm exec oxfmt --check .
|
||||
run_section "Lint" pnpm exec oxlint .
|
||||
run_section "Typecheck" pnpm run typecheck
|
||||
run_section "Check exports" pnpm run check-exports
|
||||
|
||||
run_section "Webapp unit tests" run_webapp_unit_tests
|
||||
run_section "Package unit tests" run_package_unit_tests
|
||||
run_section "Internal unit tests" run_internal_unit_tests
|
||||
run_section "Webapp E2E tests" run_webapp_e2e_tests
|
||||
run_section "CLI v3 E2E tests" run_cli_e2e_tests
|
||||
|
||||
run_section "SDK Node 20 compatibility tests" run_sdk_node_compat_tests "${NODE20_BIN}" "Node 20.20"
|
||||
if [[ -n "${NODE22_BIN}" ]]; then
|
||||
run_section "SDK Node 22 compatibility tests" run_sdk_node_compat_tests "${NODE22_BIN}" "Node 22.12"
|
||||
else
|
||||
echo "::warning::Node 22.12 was not found in /opt/hostedtoolcache; skipping SDK Node 22 compatibility tests."
|
||||
fi
|
||||
run_section "SDK Bun/Deno/Cloudflare compatibility tests" run_sdk_runtime_compat_tests "${NODE20_BIN}"
|
||||
|
||||
echo "All Linux PR checks completed."
|
||||
Reference in New Issue
Block a user