mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-12-06 04:56:15 +08:00
Bring the v0.4.17 release changes into canary (#4309)
* Bring the v0.4.17 release changes into canary - Merges main into canary after the v0.4.17 release: the changelog, versions and release workflow changes. * Restore the green-main tag script the release merge dropped
This commit is contained in:
+133
-59
@@ -15,8 +15,10 @@ on:
|
||||
# A merge queue group: the tree that would become main or canary, tested before it does. It runs the fast gate:
|
||||
# the plain shards, code quality and the TypeScript baselines. The global lanes run on the push to the branch.
|
||||
merge_group:
|
||||
# Nightly full macOS sweep. Pushes to main run only the macOS smoke job (tests_macos_smoke), and pull requests
|
||||
# run the macOS jobs only when they change darwin code (scripts/ci-lanes.mjs).
|
||||
# Nightly sweep of every lane but macos. Pushes to main run only the macOS smoke job (tests_macos_smoke), and pull
|
||||
# requests run the macOS jobs only when they change darwin code (scripts/ci-lanes.mjs). The complete macOS suite
|
||||
# runs on the newest green main commit in the post-merge lanes (postmerge.yml), which call this workflow with
|
||||
# only_lane set to macos.
|
||||
schedule:
|
||||
- cron: "17 7 * * *"
|
||||
# A manual run, for example on a release candidate commit. It runs every lane; macos_suite selects the complete
|
||||
@@ -43,6 +45,22 @@ on:
|
||||
type: choice
|
||||
options: [all, shape_overlay]
|
||||
default: all
|
||||
# The post-merge lanes (postmerge.yml): one lane on a commit that is not the caller's. Every checkout reads ref, so
|
||||
# the jobs test that commit and not the default branch's tip that a workflow_run or schedule caller starts on.
|
||||
workflow_call:
|
||||
inputs:
|
||||
ref:
|
||||
description: The commit to test. Empty tests the caller's commit.
|
||||
type: string
|
||||
default: ""
|
||||
only_lane:
|
||||
description: Run only this lane (macos); the other lanes are off and the shape overlay does not run.
|
||||
type: string
|
||||
default: ""
|
||||
macos_suite:
|
||||
description: The test suite to run on macOS (full or darwin)
|
||||
type: string
|
||||
default: full
|
||||
|
||||
concurrency:
|
||||
# A new push to a pull request cancels its previous run. Pushes to an integration branch share one group per
|
||||
@@ -53,13 +71,16 @@ concurrency:
|
||||
# (scripts/release-ci-gate.mjs) dispatches one when that commit's push run was dropped. Each merge queue group
|
||||
# runs in a group of its own commit. The nightly sweep and manual runs neither cancel nor are cancelled by push
|
||||
# runs. A pull request's dispatched full tier (a dispatch with pr) runs in a group of its own beside the
|
||||
# pull request's: it never cancels the pull request run, whose checks the merge gate requires.
|
||||
group: ci-${{ github.event_name == 'schedule' && 'schedule' || github.event_name == 'workflow_dispatch' && (inputs.pr && format('full-{0}', inputs.pr) || format('dispatch-{0}', github.run_id)) || github.event.pull_request.number || github.event_name == 'push' && format('push-{0}', github.ref_name) || github.sha }}
|
||||
# pull request's: it never cancels the pull request run, whose checks the merge gate requires. A post-merge
|
||||
# call (postmerge.yml) runs in a group of its own run and cancels nothing: the caller holds one run at a time.
|
||||
group: ci-${{ inputs.only_lane && format('postmerge-{0}', github.run_id) || github.event_name == 'schedule' && 'schedule' || github.event_name == 'workflow_dispatch' && (inputs.pr && format('full-{0}', inputs.pr) || format('dispatch-{0}', github.run_id)) || github.event.pull_request.number || github.event_name == 'push' && format('push-{0}', github.ref_name) || github.sha }}
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' && inputs.pr != '' }}
|
||||
|
||||
# The token every job gets unless it declares its own: it can read the repository and nothing else. No job here
|
||||
# writes to a branch, comments on a pull request or requests an OIDC token; the green_tag job declares its own
|
||||
# contents permission for its tag alone, and caches and artifacts do not use this token.
|
||||
# writes to a branch, comments on a pull request or requests an OIDC token; caches and artifacts do not use this
|
||||
# token. CI is also a reusable workflow the post-merge lanes call read-only, and GitHub validates every job in a
|
||||
# called workflow against the caller's permission ceiling whether or not it runs, so no job here may ask for more.
|
||||
# The green-main and green-canary tags move from green-main.yml and green-tag.yml beside CI for that reason.
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
@@ -130,9 +151,12 @@ jobs:
|
||||
? (event.merge_group?.base_ref ?? '').replace(/^refs\/heads\//, '')
|
||||
: '';
|
||||
const canary = integrationBranch === 'canary';
|
||||
// The release pull request from canary into main runs the full tier; a pull request into canary runs the
|
||||
// fast tier unless the label asks for the full suite.
|
||||
const releasePullRequest = eventName === 'pull_request' && pr?.base?.ref === 'main';
|
||||
// The release pull request from canary into main runs the full tier; a pull request into the default
|
||||
// branch (canary during development, main once the branches align) runs the fast tier unless the label
|
||||
// asks for the full suite. On main itself every pull request targets main, so the release rule applies
|
||||
// only while the default branch is another one.
|
||||
const releasePullRequest =
|
||||
eventName === 'pull_request' && pr?.base?.ref === 'main' && defaultBranch !== 'main';
|
||||
const tier = superseded ? 'superseded'
|
||||
: canary ? 'canary'
|
||||
: eventName === 'pull_request' && !releasePullRequest && !fullLabel
|
||||
@@ -151,9 +175,11 @@ jobs:
|
||||
# merge queue group runs the fast gate: the plain shards, the TypeScript 7 baselines and the checks above them.
|
||||
# Canary's merge queue and post-merge runs turn every lane off and run fast_tests with the canary tests instead.
|
||||
# The lane outputs still name what a full run would do, and the queue and post outputs below say which of the
|
||||
# two tiers this run is. The nightly sweep and manual runs run every lane but macos_smoke, which the complete
|
||||
# macOS lane covers. A pull request's fast tier turns every lane off; its ci:full run and its dispatched full
|
||||
# tier select lanes the same way against the pull request's base.
|
||||
# two tiers this run is. The nightly sweep runs every lane but macos, whose jobs the post-merge lanes
|
||||
# (postmerge.yml) run on the newest green main commit, and macos_smoke; manual runs every lane but macos_smoke,
|
||||
# which the complete macOS lane covers. A post-merge call runs only the lane it names. A pull request's fast
|
||||
# tier turns every lane off; its ci:full run and its dispatched full tier select lanes the same way against the
|
||||
# pull request's base.
|
||||
lanes:
|
||||
needs: validation_scope
|
||||
if: ${{ needs.validation_scope.outputs.full == 'true' }}
|
||||
@@ -193,6 +219,7 @@ jobs:
|
||||
env:
|
||||
EVENT: ${{ inputs.pr != '' && 'pull_request' || github.event_name }}
|
||||
TIER: ${{ needs.validation_scope.outputs.tier }}
|
||||
ONLY_LANE: ${{ inputs.only_lane }}
|
||||
BASE: ${{ github.event.pull_request.base.sha }}
|
||||
HEAD: ${{ github.event.pull_request.head.sha || github.sha }}
|
||||
PR: ${{ github.event.pull_request.number || inputs.pr }}
|
||||
@@ -207,11 +234,18 @@ jobs:
|
||||
}
|
||||
# A dispatched full tier reads the pull request's base from the API.
|
||||
base() { [ -n "$BASE" ] || BASE=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR" --jq .base.sha); }
|
||||
if [ "$TIER" = fast ]; then
|
||||
if [ "$ONLY_LANE" = macos ]; then
|
||||
printf 'linux=false\nmacos=true\neffects=false\nbootstrap=false\nprofile=false\nislands=false\nmacos_smoke=false\n' | tee -a "$GITHUB_OUTPUT"
|
||||
elif [ -n "$ONLY_LANE" ]; then
|
||||
echo "::error::unknown lane $ONLY_LANE"
|
||||
exit 1
|
||||
elif [ "$TIER" = fast ]; then
|
||||
printf 'linux=false\nmacos=false\neffects=false\nbootstrap=false\nprofile=false\nislands=false\nmacos_smoke=false\nfast=true\nqueue=false\npost=false\n' | tee -a "$GITHUB_OUTPUT"
|
||||
elif [ "$TIER" = canary ]; then
|
||||
# Canary's merge queue and post-merge runs: the fast PR jobs and the canary tests, nothing else.
|
||||
printf 'linux=false\nmacos=false\neffects=false\nbootstrap=false\nprofile=false\nislands=false\nmacos_smoke=false\nfast=true\nqueue=false\npost=false\n' | tee -a "$GITHUB_OUTPUT"
|
||||
elif [ "$EVENT" = schedule ]; then
|
||||
printf 'linux=true\nmacos=false\neffects=true\nbootstrap=true\nprofile=true\nislands=true\nmacos_smoke=false\nqueue=false\npost=false\n' | tee -a "$GITHUB_OUTPUT"
|
||||
elif [ "$EVENT" = merge_group ]; then
|
||||
queued
|
||||
printf 'queue=true\npost=false\n' | tee -a "$GITHUB_OUTPUT"
|
||||
@@ -247,6 +281,7 @@ jobs:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
fetch-depth: 0
|
||||
ref: ${{ inputs.ref }}
|
||||
- id: plan
|
||||
env:
|
||||
# The base revision's copy decides, as it does for the lane selector: a queued change cannot widen its own
|
||||
@@ -268,6 +303,8 @@ jobs:
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
@@ -363,6 +400,8 @@ jobs:
|
||||
timeout-minutes: 40
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
@@ -380,9 +419,11 @@ jobs:
|
||||
packages/llvm-darwin-arm64/bin
|
||||
packages/runtime-darwin-arm64/artifacts
|
||||
packages/runtime-darwin-arm64/runtime-pack.json
|
||||
# CI's artifacts start with ci-: a post-merge run (postmerge.yml) calls this workflow and the release rehearsal
|
||||
# in one run, whose native-<platform> artifacts would otherwise collide with these.
|
||||
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: native-darwin-arm64
|
||||
name: ci-native-darwin-arm64
|
||||
path: ${{ runner.temp }}/native-darwin-arm64.tar.gz
|
||||
retention-days: 1
|
||||
|
||||
@@ -452,6 +493,8 @@ jobs:
|
||||
SCRIPTC_TEST_SHARD: ${{ matrix.shard }}/${{ matrix.flavor == 'san' && '30' || '20' }}
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
@@ -463,7 +506,7 @@ jobs:
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: native-linux-x64-gnu
|
||||
name: ci-native-linux-x64-gnu
|
||||
path: ${{ runner.temp }}
|
||||
- run: tar -xzf "$RUNNER_TEMP/native-linux-x64-gnu.tar.gz"
|
||||
- uses: ./.github/actions/icu-downloads
|
||||
@@ -514,7 +557,8 @@ jobs:
|
||||
# arm64 macOS: same clang/libc the differential + number-formatting
|
||||
# oracles were verified against. Pull requests that change darwin code and
|
||||
# manual runs with macos_suite set to darwin run the darwin suite
|
||||
# (scripts/ci-test-plan.mjs) in three slices; the nightly schedule and
|
||||
# (scripts/ci-test-plan.mjs) in three slices; the post-merge lanes
|
||||
# (postmerge.yml, one run at a time on the newest green main commit) and
|
||||
# other manual runs run the complete suite in ten. The complete suite on
|
||||
# every push needed more macOS runners than the repository has.
|
||||
runs-on: macos-15
|
||||
@@ -534,6 +578,8 @@ jobs:
|
||||
SCRIPTC_CI_SUITE: ${{ (github.event_name != 'schedule' && inputs.macos_suite != 'full') && 'darwin' || 'full' }}
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
@@ -544,7 +590,7 @@ jobs:
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: native-darwin-arm64
|
||||
name: ci-native-darwin-arm64
|
||||
path: ${{ runner.temp }}
|
||||
- run: tar -xzf "$RUNNER_TEMP/native-darwin-arm64.tar.gz"
|
||||
- uses: ./.github/actions/icu-downloads
|
||||
@@ -579,6 +625,8 @@ jobs:
|
||||
SCRIPTC_CI_SUITE: darwin-smoke
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
@@ -608,6 +656,8 @@ jobs:
|
||||
timeout-minutes: 40
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
@@ -629,7 +679,7 @@ jobs:
|
||||
packages/runtime-linux-x64-gnu/runtime-pack.json
|
||||
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: native-linux-x64-gnu
|
||||
name: ci-native-linux-x64-gnu
|
||||
path: ${{ runner.temp }}/native-linux-x64-gnu.tar.gz
|
||||
retention-days: 1
|
||||
|
||||
@@ -658,6 +708,8 @@ jobs:
|
||||
ASAN_OPTIONS: detect_leaks=0
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
@@ -668,7 +720,7 @@ jobs:
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: native-linux-x64-gnu
|
||||
name: ci-native-linux-x64-gnu
|
||||
path: ${{ runner.temp }}
|
||||
- run: tar -xzf "$RUNNER_TEMP/native-linux-x64-gnu.tar.gz"
|
||||
- run: pnpm test tests/harness/effect.test.ts tests/harness/effect4.test.ts
|
||||
@@ -705,6 +757,8 @@ jobs:
|
||||
SCRIPTC_TEST_SHARD: ${{ matrix.shard }}/4
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
@@ -715,7 +769,7 @@ jobs:
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: native-linux-x64-gnu
|
||||
name: ci-native-linux-x64-gnu
|
||||
path: ${{ runner.temp }}
|
||||
- run: tar -xzf "$RUNNER_TEMP/native-linux-x64-gnu.tar.gz"
|
||||
# Every program of the lane loads Node from a libnode pack; the lane
|
||||
@@ -743,6 +797,8 @@ jobs:
|
||||
SCRIPTC_TEST_WORKERS: "1"
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
@@ -775,6 +831,8 @@ jobs:
|
||||
LSAN_OPTIONS: suppressions=${{ github.workspace }}/tests/harness/lsan.supp:print_suppressions=0
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
@@ -785,7 +843,7 @@ jobs:
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: native-linux-x64-gnu
|
||||
name: ci-native-linux-x64-gnu
|
||||
path: ${{ runner.temp }}
|
||||
- run: tar -xzf "$RUNNER_TEMP/native-linux-x64-gnu.tar.gz"
|
||||
- run: pnpm test tests/harness/three.test.ts -t "'nodes' runs statically through LLVM on 'native'"
|
||||
@@ -829,6 +887,8 @@ jobs:
|
||||
ASAN_OPTIONS: detect_leaks=0
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
@@ -840,7 +900,7 @@ jobs:
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: native-linux-x64-gnu
|
||||
name: ci-native-linux-x64-gnu
|
||||
path: ${{ runner.temp }}
|
||||
- run: tar -xzf "$RUNNER_TEMP/native-linux-x64-gnu.tar.gz"
|
||||
- name: Tests (${{ matrix.file }})
|
||||
@@ -857,12 +917,14 @@ jobs:
|
||||
# must build and run as in the default build. It builds its own native
|
||||
# packages, so it does not depend on the other lanes.
|
||||
shape_overlay_native:
|
||||
if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' && inputs.pr == '' }}
|
||||
if: ${{ !inputs.only_lane && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' && inputs.pr == '') }}
|
||||
name: build (Linux x64 native packages, shape overlay)
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 40
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
@@ -884,13 +946,13 @@ jobs:
|
||||
packages/runtime-linux-x64-gnu/runtime-pack.json
|
||||
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: native-linux-x64-gnu-shape-overlay
|
||||
name: ci-native-linux-x64-gnu-shape-overlay
|
||||
path: ${{ runner.temp }}/native-linux-x64-gnu.tar.gz
|
||||
retention-days: 1
|
||||
|
||||
shape_overlay:
|
||||
needs: [shape_overlay_native]
|
||||
if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' && inputs.pr == '' }}
|
||||
if: ${{ !inputs.only_lane && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' && inputs.pr == '') }}
|
||||
name: test (Linux, shape overlay, ${{ matrix.suite }} ${{ matrix.shard }}/8)
|
||||
runs-on: ubuntu-24.04
|
||||
# Longest green shard 2026-11-07..21: 59 minutes (effect).
|
||||
@@ -907,6 +969,8 @@ jobs:
|
||||
SCRIPTC_TEST_SHARD: ${{ matrix.shard }}/8
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
@@ -917,7 +981,7 @@ jobs:
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: native-linux-x64-gnu-shape-overlay
|
||||
name: ci-native-linux-x64-gnu-shape-overlay
|
||||
path: ${{ runner.temp }}
|
||||
- run: tar -xzf "$RUNNER_TEMP/native-linux-x64-gnu.tar.gz"
|
||||
# The npm suites' Node island cases load Node from a libnode pack, and
|
||||
@@ -950,6 +1014,8 @@ jobs:
|
||||
SCRIPTC_SAN: ${{ matrix.flavor == 'san' && '1' || '' }}
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
@@ -1027,6 +1093,8 @@ jobs:
|
||||
timeout-minutes: 90
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
@@ -1076,6 +1144,8 @@ jobs:
|
||||
SCRIPTC_BOOTSTRAP_PHASE: ${{ matrix.phase }}
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
@@ -1145,6 +1215,8 @@ jobs:
|
||||
SCRIPTC_NO_CACHE: "1"
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
@@ -1175,6 +1247,8 @@ jobs:
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
@@ -1209,6 +1283,8 @@ jobs:
|
||||
optimization: [release, dev]
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
@@ -1240,6 +1316,8 @@ jobs:
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
@@ -1251,7 +1329,7 @@ jobs:
|
||||
- uses: ./.github/actions/zig
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: native-linux-x64-gnu
|
||||
name: ci-native-linux-x64-gnu
|
||||
path: ${{ runner.temp }}
|
||||
- run: tar -xzf "$RUNNER_TEMP/native-linux-x64-gnu.tar.gz"
|
||||
- run: pnpm build
|
||||
@@ -1297,6 +1375,8 @@ jobs:
|
||||
timeout-minutes: 25
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
@@ -1309,7 +1389,7 @@ jobs:
|
||||
- uses: ./.github/actions/zig
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: native-linux-x64-gnu
|
||||
name: ci-native-linux-x64-gnu
|
||||
path: ${{ runner.temp }}
|
||||
- run: tar -xzf "$RUNNER_TEMP/native-linux-x64-gnu.tar.gz"
|
||||
- uses: ./.github/actions/native-packages
|
||||
@@ -1348,6 +1428,8 @@ jobs:
|
||||
timeout-minutes: 25
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
@@ -1360,7 +1442,7 @@ jobs:
|
||||
- uses: ./.github/actions/zig
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: native-linux-x64-gnu
|
||||
name: ci-native-linux-x64-gnu
|
||||
path: ${{ runner.temp }}
|
||||
- run: tar -xzf "$RUNNER_TEMP/native-linux-x64-gnu.tar.gz"
|
||||
- uses: ./.github/actions/native-packages
|
||||
@@ -1403,6 +1485,8 @@ jobs:
|
||||
SCRIPTC_TEST_SHARD: ${{ matrix.shard }}/10
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
@@ -1413,7 +1497,7 @@ jobs:
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: native-darwin-arm64
|
||||
name: ci-native-darwin-arm64
|
||||
path: ${{ runner.temp }}
|
||||
- run: tar -xzf "$RUNNER_TEMP/native-darwin-arm64.tar.gz"
|
||||
- run: pnpm build
|
||||
@@ -1449,6 +1533,8 @@ jobs:
|
||||
timeout-minutes: 70
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
@@ -1459,7 +1545,7 @@ jobs:
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: native-darwin-arm64
|
||||
name: ci-native-darwin-arm64
|
||||
path: ${{ runner.temp }}
|
||||
- run: tar -xzf "$RUNNER_TEMP/native-darwin-arm64.tar.gz"
|
||||
- run: pnpm build
|
||||
@@ -1539,10 +1625,16 @@ jobs:
|
||||
if: ${{ needs.validation_scope.outputs.full == 'true' && needs.lanes.outputs.macos == 'true' }}
|
||||
name: test (macOS x64 LLVM artifacts, no clang)
|
||||
runs-on: macos-15-intel
|
||||
# The Node island tests take most of it.
|
||||
timeout-minutes: 45
|
||||
# The Intel runner is slow: the native packages build alone took 26
|
||||
# minutes, and the Node island tests, which take most of the rest, were
|
||||
# still running when the 45-minute limit cancelled the job after 45m13s.
|
||||
# Keep half an hour of slack, as the arm64 contracts job does, so a busy
|
||||
# runner finishes them rather than timing out in them.
|
||||
timeout-minutes: 75
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
@@ -1598,6 +1690,8 @@ jobs:
|
||||
SCRIPTC_TARGET: x86_64-windows-gnu
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
- uses: ./.github/actions/zig
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
@@ -1689,6 +1783,8 @@ jobs:
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
@@ -1763,6 +1859,8 @@ jobs:
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
- uses: ./.github/actions/mobile-runtime-pack
|
||||
with:
|
||||
runtime: ${{ matrix.runtime }}
|
||||
@@ -1785,6 +1883,8 @@ jobs:
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
- uses: ./.github/actions/mobile-runtime-pack
|
||||
with:
|
||||
runtime: ${{ matrix.runtime }}
|
||||
@@ -1932,29 +2032,3 @@ jobs:
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# A post-merge run that passes moves its branch's green tag to its commit: green-main on main, green-canary on
|
||||
# canary. The tag names the newest commit on that branch whose post-merge verification (the full tier on main,
|
||||
# the lighter canary tier on canary) passed; releases, baselines and pre-warmed images may cut from it. The job
|
||||
# writes that one tag and nothing else. It never writes a branch; the token is GitHub Actions' own, and the job
|
||||
# holds `contents: write` only for the tag.
|
||||
green_tag:
|
||||
needs: [test]
|
||||
if: ${{ github.event_name == 'push' && needs.test.result == 'success' }}
|
||||
name: tag green-${{ github.ref_name }}
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 5
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
# A rerun of an older push needs the newer commits to tell whether the tag already names one.
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
- name: Move the green-${{ github.ref_name }} tag
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
SHA: ${{ github.sha }}
|
||||
BRANCH: ${{ github.ref_name }}
|
||||
run: node scripts/ci/green-tag.mjs "$SHA" --branch "$BRANCH"
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
name: Tag green-main
|
||||
|
||||
# A passing CI push to main moves the green-main tag to that commit (scripts/ci/green-main.mjs): the newest main
|
||||
# commit whose full verification passed, which releases, baselines and pre-warmed images may cut from.
|
||||
#
|
||||
# It lives beside CI rather than in it because CI is a reusable workflow the post-merge lanes call read-only: for a
|
||||
# reusable call, the caller job's permissions are the ceiling for the entire called graph, and GitHub validates
|
||||
# every job it contains against that ceiling at startup, whether or not the job runs. A contents: write job inside
|
||||
# ci.yml would make every read-only call invalid.
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: [CI]
|
||||
types: [completed]
|
||||
branches: [main]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
# One tag move at a time: a rerun of an older push must not race a newer one, and the script only moves the tag
|
||||
# forward.
|
||||
concurrency:
|
||||
group: green-main
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
green_main:
|
||||
# A push's CI run moves the tag; a pull request's or merge queue's never does, and a failing run leaves it.
|
||||
if: >-
|
||||
github.event.workflow_run.event == 'push' &&
|
||||
github.event.workflow_run.conclusion == 'success'
|
||||
name: tag green-main
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 5
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
# A rerun of an older push needs the newer commits to tell whether the tag already names one.
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
- name: Move the green-main tag
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
SHA: ${{ github.event.workflow_run.head_sha }}
|
||||
run: node scripts/ci/green-main.mjs "$SHA"
|
||||
@@ -0,0 +1,48 @@
|
||||
name: Tag green-canary
|
||||
|
||||
# A passing CI push to canary moves the green-canary tag to that commit (scripts/ci/green-tag.mjs): the newest
|
||||
# canary commit whose post-merge verification passed, which releases, baselines and pre-warmed images may cut from.
|
||||
#
|
||||
# It lives beside CI rather than in it because CI is a reusable workflow the post-merge lanes (postmerge.yml) call
|
||||
# read-only: for a reusable call, the caller job's permissions are the ceiling for the entire called graph, and
|
||||
# GitHub validates every job it contains against that ceiling at startup, whether or not the job runs. A
|
||||
# contents: write job inside ci.yml would make every read-only call invalid. green-main.yml moves main's tag the
|
||||
# same way.
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: [CI]
|
||||
types: [completed]
|
||||
branches: [canary]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
# One tag move at a time: a rerun of an older push must not race a newer one, and the script only moves the tag
|
||||
# forward.
|
||||
concurrency:
|
||||
group: green-canary
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
green_canary:
|
||||
# A push's CI run moves the tag; a pull request's or merge queue's never does, and a failing run leaves it.
|
||||
if: >-
|
||||
github.event.workflow_run.event == 'push' &&
|
||||
github.event.workflow_run.conclusion == 'success'
|
||||
name: tag green-canary
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 5
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
# A rerun of an older push needs the newer commits to tell whether the tag already names one.
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
- name: Move the green-canary tag
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
SHA: ${{ github.event.workflow_run.head_sha }}
|
||||
run: node scripts/ci/green-tag.mjs "$SHA" --branch canary
|
||||
@@ -22,6 +22,11 @@ name: libnode packs
|
||||
on:
|
||||
workflow_dispatch:
|
||||
workflow_call:
|
||||
inputs:
|
||||
ref:
|
||||
description: The commit to build. Empty builds the caller's commit.
|
||||
type: string
|
||||
default: ""
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
@@ -76,6 +81,8 @@ jobs:
|
||||
SCRIPTC_LIBNODE_TOOLCHAIN: ${{ matrix.toolchain }}
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
|
||||
@@ -0,0 +1,206 @@
|
||||
name: Post-merge lanes
|
||||
|
||||
# The lanes the merge queue does not run, on the newest green main commit: the complete macOS suite (ci.yml's macos
|
||||
# lane) and the release rehearsal (release-dry-run.yml). The queue's required check runs every other lane before a
|
||||
# batch lands, so main's own push run mostly confirms it; a macOS-only or release-only break used to wait for the
|
||||
# nightly sweep, and once went unseen for four days.
|
||||
#
|
||||
# A run starts whenever a CI push run on main succeeds, and every three hours in case none does. It tests the
|
||||
# newest commit whose CI push run is green, and does nothing when the previous run already tested that commit.
|
||||
#
|
||||
# When a lane job turns red (it was green at its last result), the run bisects the batches that landed on main
|
||||
# since that job's last green commit (each push to main: one merge queue merge) and then the commits of the first
|
||||
# bad batch, on one runner per red job, and names the first bad commit in the job summary and in the
|
||||
# postmerge-blame artifact (scripts/postmerge.mjs). It opens no issue and no pull request.
|
||||
#
|
||||
# Runner cost: one run at a time, and while it runs only the newest waiting run is kept (GitHub cancels the older
|
||||
# pending one when another queues). A bisection probes at most six commits (the red one first), one red job per
|
||||
# recipe and three per run; a job that was already red at its previous result is not bisected again.
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: [CI]
|
||||
types: [completed]
|
||||
branches: [main]
|
||||
schedule:
|
||||
- cron: "23 */3 * * *"
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
sha:
|
||||
description: Test this commit instead of the newest green main commit (it is tested even when tested before)
|
||||
type: string
|
||||
default: ""
|
||||
|
||||
concurrency:
|
||||
# Not cancel-in-progress: a running run, and its bisection, finishes. Of the runs that queue meanwhile, GitHub
|
||||
# keeps only the newest.
|
||||
group: postmerge
|
||||
cancel-in-progress: false
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
pick:
|
||||
name: Pick the newest green main commit
|
||||
# A workflow_run starts on every CI run that completes on main; only a green push run is news.
|
||||
if: >-
|
||||
github.event_name != 'workflow_run' ||
|
||||
(github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push')
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 10
|
||||
permissions:
|
||||
contents: read
|
||||
actions: read
|
||||
outputs:
|
||||
sha: ${{ steps.pick.outputs.sha }}
|
||||
skip: ${{ steps.pick.outputs.skip }}
|
||||
steps:
|
||||
# The whole history: a commit counts only when it is on main.
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- id: pick
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
POSTMERGE_SHA: ${{ inputs.sha }}
|
||||
run: node scripts/postmerge.mjs pick
|
||||
|
||||
macos:
|
||||
name: macos
|
||||
needs: pick
|
||||
if: ${{ needs.pick.outputs.skip == 'false' }}
|
||||
uses: ./.github/workflows/ci.yml
|
||||
# This job's permissions are the ceiling for the whole called graph, and GitHub validates every job in it
|
||||
# whether or not the job runs: the lane selector reads pull requests, and CI asks for nothing more.
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: read
|
||||
with:
|
||||
ref: ${{ needs.pick.outputs.sha }}
|
||||
only_lane: macos
|
||||
macos_suite: full
|
||||
|
||||
rehearsal:
|
||||
name: rehearsal
|
||||
needs: pick
|
||||
if: ${{ needs.pick.outputs.skip == 'false' }}
|
||||
uses: ./.github/workflows/release-dry-run.yml
|
||||
permissions:
|
||||
contents: read
|
||||
with:
|
||||
ref: ${{ needs.pick.outputs.sha }}
|
||||
|
||||
# Records this run's lane results (the postmerge-state artifact that later runs read) and plans a bisection for
|
||||
# each job that turned red.
|
||||
plan:
|
||||
name: Plan bisections
|
||||
needs: [pick, macos, rehearsal]
|
||||
if: ${{ !cancelled() && needs.pick.outputs.skip == 'false' }}
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 15
|
||||
permissions:
|
||||
contents: read
|
||||
actions: read
|
||||
outputs:
|
||||
tasks: ${{ steps.plan.outputs.tasks }}
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- id: plan
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
SHA: ${{ needs.pick.outputs.sha }}
|
||||
run: node scripts/postmerge.mjs plan --sha "$SHA" --state "$RUNNER_TEMP/postmerge-state"
|
||||
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: postmerge-state
|
||||
path: ${{ runner.temp }}/postmerge-state
|
||||
retention-days: 90
|
||||
if-no-files-found: error
|
||||
|
||||
bisect:
|
||||
name: Bisect (${{ matrix.job }})
|
||||
needs: [pick, plan]
|
||||
if: ${{ !cancelled() && needs.plan.outputs.tasks != '' && needs.plan.outputs.tasks != '[]' }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include: ${{ fromJSON(needs.plan.outputs.tasks) }}
|
||||
runs-on: ${{ matrix.runner }}
|
||||
# Six probes of the slowest recipe do not fit; the script stops probing after POSTMERGE_MINUTES and reports the
|
||||
# range it narrowed the change to.
|
||||
timeout-minutes: 340
|
||||
permissions:
|
||||
contents: read
|
||||
steps:
|
||||
# This commit's script and toolchain set-up; the script checks out each probed commit.
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version-file: .node-version
|
||||
- name: Install macOS LLVM
|
||||
if: matrix.setup == 'macos'
|
||||
run: brew install llvm@22
|
||||
- uses: ./.github/actions/release-toolchain
|
||||
if: matrix.setup == 'release-toolchain'
|
||||
with:
|
||||
platform: ${{ matrix.platform }}
|
||||
llvm-asset: ${{ matrix.llvm_asset }}
|
||||
use-zig: ${{ matrix.use_zig }}
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: postmerge-state
|
||||
path: ${{ runner.temp }}/postmerge-state
|
||||
# The script parses each probed commit's workflow with this checkout's js-yaml.
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- name: Bisect
|
||||
env:
|
||||
KEY: ${{ matrix.key }}
|
||||
POSTMERGE_MINUTES: "300"
|
||||
run: >-
|
||||
node scripts/postmerge.mjs bisect --task "$KEY"
|
||||
--tasks "$RUNNER_TEMP/postmerge-state/tasks.json" --out "$RUNNER_TEMP/bisect/$KEY"
|
||||
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
if: always()
|
||||
with:
|
||||
name: postmerge-bisect-${{ matrix.key }}
|
||||
path: ${{ runner.temp }}/bisect/${{ matrix.key }}
|
||||
retention-days: 30
|
||||
if-no-files-found: warn
|
||||
|
||||
# The job summary and the postmerge-blame artifact: the red jobs, and for each the first bad commit (or the range
|
||||
# it was narrowed to, or why it was not bisected).
|
||||
report:
|
||||
name: Report
|
||||
needs: [pick, plan, bisect]
|
||||
if: ${{ !cancelled() && needs.plan.result == 'success' }}
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 10
|
||||
permissions:
|
||||
contents: read
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: postmerge-state
|
||||
path: ${{ runner.temp }}/postmerge-state
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
pattern: postmerge-bisect-*
|
||||
path: ${{ runner.temp }}/postmerge/bisect
|
||||
- run: node scripts/postmerge.mjs report --dir "$RUNNER_TEMP/postmerge/bisect" --state "$RUNNER_TEMP/postmerge-state"
|
||||
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: postmerge-blame
|
||||
path: ${{ runner.temp }}/postmerge/postmerge-blame
|
||||
retention-days: 90
|
||||
if-no-files-found: error
|
||||
@@ -8,13 +8,14 @@ name: Release build
|
||||
# Two workflows call it, so the release and its rehearsal build exactly the
|
||||
# same way:
|
||||
# - release.yml, before it publishes;
|
||||
# - release-dry-run.yml, nightly on main and on pull requests that prepare a
|
||||
# release or change how it builds, so a package that no longer builds shows
|
||||
# up before a release run instead of in it.
|
||||
# - release-dry-run.yml, on the newest green main commit (postmerge.yml) and
|
||||
# on pull requests that prepare a release or change how it builds, so a
|
||||
# package that no longer builds shows up before a release run instead of in
|
||||
# it.
|
||||
#
|
||||
# Only the native CLIs use the compiler profile. The helpers and runtime packs
|
||||
# (packs), the mobile packs, and the caller's libnode packs build while
|
||||
# cli-profile collects it, and each platform's CLI job (cli) starts from its
|
||||
# cli-layout and cli-profile collect it, and each platform's CLI job (cli) starts from its
|
||||
# packs once the profile is ready, so the profile's hour and a half is no
|
||||
# longer added to every platform's build.
|
||||
|
||||
@@ -23,11 +24,15 @@ on:
|
||||
inputs:
|
||||
collect-profile:
|
||||
description: >-
|
||||
Collect the native compiler profile and layout on this commit (cli-profile, about 90 minutes) and build the
|
||||
Collect the native compiler profile and layout on this commit (two jobs, about 45 and 100 minutes) and build the
|
||||
native CLIs with them. Without it they build with the committed profile and layout, which is also what a
|
||||
release build falls back to when the collection fails.
|
||||
type: boolean
|
||||
default: false
|
||||
ref:
|
||||
description: The commit to build. Empty builds the caller's commit; every checkout reads it.
|
||||
type: string
|
||||
default: ""
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
@@ -43,25 +48,32 @@ jobs:
|
||||
platforms: ${{ steps.platforms.outputs.platforms }}
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
- id: platforms
|
||||
run: echo "platforms=$(jq -c . .github/release-platforms.json)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# Collects the native compiler's function layout and profile on this commit
|
||||
# (scripts/refresh-cli-layout.mjs, scripts/refresh-cli-profile.mjs), so every
|
||||
# platform's CLI build optimizes and lays out the code it compiles. The
|
||||
# committed ones fall behind main within a day or two. If this job fails,
|
||||
# the CLI builds use the committed profile and layout.
|
||||
cli-profile:
|
||||
name: Collect the native compiler profile
|
||||
# Collects the native compiler's function layout on this commit
|
||||
# (scripts/refresh-cli-layout.mjs), then its profile with that layout
|
||||
# (scripts/refresh-cli-profile.mjs), so every platform's CLI build optimizes
|
||||
# and lays out the code it compiles. The committed ones fall behind main
|
||||
# within a day or two. Three instrumented compiler builds and their training
|
||||
# do not fit one job's 120-minute limit, so the layout is collected here and
|
||||
# the profile in the job below, which takes the layout through an artifact.
|
||||
# If either job fails, the CLI builds use the committed profile and layout.
|
||||
cli-layout:
|
||||
name: Collect the native compiler layout
|
||||
if: inputs.collect-profile
|
||||
runs-on: ubuntu-24.04
|
||||
# The layout and the profile's two phases each build an instrumented compiler.
|
||||
timeout-minutes: 120
|
||||
# One instrumented build and its training: about 45 minutes.
|
||||
timeout-minutes: 60
|
||||
continue-on-error: true
|
||||
permissions:
|
||||
contents: read
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
@@ -81,14 +93,62 @@ jobs:
|
||||
git clone --quiet --depth 1 https://github.com/vercel-labs/tsc-ts "$RUNNER_TEMP/tsc-ts"
|
||||
echo "tsc-ts $(git -C "$RUNNER_TEMP/tsc-ts" rev-parse HEAD)"
|
||||
npm ci --prefix "$RUNNER_TEMP/tsc-ts"
|
||||
# The layout comes first: the profile matches the functions of builds
|
||||
# with the layout its instrumented compiler was built with, so the
|
||||
# profile is collected with a second instrumented compiler built with
|
||||
# this layout.
|
||||
- name: Collect the function layout
|
||||
run: >-
|
||||
node scripts/refresh-cli-layout.mjs --jobs 4
|
||||
--output "$RUNNER_TEMP/cli-profile/cli.layout.gz" --work "$RUNNER_TEMP/cli-layout-work"
|
||||
--output "$RUNNER_TEMP/cli-layout/cli.layout.gz" --work "$RUNNER_TEMP/cli-layout-work"
|
||||
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: cli-layout
|
||||
path: ${{ runner.temp }}/cli-layout/cli.layout.gz
|
||||
retention-days: 7
|
||||
if-no-files-found: error
|
||||
|
||||
# The profile matches the functions of builds with the layout its
|
||||
# instrumented compiler was built with, so it is collected with a second
|
||||
# instrumented compiler built with the layout the job above collects.
|
||||
cli-profile:
|
||||
name: Collect the native compiler profile
|
||||
needs: cli-layout
|
||||
if: ${{ inputs.collect-profile && !cancelled() }}
|
||||
runs-on: ubuntu-24.04
|
||||
# The instrumented build, the first phase's training, the context-sensitive
|
||||
# instrumented build and its training: about 100 minutes.
|
||||
timeout-minutes: 150
|
||||
continue-on-error: true
|
||||
permissions:
|
||||
contents: read
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version: "24"
|
||||
cache: pnpm
|
||||
- uses: ./.github/actions/llvm-linux
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- uses: ./.github/actions/zig
|
||||
- uses: ./.github/actions/native-packages
|
||||
with:
|
||||
target: linux-x64-gnu
|
||||
- run: pnpm --filter @scriptc/compiler --filter scriptc build
|
||||
- name: Check out tsc-ts
|
||||
run: |
|
||||
git clone --quiet --depth 1 https://github.com/vercel-labs/tsc-ts "$RUNNER_TEMP/tsc-ts"
|
||||
echo "tsc-ts $(git -C "$RUNNER_TEMP/tsc-ts" rev-parse HEAD)"
|
||||
npm ci --prefix "$RUNNER_TEMP/tsc-ts"
|
||||
# A layout that could not be collected leaves this step empty and the
|
||||
# profile step fails, which the job's continue-on-error tolerates.
|
||||
- name: Take the function layout
|
||||
continue-on-error: true
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: cli-layout
|
||||
path: ${{ runner.temp }}/cli-profile
|
||||
- name: Collect the profile
|
||||
env:
|
||||
SCRIPTC_NATIVE_LAYOUT: ${{ runner.temp }}/cli-profile/cli.layout.gz
|
||||
@@ -119,6 +179,8 @@ jobs:
|
||||
timeout-minutes: 90
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
@@ -222,6 +284,8 @@ jobs:
|
||||
timeout-minutes: 90
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
@@ -270,11 +334,11 @@ jobs:
|
||||
run: |
|
||||
if [ -n "$COLLECTED" ]; then
|
||||
echo "SCRIPTC_NATIVE_PROFILE_USE=$COLLECTED" >> "$GITHUB_ENV"
|
||||
echo "The native CLI builds with the profile collected on $GITHUB_SHA"
|
||||
echo "The native CLI builds with the profile collected on $(git rev-parse HEAD)"
|
||||
layout="$(dirname "$COLLECTED")/cli.layout.gz"
|
||||
if [ -f "$layout" ]; then
|
||||
echo "SCRIPTC_NATIVE_LAYOUT=$layout" >> "$GITHUB_ENV"
|
||||
echo "The native CLI builds with the function layout collected on $GITHUB_SHA"
|
||||
echo "The native CLI builds with the function layout collected on $(git rev-parse HEAD)"
|
||||
fi
|
||||
elif [ "$COLLECTED_PROFILE" = true ]; then
|
||||
echo "::warning::No profile was collected on this commit; the native CLI builds with the committed profile"
|
||||
@@ -332,6 +396,8 @@ jobs:
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
- uses: ./.github/actions/mobile-runtime-pack
|
||||
with:
|
||||
runtime: ${{ matrix.runtime }}
|
||||
|
||||
@@ -6,16 +6,23 @@ name: Release dry run
|
||||
# the packages the way the publish job does, checks their versions, packs
|
||||
# each one, and packages the standalone compilers the GitHub release
|
||||
# attaches. A package that no longer builds or packs on one platform then
|
||||
# fails here, nightly or on the pull request that caused it, and not in the
|
||||
# release run.
|
||||
# fails here, on the newest green main commit (the post-merge lanes,
|
||||
# postmerge.yml, call this workflow) or on the pull request that caused it,
|
||||
# and not in the release run.
|
||||
#
|
||||
# The native CLIs build with the committed profile and layout (release.yml's
|
||||
# cli-profile job collects a fresh one for about two hours; the dry run does
|
||||
# not need it), which is what a release falls back to when that job fails.
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "41 5 * * *"
|
||||
# The post-merge lanes call it with the commit to rehearse; every checkout
|
||||
# reads ref, so the run builds that commit and not the caller's.
|
||||
workflow_call:
|
||||
inputs:
|
||||
ref:
|
||||
description: The commit to rehearse. Empty rehearses the caller's commit.
|
||||
type: string
|
||||
default: ""
|
||||
workflow_dispatch:
|
||||
pull_request:
|
||||
# A release-prep pull request bumps packages/cli/package.json; the other
|
||||
@@ -42,7 +49,9 @@ on:
|
||||
- "scripts/smoke-native-install.mjs"
|
||||
|
||||
concurrency:
|
||||
group: release-dry-run-${{ github.event.pull_request.number || github.ref }}
|
||||
# A post-merge call runs in a group of its own run, so a manual dry run on
|
||||
# main does not cancel it.
|
||||
group: release-dry-run-${{ inputs.ref && format('postmerge-{0}', github.run_id) || github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
@@ -52,10 +61,14 @@ jobs:
|
||||
build:
|
||||
name: Build
|
||||
uses: ./.github/workflows/release-build.yml
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
|
||||
libnode:
|
||||
name: libnode
|
||||
uses: ./.github/workflows/libnode-packs.yml
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
|
||||
# The publish job's preparation, up to the upload: the same assembly,
|
||||
# build and version check, then a pack of every package it publishes.
|
||||
@@ -66,6 +79,8 @@ jobs:
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
pattern: native-*
|
||||
|
||||
+42
-1
@@ -6,13 +6,54 @@ All notable changes to scriptc will be documented in this file.
|
||||
|
||||
<!-- release:start -->
|
||||
|
||||
## 0.4.17
|
||||
|
||||
### Highlights
|
||||
|
||||
- **Node.js parity:**
|
||||
- **http and http2:** HTTP/2 streams send trailers through `sendTrailers` and the `'trailers'` and `'wantTrailers'` paths, send informational responses through `additionalHeaders`, `writeContinue`, `writeEarlyHints` and `writeInformation`, answer the client's `'headers'` and `'continue'` events, and keep `sentHeaders`, `sentInfoHeaders`, `sentTrailers` and `state` readable for the stream's lifetime; `respondWithFile` and `respondWithFD` send files with `statCheck`, `onError`, range and blocked-response handling, and the compatibility request and stream state follows Node's `endAfterHeaders`, `authority` and `statusMessage` behavior. Sessions answer `session.encrypted` and `session.alpnProtocol`, responses take `sendDate`, servers dispose through `[Symbol.asyncDispose]()`, session failures report Node's `ERR_HTTP2_ERROR`, and `Expect: 100-continue` requests route through `checkContinue`. `writeHead(status, headers)` sends its headers without adding them to `getHeaders`, `getHeader`, or `getHeaderNames`, a CONNECT or upgrade response takes its socket out of the agent before the listener runs, a request waiting for a free slot emits `'socket'` when the agent assigns it one, and a pooled socket whose peer closed is not reused. `server.on('connect')` and `server.on('upgrade')` listeners written in plain JavaScript compile with Node's request, socket and head arguments, and `http.setGlobalProxyFromEnv` proxies plain HTTP requests with Node's `NO_PROXY` routing, credentials, variable precedence and `NODE_USE_ENV_PROXY` switch, including CONNECT tunnels for HTTPS targets.
|
||||
- **stream:** `stream.compose` and `stream.pipeline` take a `TransformStream` or any readable/writable pair as a stage, `stream/consumers` reads web streams and constructor-function streams, `Readable.from` takes its `encoding` option, `Readable.toWeb` and `Duplex.toWeb` take `type: 'bytes'` and `readableType` so a BYOB reader reads into its own view and a chunk larger than that view keeps its remainder for the next read, `Writable.toWeb` accepts any writable-like object with Node's cancellation and premature-close behavior, and queued reads on a byte stream are served one pull at a time instead of recursing on the same stack.
|
||||
- **tls:** `tlsSocket.getTLSTicket()` answers the ticket the client received, a `TLSSocket` emits `'keylog'` and `'session'` events, `tls.createServer` and `https.createServer` refuse `ALPNCallback` together with `ALPNProtocols` with `ERR_TLS_ALPN_CALLBACK_WITH_PROTOCOLS`, and a `TLSSocket` refuses a `secureContext` that is not a context with `ERR_TLS_INVALID_CONTEXT`.
|
||||
- **crypto:** `crypto.subtle.wrapKey` and `unwrapKey` take asymmetric keys, including RSA-OAEP wrapping and unwrapping, `crypto.setFips(true)` succeeds with `getFips()` answering 1 and later fetches failing with `ERR_OSSL_EVP_UNSUPPORTED`, and the remaining unsupported key types and WebCrypto algorithms refuse with documented errors.
|
||||
- **child_process and cluster:** `spawnSync(...).pid` answers the child's process id, or 0 when the spawn failed, `child.stdio` is Node's per-child array holding the same stream objects as `child.stdin`, `stdout` and `stderr` with `null` at unpiped slots, `spawn`, `spawnSync` and the callback `execFile` accept `shell: true` with separate arguments, an `exec` or `execFile` call stops through its `signal`, keeps the output it produced, and hands the same `AbortError` to its callback and listeners, a bridged child stdin write answers by the writer's own result and the child's `'close'` waits for its bridged stdout and stderr, and `node:cluster` runs with forked workers and IPC, including `setupPrimary` credentials, worker messages and send outcomes.
|
||||
- **net, dgram and perf_hooks:** `new net.Socket()` builds an idle socket with Node's address, pending and stream flags, `socket.connect(port[, host][, listener])` dials it and `allowHalfOpen` keeps the write half open after the peer ends, a dgram resolver's own error reaches the callback, and the perf_hooks histogram bucket helpers answer Node's bucket maps and error codes while resource-timing fields the timing info omits read as `undefined` and drop out of `toJSON`.
|
||||
- **events, timers and Windows:** a `'newListener'` or `'removeListener'` listener receives a symbol-keyed event's name as the symbol itself, the check phase runs before the next timers phase when a poll callback has queued an immediate, `test(fn)`, `test("", fn)`, `describe(fn)` and `suite(fn)` take their name from the function at run time, or `<anonymous>`, as Node does, `node:test` mocks without an implementation compile, and `performance.now()` and `process.uptime()` on Windows read the high-resolution counter instead of a clock that moves in 15.6 ms steps.
|
||||
- **diagnostics_channel:** a console method held as a separate function value publishes on its `console.*` channel, and a channel's bound stores are snapshotted before its transforms run.
|
||||
- **the environment:** every runtime read of the process environment goes through the lock, so a `SHARE_ENV` worker writing `process.env` can no longer crash a concurrent read.
|
||||
- **TypeScript parity:**
|
||||
- A React and Ink terminal app's compile gaps close: `execFileSync` with a shell, a `process.env` value read through an import, `Reflect.construct` with `new.target` in a Node island, `process` and `statfs` reads, sloppy-mode `arguments` passed to `apply`, and `process.stdin.ref` and `unref` compile and match Node.
|
||||
- React's module shapes compile statically: a JSX automatic runtime loaded from an npm package, React's default export aliasing and re-exports, a conditional CommonJS export alias, exports added after `module.exports`, and react-reconciler's CommonJS function export no longer fall back to Node.
|
||||
- An array literal that spreads a variable-length array into a destructuring tuple context compiles, and a closure created above a destructuring declaration can capture its targets with the same temporal dead zone check as a plain `const`.
|
||||
- A callback written as a bare expression where a `void` return is expected, such as `pipeline(..., (err) => err ? reject(err) : resolve())`, compiles and discards its value, `void e` used as a value evaluates `e` for its effects and answers `undefined`, and a JavaScript function inferred to return `never` that still returns an expression answers a checked-dynamic value instead of compiling as divergent.
|
||||
- A member call through a generic receiver whose method has no compiled body dispatches at run time instead of being deferred, so a call such as `querySelector` on an element in a UI library runs instead of throwing.
|
||||
- **CommonJS and islands:**
|
||||
- A CommonJS import binds to the export of the module it names, so a declaration file that re-exports a name from another module no longer points the import at that other module's value, which fixes a startup crash in React 19 apps when `@types/react` is installed deduplicated.
|
||||
- A literal `import("ms")` refused with SC2013 now names the runtime package (`ms`, or `@scope/name`) and hints that a static import joins the graph or that the package can run in a Node island, and a coverage report's island header says the build needs the libnode pack for its target.
|
||||
- **Faster builds:**
|
||||
- Long runs of class branches in the dynamic static-field and property helpers become one switch on the class key, or chunk functions called in order: cold builds of large React and three.js apps are 13% to 23% faster with 3% to 4% smaller binaries, hello world is 1.7% faster, ui-settings is 1.3% faster with 1.1% to 1.6% smaller executables, and a five-page WPT program's static-field helper frame drops from 110,136 to 1,112 bytes, with byte-identical output.
|
||||
- The class-case table that selected a property helper's class now covers every generated class table, so cold builds are 1.40% faster for hello world and 1.35% for ui-settings.
|
||||
- Emission writes the module to a file and the frontend process exits before code generation, so the program text is not held during codegen: peak memory falls 31% for a dev build and 18% for a release build of the counter app, with identical executables.
|
||||
- The finish-module passes do less work in devirtualization, cycle checks and jsval promotion: the counter app's finish-module phase is 16.8% faster and its total lowering 5.2% faster, with byte-identical IR.
|
||||
- The checker memoizes immediate aliases and module export lists, so the effect/metric-counter workload drops from 87,608 to 914 raw checker queries and lowers 10.2% faster, and a held-constructor diagnostic is marked only where lowering meets a constructor, which makes ui-settings lowering 1.75 times faster, both with byte-identical IR.
|
||||
- Dynamic-class dispatch helpers are named from their dispatch key instead of a counter, so names stay stable across edits: ui-settings cold builds 2.5% faster with a 16 KB smaller binary, and an in-place lifted-helper write is carried in the unit's record, so journal-serial lowering keeps the change instead of failing.
|
||||
|
||||
### Fixes
|
||||
|
||||
- A build whose executable was already written no longer fails when OneDrive or another sync client still holds a handle on the scratch directory: the staging directory removal retries on `EPERM` and `EBUSY` and leaves a directory that still cannot be removed instead of failing a successful build.
|
||||
- A dev library build keeps its TypeScript sources through the emitter, so debuggers and stack frames name the TypeScript lines.
|
||||
- A program with HTTP/2 or TLS event listeners and a net socket `'data'` listener no longer fails to compile with a duplicate function definition.
|
||||
- A large string or JSON builder past 4 MiB no longer crashes on older kernels when its fixed move fails, and a region held only by an array's metadata is collected.
|
||||
- An async fiber gets the main thread's 8 MiB stack budget on 64-bit native targets (WASI and 32-bit targets keep 512 KiB), so a nine-module top-level-await program with deep frames starts instead of throwing `RangeError`.
|
||||
- Performance warnings are quieter on ordinary code: SC6001 no longer reports a record copy passed to a parameter that is only read, SC6014 no longer reports plain same-shape spreads and clones, and SC6101 prints one line by default with the function list kept in the JSON diagnostic and `coverage --explain-dynamic`.
|
||||
- A release publishes every package under `next`, installs it from npm and runs a smoke test on Linux x64 and arm64, macOS arm64 and x64, and Windows x64 before moving `latest`, and never reuses a version whose publish failed partway, so a retried release cannot mix runtime packs from an earlier attempt.
|
||||
<!-- release:end -->
|
||||
|
||||
## 0.4.16
|
||||
|
||||
### Highlights
|
||||
|
||||
- **Fixes:**
|
||||
- The npm runtime and LLVM helper packages now match the CLI. In 0.4.15 they were stale: an earlier, failed release attempt had published them for an older runtime ABI, so every 0.4.15 install rejected its runtime pack with SC3003 ("installed runtime-pack.json is malformed or incompatible") on every platform (#4011). The release now publishes a version npm already has only when npm holds the same files.
|
||||
<!-- release:end -->
|
||||
|
||||
## 0.4.15
|
||||
|
||||
|
||||
+3
-3
@@ -11,13 +11,13 @@ To prepare a release:
|
||||
5. Remove the `<!-- release:start -->` and `<!-- release:end -->` markers from the previous release entry; only the latest release should have markers
|
||||
6. With Zig on `PATH`, run `SCRIPTC_CROSS=1 pnpm exec vitest run tests/harness/library-cross.test.ts` and require the cross-target library conformance lane to pass
|
||||
7. Refresh the runtime profile on a quiet Linux x64 host: `node scripts/refresh-runtime-profile.mjs --tsc-ts <tsc-ts checkout> --project <TypeORM>:tsconfig.bench.json --project <T3 server>:tsconfig.bench.json --project <VS Code>/src:tsconfig.bench.json`, and include the new `packages/runtime-pack-common/profiles/linux-x64-gnu.profdata.gz` (see the runtime profile paragraph below)
|
||||
8. Commit to `canary` and open the `canary` -> `main` release pull request; `main` moves only when that pull request merges, and the release runs on `main`
|
||||
8. Commit to `main`
|
||||
|
||||
CI (`.github/workflows/release.yml`) compares the version in `packages/cli/package.json` to what `scriptc` has on npm. If it differs, it builds platform packages on matching macOS, Linux, and Windows runners, verifies the version spine, and publishes the runtime, helper, compiler, and CLI packages in dependency order. After the publish succeeds, a separate job creates the git tag `v<version>` and the GitHub release with the marked changelog entry as its body, and attaches `surface-manifest.json` — the machine-readable listing of the surface the static tier compiles at that version (stable per-entry ids, so two releases diff mechanically; see `packages/compiler/src/coverage/surface-manifest.ts` for the schema). The job regenerates the manifest from the tree and fails on any byte difference from the committed file before attaching, so the asset is always the manifest of the code being released. The same file ships inside the `@scriptc/compiler` package as `@scriptc/compiler/surface-manifest.json`.
|
||||
|
||||
The release job builds each pinned LLVM helper, precompiled runtime pack, and native CLI on its matching host, through `.github/workflows/release-build.yml`. The release dry run (`.github/workflows/release-dry-run.yml`) calls the same workflow nightly on canary and on pull requests that bump `packages/cli/package.json` or change how the release builds; it restores the libnode packs, assembles and packs every package as the publish job does, and packages the standalone compilers, but uploads nothing. A green dry run on the release commit means the release run's builds will pass; run it by hand (Actions → Release dry run) on a release-prep branch before merging it. Each LLVM helper package also carries the comptime evaluator, `bin/scriptc-comptime`, built with the helper. The native CLI package bundles its TypeScript checker and declarations, and depends on its platform's LLVM helper and runtime pack packages at the same version; the compiler resolves them beside itself. The standalone archives bundle the helper and runtime pack too. npm postinstall installs the matching native executable; Node is needed for npm installation but not native compilation or execution. The user's toolchain performs the final platform link. Sanitized builds also use it to instrument program LLVM and compile the C runtime. Platform packages publish ahead of `@scriptc/compiler` and `scriptc`. The GitHub release attaches standalone compiler archives, their SHA-256 checksums, and the surface manifest after npm publication succeeds.
|
||||
The release job builds each pinned LLVM helper, precompiled runtime pack, and native CLI on its matching host, through `.github/workflows/release-build.yml`. The release dry run (`.github/workflows/release-dry-run.yml`) calls the same workflow on the newest green main commit (the post-merge lanes, `.github/workflows/postmerge.yml`) and on pull requests that bump `packages/cli/package.json` or change how the release builds; it restores the libnode packs, assembles and packs every package as the publish job does, and packages the standalone compilers, but uploads nothing. A green dry run on the release commit means the release run's builds will pass; run it by hand (Actions → Release dry run) on a release-prep branch before merging it. Each LLVM helper package also carries the comptime evaluator, `bin/scriptc-comptime`, built with the helper. The native CLI package bundles its TypeScript checker and declarations, and depends on its platform's LLVM helper and runtime pack packages at the same version; the compiler resolves them beside itself. The standalone archives bundle the helper and runtime pack too. npm postinstall installs the matching native executable; Node is needed for npm installation but not native compilation or execution. The user's toolchain performs the final platform link. Sanitized builds also use it to instrument program LLVM and compile the C runtime. Platform packages publish ahead of `@scriptc/compiler` and `scriptc`. The GitHub release attaches standalone compiler archives, their SHA-256 checksums, and the surface manifest after npm publication succeeds.
|
||||
|
||||
Release builds of the native CLI optimize the compiler with a profile collected on the release commit. The `cli-profile` job runs `node scripts/refresh-cli-profile.mjs` on Linux x64, which builds an instrumented compiler, runs it on tsc-ts, a slice of the corpus, and the runtime benchmark workloads, and writes the merged profile. The profile keeps the functions that training never ran, with zero counts, so the CLI builds optimize them as cold code and place them after the code that ran. Every platform's CLI build uses that profile (`SCRIPTC_NATIVE_PROFILE_USE`), and the GitHub release attaches it as `scriptc-<version>-cli.profdata.gz`. Only the CLI builds wait for the profile: each platform's LLVM helper and runtime pack build while it is collected (release-build.yml's `packs` jobs, platforms listed in `.github/release-platforms.json`), and its CLI job starts from them once the profile is ready. Code the profile does not describe, or describes from older compiler sources, is optimized as without a profile. When the profile job fails, the CLI builds use the committed profile `packages/compiler/native/cli.profdata.gz`, which local and CI builds of the native compiler also use. The nightly `profile-refresh` workflow (`profile-refresh.yml`) refreshes the committed profile from canary: it collects one with the committed layout, builds the native compiler with it to report the match, and opens a pull request into canary that replaces `packages/compiler/native/cli.profdata.gz`. To refresh it by hand, run `node scripts/refresh-cli-profile.mjs --tsc-ts <tsc-ts checkout>` on a quiet Linux x64 host and commit the new profile on its own. CI's `native_profile` job builds the native compiler with the committed layout and profile and reports the share of the profiled functions that match, with a warning below 95%; a stale profile does not fail it. It fails when the profile cannot be judged: missing, unreadable, or describing a build laid out differently from the one that collected it.
|
||||
Release builds of the native CLI optimize the compiler with a profile collected on the release commit. The `cli-profile` job runs `node scripts/refresh-cli-profile.mjs` on Linux x64, which builds an instrumented compiler, runs it on tsc-ts, a slice of the corpus, and the runtime benchmark workloads, and writes the merged profile. The profile keeps the functions that training never ran, with zero counts, so the CLI builds optimize them as cold code and place them after the code that ran. Every platform's CLI build uses that profile (`SCRIPTC_NATIVE_PROFILE_USE`), and the GitHub release attaches it as `scriptc-<version>-cli.profdata.gz`. Only the CLI builds wait for the profile: each platform's LLVM helper and runtime pack build while it is collected (release-build.yml's `packs` jobs, platforms listed in `.github/release-platforms.json`), and its CLI job starts from them once the profile is ready. Code the profile does not describe, or describes from older compiler sources, is optimized as without a profile. When the profile job fails, the CLI builds use the committed profile `packages/compiler/native/cli.profdata.gz`, which local and CI builds of the native compiler also use. The nightly `profile-refresh` workflow (`profile-refresh.yml`) refreshes the committed profile from main: it collects one with the committed layout, builds the native compiler with it to report the match, and opens a pull request that replaces `packages/compiler/native/cli.profdata.gz`. To refresh it by hand, run `node scripts/refresh-cli-profile.mjs --tsc-ts <tsc-ts checkout>` on a quiet Linux x64 host and commit the new profile on its own. CI's `native_profile` job builds the native compiler with the committed layout and profile and reports the share of the profiled functions that match, with a warning below 95%; a stale profile does not fail it. It fails when the profile cannot be judged: missing, unreadable, or describing a build laid out differently from the one that collected it.
|
||||
|
||||
Builds of the native compiler also order its functions by the committed layout `packages/compiler/native/cli.layout.gz`: the functions that `--version` and rebuilds of unchanged programs run come first, then the ones other builds run, ordered by the share of the layout's training builds that run each, so a run maps fewer pages of the executable. Functions the layout does not list keep their usual order. Function names of closures and generated helpers change with nearby edits, so the `cli-profile` job also collects a layout on the release commit (`scripts/refresh-cli-layout.mjs`), and the CLI builds use it (`SCRIPTC_NATIVE_LAYOUT`). Instrumented builds use the same layout as optimized builds, because a function laid out in a different partition than in the instrumented build no longer matches its profile record. The job therefore collects the layout first and then builds the instrumented compiler for the profile with that layout. Refresh the committed layout the same way, with `node scripts/refresh-cli-layout.mjs`, before the profile, and commit each on its own.
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"nodeVersion": "24.22.1",
|
||||
"compilerVersion": "0.4.16",
|
||||
"compilerVersion": "0.4.17",
|
||||
"refusals": [
|
||||
{
|
||||
"row": "crypto:d61ebc090db7",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scriptc/cli-darwin-arm64",
|
||||
"version": "0.4.16",
|
||||
"version": "0.4.17",
|
||||
"description": "Native scriptc compiler for darwin-arm64",
|
||||
"license": "Apache-2.0",
|
||||
"homepage": "https://scriptc.dev",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scriptc/cli-darwin-x64",
|
||||
"version": "0.4.16",
|
||||
"version": "0.4.17",
|
||||
"description": "Native scriptc compiler for darwin-x64",
|
||||
"license": "Apache-2.0",
|
||||
"homepage": "https://scriptc.dev",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scriptc/cli-linux-arm64-gnu",
|
||||
"version": "0.4.16",
|
||||
"version": "0.4.17",
|
||||
"description": "Native scriptc compiler for linux-arm64-gnu",
|
||||
"license": "Apache-2.0",
|
||||
"homepage": "https://scriptc.dev",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scriptc/cli-linux-arm64-musl",
|
||||
"version": "0.4.16",
|
||||
"version": "0.4.17",
|
||||
"description": "Native scriptc compiler for linux-arm64-musl",
|
||||
"license": "Apache-2.0",
|
||||
"homepage": "https://scriptc.dev",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scriptc/cli-linux-x64-gnu",
|
||||
"version": "0.4.16",
|
||||
"version": "0.4.17",
|
||||
"description": "Native scriptc compiler for linux-x64-gnu",
|
||||
"license": "Apache-2.0",
|
||||
"homepage": "https://scriptc.dev",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scriptc/cli-linux-x64-musl",
|
||||
"version": "0.4.16",
|
||||
"version": "0.4.17",
|
||||
"description": "Native scriptc compiler for linux-x64-musl",
|
||||
"license": "Apache-2.0",
|
||||
"homepage": "https://scriptc.dev",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scriptc/cli-win32-x64-msvc",
|
||||
"version": "0.4.16",
|
||||
"version": "0.4.17",
|
||||
"description": "Native scriptc compiler for win32-x64-msvc",
|
||||
"license": "Apache-2.0",
|
||||
"homepage": "https://scriptc.dev",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "scriptc",
|
||||
"version": "0.4.16",
|
||||
"version": "0.4.17",
|
||||
"description": "Compile ordinary TypeScript and JavaScript to small, fast native executables and WebAssembly modules that run without Node.js",
|
||||
"license": "Apache-2.0",
|
||||
"homepage": "https://scriptc.dev",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scriptc/compiler",
|
||||
"version": "0.4.16",
|
||||
"version": "0.4.17",
|
||||
"description": "The scriptc compiler — TypeScript/JavaScript frontend, typed IR, LLVM backend",
|
||||
"license": "Apache-2.0",
|
||||
"homepage": "https://scriptc.dev",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"schemaVersion": 2,
|
||||
"compilerVersion": "0.4.16",
|
||||
"compilerVersion": "0.4.17",
|
||||
"coverage": [
|
||||
"Entries are projected mechanically from the compiler's own decision tables: the diagnostics registry, the unsupported-syntax dispatch tables, the stdlib and node-builtin lowering tables, and the supported-builtin-module list. Nothing is hand-maintained; the manifest regenerates byte-identically from the source tree at this version.",
|
||||
"Absence from this manifest means 'not projected', never 'unsupported'. Surfaces lowered through dedicated code paths rather than tables are not yet projected: console, JSON, Promise/async and the timer surface, the net/http/tls/https/dgram/dns/assert/test/stream/readline module member surfaces, template literals, the regex slice, global functions (parseInt, parseFloat, isNaN, isFinite), and the process surface outside its ambient slice.",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scriptc/experimental",
|
||||
"version": "0.4.16",
|
||||
"version": "0.4.17",
|
||||
"description": "Experimental scriptc APIs, with Node.js implementations: lifetime regions for ProgramLifetime objects, intern tables shared between threads, per-thread slots on shared objects, array fields kept in their instances, classes with one owner per instance, and parallel loops",
|
||||
"license": "Apache-2.0",
|
||||
"homepage": "https://scriptc.dev",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"nodeVersion": "24.22.1",
|
||||
"compilerVersion": "0.4.16",
|
||||
"compilerVersion": "0.4.17",
|
||||
"refusals": [
|
||||
{
|
||||
"row": "crypto:d61ebc090db7",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scriptc/libnode-darwin-arm64",
|
||||
"version": "0.4.16",
|
||||
"version": "0.4.17",
|
||||
"description": "Prebuilt Node.js shared library and scriptc bridge for Node islands on macOS arm64",
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"homepage": "https://scriptc.dev",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scriptc/libnode-darwin-x64",
|
||||
"version": "0.4.16",
|
||||
"version": "0.4.17",
|
||||
"description": "Prebuilt Node.js shared library and scriptc bridge for Node islands on macOS x64",
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"homepage": "https://scriptc.dev",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scriptc/libnode-linux-arm64-gnu",
|
||||
"version": "0.4.16",
|
||||
"version": "0.4.17",
|
||||
"description": "Prebuilt Node.js shared library and scriptc bridge for Node islands on Linux arm64 glibc",
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"homepage": "https://scriptc.dev",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scriptc/libnode-linux-x64-gnu",
|
||||
"version": "0.4.16",
|
||||
"version": "0.4.17",
|
||||
"description": "Prebuilt Node.js shared library and scriptc bridge for Node islands on Linux x64 glibc",
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"homepage": "https://scriptc.dev",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scriptc/llvm-darwin-arm64",
|
||||
"version": "0.4.16",
|
||||
"version": "0.4.17",
|
||||
"description": "Pinned LLVM code-generation helper for scriptc on macOS arm64",
|
||||
"license": "Apache-2.0 WITH LLVM-exception",
|
||||
"homepage": "https://scriptc.dev",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scriptc/llvm-darwin-x64",
|
||||
"version": "0.4.16",
|
||||
"version": "0.4.17",
|
||||
"description": "Pinned LLVM code-generation helper for scriptc on macOS x64",
|
||||
"license": "Apache-2.0 WITH LLVM-exception",
|
||||
"homepage": "https://scriptc.dev",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scriptc/llvm-linux-arm64-gnu",
|
||||
"version": "0.4.16",
|
||||
"version": "0.4.17",
|
||||
"description": "Pinned LLVM code-generation helper for scriptc on Linux arm64",
|
||||
"license": "Apache-2.0 WITH LLVM-exception",
|
||||
"homepage": "https://scriptc.dev",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scriptc/llvm-linux-arm64-musl",
|
||||
"version": "0.4.16",
|
||||
"version": "0.4.17",
|
||||
"description": "Statically linked LLVM code-generation helper for scriptc on Linux arm64 musl",
|
||||
"license": "Apache-2.0 WITH LLVM-exception",
|
||||
"homepage": "https://scriptc.dev",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scriptc/llvm-linux-x64-gnu",
|
||||
"version": "0.4.16",
|
||||
"version": "0.4.17",
|
||||
"description": "Pinned LLVM code-generation helper for scriptc on Linux x64",
|
||||
"license": "Apache-2.0 WITH LLVM-exception",
|
||||
"homepage": "https://scriptc.dev",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scriptc/llvm-linux-x64-musl",
|
||||
"version": "0.4.16",
|
||||
"version": "0.4.17",
|
||||
"description": "Statically linked LLVM code-generation helper for scriptc on Linux x64 musl",
|
||||
"license": "Apache-2.0 WITH LLVM-exception",
|
||||
"homepage": "https://scriptc.dev",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scriptc/llvm-win32-x64-msvc",
|
||||
"version": "0.4.16",
|
||||
"version": "0.4.17",
|
||||
"description": "Pinned LLVM code-generation helper for scriptc on Windows x64",
|
||||
"license": "Apache-2.0 WITH LLVM-exception",
|
||||
"homepage": "https://scriptc.dev",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scriptc/node",
|
||||
"version": "0.4.16",
|
||||
"version": "0.4.17",
|
||||
"description": "Call into Node.js from scriptc programs: run an export of a JavaScript module in a Node.js helper process and copy JSON data both ways. Under Node.js the calls run in-process.",
|
||||
"license": "Apache-2.0",
|
||||
"homepage": "https://scriptc.dev",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scriptc/runtime-android-arm64",
|
||||
"version": "0.4.16",
|
||||
"version": "0.4.17",
|
||||
"description": "Precompiled scriptc library runtime pack for Android arm64",
|
||||
"license": "Apache-2.0",
|
||||
"homepage": "https://scriptc.dev",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scriptc/runtime-darwin-arm64",
|
||||
"version": "0.4.16",
|
||||
"version": "0.4.17",
|
||||
"description": "Precompiled scriptc runtime pack for macOS arm64",
|
||||
"license": "Apache-2.0",
|
||||
"homepage": "https://scriptc.dev",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scriptc/runtime-darwin-x64",
|
||||
"version": "0.4.16",
|
||||
"version": "0.4.17",
|
||||
"description": "Precompiled scriptc runtime pack for macOS x64",
|
||||
"license": "Apache-2.0",
|
||||
"homepage": "https://scriptc.dev",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scriptc/runtime-ios-arm64",
|
||||
"version": "0.4.16",
|
||||
"version": "0.4.17",
|
||||
"description": "Precompiled scriptc library runtime pack for iOS arm64",
|
||||
"license": "Apache-2.0",
|
||||
"homepage": "https://scriptc.dev",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scriptc/runtime-ios-simulator-arm64",
|
||||
"version": "0.4.16",
|
||||
"version": "0.4.17",
|
||||
"description": "Precompiled scriptc library runtime pack for iOS simulator arm64",
|
||||
"license": "Apache-2.0",
|
||||
"homepage": "https://scriptc.dev",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scriptc/runtime-linux-arm64-gnu",
|
||||
"version": "0.4.16",
|
||||
"version": "0.4.17",
|
||||
"description": "Precompiled scriptc runtime pack for Linux arm64 glibc",
|
||||
"license": "Apache-2.0",
|
||||
"homepage": "https://scriptc.dev",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scriptc/runtime-linux-arm64-musl",
|
||||
"version": "0.4.16",
|
||||
"version": "0.4.17",
|
||||
"description": "Precompiled scriptc runtime pack for Linux arm64 musl",
|
||||
"license": "Apache-2.0",
|
||||
"homepage": "https://scriptc.dev",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scriptc/runtime-linux-x64-gnu",
|
||||
"version": "0.4.16",
|
||||
"version": "0.4.17",
|
||||
"description": "Precompiled scriptc runtime pack for Linux x64 glibc",
|
||||
"license": "Apache-2.0",
|
||||
"homepage": "https://scriptc.dev",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scriptc/runtime-linux-x64-musl",
|
||||
"version": "0.4.16",
|
||||
"version": "0.4.17",
|
||||
"description": "Precompiled scriptc runtime pack for Linux x64 musl",
|
||||
"license": "Apache-2.0",
|
||||
"homepage": "https://scriptc.dev",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scriptc/runtime-wasm32-wasi",
|
||||
"version": "0.4.16",
|
||||
"version": "0.4.17",
|
||||
"description": "Precompiled scriptc runtime pack for WASI Preview 1",
|
||||
"license": "Apache-2.0",
|
||||
"homepage": "https://scriptc.dev",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scriptc/runtime-win32-x64-msvc",
|
||||
"version": "0.4.16",
|
||||
"version": "0.4.17",
|
||||
"description": "Precompiled scriptc runtime pack for Windows x64 MSVC",
|
||||
"license": "Apache-2.0",
|
||||
"homepage": "https://scriptc.dev",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scriptc/runtime",
|
||||
"version": "0.4.16",
|
||||
"version": "0.4.17",
|
||||
"description": "scriptc native runtime sources and vendored dependencies",
|
||||
"license": "Apache-2.0",
|
||||
"homepage": "https://scriptc.dev",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scriptc/threads",
|
||||
"version": "0.4.16",
|
||||
"version": "0.4.17",
|
||||
"description": "Zero-copy publication of immutable object graphs to worker threads (scriptc), with a deep-freezing Node.js implementation",
|
||||
"license": "Apache-2.0",
|
||||
"homepage": "https://scriptc.dev",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scriptc/types",
|
||||
"version": "0.4.16",
|
||||
"version": "0.4.17",
|
||||
"description": "Contract types for scriptc: type-only annotations (Int32, NoThrow, Immutable) that scriptc checks and optimizes, with no runtime semantics",
|
||||
"license": "Apache-2.0",
|
||||
"homepage": "https://scriptc.dev",
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
#!/usr/bin/env node
|
||||
// Moves the green-main tag to the commit of a passing CI push to main (.github/workflows/green-main.yml).
|
||||
//
|
||||
// green-main names the newest commit on main whose full post-merge verification passed: the commit a release, a
|
||||
// nightly baseline or a pre-warmed sandbox image may cut from. The tag is the only ref this writes; it never
|
||||
// touches a branch, and in particular never main. The workflow grants the job `contents: write` for that one tag
|
||||
// and the token is GitHub Actions' own GITHUB_TOKEN.
|
||||
//
|
||||
// usage: node scripts/ci/green-main.mjs <commit-sha> [--dry-run]
|
||||
// environment: GITHUB_REPOSITORY (owner/repo), GH_TOKEN (set by the workflow's token)
|
||||
import { execFileSync } from "node:child_process";
|
||||
|
||||
export const GREEN_MAIN_TAG = "green-main";
|
||||
// The API names a tag by the path below "refs/", and creates one by its full ref.
|
||||
export const TAG_PATH = `tags/${GREEN_MAIN_TAG}`;
|
||||
export const TAG_REF = `refs/${TAG_PATH}`;
|
||||
|
||||
/**
|
||||
* What moving the tag from `currentSha` to `nextSha` takes: create it, move it forward, leave it, or stale when
|
||||
* the tag already names a newer commit. `ancestor` says `nextSha` descends from `currentSha`; a rerun of an older
|
||||
* push passes an older commit and must never drag the tag back.
|
||||
*/
|
||||
export function tagAction(currentSha, nextSha, { ancestor = false } = {}) {
|
||||
if (typeof nextSha !== "string" || !/^[0-9a-f]{40}$/.test(nextSha))
|
||||
throw new Error(`green-main needs a full commit sha, got ${JSON.stringify(nextSha)}`);
|
||||
if (currentSha === nextSha) return "unchanged";
|
||||
if (typeof currentSha !== "string" || currentSha.length === 0) return "create";
|
||||
return ancestor ? "update" : "stale";
|
||||
}
|
||||
|
||||
/** The REST request that performs `action` for `sha` in `repo`: a tag ref, and nothing else. */
|
||||
export function tagRequest(action, repo, sha) {
|
||||
if (!/^[^/]+\/[^/]+$/.test(repo)) throw new Error(`invalid repository ${JSON.stringify(repo)}`);
|
||||
if (action === "create")
|
||||
return {
|
||||
method: "POST",
|
||||
path: `repos/${repo}/git/refs`,
|
||||
fields: { ref: TAG_REF, sha },
|
||||
};
|
||||
if (action === "update")
|
||||
return {
|
||||
method: "PATCH",
|
||||
path: `repos/${repo}/git/refs/${TAG_PATH}`,
|
||||
// `force` is a boolean in the API's request body; `gh api -F` sends it as one.
|
||||
fields: { sha, force: true },
|
||||
};
|
||||
throw new Error(`nothing to request for ${action}`);
|
||||
}
|
||||
|
||||
/** The `gh api` arguments for a request: strings with `-f`, booleans and numbers with `-F`. */
|
||||
export function ghArgs({ method, path, fields }) {
|
||||
const args = ["api", "--method", method, path];
|
||||
for (const [name, value] of Object.entries(fields))
|
||||
args.push(
|
||||
typeof value === "boolean" || typeof value === "number" ? "-F" : "-f",
|
||||
`${name}=${value}`,
|
||||
);
|
||||
return args;
|
||||
}
|
||||
|
||||
function gh(args) {
|
||||
return execFileSync("gh", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] });
|
||||
}
|
||||
|
||||
function git(args, cwd = process.cwd()) {
|
||||
return execFileSync("git", args, { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] });
|
||||
}
|
||||
|
||||
/** Whether `ancestor` is an ancestor of `descendant` in the repository at `cwd`. */
|
||||
export function isAncestor(ancestor, descendant, cwd = process.cwd()) {
|
||||
try {
|
||||
git(["merge-base", "--is-ancestor", ancestor, descendant], cwd);
|
||||
return true;
|
||||
} catch (error) {
|
||||
// 1 is "not an ancestor"; anything else is a missing object or a broken repository.
|
||||
if (error.status === 1) return false;
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/** Makes sure the commit is present locally: a rerun's checkout may not reach the tag's commit. */
|
||||
function ensureCommit(sha) {
|
||||
try {
|
||||
git(["cat-file", "-e", `${sha}^{commit}`]);
|
||||
} catch {
|
||||
git(["fetch", "--no-tags", "--quiet", "origin", sha]);
|
||||
}
|
||||
}
|
||||
|
||||
/** The commit the tag names now, or undefined when it does not exist yet. */
|
||||
export function currentTagSha(repo) {
|
||||
try {
|
||||
const ref = JSON.parse(gh(["api", `repos/${repo}/git/ref/${TAG_PATH}`]));
|
||||
return ref?.object?.sha;
|
||||
} catch (error) {
|
||||
const text = `${error.stderr ?? ""}${error.message ?? ""}`;
|
||||
// A 404 is the first run: the tag is created below. Any other failure is real.
|
||||
if (/HTTP 404|Not Found/.test(text)) return undefined;
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
function main() {
|
||||
const [sha] = process.argv.slice(2).filter((arg) => !arg.startsWith("--"));
|
||||
const dryRun = process.argv.includes("--dry-run");
|
||||
const repo = process.env.GITHUB_REPOSITORY ?? "";
|
||||
// Reading the tag is read-only; a dry run still reports whether it would create or update.
|
||||
const current = currentTagSha(repo);
|
||||
let ancestor = false;
|
||||
if (typeof current === "string" && current.length > 0 && current !== sha) {
|
||||
ensureCommit(current);
|
||||
ancestor = isAncestor(current, sha);
|
||||
}
|
||||
const action = tagAction(current, sha, { ancestor });
|
||||
if (action === "unchanged") {
|
||||
console.log(`green-main already names ${sha}`);
|
||||
return;
|
||||
}
|
||||
if (action === "stale") {
|
||||
console.log(
|
||||
`::notice::green-main already names a newer passing commit (${current}); leaving it rather than moving ` +
|
||||
`it back to ${sha}`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
const request = tagRequest(action, repo, sha);
|
||||
if (dryRun) {
|
||||
console.log(`${request.method} ${request.path} ${JSON.stringify(request.fields)}`);
|
||||
return;
|
||||
}
|
||||
gh([...ghArgs(request), "--silent"]);
|
||||
console.log(`green-main now names ${sha} (${action})`);
|
||||
}
|
||||
|
||||
if (process.argv[1] && import.meta.url === new URL(`file://${process.argv[1]}`).href) main();
|
||||
@@ -0,0 +1,849 @@
|
||||
#!/usr/bin/env node
|
||||
// The post-merge lanes (.github/workflows/postmerge.yml): the complete macOS suite and the release rehearsal on the
|
||||
// newest green main commit, and, when one of their jobs turns red, a bisection over the main batches since that
|
||||
// job's last green commit that names the first bad commit.
|
||||
//
|
||||
// usage:
|
||||
// postmerge.mjs pick the commit to test (GITHUB_OUTPUT: sha, skip)
|
||||
// postmerge.mjs plan --sha <sha> record this run's job results, and plan a bisection for each job that
|
||||
// turned red (GITHUB_OUTPUT: tasks)
|
||||
// postmerge.mjs bisect --task <json> run one planned bisection on this runner
|
||||
// postmerge.mjs report --dir <dir> the job summary and the blame report from the bisections' results
|
||||
//
|
||||
// pick, plan and report call `gh` with GH_TOKEN (actions: read, contents: read) and read GITHUB_REPOSITORY and
|
||||
// GITHUB_RUN_ID. Each run uploads its job results as the postmerge-state artifact; later runs read them to find a
|
||||
// job's last green commit and to skip a commit that was already tested.
|
||||
//
|
||||
// A bisection probes one commit by checking it out, building it, and running the red job's own commands from that
|
||||
// commit's workflow file (the recipes below name the steps), with the job's matrix values. It first probes the red
|
||||
// commit itself: a job that passes there is reported as not reproduced, and nothing is bisected. It then searches
|
||||
// the batches (each push to main: one merge queue merge, or one direct push) for the first bad batch, and inside a
|
||||
// batch of several commits, the first bad commit. It stops after maxProbes probes or when its time runs out, and
|
||||
// then reports the range it narrowed the change to.
|
||||
import { execFileSync, spawnSync } from "node:child_process";
|
||||
import {
|
||||
appendFileSync,
|
||||
copyFileSync,
|
||||
existsSync,
|
||||
mkdirSync,
|
||||
mkdtempSync,
|
||||
readFileSync,
|
||||
readdirSync,
|
||||
writeFileSync,
|
||||
} from "node:fs";
|
||||
import { createRequire } from "node:module";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { fileURLToPath, pathToFileURL } from "node:url";
|
||||
|
||||
export const STATE_ARTIFACT = "postmerge-state";
|
||||
export const BLAME_ARTIFACT = "postmerge-blame";
|
||||
/** How many earlier results (runs that left a state) are read for a job's last green commit. */
|
||||
export const STATE_HISTORY = 30;
|
||||
/** At most this many bisections per run, one per recipe; they run in parallel. */
|
||||
export const MAX_BISECTIONS = 3;
|
||||
/** At most this many probes per bisection, the red commit's included: 2^5 batches. */
|
||||
export const MAX_PROBES = 6;
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------
|
||||
// Recipes: how to probe one red job on one runner.
|
||||
|
||||
const ci = ".github/workflows/ci.yml";
|
||||
const releaseBuild = ".github/workflows/release-build.yml";
|
||||
const platforms = ".github/release-platforms.json";
|
||||
|
||||
/** The commands .github/actions/native-packages runs when nothing is cached, for one target. */
|
||||
export function nativePackages(target, { linux = false } = {}) {
|
||||
const runtime = linux
|
||||
? 'CC=zig AR=zig pnpm --filter "@scriptc/runtime-$SCRIPTC_PACKAGE_TARGET" build:native'
|
||||
: 'pnpm --filter "@scriptc/runtime-$SCRIPTC_PACKAGE_TARGET" build:native';
|
||||
return {
|
||||
name: `Build native packages (${target})`,
|
||||
env: { SCRIPTC_PACKAGE_TARGET: target },
|
||||
run: [
|
||||
'pnpm --filter "@scriptc/llvm-$SCRIPTC_PACKAGE_TARGET" build:native',
|
||||
runtime,
|
||||
'node "packages/runtime-$SCRIPTC_PACKAGE_TARGET/scripts/verify.mjs"',
|
||||
].join("\n"),
|
||||
};
|
||||
}
|
||||
|
||||
const install = { name: "Install", run: "pnpm install --frozen-lockfile" };
|
||||
const build = { name: "Build", run: "pnpm build" };
|
||||
// .github/actions/libnode without a cached libnode-packs build: the pinned development pack.
|
||||
const libnode = {
|
||||
name: "libnode development pack",
|
||||
run: 'node packages/libnode-common/fetch-dev-pack.mjs --out "$SCRIPTC_LIBNODE"',
|
||||
};
|
||||
|
||||
/**
|
||||
* Each recipe matches the names the jobs API reports for a job of this workflow ("<caller job> / <job>", one level
|
||||
* per reusable workflow call), and probes it with fixed commands (prelude) and then the job's own steps, replayed
|
||||
* from the probed commit's workflow file. A replayed step is named by a prefix of its name; `when` decides from the
|
||||
* matrix whether the job runs it. `setup` is the toolchain the bisect job installs once, before the first probe.
|
||||
*/
|
||||
export const recipes = [
|
||||
{
|
||||
id: "native_macos",
|
||||
pattern: /^macos \/ build \(macOS arm64 native packages\)$/,
|
||||
runner: () => "macos-15",
|
||||
setup: "macos",
|
||||
timeoutMinutes: 40,
|
||||
prelude: () => [install, nativePackages("darwin-arm64")],
|
||||
workflow: ci,
|
||||
job: "native_macos",
|
||||
steps: [],
|
||||
env: () => ({}),
|
||||
},
|
||||
{
|
||||
id: "tests_macos",
|
||||
pattern: /^macos \/ test \(macOS, (?<flavor>plain|san), (?<shard>\d+)\/10\)$/,
|
||||
runner: () => "macos-15",
|
||||
setup: "macos",
|
||||
timeoutMinutes: 120,
|
||||
prelude: () => [install, nativePackages("darwin-arm64"), build, libnode],
|
||||
workflow: ci,
|
||||
job: "tests_macos",
|
||||
steps: [{ step: "Tests (" }],
|
||||
env: ({ flavor, shard }) => ({
|
||||
SCRIPTC_TEST_WORKERS: "4",
|
||||
SCRIPTC_SAN: flavor === "san" ? "1" : "",
|
||||
SCRIPTC_TEST_SHARD: `${shard}/10`,
|
||||
SCRIPTC_CI_SUITE: "full",
|
||||
}),
|
||||
},
|
||||
{
|
||||
id: "llvm_artifacts_macos_arm64",
|
||||
pattern: /^macos \/ test \(macOS arm64 LLVM artifacts, no clang, (?<shard>\d+)\/10\)$/,
|
||||
runner: () => "macos-15",
|
||||
setup: "macos",
|
||||
timeoutMinutes: 70,
|
||||
prelude: () => [install, nativePackages("darwin-arm64"), build, libnode],
|
||||
workflow: ci,
|
||||
job: "llvm_artifacts_macos_arm64",
|
||||
steps: [{ step: "LLVM release/dev differential" }],
|
||||
env: ({ shard }) => ({ SCRIPTC_TEST_SHARD: `${shard}/10` }),
|
||||
},
|
||||
{
|
||||
id: "llvm_artifacts_macos_arm64_contracts",
|
||||
pattern: /^macos \/ test \(macOS arm64 LLVM artifacts, no clang, contracts\)$/,
|
||||
runner: () => "macos-15",
|
||||
setup: "macos",
|
||||
timeoutMinutes: 70,
|
||||
prelude: () => [install, nativePackages("darwin-arm64"), build, libnode],
|
||||
workflow: ci,
|
||||
job: "llvm_artifacts_macos_arm64_contracts",
|
||||
steps: [
|
||||
{ step: "Node island harness" },
|
||||
{ step: "No-clang assembly/object contract" },
|
||||
{ step: "Helper diagnostics and object/link parity" },
|
||||
{ step: "Packaged helper contract" },
|
||||
{ step: "Packed npm installation smoke" },
|
||||
],
|
||||
env: () => ({}),
|
||||
},
|
||||
{
|
||||
id: "llvm_artifacts_macos_x64",
|
||||
pattern: /^macos \/ test \(macOS x64 LLVM artifacts, no clang\)$/,
|
||||
runner: () => "macos-15-intel",
|
||||
setup: "macos",
|
||||
timeoutMinutes: 45,
|
||||
prelude: () => [install, nativePackages("darwin-x64"), build, libnode],
|
||||
workflow: ci,
|
||||
job: "llvm_artifacts_macos_x64",
|
||||
steps: [
|
||||
{ step: "Node islands (Intel)" },
|
||||
{ step: "Intel Mach-O no-clang object contract" },
|
||||
{ step: "Intel helper/runtime-pack executable smoke" },
|
||||
],
|
||||
env: () => ({}),
|
||||
},
|
||||
// The rehearsal's platform builds (release-build.yml's packs and cli jobs). Windows is not probed: the probe runs
|
||||
// its steps with bash.
|
||||
{
|
||||
id: "release_packs",
|
||||
pattern: /^rehearsal \/ Build \/ Build helper and runtime pack \((?<platform>[^)]+)\)$/,
|
||||
platform: true,
|
||||
runner: (matrix) => matrix.runner,
|
||||
setup: "release-toolchain",
|
||||
timeoutMinutes: 90,
|
||||
prelude: () => [],
|
||||
workflow: releaseBuild,
|
||||
job: "packs",
|
||||
steps: [
|
||||
// It edits pnpm-workspace.yaml, so it runs before the install, as in the job.
|
||||
{
|
||||
step: "Let pnpm install musl platform packages",
|
||||
when: (m) => (m.cli_target ?? "").endsWith("-musl"),
|
||||
beforeInstall: true,
|
||||
},
|
||||
{ step: "Build native packages (POSIX)" },
|
||||
{ step: "Build host helper for cross-libc bootstrap", when: (m) => Boolean(m.seed_helper) },
|
||||
],
|
||||
env: () => ({}),
|
||||
},
|
||||
{
|
||||
id: "release_cli",
|
||||
pattern: /^rehearsal \/ Build \/ Build native package \((?<platform>[^)]+)\)$/,
|
||||
platform: true,
|
||||
runner: (matrix) => matrix.runner,
|
||||
setup: "release-toolchain",
|
||||
timeoutMinutes: 150,
|
||||
prelude: () => [],
|
||||
workflow: releaseBuild,
|
||||
job: "cli",
|
||||
// The packs job's build first: the cli job starts from its artifact.
|
||||
packsFirst: true,
|
||||
steps: [{ step: "Build native CLI distribution", when: (m) => Boolean(m.cli) }],
|
||||
env: () => ({}),
|
||||
},
|
||||
];
|
||||
|
||||
/** The recipe and matrix values for a job name the jobs API reports, or undefined when no recipe probes it. */
|
||||
export function recipeFor(name, platformList = []) {
|
||||
for (const recipe of recipes) {
|
||||
const match = recipe.pattern.exec(name);
|
||||
if (!match) continue;
|
||||
let matrix = { ...match.groups };
|
||||
if (recipe.platform) {
|
||||
const platform = platformList.find((p) => p.platform === matrix.platform);
|
||||
if (!platform || platform.platform === "windows-x64") return undefined;
|
||||
matrix = { ...platform };
|
||||
}
|
||||
return { recipe, matrix };
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/** `${{ matrix.<key> }}` and `${{ runner.temp }}` filled in; any other expression cannot be replayed. */
|
||||
export function substitute(text, matrix, runnerTemp) {
|
||||
return text.replace(/\$\{\{\s*([^}]*?)\s*\}\}/g, (whole, expression) => {
|
||||
const key = /^matrix\.([\w-]+)$/.exec(expression)?.[1];
|
||||
if (key !== undefined) return String(matrix[key] ?? "");
|
||||
if (expression === "runner.temp") return runnerTemp;
|
||||
throw new Error(`cannot replay ${whole}`);
|
||||
});
|
||||
}
|
||||
|
||||
/** The steps a recipe's job runs, read from a parsed workflow, with the matrix filled in. */
|
||||
export function replaySteps(workflow, recipe, matrix, runnerTemp) {
|
||||
const jobOf = (id) => {
|
||||
const job = workflow.jobs?.[id];
|
||||
if (!job) throw new Error(`the workflow has no job ${id}`);
|
||||
return job;
|
||||
};
|
||||
const pick = (job, refs) =>
|
||||
refs
|
||||
.filter((ref) => !ref.when || ref.when(matrix))
|
||||
.map((ref) => {
|
||||
const step = job.steps.find(
|
||||
(s) => typeof s.name === "string" && s.name.startsWith(ref.step),
|
||||
);
|
||||
if (!step) throw new Error(`no step named ${ref.step}`);
|
||||
if (typeof step.run !== "string") throw new Error(`step ${ref.step} has no run`);
|
||||
const env = Object.fromEntries(
|
||||
Object.entries(step.env ?? {}).map(([k, v]) => [
|
||||
k,
|
||||
substitute(String(v), matrix, runnerTemp),
|
||||
]),
|
||||
);
|
||||
return {
|
||||
name: ref.step,
|
||||
env,
|
||||
run: substitute(step.run, matrix, runnerTemp),
|
||||
beforeInstall: ref.beforeInstall === true,
|
||||
};
|
||||
});
|
||||
const steps = [];
|
||||
if (recipe.packsFirst) {
|
||||
const packs = recipes.find((r) => r.id === "release_packs");
|
||||
steps.push(...pick(jobOf(packs.job), packs.steps));
|
||||
}
|
||||
steps.push(...pick(jobOf(recipe.job), recipe.steps));
|
||||
return steps;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------
|
||||
// Results, batches and the search.
|
||||
|
||||
/** The lane jobs of a run (the jobs of the macos and rehearsal calls) and their conclusions. */
|
||||
export function laneJobs(jobs) {
|
||||
const out = {};
|
||||
for (const job of jobs) {
|
||||
if (!/^(macos|rehearsal) \//.test(job.name)) continue;
|
||||
out[job.name] = job.status === "completed" ? job.conclusion : job.status;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
const red = (conclusion) => conclusion === "failure" || conclusion === "timed_out";
|
||||
|
||||
/**
|
||||
* What an earlier run says about a job, from the states of earlier runs (newest first): its last green commit, and
|
||||
* whether its most recent result was red (then it was red before this run, and is not bisected again).
|
||||
*/
|
||||
export function history(states, name) {
|
||||
let previous;
|
||||
for (const state of states) {
|
||||
const conclusion = state.jobs?.[name];
|
||||
if (conclusion === undefined || conclusion === "skipped" || conclusion === "cancelled")
|
||||
continue;
|
||||
previous ??= { sha: state.sha, conclusion, runId: state.runId };
|
||||
if (conclusion === "success") return { lastGreen: state.sha, previous };
|
||||
}
|
||||
return { lastGreen: undefined, previous };
|
||||
}
|
||||
|
||||
/**
|
||||
* The batches from `good` (exclusive) to `bad` (inclusive): `commits` are main's first-parent commits in that range,
|
||||
* oldest first; `pushes` are the commits main's pushes left it at (the activity API's `after`). Each batch ends at a
|
||||
* push; commits that no push names (an incomplete activity history) join the batch of the next push. With no pushes
|
||||
* known, every commit is its own batch.
|
||||
*/
|
||||
export function batches(commits, pushes) {
|
||||
if (commits.length === 0) return [];
|
||||
const tips = new Set(pushes);
|
||||
const out = [];
|
||||
let current = [];
|
||||
for (const [index, sha] of commits.entries()) {
|
||||
current.push(sha);
|
||||
if (tips.size === 0 || tips.has(sha) || index === commits.length - 1) {
|
||||
out.push(current);
|
||||
current = [];
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* The first item for which probe reports "fail", given that the item before items[0] passes and that the last item
|
||||
* fails (it is not probed again). Binary search; `probe` returns "pass" or "fail". Stops early when budget() is
|
||||
* false and then returns the narrowed range: firstBad undefined, lastGood and firstKnownBad the ends.
|
||||
*/
|
||||
export async function search(items, probe, budget = () => true) {
|
||||
let lo = -1; // index of the last item known to pass (-1: the item before the list)
|
||||
let hi = items.length - 1; // index of the first item known to fail
|
||||
while (hi - lo > 1) {
|
||||
if (!budget()) return { firstBad: undefined, lastGood: lo, firstKnownBad: hi };
|
||||
const mid = Math.floor((lo + hi) / 2);
|
||||
if ((await probe(items[mid])) === "pass") lo = mid;
|
||||
else hi = mid;
|
||||
}
|
||||
return { firstBad: hi, lastGood: lo, firstKnownBad: hi };
|
||||
}
|
||||
|
||||
/**
|
||||
* The whole bisection: the red commit (the last batch's tip) is probed first, then the batches, then the commits of
|
||||
* the first bad batch. Returns a result the report formats.
|
||||
*/
|
||||
export async function bisect(
|
||||
batchList,
|
||||
probe,
|
||||
{ maxProbes = MAX_PROBES, deadline = Infinity, now = Date.now } = {},
|
||||
) {
|
||||
const probes = [];
|
||||
const run = async (sha) => {
|
||||
const result = await probe(sha);
|
||||
probes.push({ sha, result });
|
||||
return result;
|
||||
};
|
||||
const budget = () => probes.length < maxProbes && now() < deadline;
|
||||
if (batchList.length === 0) return { outcome: "no-candidates", probes };
|
||||
const tips = batchList.map((batch) => batch.at(-1));
|
||||
if ((await run(tips.at(-1))) === "pass") return { outcome: "not-reproduced", probes };
|
||||
const level1 = await search(tips, run, budget);
|
||||
if (level1.firstBad === undefined) {
|
||||
return {
|
||||
outcome: "narrowed",
|
||||
probes,
|
||||
lastGood: level1.lastGood >= 0 ? tips[level1.lastGood] : undefined,
|
||||
candidates: batchList.slice(level1.lastGood + 1, level1.firstKnownBad + 1).flat(),
|
||||
};
|
||||
}
|
||||
const batch = batchList[level1.firstBad];
|
||||
const level2 = await search(batch, run, budget);
|
||||
if (level2.firstBad === undefined) {
|
||||
return {
|
||||
outcome: "narrowed",
|
||||
probes,
|
||||
batch,
|
||||
candidates: batch.slice(level2.lastGood + 1, level2.firstKnownBad + 1),
|
||||
};
|
||||
}
|
||||
return { outcome: "found", probes, batch, firstBad: batch[level2.firstBad] };
|
||||
}
|
||||
|
||||
/** One bisection's result as Markdown, with the commits' subjects (`describe(sha)`). */
|
||||
export function formatResult(task, result, describe = (sha) => sha) {
|
||||
const short = (sha) => sha.slice(0, 12);
|
||||
const line = (sha) => `\`${short(sha)}\` ${describe(sha)}`;
|
||||
const out = [`### ${task.job}`, ""];
|
||||
out.push(
|
||||
`Red at \`${short(task.bad)}\`, last green at \`${short(task.good)}\`; ${task.commits} commits in ${task.batches} batches.`,
|
||||
"",
|
||||
);
|
||||
switch (result.outcome) {
|
||||
case "found":
|
||||
out.push(`**First bad commit: ${line(result.firstBad)}**`);
|
||||
if (result.batch.length > 1)
|
||||
out.push(
|
||||
"",
|
||||
`It landed in a batch of ${result.batch.length} commits, ending at \`${short(result.batch.at(-1))}\`.`,
|
||||
);
|
||||
break;
|
||||
case "narrowed":
|
||||
out.push(
|
||||
`Not narrowed to one commit within ${result.probes.length} probes. The change is one of:`,
|
||||
"",
|
||||
);
|
||||
for (const sha of result.candidates) out.push(`- ${line(sha)}`);
|
||||
break;
|
||||
case "not-reproduced":
|
||||
out.push(
|
||||
`The job passed when probed again at \`${short(task.bad)}\`: a flaky failure, or one that needs the full job. Not bisected.`,
|
||||
);
|
||||
break;
|
||||
case "no-candidates":
|
||||
out.push("No commits between the last green and the red commit.");
|
||||
break;
|
||||
default:
|
||||
out.push(`The bisection did not finish: ${result.error ?? result.outcome}.`);
|
||||
}
|
||||
if (result.probes?.length) {
|
||||
out.push("", "| Probe | Result |", "| --- | --- |");
|
||||
for (const p of result.probes) out.push(`| \`${short(p.sha)}\` | ${p.result} |`);
|
||||
}
|
||||
return out.join("\n");
|
||||
}
|
||||
|
||||
/** The summary of a run: the tested commit, its red jobs, and each bisection or why a job was not bisected. */
|
||||
export function formatReport({ sha, jobs, skipped = [], results = [] }, describe) {
|
||||
const redJobs = Object.entries(jobs).filter(([, c]) => red(c));
|
||||
const out = [`## Post-merge lanes on \`${sha.slice(0, 12)}\``, ""];
|
||||
out.push(redJobs.length === 0 ? "Every lane job is green." : `${redJobs.length} red job(s):`, "");
|
||||
for (const [name] of redJobs) out.push(`- ${name}`);
|
||||
if (skipped.length) {
|
||||
out.push("", "Not bisected:", "");
|
||||
for (const s of skipped) out.push(`- ${s.job}: ${s.reason}`);
|
||||
}
|
||||
for (const { task, result } of results) out.push("", formatResult(task, result, describe));
|
||||
return `${out.join("\n")}\n`;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------
|
||||
// GitHub and git.
|
||||
|
||||
function gh(...args) {
|
||||
return execFileSync("gh", args, { encoding: "utf8", maxBuffer: 1 << 28 });
|
||||
}
|
||||
function git(...args) {
|
||||
return execFileSync("git", args, { encoding: "utf8", maxBuffer: 1 << 28 }).trim();
|
||||
}
|
||||
const repo = () => process.env.GITHUB_REPOSITORY;
|
||||
const output = (text) => {
|
||||
if (process.env.GITHUB_OUTPUT) appendFileSync(process.env.GITHUB_OUTPUT, text);
|
||||
process.stdout.write(text);
|
||||
};
|
||||
|
||||
/** The events that start this workflow on main. A run of any other event, branch or repository (a pull request that
|
||||
* adds a trigger to this file, a dispatch on another branch, a fork) never counts as a post-merge result. */
|
||||
export const TRUSTED_EVENTS = ["workflow_run", "schedule", "workflow_dispatch"];
|
||||
|
||||
/** The runs whose results can count: this workflow's own, started on the repository's main by a trusted event. */
|
||||
export function trustedRuns(runs, repository, branch = "main") {
|
||||
return runs.filter(
|
||||
(run) =>
|
||||
/^\.github\/workflows\/postmerge\.yml(@|$)/.test(String(run.path)) &&
|
||||
TRUSTED_EVENTS.includes(run.event) &&
|
||||
run.head_branch === branch &&
|
||||
run.repository?.full_name === repository &&
|
||||
run.head_repository?.full_name === repository,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* A run's state when it is well formed and its commit is one that run could have tested: a full SHA that is the
|
||||
* run's own commit or an ancestor of it (`isAncestor(sha, runSha)`), with lane job results only. Undefined
|
||||
* otherwise.
|
||||
*/
|
||||
export function validState(state, run, isAncestor) {
|
||||
if (typeof state !== "object" || state === null) return undefined;
|
||||
if (typeof state.sha !== "string" || !/^[0-9a-f]{40}$/.test(state.sha)) return undefined;
|
||||
if (typeof state.jobs !== "object" || state.jobs === null || Array.isArray(state.jobs))
|
||||
return undefined;
|
||||
for (const [name, conclusion] of Object.entries(state.jobs))
|
||||
if (
|
||||
!/^(macos|rehearsal) \//.test(name) ||
|
||||
typeof conclusion !== "string" ||
|
||||
!/^[a-z_]{1,32}$/.test(conclusion)
|
||||
)
|
||||
return undefined;
|
||||
if (!isAncestor(state.sha, run.head_sha)) return undefined;
|
||||
return { sha: state.sha, jobs: state.jobs, runId: run.id };
|
||||
}
|
||||
|
||||
const isAncestor = (sha, of) =>
|
||||
typeof of === "string" &&
|
||||
spawnSync("git", ["merge-base", "--is-ancestor", sha, of], { stdio: "ignore" }).status === 0;
|
||||
|
||||
/**
|
||||
* The first `limit` states the runs left, newest first. `limit` counts states, not runs: a run that found nothing new
|
||||
* (pick's skip) leaves no state, and however many of those came since, the last tested commit is still found.
|
||||
*/
|
||||
export function collectStates(runs, limit, readState) {
|
||||
const states = [];
|
||||
for (const run of runs) {
|
||||
if (states.length >= limit) break;
|
||||
const state = readState(run);
|
||||
if (state !== undefined) states.push(state);
|
||||
}
|
||||
return states;
|
||||
}
|
||||
|
||||
/** The trusted completed runs on main, newest first, a page of 100 at a time, at most `pages` pages. */
|
||||
function* trustedRunPages(pages = 5) {
|
||||
for (let page = 1; page <= pages; page++) {
|
||||
const runs = JSON.parse(
|
||||
gh(
|
||||
"api",
|
||||
`repos/${repo()}/actions/workflows/postmerge.yml/runs?branch=main&status=completed&per_page=100&page=${page}`,
|
||||
),
|
||||
).workflow_runs;
|
||||
yield* trustedRuns(runs, repo());
|
||||
if (runs.length < 100) return;
|
||||
}
|
||||
}
|
||||
|
||||
/** The states of this workflow's earlier completed trusted runs on main, newest first. */
|
||||
function loadStates(limit = STATE_HISTORY) {
|
||||
const dir = mkdtempSync(join(tmpdir(), "postmerge-state-"));
|
||||
const readState = (run) => {
|
||||
if (String(run.id) === process.env.GITHUB_RUN_ID) return undefined;
|
||||
// Most runs that found nothing new left no state; ask for it before downloading.
|
||||
const listed = JSON.parse(
|
||||
gh("api", `repos/${repo()}/actions/runs/${run.id}/artifacts?name=${STATE_ARTIFACT}`),
|
||||
).artifacts.filter((artifact) => !artifact.expired);
|
||||
if (listed.length === 0) return undefined;
|
||||
const target = join(dir, String(run.id));
|
||||
const got = spawnSync(
|
||||
"gh",
|
||||
["run", "download", String(run.id), "-R", repo(), "-n", STATE_ARTIFACT, "-D", target],
|
||||
{ stdio: "ignore" },
|
||||
);
|
||||
if (got.status !== 0 || !existsSync(join(target, "state.json"))) return undefined;
|
||||
let state;
|
||||
try {
|
||||
state = validState(
|
||||
JSON.parse(readFileSync(join(target, "state.json"), "utf8")),
|
||||
run,
|
||||
isAncestor,
|
||||
);
|
||||
} catch {
|
||||
state = undefined;
|
||||
}
|
||||
if (state === undefined)
|
||||
console.log(
|
||||
`::warning::run ${run.id} left a postmerge-state that is not valid; it does not count`,
|
||||
);
|
||||
return state;
|
||||
};
|
||||
return collectStates(trustedRunPages(), limit, readState);
|
||||
}
|
||||
|
||||
function pick() {
|
||||
const requested = process.env.POSTMERGE_SHA?.trim();
|
||||
let sha = requested;
|
||||
if (requested && !(/^[0-9a-f]{40}$/.test(requested) && isAncestor(requested, "origin/main"))) {
|
||||
throw new Error(`${requested} is not a full SHA of a commit on main`);
|
||||
}
|
||||
if (!sha) {
|
||||
const runs = JSON.parse(
|
||||
gh(
|
||||
"api",
|
||||
`repos/${repo()}/actions/workflows/ci.yml/runs?branch=main&event=push&status=success&per_page=20`,
|
||||
),
|
||||
).workflow_runs;
|
||||
sha = runs.find(
|
||||
(run) => run.head_repository?.full_name === repo() && isAncestor(run.head_sha, "origin/main"),
|
||||
)?.head_sha;
|
||||
}
|
||||
if (!sha) {
|
||||
console.log("No green main commit found");
|
||||
output("sha=\nskip=true\n");
|
||||
return;
|
||||
}
|
||||
const [latest] = loadStates(1);
|
||||
const skip = !requested && latest?.sha === sha;
|
||||
console.log(skip ? `${sha} was tested by run ${latest.runId}; nothing new` : `Test ${sha}`);
|
||||
output(`sha=${sha}\nskip=${skip}\n`);
|
||||
}
|
||||
|
||||
function plan(sha, stateDir) {
|
||||
const jobs = JSON.parse(
|
||||
gh(
|
||||
"api",
|
||||
"--paginate",
|
||||
"--slurp",
|
||||
`repos/${repo()}/actions/runs/${process.env.GITHUB_RUN_ID}/jobs?per_page=100`,
|
||||
),
|
||||
).flatMap((page) => page.jobs);
|
||||
const lanes = laneJobs(jobs);
|
||||
mkdirSync(stateDir, { recursive: true });
|
||||
writeFileSync(join(stateDir, "state.json"), `${JSON.stringify({ sha, jobs: lanes }, null, 2)}\n`);
|
||||
const states = loadStates();
|
||||
const platformList = JSON.parse(readFileSync(platforms, "utf8"));
|
||||
let pushes = [];
|
||||
try {
|
||||
pushes = JSON.parse(
|
||||
gh(
|
||||
"api",
|
||||
"--paginate",
|
||||
"--slurp",
|
||||
`repos/${repo()}/activity?ref=refs/heads/main&per_page=100`,
|
||||
),
|
||||
)
|
||||
.flat()
|
||||
.map((a) => a.after);
|
||||
} catch {
|
||||
console.log("::warning::the activity API did not answer; every commit is its own batch");
|
||||
}
|
||||
const tasks = [];
|
||||
const skipped = [];
|
||||
const used = new Set();
|
||||
for (const [name, conclusion] of Object.entries(lanes)) {
|
||||
if (!red(conclusion)) continue;
|
||||
const { lastGreen, previous } = history(states, name);
|
||||
const found = recipeFor(name, platformList);
|
||||
let reason;
|
||||
if (previous && red(previous.conclusion))
|
||||
reason = `already red at \`${previous.sha.slice(0, 12)}\` (run ${previous.runId}), so it did not turn red here`;
|
||||
else if (!lastGreen) reason = `no green result in the last ${STATE_HISTORY} results`;
|
||||
else if (!found) reason = "no recipe probes this job on one runner";
|
||||
else if (used.has(found.recipe.id))
|
||||
reason = `another ${found.recipe.id} job is bisected in this run`;
|
||||
else if (tasks.length >= MAX_BISECTIONS)
|
||||
reason = `at most ${MAX_BISECTIONS} bisections run at once`;
|
||||
if (reason) {
|
||||
skipped.push({ job: name, reason });
|
||||
continue;
|
||||
}
|
||||
const commits = git("rev-list", "--first-parent", "--reverse", `${lastGreen}..${sha}`)
|
||||
.split("\n")
|
||||
.filter(Boolean);
|
||||
const batchList = batches(commits, pushes);
|
||||
used.add(found.recipe.id);
|
||||
tasks.push({
|
||||
key: `${tasks.length + 1}`,
|
||||
job: name,
|
||||
recipe: found.recipe.id,
|
||||
matrix: found.matrix,
|
||||
runner: found.recipe.runner(found.matrix),
|
||||
setup: found.recipe.setup,
|
||||
good: lastGreen,
|
||||
bad: sha,
|
||||
commits: commits.length,
|
||||
batches: batchList.length,
|
||||
batchList,
|
||||
});
|
||||
}
|
||||
writeFileSync(join(stateDir, "skipped.json"), `${JSON.stringify(skipped, null, 2)}\n`);
|
||||
for (const s of skipped) console.log(`${s.job}: not bisected, ${s.reason}`);
|
||||
// The matrix carries what the bisect job's steps read; the batches go in the state artifact.
|
||||
writeFileSync(join(stateDir, "tasks.json"), `${JSON.stringify(tasks, null, 2)}\n`);
|
||||
const matrix = tasks.map(({ key, job, runner, setup, matrix }) => ({
|
||||
key,
|
||||
job,
|
||||
runner,
|
||||
setup,
|
||||
platform: matrix.platform ?? "",
|
||||
llvm_asset: matrix.llvm_asset ?? "",
|
||||
use_zig: String(Boolean(matrix.use_zig)),
|
||||
}));
|
||||
output(`tasks=${JSON.stringify(matrix)}\n`);
|
||||
}
|
||||
|
||||
/**
|
||||
* The order a probe runs its steps in: the replayed steps that must precede the install (beforeInstall), the
|
||||
* install, the rest of the prelude, and the other replayed steps.
|
||||
*/
|
||||
export function probeOrder(prelude, steps) {
|
||||
return [
|
||||
...steps.filter((step) => step.beforeInstall),
|
||||
prelude[0] ?? install,
|
||||
...prelude.slice(1),
|
||||
...steps.filter((step) => !step.beforeInstall),
|
||||
];
|
||||
}
|
||||
|
||||
function probeCommit(task, recipe, sha, logDir, current, load) {
|
||||
const runnerTemp = process.env.RUNNER_TEMP ?? tmpdir();
|
||||
const probeTemp = mkdtempSync(join(runnerTemp, "probe-"));
|
||||
const log = join(logDir, `${sha.slice(0, 12)}.log`);
|
||||
const say = (text) => appendFileSync(log, `${text}\n`);
|
||||
git("checkout", "--force", "--quiet", sha);
|
||||
// Keep the build caches (node_modules/.cache): the native builds reuse a cached build whose inputs match.
|
||||
git("clean", "-ffdxq", "-e", "/node_modules/.cache/");
|
||||
const env = {
|
||||
...process.env,
|
||||
...recipe.env(task.matrix),
|
||||
SCRIPTC_LIBNODE: join(probeTemp, "libnode"),
|
||||
RUNNER_TEMP: probeTemp,
|
||||
};
|
||||
const exec = (step) => {
|
||||
say(`::group::${step.name}`);
|
||||
const r = spawnSync("bash", ["-eo", "pipefail", "-c", step.run], {
|
||||
env: { ...env, ...step.env },
|
||||
stdio: ["ignore", "pipe", "pipe"],
|
||||
encoding: "utf8",
|
||||
maxBuffer: 1 << 30,
|
||||
timeout: recipe.timeoutMinutes * 60_000,
|
||||
});
|
||||
say(`${r.stdout ?? ""}${r.stderr ?? ""}`);
|
||||
say("::endgroup::");
|
||||
return r.status === 0;
|
||||
};
|
||||
const prelude = recipe.prelude(task.matrix);
|
||||
let steps;
|
||||
try {
|
||||
steps = replaySteps(
|
||||
load(readFileSync(recipe.workflow, "utf8")),
|
||||
recipe,
|
||||
task.matrix,
|
||||
probeTemp,
|
||||
);
|
||||
} catch (error) {
|
||||
// The probed commit's workflow predates the job or a step: replay today's.
|
||||
say(
|
||||
`the commit's ${recipe.workflow} cannot be replayed (${error.message}); replaying the current one`,
|
||||
);
|
||||
steps = replaySteps(load(current[recipe.workflow]), recipe, task.matrix, probeTemp);
|
||||
}
|
||||
for (const step of probeOrder(prelude, steps)) if (!exec(step)) return "fail";
|
||||
return "pass";
|
||||
}
|
||||
|
||||
async function runBisect(taskKey, tasksFile, outDir) {
|
||||
const task = JSON.parse(readFileSync(tasksFile, "utf8")).find((t) => t.key === taskKey);
|
||||
if (!task) throw new Error(`no task ${taskKey}`);
|
||||
const recipe = recipes.find((r) => r.id === task.recipe);
|
||||
mkdirSync(join(outDir, "logs"), { recursive: true });
|
||||
// Today's workflow file, for commits whose own cannot be replayed, and the YAML parser, loaded from this
|
||||
// checkout's dependencies before the first probe removes them.
|
||||
const current = { [recipe.workflow]: readFileSync(recipe.workflow, "utf8") };
|
||||
const { load } = createRequire(join(process.cwd(), "package.json"))("js-yaml");
|
||||
// Leave room for the report inside the bisect job's limit.
|
||||
const deadline = Date.now() + Number(process.env.POSTMERGE_MINUTES ?? 300) * 60_000;
|
||||
let result;
|
||||
try {
|
||||
result = await bisect(
|
||||
task.batchList,
|
||||
async (sha) => {
|
||||
const r = probeCommit(task, recipe, sha, join(outDir, "logs"), current, load);
|
||||
console.log(`${sha}: ${r}`);
|
||||
return r;
|
||||
},
|
||||
{ deadline },
|
||||
);
|
||||
} catch (error) {
|
||||
result = { outcome: "error", error: String(error?.message ?? error), probes: [] };
|
||||
}
|
||||
writeFileSync(join(outDir, "result.json"), `${JSON.stringify({ task, result }, null, 2)}\n`);
|
||||
console.log(formatResult(task, result));
|
||||
}
|
||||
|
||||
function report(dir, stateDir) {
|
||||
const state = JSON.parse(readFileSync(join(stateDir, "state.json"), "utf8"));
|
||||
const skipped = existsSync(join(stateDir, "skipped.json"))
|
||||
? JSON.parse(readFileSync(join(stateDir, "skipped.json"), "utf8"))
|
||||
: [];
|
||||
const results = [];
|
||||
if (existsSync(dir)) {
|
||||
for (const entry of readdirSync(dir).sort()) {
|
||||
const file = join(dir, entry, "result.json");
|
||||
if (existsSync(file)) results.push(JSON.parse(readFileSync(file, "utf8")));
|
||||
}
|
||||
}
|
||||
// A planned bisection that left no result (its job failed or was cancelled) is reported as unfinished.
|
||||
const tasks = existsSync(join(stateDir, "tasks.json"))
|
||||
? JSON.parse(readFileSync(join(stateDir, "tasks.json"), "utf8"))
|
||||
: [];
|
||||
for (const task of tasks)
|
||||
if (!results.some((r) => r.task.key === task.key))
|
||||
results.push({
|
||||
task,
|
||||
result: { outcome: "unfinished", error: "the bisect job left no result", probes: [] },
|
||||
});
|
||||
const describe = (sha) => {
|
||||
try {
|
||||
return git("log", "-1", "--format=%s", sha);
|
||||
} catch {
|
||||
return "";
|
||||
}
|
||||
};
|
||||
const markdown = formatReport({ ...state, skipped, results }, describe);
|
||||
if (process.env.GITHUB_STEP_SUMMARY) appendFileSync(process.env.GITHUB_STEP_SUMMARY, markdown);
|
||||
const out = join(dir, "..", BLAME_ARTIFACT);
|
||||
mkdirSync(out, { recursive: true });
|
||||
writeFileSync(join(out, "blame.md"), markdown);
|
||||
writeFileSync(
|
||||
join(out, "blame.json"),
|
||||
`${JSON.stringify(
|
||||
{
|
||||
sha: state.sha,
|
||||
red: Object.entries(state.jobs)
|
||||
.filter(([, c]) => red(c))
|
||||
.map(([name]) => name),
|
||||
skipped,
|
||||
bisections: results.map(({ task, result }) => ({
|
||||
job: task.job,
|
||||
good: task.good,
|
||||
bad: task.bad,
|
||||
outcome: result.outcome,
|
||||
firstBad: result.firstBad,
|
||||
candidates: result.candidates,
|
||||
probes: result.probes,
|
||||
})),
|
||||
},
|
||||
null,
|
||||
2,
|
||||
)}\n`,
|
||||
);
|
||||
console.log(markdown);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const [command, ...args] = process.argv.slice(2);
|
||||
const option = (name) => (args.includes(name) ? args[args.indexOf(name) + 1] : undefined);
|
||||
switch (command) {
|
||||
case "pick":
|
||||
return pick();
|
||||
case "plan":
|
||||
return plan(option("--sha"), option("--state"));
|
||||
case "bisect": {
|
||||
// Probing checks out other commits; run from a copy so this script stays the one that started.
|
||||
const self = fileURLToPath(import.meta.url);
|
||||
if (!process.env.POSTMERGE_COPY) {
|
||||
const copy = join(
|
||||
mkdtempSync(join(process.env.RUNNER_TEMP ?? tmpdir(), "postmerge-")),
|
||||
"postmerge.mjs",
|
||||
);
|
||||
copyFileSync(self, copy);
|
||||
const r = spawnSync(process.execPath, [copy, command, ...args], {
|
||||
stdio: "inherit",
|
||||
env: { ...process.env, POSTMERGE_COPY: "1" },
|
||||
});
|
||||
process.exit(r.status ?? 1);
|
||||
}
|
||||
return runBisect(option("--task"), option("--tasks"), option("--out"));
|
||||
}
|
||||
case "report":
|
||||
return report(option("--dir"), option("--state"));
|
||||
default:
|
||||
console.error(
|
||||
"usage: postmerge.mjs pick | plan --sha <sha> --state <dir> | bisect --task <key> --tasks <file> --out <dir> | report --dir <dir> --state <dir>",
|
||||
);
|
||||
process.exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) await main();
|
||||
@@ -6,6 +6,9 @@ import { Writable } from "node:stream";
|
||||
|
||||
function fake(highWaterMark) {
|
||||
const listeners = new Map();
|
||||
const emit = (name, arg) => {
|
||||
for (const fn of listeners.get(name) ?? []) fn(arg);
|
||||
};
|
||||
const target = {
|
||||
writable: true,
|
||||
destroyed: false,
|
||||
@@ -15,16 +18,26 @@ function fake(highWaterMark) {
|
||||
},
|
||||
end() {
|
||||
target.writable = false;
|
||||
setImmediate(() => {
|
||||
emit("finish");
|
||||
emit("close");
|
||||
});
|
||||
},
|
||||
destroy() {
|
||||
target.destroyed = true;
|
||||
setImmediate(() => emit("close"));
|
||||
},
|
||||
on(name, fn) {
|
||||
const list = listeners.get(name);
|
||||
if (list) list.push(fn);
|
||||
else listeners.set(name, [fn]);
|
||||
return target;
|
||||
},
|
||||
removeListener(name, fn) {
|
||||
const list = listeners.get(name);
|
||||
if (list) listeners.set(name, list.filter((entry) => entry !== fn));
|
||||
return target;
|
||||
},
|
||||
removeListener() {},
|
||||
};
|
||||
return target;
|
||||
}
|
||||
@@ -46,9 +59,11 @@ for (const [label, highWaterMark] of [
|
||||
console.log(label, thrown, first);
|
||||
}
|
||||
|
||||
// A well-formed duck writable still adapts and can be dropped.
|
||||
// A well-formed duck writable still adapts; closing the stream releases the
|
||||
// adapter. A dropped WritableStream keeps its adapter until it closes, and
|
||||
// the sanitized lane's audit fails any runtime value still live at exit.
|
||||
for (let i = 0; i < 10; i++) {
|
||||
const web = Writable.toWeb(fake(16));
|
||||
web.getWriter().releaseLock();
|
||||
const writer = Writable.toWeb(fake(16)).getWriter();
|
||||
await writer.close();
|
||||
}
|
||||
console.log("done");
|
||||
|
||||
@@ -14,11 +14,16 @@ import {
|
||||
tagRequest,
|
||||
} from "../../scripts/ci/green-tag.mjs";
|
||||
|
||||
// The tag job lives beside CI (green-tag.yml): ci.yml is a reusable workflow the
|
||||
// post-merge lanes call read-only, and a `contents: write` job inside it would make
|
||||
// every such call invalid (postmerge.test.ts pins the ceiling).
|
||||
const workflow = load(
|
||||
readFileSync(new URL("../../.github/workflows/ci.yml", import.meta.url), "utf8"),
|
||||
readFileSync(new URL("../../.github/workflows/green-tag.yml", import.meta.url), "utf8"),
|
||||
) as {
|
||||
on: { push: { branches: string[] }; pull_request: { branches?: string[] } };
|
||||
concurrency: { group: string };
|
||||
on: {
|
||||
workflow_run: { workflows: string[]; types: string[]; branches: string[] };
|
||||
};
|
||||
concurrency: { group: string; "cancel-in-progress": boolean };
|
||||
jobs: Record<
|
||||
string,
|
||||
{
|
||||
@@ -123,24 +128,25 @@ test("every request writes one green tag and nothing else", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
test("a passing push moves that branch's tag; a failing or non-push run never does", () => {
|
||||
// Push runs on both integration branches; pull requests run on every base (stacks target their lower branch),
|
||||
// and a push's run is not cancelled by the other branch's.
|
||||
expect(workflow.on.push.branches).toEqual(["main", "canary"]);
|
||||
expect(workflow.on.pull_request.branches).toBeUndefined();
|
||||
expect(workflow.concurrency.group).toContain("format('push-{0}', github.ref_name)");
|
||||
const job = workflow.jobs.green_tag!;
|
||||
expect(job.name).toBe("tag green-${{ github.ref_name }}");
|
||||
expect(job.needs).toEqual(["test"]);
|
||||
expect(job.if).toBe("${{ github.event_name == 'push' && needs.test.result == 'success' }}");
|
||||
test("a passing canary push moves the green-canary tag; a failing or non-push run never does", () => {
|
||||
// The CI run on a canary push moves the tag; a pull request's or merge queue's run never does, and a push's
|
||||
// run is not cancelled by the other branch's (ci.yml's per-branch pre-merge groups).
|
||||
expect(workflow.on.workflow_run).toEqual({
|
||||
workflows: ["CI"],
|
||||
types: ["completed"],
|
||||
branches: ["canary"],
|
||||
});
|
||||
expect(workflow.concurrency).toEqual({ group: "green-canary", "cancel-in-progress": false });
|
||||
const job = workflow.jobs.green_canary!;
|
||||
expect(job.name).toBe("tag green-canary");
|
||||
expect(job.if).toContain("github.event.workflow_run.event == 'push'");
|
||||
expect(job.if).toContain("github.event.workflow_run.conclusion == 'success'");
|
||||
// The one permission is the tag write; the job is not part of the required check.
|
||||
expect(job.permissions).toEqual({ contents: "write" });
|
||||
expect(workflow.jobs.test!.needs).not.toContain("green_tag");
|
||||
const step = job.steps!.find((candidate) => candidate.run?.includes("green-tag.mjs"))!;
|
||||
expect(step.run).toBe('node scripts/ci/green-tag.mjs "$SHA" --branch "$BRANCH"');
|
||||
expect(step.run).toBe('node scripts/ci/green-tag.mjs "$SHA" --branch canary');
|
||||
expect(step.env).toEqual({
|
||||
GH_TOKEN: "${{ github.token }}",
|
||||
SHA: "${{ github.sha }}",
|
||||
BRANCH: "${{ github.ref_name }}",
|
||||
SHA: "${{ github.event.workflow_run.head_sha }}",
|
||||
});
|
||||
});
|
||||
|
||||
@@ -275,14 +275,14 @@ test("CI runs the base commit's lane selection against the pull request's diff",
|
||||
expect(lanesScript.match(/every$/gm)).toHaveLength(2);
|
||||
});
|
||||
|
||||
function runLanes(event: string, tier = "full") {
|
||||
function runLanes(event: string, tier = "full", onlyLane = "") {
|
||||
const directory = mkdtempSync(join(tmpdir(), "ci-lanes-"));
|
||||
try {
|
||||
const output = join(directory, "output");
|
||||
writeFileSync(output, "");
|
||||
const result = spawnSync("bash", ["-e", "-o", "pipefail", "-c", lanesScript], {
|
||||
encoding: "utf8",
|
||||
env: { ...process.env, EVENT: event, TIER: tier, GITHUB_OUTPUT: output },
|
||||
env: { ...process.env, EVENT: event, TIER: tier, ONLY_LANE: onlyLane, GITHUB_OUTPUT: output },
|
||||
});
|
||||
expect(result.status, result.stderr).toBe(0);
|
||||
return readFileSync(output, "utf8");
|
||||
@@ -291,7 +291,7 @@ function runLanes(event: string, tier = "full") {
|
||||
}
|
||||
}
|
||||
|
||||
test("pushes to main and merge queue groups name every lane, and say which tier they run; the nightly sweep and manual runs run every lane", () => {
|
||||
test("pushes to main and merge queue groups run every lane except macos, and the macOS smoke job, and say which tier they run; the nightly sweep runs every lane but macos, and manual runs every lane", () => {
|
||||
// A push to main runs the global lanes the merge queue leaves out; a merge queue group runs the fast gate.
|
||||
expect(runLanes("push")).toBe(
|
||||
"linux=true\nmacos=false\neffects=true\nbootstrap=true\nprofile=true\nislands=true\nmacos_smoke=true\nqueue=false\npost=true\n",
|
||||
@@ -301,10 +301,13 @@ test("pushes to main and merge queue groups name every lane, and say which tier
|
||||
);
|
||||
// The workflow starts on a merge queue group, which is what would become main.
|
||||
expect("merge_group" in workflow.on).toBe(true);
|
||||
for (const event of ["schedule", "workflow_dispatch"])
|
||||
expect(runLanes(event), event).toBe(
|
||||
"linux=true\nmacos=true\neffects=true\nbootstrap=true\nprofile=true\nislands=true\nmacos_smoke=false\nqueue=false\npost=false\n",
|
||||
);
|
||||
// The complete macOS suite runs in the post-merge lanes (postmerge.yml), not in the nightly sweep.
|
||||
expect(runLanes("schedule")).toBe(
|
||||
"linux=true\nmacos=false\neffects=true\nbootstrap=true\nprofile=true\nislands=true\nmacos_smoke=false\nqueue=false\npost=false\n",
|
||||
);
|
||||
expect(runLanes("workflow_dispatch")).toBe(
|
||||
"linux=true\nmacos=true\neffects=true\nbootstrap=true\nprofile=true\nislands=true\nmacos_smoke=false\nqueue=false\npost=false\n",
|
||||
);
|
||||
expect(workflow.on.workflow_dispatch.inputs["macos_suite"]).toEqual({
|
||||
description: "The test suite to run on macOS",
|
||||
type: "choice",
|
||||
@@ -358,3 +361,25 @@ test("every job on a macOS runner is in the macos lane, but the main push smoke
|
||||
expect(smoke.strategy).toBeUndefined();
|
||||
expect(smoke.env).toMatchObject({ SCRIPTC_CI_SUITE: "darwin-smoke", SCRIPTC_TEST_SHARD: "1/1" });
|
||||
});
|
||||
|
||||
test("a post-merge call runs only the lane it names, whatever event started its caller", () => {
|
||||
for (const event of ["workflow_run", "schedule", "workflow_dispatch", "push"])
|
||||
expect(runLanes(event, "full", "macos"), event).toBe(
|
||||
"linux=false\nmacos=true\neffects=false\nbootstrap=false\nprofile=false\nislands=false\nmacos_smoke=false\n",
|
||||
);
|
||||
const directory = mkdtempSync(join(tmpdir(), "ci-lanes-"));
|
||||
try {
|
||||
const result = spawnSync("bash", ["-e", "-o", "pipefail", "-c", lanesScript], {
|
||||
encoding: "utf8",
|
||||
env: {
|
||||
...process.env,
|
||||
EVENT: "schedule",
|
||||
ONLY_LANE: "linux",
|
||||
GITHUB_OUTPUT: join(directory, "out"),
|
||||
},
|
||||
});
|
||||
expect(result.status).toBe(1);
|
||||
} finally {
|
||||
rmSync(directory, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
@@ -4,7 +4,6 @@ import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { load } from "js-yaml";
|
||||
import { expect, test } from "vitest";
|
||||
import { CANARY_SUITES } from "../../scripts/ci/canary-suite.mjs";
|
||||
|
||||
type Job = {
|
||||
needs?: string | string[];
|
||||
@@ -21,10 +20,8 @@ const scopeScript = scopeJob.steps!.find((step) => step.id === "scope")!.run!;
|
||||
// Validation jobs that run only nightly and on manual runs, outside the
|
||||
// required check (the shape overlay over the real-package suites).
|
||||
const nightlyJobs = ["shape_overlay_native", "shape_overlay"];
|
||||
// The tag job follows the required check and is not part of it.
|
||||
const heavyJobs = Object.keys(workflow.jobs).filter(
|
||||
(name) =>
|
||||
!["validation_scope", "code_quality", "test", "green_tag", ...nightlyJobs].includes(name),
|
||||
(name) => !["validation_scope", "code_quality", "test", ...nightlyJobs].includes(name),
|
||||
);
|
||||
|
||||
const repository = "vercel-labs/scriptc";
|
||||
@@ -200,33 +197,13 @@ const laneOf = (name: string) => {
|
||||
return laneNames.find((lane) => condition.includes(`needs.lanes.outputs.${lane} == 'true'`));
|
||||
};
|
||||
|
||||
test("a pull request into canary runs the fast tier, and ci:full opts it into the full suite", () => {
|
||||
// Canary's merge queue and post-merge runs take the lighter canary tier; main's keep the full tier. A pull
|
||||
// request into canary stays fast, and the ci:full label still opts it into the full suite.
|
||||
expect(
|
||||
runScopeOutputs("push", { repository: { full_name: repository }, ref: "refs/heads/canary" }),
|
||||
).toBe("full=true\ntier=canary\n");
|
||||
expect(
|
||||
runScopeOutputs("push", { repository: { full_name: repository }, ref: "refs/heads/main" }),
|
||||
).toBe("full=true\ntier=full\n");
|
||||
expect(
|
||||
runScopeOutputs("merge_group", {
|
||||
repository: { full_name: repository },
|
||||
merge_group: { base_ref: "refs/heads/canary" },
|
||||
}),
|
||||
).toBe("full=true\ntier=canary\n");
|
||||
expect(
|
||||
runScopeOutputs("merge_group", {
|
||||
repository: { full_name: repository },
|
||||
merge_group: { base_ref: "refs/heads/main" },
|
||||
}),
|
||||
).toBe("full=true\ntier=full\n");
|
||||
test("a pull request runs the fast tier unless the ci:full label asks for the full suite", () => {
|
||||
const ordinary = {
|
||||
repository: { full_name: repository, default_branch: "canary" },
|
||||
repository: { full_name: repository, default_branch: "main" },
|
||||
pull_request: {
|
||||
author_association: "MEMBER",
|
||||
head: { repo: { full_name: repository } },
|
||||
base: { ref: "canary", repo: { full_name: repository } },
|
||||
base: { ref: "main", repo: { full_name: repository } },
|
||||
labels: [{ name: "enhancement" }],
|
||||
},
|
||||
};
|
||||
@@ -266,8 +243,9 @@ test("a superseded dispatch passes the required check and reports no status", ()
|
||||
test("nightly validation jobs run only on schedule or manual runs, outside the required check", () => {
|
||||
for (const name of nightlyJobs) {
|
||||
expect(workflow.jobs[name], name).toBeDefined();
|
||||
// A post-merge call (only_lane) starts from a schedule or manual caller too, and runs none of them.
|
||||
expect(workflow.jobs[name]!.if, name).toBe(
|
||||
"${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' && inputs.pr == '' }}",
|
||||
"${{ !inputs.only_lane && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' && inputs.pr == '') }}",
|
||||
);
|
||||
expect(workflow.jobs.test!.needs, name).not.toContain(name);
|
||||
}
|
||||
@@ -445,26 +423,17 @@ function runGate(
|
||||
return spawnSync("bash", ["-e", "-o", "pipefail", "-c", script], { encoding: "utf8" });
|
||||
}
|
||||
|
||||
test("a pull request into canary runs the fast tier, and the release pull request into main the full tier", () => {
|
||||
test("the fast tier needs no gate on the default branch, and other events never take it", () => {
|
||||
const ordinary = {
|
||||
repository: { full_name: repository, default_branch: "canary" },
|
||||
repository: { full_name: repository, default_branch: "main" },
|
||||
pull_request: {
|
||||
author_association: "MEMBER",
|
||||
head: { repo: { full_name: repository } },
|
||||
base: { ref: "canary", repo: { full_name: repository } },
|
||||
base: { ref: "main", repo: { full_name: repository } },
|
||||
labels: [],
|
||||
},
|
||||
};
|
||||
expect(runScopeOutputs("pull_request", ordinary)).toBe("full=true\ntier=fast\n");
|
||||
// The canary -> main release pull request runs the full tier.
|
||||
const release = {
|
||||
...ordinary,
|
||||
pull_request: {
|
||||
...ordinary.pull_request,
|
||||
base: { ref: "main", repo: { full_name: repository } },
|
||||
},
|
||||
};
|
||||
expect(runScopeOutputs("pull_request", release)).toBe("full=true\ntier=full\n");
|
||||
// The label asks for the full suite in the pull request's own run.
|
||||
const labeled = {
|
||||
...ordinary,
|
||||
@@ -476,31 +445,6 @@ test("a pull request into canary runs the fast tier, and the release pull reques
|
||||
);
|
||||
});
|
||||
|
||||
test("a canary post-merge passes on the fast jobs and the canary tests, not the heavy lanes", () => {
|
||||
const canaryLanes = {
|
||||
linux: "false",
|
||||
macos: "false",
|
||||
effects: "false",
|
||||
bootstrap: "false",
|
||||
macos_smoke: "false",
|
||||
fast: "true",
|
||||
};
|
||||
expect(runGate("true", {}, canaryLanes, "canary").status).toBe(0);
|
||||
// The fast tier and the canary tests are required on canary.
|
||||
expect(runGate("true", { fast_tests: "failure" }, canaryLanes, "canary").status).toBe(1);
|
||||
// The lane selector picks the canary tier, and the fast job adds the source-rule and snapshot tests there.
|
||||
const lanesScript = workflow.jobs.lanes!.steps!.find((step) => step.id === "lanes")!.run!;
|
||||
expect(lanesScript).toContain('"$TIER" = canary');
|
||||
const canaryStep = workflow.jobs.fast_tests!.steps!.find(
|
||||
(step) => step.name === "Canary source-rule and snapshot tests",
|
||||
)!;
|
||||
expect(canaryStep.if).toBe("needs.validation_scope.outputs.tier == 'canary'");
|
||||
// The workflow runs the suite script, and the script names the source-rule and snapshot tests.
|
||||
expect(canaryStep.run?.trim()).toBe("node scripts/ci/canary-suite.mjs");
|
||||
expect(CANARY_SUITES).toContain("tests/harness/diagnostics.test.ts");
|
||||
expect(CANARY_SUITES).toContain("tests/harness/surface-manifest.test.ts");
|
||||
});
|
||||
|
||||
test("the required test check passes only after full validation", () => {
|
||||
expect(runGate("true").status).toBe(0);
|
||||
// A lane that is off may skip its jobs; a lane that is on may not.
|
||||
|
||||
@@ -573,7 +573,7 @@ test("pull requests run the full suite on Linux and the darwin suite on macOS",
|
||||
expect(linux.steps.some((step) => step.uses === "./.github/actions/llvm-linux")).toBe(true);
|
||||
expect(
|
||||
linux.steps.find((step) => step.uses?.startsWith("actions/download-artifact"))!.with!.name,
|
||||
).toBe("native-linux-x64-gnu");
|
||||
).toBe("ci-native-linux-x64-gnu");
|
||||
expect(macos["runs-on"]).toBe("macos-15");
|
||||
expect(macos.needs).toContain("native_macos");
|
||||
// Pull requests and manual runs with macos_suite set to darwin run the darwin
|
||||
|
||||
@@ -0,0 +1,607 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { load } from "js-yaml";
|
||||
import { expect, test } from "vitest";
|
||||
import {
|
||||
BLAME_ARTIFACT,
|
||||
MAX_PROBES,
|
||||
STATE_ARTIFACT,
|
||||
batches,
|
||||
bisect,
|
||||
formatReport,
|
||||
history,
|
||||
laneJobs,
|
||||
nativePackages,
|
||||
probeOrder,
|
||||
recipeFor,
|
||||
recipes,
|
||||
replaySteps,
|
||||
search,
|
||||
substitute,
|
||||
collectStates,
|
||||
trustedRuns,
|
||||
validState,
|
||||
} from "../../scripts/postmerge.mjs";
|
||||
|
||||
const root = join(import.meta.dirname, "../..");
|
||||
const read = (path: string) => readFileSync(join(root, path), "utf8");
|
||||
|
||||
type Step = {
|
||||
name?: string;
|
||||
uses?: string;
|
||||
run?: string;
|
||||
if?: string;
|
||||
with?: Record<string, unknown>;
|
||||
};
|
||||
type Job = {
|
||||
name?: string;
|
||||
if?: string;
|
||||
uses?: string;
|
||||
with?: Record<string, unknown>;
|
||||
needs?: string | string[];
|
||||
permissions?: Record<string, string>;
|
||||
"runs-on"?: string;
|
||||
"timeout-minutes"?: number | string;
|
||||
steps?: Step[];
|
||||
};
|
||||
type Workflow = {
|
||||
name: string;
|
||||
on: Record<string, any>;
|
||||
concurrency?: { group: string; "cancel-in-progress": unknown };
|
||||
permissions?: Record<string, string>;
|
||||
jobs: Record<string, Job>;
|
||||
};
|
||||
const workflow = (path: string) => load(read(path)) as Workflow;
|
||||
|
||||
const postmerge = workflow(".github/workflows/postmerge.yml");
|
||||
const ci = workflow(".github/workflows/ci.yml");
|
||||
const dryRun = workflow(".github/workflows/release-dry-run.yml");
|
||||
const releaseBuild = workflow(".github/workflows/release-build.yml");
|
||||
const platforms = JSON.parse(read(".github/release-platforms.json")) as Record<string, any>[];
|
||||
// The workflows the post-merge lanes call, directly or through another call.
|
||||
const callable = [
|
||||
".github/workflows/ci.yml",
|
||||
".github/workflows/release-dry-run.yml",
|
||||
".github/workflows/release-build.yml",
|
||||
".github/workflows/libnode-packs.yml",
|
||||
];
|
||||
|
||||
test("the post-merge lanes run one at a time on main's green CI pushes and a schedule", () => {
|
||||
expect(postmerge.on.workflow_run).toEqual({
|
||||
workflows: [ci.name],
|
||||
types: ["completed"],
|
||||
branches: ["main"],
|
||||
});
|
||||
expect(postmerge.on.schedule).toHaveLength(1);
|
||||
expect(postmerge.on.workflow_dispatch.inputs.sha.default).toBe("");
|
||||
// One group without cancel-in-progress: a running run (and its bisection) finishes, and GitHub keeps only the
|
||||
// newest pending run.
|
||||
expect(postmerge.concurrency).toEqual({ group: "postmerge", "cancel-in-progress": false });
|
||||
expect(postmerge.jobs.pick!.if).toContain("github.event.workflow_run.conclusion == 'success'");
|
||||
expect(postmerge.jobs.pick!.if).toContain("github.event.workflow_run.event == 'push'");
|
||||
});
|
||||
|
||||
test("the post-merge lanes test the picked commit with the macos lane and the release rehearsal", () => {
|
||||
const sha = "${{ needs.pick.outputs.sha }}";
|
||||
const macos = postmerge.jobs.macos!;
|
||||
expect(macos.uses).toBe("./.github/workflows/ci.yml");
|
||||
expect(macos.with).toEqual({ ref: sha, only_lane: "macos", macos_suite: "full" });
|
||||
const rehearsal = postmerge.jobs.rehearsal!;
|
||||
expect(rehearsal.uses).toBe("./.github/workflows/release-dry-run.yml");
|
||||
expect(rehearsal.with).toEqual({ ref: sha });
|
||||
for (const job of [macos, rehearsal])
|
||||
expect(job.if).toBe("${{ needs.pick.outputs.skip == 'false' }}");
|
||||
// The lane jobs' names are what the recipes and the state key on.
|
||||
expect(macos.name).toBe("macos");
|
||||
expect(rehearsal.name).toBe("rehearsal");
|
||||
expect(postmerge.jobs.plan!.needs).toEqual(["pick", "macos", "rehearsal"]);
|
||||
});
|
||||
|
||||
test("the post-merge lanes only read: no job can open an issue or a pull request, or push", () => {
|
||||
expect(postmerge.permissions).toEqual({ contents: "read" });
|
||||
for (const [name, job] of Object.entries(postmerge.jobs)) {
|
||||
for (const [scope, level] of Object.entries(job.permissions ?? {}))
|
||||
expect(level, `${name} ${scope}`).toBe("read");
|
||||
if (job.uses === undefined) expect(job["timeout-minutes"], name).toBeDefined();
|
||||
}
|
||||
const text = read(".github/workflows/postmerge.yml");
|
||||
expect(text).not.toMatch(/gh (issue|pr) /);
|
||||
const script = read("scripts/postmerge.mjs");
|
||||
expect(script).not.toMatch(/"(issue|pr)", "create"|\/issues|\/pulls|--method|-X POST/);
|
||||
// The artifacts the script reads and writes are the ones the workflow uploads.
|
||||
expect(text).toContain(`name: ${STATE_ARTIFACT}`);
|
||||
expect(text).toContain(`name: ${BLAME_ARTIFACT}`);
|
||||
});
|
||||
|
||||
test("every workflow the post-merge lanes call takes a ref and checks it out", () => {
|
||||
for (const path of callable) {
|
||||
const wf = workflow(path);
|
||||
expect(wf.on.workflow_call?.inputs?.ref, path).toEqual(
|
||||
expect.objectContaining({ type: "string", default: "" }),
|
||||
);
|
||||
for (const [name, job] of Object.entries(wf.jobs)) {
|
||||
// A nested call passes the ref on.
|
||||
if (job.uses?.startsWith("./.github/workflows/")) {
|
||||
expect(job.with?.ref, `${path} ${name}`).toBe("${{ inputs.ref }}");
|
||||
continue;
|
||||
}
|
||||
// A pull request's fast tier checks out the pull request; a post-merge call turns that tier off.
|
||||
if (job.if?.includes("needs.lanes.outputs.fast == 'true'")) continue;
|
||||
for (const step of job.steps ?? []) {
|
||||
if (!step.uses?.startsWith("actions/checkout@")) continue;
|
||||
// The lane selector's checkout runs on pull requests alone, at the pull request's head.
|
||||
// (and on a pull request's dispatched expensive tier, which a post-merge call never is).
|
||||
if (step.if?.startsWith("github.event_name == 'pull_request'")) continue;
|
||||
expect(step.with?.ref, `${path} ${name}`).toBe("${{ inputs.ref }}");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test("a post-merge call of CI runs in its own concurrency group and skips the nightly-only jobs", () => {
|
||||
expect(ci.concurrency!.group).toMatch(
|
||||
/^ci-\$\{\{ inputs\.only_lane && format\('postmerge-\{0\}', github\.run_id\) \|\|/,
|
||||
);
|
||||
expect(dryRun.concurrency!.group).toContain(
|
||||
"inputs.ref && format('postmerge-{0}', github.run_id)",
|
||||
);
|
||||
// The rehearsal no longer has a nightly schedule of its own; the post-merge lanes run it.
|
||||
expect(dryRun.on.schedule).toBeUndefined();
|
||||
for (const [name, job] of Object.entries(ci.jobs))
|
||||
if (
|
||||
job.if?.includes("github.event_name == 'schedule'") &&
|
||||
!job.if.includes("needs.lanes.outputs")
|
||||
)
|
||||
expect(job.if, name).toContain("!inputs.only_lane");
|
||||
});
|
||||
|
||||
// Job names as the jobs API reports them in a post-merge run: "<caller> / [<nested caller> / ]<job>".
|
||||
function macosJobNames(id: string): string[] {
|
||||
const job = ci.jobs[id]!;
|
||||
const full = String(job.name).replace(
|
||||
/\$\{\{ \(github\.event_name != 'schedule' && inputs\.macos_suite != 'full'\) && '([^']*)' \|\| '([^']*)' \}\}/g,
|
||||
"$2",
|
||||
);
|
||||
const matrix = (job as any).strategy?.matrix ?? {};
|
||||
const flavors: string[] = matrix.flavor ?? [""];
|
||||
const shards: string[] = String(matrix.shard ?? "").includes("fromJSON")
|
||||
? Array.from({ length: 10 }, (_, i) => String(i + 1))
|
||||
: (matrix.shard ?? [""]).map(String);
|
||||
const runtimes: string[] = matrix.runtime ?? [""];
|
||||
const names = [];
|
||||
for (const flavor of flavors)
|
||||
for (const shard of shards)
|
||||
for (const runtime of runtimes)
|
||||
names.push(
|
||||
`macos / ${full
|
||||
.replaceAll("${{ matrix.flavor }}", flavor)
|
||||
.replaceAll("${{ matrix.shard }}", shard)
|
||||
.replaceAll("${{ matrix.runtime }}", runtime)}`,
|
||||
);
|
||||
return names;
|
||||
}
|
||||
|
||||
// Jobs no recipe probes on one runner, and why.
|
||||
const unprobed: Record<string, string> = {
|
||||
// ci.yml's macos lane: built through the mobile-runtime-pack action.
|
||||
mobile_runtime_packs_ios: "composite action",
|
||||
// release-build.yml and release-dry-run.yml: they need other jobs' artifacts, or are not platform builds.
|
||||
plan: "reads a file",
|
||||
"cli-layout": "not run by the rehearsal",
|
||||
"cli-profile": "not run by the rehearsal",
|
||||
mobile: "composite action",
|
||||
assemble: "needs every platform's artifacts",
|
||||
};
|
||||
|
||||
test("every job of the macos lane has a recipe that matches its names", () => {
|
||||
const macosLane = Object.entries(ci.jobs)
|
||||
.filter(([, job]) => job.if?.includes("needs.lanes.outputs.macos == 'true'"))
|
||||
.map(([id]) => id);
|
||||
expect(macosLane.length).toBeGreaterThan(4);
|
||||
for (const id of macosLane) {
|
||||
if (id in unprobed) continue;
|
||||
const recipe = recipes.find(
|
||||
(r: { job: string; workflow: string }) => r.job === id && r.workflow.endsWith("ci.yml"),
|
||||
);
|
||||
expect(recipe, id).toBeDefined();
|
||||
for (const name of macosJobNames(id))
|
||||
expect(recipeFor(name, platforms)?.recipe.id, name).toBe(recipe.id);
|
||||
}
|
||||
});
|
||||
|
||||
test("the rehearsal's platform builds have recipes that match their names", () => {
|
||||
const prefix = `rehearsal / ${dryRun.jobs.build!.name} /`;
|
||||
expect(dryRun.jobs.build!.uses).toBe("./.github/workflows/release-build.yml");
|
||||
for (const id of Object.keys(releaseBuild.jobs)) {
|
||||
if (id in unprobed) continue;
|
||||
const recipe = recipes.find(
|
||||
(r: { job: string; workflow: string }) =>
|
||||
r.job === id && r.workflow.endsWith("release-build.yml"),
|
||||
);
|
||||
expect(recipe, id).toBeDefined();
|
||||
for (const platform of platforms) {
|
||||
const name = `${prefix} ${String(releaseBuild.jobs[id]!.name).replace("${{ matrix.platform }}", platform.platform)}`;
|
||||
const found = recipeFor(name, platforms);
|
||||
if (platform.platform === "windows-x64") expect(found, name).toBeUndefined();
|
||||
else {
|
||||
expect(found?.recipe.id, name).toBe(recipe.id);
|
||||
expect(found!.recipe.runner(found!.matrix), name).toBe(platform.runner);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const id of ["libnode", "assemble"]) expect(dryRun.jobs[id], id).toBeDefined();
|
||||
});
|
||||
|
||||
test("every recipe replays the current workflow's steps without an expression it cannot fill in", () => {
|
||||
const files: Record<string, Workflow> = {
|
||||
".github/workflows/ci.yml": ci,
|
||||
".github/workflows/release-build.yml": releaseBuild,
|
||||
};
|
||||
for (const recipe of recipes) {
|
||||
const matrices = recipe.platform
|
||||
? platforms.filter((p) => p.platform !== "windows-x64").map((p) => ({ ...p }))
|
||||
: [{ flavor: "san", shard: "3" }];
|
||||
for (const matrix of matrices) {
|
||||
const steps = replaySteps(files[recipe.workflow], recipe, matrix, "/tmp/probe");
|
||||
expect(steps.length, recipe.id).toBe(
|
||||
recipe.steps.filter((s: { when?: (m: unknown) => boolean }) => !s.when || s.when(matrix))
|
||||
.length +
|
||||
(recipe.packsFirst ? 2 : 0) -
|
||||
(recipe.packsFirst && !matrix.seed_helper ? 1 : 0) +
|
||||
(recipe.packsFirst && String(matrix.cli_target ?? "").endsWith("-musl") ? 1 : 0),
|
||||
);
|
||||
for (const step of steps) {
|
||||
expect(step.run, `${recipe.id} ${step.name}`).not.toContain("${{");
|
||||
for (const value of Object.values(step.env)) expect(value).not.toContain("${{");
|
||||
}
|
||||
}
|
||||
}
|
||||
// The tests_macos recipe runs the job's own test command, with the job's environment for the complete suite.
|
||||
// Steps after it keep the failure report; the command is the job's last step that runs something.
|
||||
const tests = recipes.find((r: { id: string }) => r.id === "tests_macos");
|
||||
const testCommand = ci.jobs
|
||||
.tests_macos!.steps!.filter((step) => step.run !== undefined)
|
||||
.at(-1)!.run;
|
||||
expect(replaySteps(ci, tests, {}, "/tmp").map((s: { run: string }) => s.run)).toEqual([
|
||||
testCommand,
|
||||
]);
|
||||
expect(tests.env({ flavor: "san", shard: "4" })).toEqual({
|
||||
SCRIPTC_TEST_WORKERS: "4",
|
||||
SCRIPTC_SAN: "1",
|
||||
SCRIPTC_TEST_SHARD: "4/10",
|
||||
SCRIPTC_CI_SUITE: "full",
|
||||
});
|
||||
});
|
||||
|
||||
test("the probes' fixed commands are the ones the actions they stand for run", () => {
|
||||
const action = read(".github/actions/native-packages/action.yml");
|
||||
for (const target of ["darwin-arm64", "darwin-x64"])
|
||||
for (const line of nativePackages(target).run.split("\n")) expect(action, line).toContain(line);
|
||||
for (const line of nativePackages("x", { linux: true }).run.split("\n"))
|
||||
expect(action, line).toContain(line);
|
||||
expect(read(".github/actions/libnode/action.yml")).toContain(
|
||||
"node packages/libnode-common/fetch-dev-pack.mjs --out",
|
||||
);
|
||||
});
|
||||
|
||||
test("substitute fills in matrix values and the runner's temporary directory, and nothing else", () => {
|
||||
expect(
|
||||
substitute(
|
||||
"pnpm --filter @scriptc/${{ matrix.helper }} -o ${{ runner.temp }}/x",
|
||||
{ helper: "llvm-a" },
|
||||
"/t",
|
||||
),
|
||||
).toBe("pnpm --filter @scriptc/llvm-a -o /t/x");
|
||||
expect(substitute("${{ matrix.missing }}", {}, "/t")).toBe("");
|
||||
expect(() => substitute("${{ github.sha }}", {}, "/t")).toThrow(/cannot replay/);
|
||||
});
|
||||
|
||||
test("batches end at each push to main", () => {
|
||||
expect(batches(["a", "b", "c", "d", "e"], ["b", "e", "zzz"])).toEqual([
|
||||
["a", "b"],
|
||||
["c", "d", "e"],
|
||||
]);
|
||||
// Without the activity history every commit is a batch; the red commit always ends one.
|
||||
expect(batches(["a", "b"], [])).toEqual([["a"], ["b"]]);
|
||||
expect(batches(["a", "b", "c"], ["a"])).toEqual([["a"], ["b", "c"]]);
|
||||
expect(batches([], ["a"])).toEqual([]);
|
||||
});
|
||||
|
||||
const probeWith = (firstBad: string, order: string[]) => {
|
||||
const probed: string[] = [];
|
||||
const probe = async (sha: string) => {
|
||||
probed.push(sha);
|
||||
return order.indexOf(sha) >= order.indexOf(firstBad) ? "fail" : "pass";
|
||||
};
|
||||
return { probe, probed };
|
||||
};
|
||||
|
||||
test("search finds the first failing item in about log2(n) probes", async () => {
|
||||
const items = Array.from({ length: 16 }, (_, i) => `c${i}`);
|
||||
for (const bad of items) {
|
||||
const { probe, probed } = probeWith(bad, items);
|
||||
const { firstBad } = await search(items, probe);
|
||||
expect(items[firstBad!]).toBe(bad);
|
||||
expect(probed.length).toBeLessThanOrEqual(4);
|
||||
// The last item is known bad and is never probed again.
|
||||
expect(probed).not.toContain("c15");
|
||||
}
|
||||
});
|
||||
|
||||
test("a bisection names the first bad commit inside the first bad batch", async () => {
|
||||
const list = [["a"], ["b", "c", "d"], ["e"], ["f", "g"]];
|
||||
const order = list.flat();
|
||||
const { probe, probed } = probeWith("c", order);
|
||||
const result = await bisect(list, probe);
|
||||
expect(result.outcome).toBe("found");
|
||||
expect(result.firstBad).toBe("c");
|
||||
expect(result.batch).toEqual(["b", "c", "d"]);
|
||||
// The red commit first, then the batches, then the commits of the bad batch.
|
||||
expect(probed[0]).toBe("g");
|
||||
expect(probed.length).toBeLessThanOrEqual(MAX_PROBES);
|
||||
expect(result.probes.map((p: { sha: string }) => p.sha)).toEqual(probed);
|
||||
});
|
||||
|
||||
test("a bisection that does not reproduce the red result stops after one probe", async () => {
|
||||
const result = await bisect([["a"], ["b"]], async () => "pass");
|
||||
expect(result).toEqual({ outcome: "not-reproduced", probes: [{ sha: "b", result: "pass" }] });
|
||||
});
|
||||
|
||||
test("a bisection out of probes reports the range it narrowed the change to", async () => {
|
||||
const list = Array.from({ length: 64 }, (_, i) => [`c${i}`]);
|
||||
const { probe } = probeWith("c40", list.flat());
|
||||
const result = await bisect(list, probe, { maxProbes: 3 });
|
||||
expect(result.outcome).toBe("narrowed");
|
||||
expect(result.probes).toHaveLength(3);
|
||||
expect(result.candidates).toContain("c40");
|
||||
expect(result.candidates.length).toBeLessThan(64);
|
||||
// Out of time behaves the same way.
|
||||
let clock = 0;
|
||||
const timed = await bisect(list, probeWith("c40", list.flat()).probe, {
|
||||
deadline: 2,
|
||||
now: () => clock++,
|
||||
});
|
||||
expect(timed.outcome).toBe("narrowed");
|
||||
});
|
||||
|
||||
test("a job's history gives its last green commit and whether it was already red", () => {
|
||||
const states = [
|
||||
{ sha: "s3", runId: 3, jobs: { "macos / x": "cancelled" } },
|
||||
{ sha: "s2", runId: 2, jobs: { "macos / x": "failure", "macos / y": "success" } },
|
||||
{ sha: "s1", runId: 1, jobs: { "macos / x": "success" } },
|
||||
];
|
||||
expect(history(states, "macos / x")).toEqual({
|
||||
lastGreen: "s1",
|
||||
previous: { sha: "s2", conclusion: "failure", runId: 2 },
|
||||
});
|
||||
expect(history(states, "macos / y").lastGreen).toBe("s2");
|
||||
expect(history(states, "macos / z")).toEqual({ lastGreen: undefined, previous: undefined });
|
||||
});
|
||||
|
||||
test("the state keeps the lane jobs of a run and the report names the first bad commit", () => {
|
||||
const jobs = laneJobs([
|
||||
{ name: "Pick the newest green main commit", status: "completed", conclusion: "success" },
|
||||
{ name: "macos / test (macOS, san, 4/10)", status: "completed", conclusion: "failure" },
|
||||
{
|
||||
name: "rehearsal / Build / Build native package (linux-x64)",
|
||||
status: "completed",
|
||||
conclusion: "success",
|
||||
},
|
||||
{
|
||||
name: "macos / build (macOS arm64 native packages)",
|
||||
status: "in_progress",
|
||||
conclusion: null,
|
||||
},
|
||||
]);
|
||||
expect(jobs).toEqual({
|
||||
"macos / test (macOS, san, 4/10)": "failure",
|
||||
"rehearsal / Build / Build native package (linux-x64)": "success",
|
||||
"macos / build (macOS arm64 native packages)": "in_progress",
|
||||
});
|
||||
const task = {
|
||||
key: "1",
|
||||
job: "macos / test (macOS, san, 4/10)",
|
||||
good: "a".repeat(40),
|
||||
bad: "f".repeat(40),
|
||||
commits: 6,
|
||||
batches: 3,
|
||||
};
|
||||
const report = formatReport(
|
||||
{
|
||||
sha: "f".repeat(40),
|
||||
jobs,
|
||||
skipped: [{ job: "macos / other", reason: "no recipe probes this job on one runner" }],
|
||||
results: [
|
||||
{
|
||||
task,
|
||||
result: {
|
||||
outcome: "found",
|
||||
firstBad: "c".repeat(40),
|
||||
batch: ["b".repeat(40), "c".repeat(40)],
|
||||
probes: [{ sha: "f".repeat(40), result: "fail" }],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
() => "Break darwin",
|
||||
);
|
||||
expect(report).toContain("**First bad commit: `cccccccccccc` Break darwin**");
|
||||
expect(report).toContain("- macos / test (macOS, san, 4/10)");
|
||||
expect(report).toContain("macos / other: no recipe probes this job on one runner");
|
||||
});
|
||||
|
||||
test("a musl platform build lets pnpm install musl packages before the install, as the job does", () => {
|
||||
for (const id of ["release_packs", "release_cli"]) {
|
||||
const recipe = recipes.find((r: { id: string }) => r.id === id);
|
||||
const musl = platforms.find((p) => String(p.cli_target ?? "").endsWith("-musl"))!;
|
||||
const steps = replaySteps(releaseBuild, recipe, musl, "/tmp/probe");
|
||||
const order = probeOrder(recipe.prelude(musl), steps).map(
|
||||
(step: { name: string }) => step.name,
|
||||
);
|
||||
expect(order.indexOf("Let pnpm install musl platform packages"), id).toBe(0);
|
||||
expect(order.indexOf("Install"), id).toBe(1);
|
||||
}
|
||||
// In the job too, the step comes before pnpm install.
|
||||
const packs = releaseBuild.jobs.packs!.steps!;
|
||||
expect(packs.findIndex((s) => s.name === "Let pnpm install musl platform packages")).toBeLessThan(
|
||||
packs.findIndex((s) => s.run === "pnpm install --frozen-lockfile"),
|
||||
);
|
||||
});
|
||||
|
||||
// The artifacts each workflow of a post-merge run uploads, and the patterns it downloads: one run holds them all.
|
||||
function artifactNames(path: string) {
|
||||
const uploads: string[] = [];
|
||||
const downloads: string[] = [];
|
||||
for (const job of Object.values(workflow(path).jobs))
|
||||
for (const step of job.steps ?? []) {
|
||||
const name = step.with?.name;
|
||||
const pattern = step.with?.pattern;
|
||||
if (step.uses?.startsWith("actions/upload-artifact@") && typeof name === "string")
|
||||
uploads.push(name);
|
||||
if (step.uses?.startsWith("actions/download-artifact@"))
|
||||
downloads.push(String(pattern ?? name));
|
||||
}
|
||||
return { uploads, downloads };
|
||||
}
|
||||
const glob = (pattern: string) =>
|
||||
new RegExp(`^${pattern.replace(/\$\{\{[^}]*\}\}/g, ".+").replace(/\*/g, ".*")}$`);
|
||||
|
||||
test("CI's artifacts in a post-merge run neither collide with the rehearsal's nor match what it downloads", () => {
|
||||
const ciNames = artifactNames(".github/workflows/ci.yml");
|
||||
const release = [
|
||||
".github/workflows/release-dry-run.yml",
|
||||
".github/workflows/release-build.yml",
|
||||
".github/workflows/libnode-packs.yml",
|
||||
].map(artifactNames);
|
||||
const releaseUploads = release.flatMap((r) => r.uploads);
|
||||
const releaseDownloads = release.flatMap((r) => r.downloads);
|
||||
expect(ciNames.uploads.length).toBeGreaterThan(3);
|
||||
for (const name of ciNames.uploads) {
|
||||
for (const other of releaseUploads)
|
||||
expect(
|
||||
glob(other).test(name.replace(/\$\{\{[^}]*\}\}/g, "x")) || glob(name).test(other),
|
||||
`${name} / ${other}`,
|
||||
).toBe(false);
|
||||
for (const pattern of releaseDownloads)
|
||||
expect(
|
||||
glob(pattern).test(name.replace(/\$\{\{[^}]*\}\}/g, "x")),
|
||||
`${pattern} matches ${name}`,
|
||||
).toBe(false);
|
||||
}
|
||||
// CI's own downloads find its uploads.
|
||||
for (const pattern of ciNames.downloads)
|
||||
expect(
|
||||
ciNames.uploads.some((name) => glob(pattern).test(name) || pattern === name),
|
||||
pattern,
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
const repository = "vercel-labs/scriptc";
|
||||
const runOf = (id: number, fields: Record<string, unknown> = {}) => ({
|
||||
id,
|
||||
path: ".github/workflows/postmerge.yml",
|
||||
event: "workflow_run",
|
||||
head_branch: "main",
|
||||
head_sha: "b".repeat(40),
|
||||
repository: { full_name: repository },
|
||||
head_repository: { full_name: repository },
|
||||
...fields,
|
||||
});
|
||||
|
||||
test("only this workflow's runs on main, started by its own triggers, count as post-merge results", () => {
|
||||
const runs = [
|
||||
runOf(1),
|
||||
runOf(2, { event: "schedule" }),
|
||||
runOf(3, { event: "workflow_dispatch" }),
|
||||
// A pull request that adds a trigger to postmerge.yml runs it as its own, and can upload a state.
|
||||
runOf(4, { event: "pull_request", head_branch: "feature" }),
|
||||
runOf(5, { event: "pull_request" }),
|
||||
// A dispatch on another branch, and a fork whose branch is also called main.
|
||||
runOf(6, { event: "workflow_dispatch", head_branch: "feature" }),
|
||||
runOf(7, { head_repository: { full_name: "someone/scriptc" } }),
|
||||
runOf(8, { path: ".github/workflows/other.yml" }),
|
||||
runOf(9, { event: "push" }),
|
||||
];
|
||||
expect(trustedRuns(runs, repository).map((run: { id: number }) => run.id)).toEqual([1, 2, 3]);
|
||||
// The state loader reads trusted runs only.
|
||||
const script = read("scripts/postmerge.mjs");
|
||||
const loader = script.slice(
|
||||
script.indexOf("function* trustedRunPages"),
|
||||
script.indexOf("function pick"),
|
||||
);
|
||||
expect(loader).toContain("trustedRuns(");
|
||||
expect(loader).toContain("validState(");
|
||||
});
|
||||
|
||||
test("a state counts only when it is well formed and names a commit its run could have tested", () => {
|
||||
const run = runOf(1);
|
||||
const ancestors = new Set(["a".repeat(40), "b".repeat(40)]);
|
||||
const isAncestor = (sha: string, of: string) => of === "b".repeat(40) && ancestors.has(sha);
|
||||
const good = { sha: "a".repeat(40), jobs: { "macos / test (macOS, san, 4/10)": "success" } };
|
||||
expect(validState(good, run, isAncestor)).toEqual({ ...good, runId: 1 });
|
||||
// A commit that is not the run's or an ancestor of it: a state cannot claim an untested commit was tested.
|
||||
expect(validState({ ...good, sha: "c".repeat(40) }, run, isAncestor)).toBeUndefined();
|
||||
for (const bad of [
|
||||
null,
|
||||
"text",
|
||||
{ ...good, sha: "a".repeat(12) },
|
||||
{ ...good, sha: "A".repeat(40) },
|
||||
{ ...good, jobs: [] },
|
||||
{ ...good, jobs: { "pick / x": "success" } },
|
||||
{ ...good, jobs: { "macos / x": 1 } },
|
||||
{ ...good, jobs: { "macos / x": "success; rm -rf /" } },
|
||||
])
|
||||
expect(validState(bad, run, isAncestor), JSON.stringify(bad)).toBeUndefined();
|
||||
});
|
||||
|
||||
test("runs that found nothing new do not push the last tested commit out of the lookup", () => {
|
||||
// Five scheduled runs that skipped (no state), then the run that tested the commit.
|
||||
const runs = [1, 2, 3, 4, 5, 6, 7].map((id) => ({ id }));
|
||||
const states: Record<number, { sha: string }> = { 6: { sha: "tested" }, 7: { sha: "older" } };
|
||||
const visited: number[] = [];
|
||||
const found = collectStates(runs, 1, (run: { id: number }) => {
|
||||
visited.push(run.id);
|
||||
return states[run.id];
|
||||
});
|
||||
expect(found).toEqual([{ sha: "tested" }]);
|
||||
// It stops once it has enough.
|
||||
expect(visited).toEqual([1, 2, 3, 4, 5, 6]);
|
||||
expect(collectStates(runs, 30, (run: { id: number }) => states[run.id])).toEqual([
|
||||
{ sha: "tested" },
|
||||
{ sha: "older" },
|
||||
]);
|
||||
// pick asks for the newest state, however many runs skipped since.
|
||||
expect(read("scripts/postmerge.mjs")).toContain("loadStates(1)");
|
||||
});
|
||||
|
||||
const LEVEL: Record<string, number> = { none: 0, read: 1, write: 2 };
|
||||
/** Every permission the jobs of a called workflow ask for, at its highest level, following nested calls. */
|
||||
function askedFor(path: string): Record<string, string> {
|
||||
const wf = workflow(path);
|
||||
const asked: Record<string, string> = {};
|
||||
const add = (permissions: Record<string, string> | undefined) => {
|
||||
for (const [scope, level] of Object.entries(permissions ?? {}))
|
||||
if ((LEVEL[level] ?? 0) > (LEVEL[asked[scope] ?? "none"] ?? 0)) asked[scope] = level;
|
||||
};
|
||||
add(wf.permissions);
|
||||
for (const job of Object.values(wf.jobs)) {
|
||||
add(job.permissions);
|
||||
if (job.uses?.startsWith("./.github/workflows/")) add(askedFor(job.uses.slice(2)));
|
||||
}
|
||||
return asked;
|
||||
}
|
||||
|
||||
test("each post-merge call grants every permission the called workflow's jobs ask for", () => {
|
||||
// GitHub rejects a call whose workflow asks for more than the calling job grants, even for jobs that do not run.
|
||||
for (const name of ["macos", "rehearsal"]) {
|
||||
const job = postmerge.jobs[name]!;
|
||||
const granted = job.permissions ?? {};
|
||||
for (const [scope, level] of Object.entries(askedFor(job.uses!.slice(2))))
|
||||
expect(LEVEL[granted[scope] ?? "none"], `${name}: ${scope}: ${level}`).toBeGreaterThanOrEqual(
|
||||
LEVEL[level]!,
|
||||
);
|
||||
}
|
||||
// The post-merge call reports no ci/full status: it tests another commit, and one lane of it. CI's required
|
||||
// check writes no status of its own, so the call has none to report.
|
||||
expect(ci.jobs.test!.steps!.some((step) => step.name === "Report ci/full")).toBe(false);
|
||||
});
|
||||
@@ -0,0 +1,27 @@
|
||||
// Every repository script a workflow runs must exist: a workflow that
|
||||
// references a script the tree does not carry fails its job at run time
|
||||
// (the green-main tag job did after a merge dropped the file).
|
||||
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { expect, test } from "vitest";
|
||||
|
||||
const root = join(import.meta.dirname, "../..");
|
||||
const workflows = join(root, ".github/workflows");
|
||||
|
||||
test("every script a workflow runs exists in the tree", () => {
|
||||
const missing: string[] = [];
|
||||
for (const name of readdirSync(workflows)) {
|
||||
if (!/\.ya?ml$/.test(name)) continue;
|
||||
const text = readFileSync(join(workflows, name), "utf8");
|
||||
for (const line of text.split("\n")) {
|
||||
for (const match of line.matchAll(/\bnode (scripts\/[\w./-]+\.m?js)/g)) {
|
||||
const path = match[1]!;
|
||||
// A step that runs a script only when the checkout carries it
|
||||
// (`[ ! -f path ] || node path`) asks for nothing missing.
|
||||
if (line.includes(`[ ! -f ${path} ]`)) continue;
|
||||
if (!existsSync(join(root, path))) missing.push(`${name}: ${path}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
expect(missing).toEqual([]);
|
||||
});
|
||||
Reference in New Issue
Block a user