Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 0 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
!packages/
!packages/cli/
!packages/cli/package.json
!packages/cli/scripts/
!packages/cli/scripts/warm-cache.mjs
!packages/compiler/
!packages/compiler/package.json
!packages/runtime/
Expand Down
95 changes: 76 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
branches: [main]
pull_request:

concurrency:
group: ci-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
tests:
name: test (${{ matrix.flavor }}, ${{ matrix.shard }}/10)
Expand Down Expand Up @@ -64,6 +68,7 @@ jobs:
--exclude=tests/harness/self-hosting.test.ts
--exclude=tests/harness/self-hosting-llvm-emitter.test.ts
--exclude=tests/harness/self-hosting-native-driver.test.ts
--exclude=tests/harness/self-hosting-bootstrap.test.ts
--exclude=tests/harness/fetch.test.ts
--exclude=tests/harness/npm-static.test.ts
--exclude=tests/harness/surface-manifest.test.ts
Expand All @@ -83,12 +88,6 @@ jobs:
env:
SCRIPTC_TEST_WORKERS: "1"
run: pnpm test tests/harness/self-hosting-llvm-emitter.test.ts
- name: Tests (native compiler bootstrap)
if: matrix.shard == 6
env:
SCRIPTC_TEST_WORKERS: "1"
VITEST_RPC_TIMEOUT: "180000"
run: pnpm test tests/harness/self-hosting-native-driver.test.ts
# These long files otherwise collide in one Vitest file shard and contend
# for the worker RPC. Spread them across jobs with one worker each.
- name: Tests (fetch)
Expand Down Expand Up @@ -117,6 +116,10 @@ jobs:
SCRIPTC_TEST_STABLE_TOOLCHAIN: "0"
run: pnpm test packages/compiler/src/backend/native-toolchain.test.ts
- name: Tests (case-sharded, slice ${{ matrix.shard }}/10)
env:
# differential.test.ts owns release; this companion adds dev.
# Packaged-artifact jobs still exercise both optimization modes.
SCRIPTC_LLVM_TEST_MODE: dev
run: >-
pnpm test
tests/harness/differential.test.ts
Expand All @@ -131,6 +134,53 @@ jobs:
if: matrix.flavor == 'plain'
run: pnpm test tests/harness/coverage.test.ts

# Full compiler rebuilds dominate the critical path. Start them immediately
# after setup, independently of corpus and integration test shards.
bootstrap:
name: test (Linux, ${{ matrix.flavor }}, ${{ matrix.compiler }} bootstrap)
# These contracts are portable. Standard Linux runners have enough memory
# for LLVM optimization alongside the compiler that produces its input.
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
flavor: [plain, san]
compiler: [frontend, native]
include:
- compiler: frontend
test: tests/harness/self-hosting-bootstrap.test.ts
- compiler: native
test: tests/harness/self-hosting-native-driver.test.ts
env:
SCRIPTC_TEST_WORKERS: "1"
SCRIPTC_SAN: ${{ matrix.flavor == 'san' && '1' || '' }}
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 11.1.3
- uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: pnpm
- name: Install pinned LLVM development distribution
run: |
sudo apt-get update
sudo apt-get install --yes g++ zlib1g-dev libzstd-dev
curl -fL --retry 3 -o "$RUNNER_TEMP/llvm.tar.xz" https://github.com/llvm/llvm-project/releases/download/llvmorg-22.1.8/LLVM-22.1.8-Linux-X64.tar.xz
tar -xJf "$RUNNER_TEMP/llvm.tar.xz" -C "$RUNNER_TEMP"
mv "$RUNNER_TEMP/LLVM-22.1.8-Linux-X64" "$RUNNER_TEMP/llvm-22.1.8"
echo "LLVM_DIR=$RUNNER_TEMP/llvm-22.1.8/lib/cmake/llvm" >> "$GITHUB_ENV"
echo "$RUNNER_TEMP/llvm-22.1.8/bin" >> "$GITHUB_PATH"
- run: pnpm install --frozen-lockfile
- run: pnpm --filter @scriptc/llvm-linux-x64-gnu build:native
- uses: vercel-labs/setup-zig@v1
with:
version: 0.16.0
- run: CC=zig AR=zig pnpm --filter @scriptc/runtime-linux-x64-gnu build:native
- run: pnpm build
- run: pnpm test ${{ matrix.test }}

# A real host-clang/glibc build, not the zig cross-target lane: catches
# Linux feature-test macro omissions at compile time and separate-libm
# omissions/order errors at link time.
Expand Down Expand Up @@ -292,16 +342,8 @@ jobs:
packages/cli/test/native-link-info.test.ts
packages/cli/test/runtime-pack.test.ts
tests/harness/native-object-example.test.ts
- name: Default helper/runtime-pack executable does not compile C
if: matrix.shard == 1
- name: LLVM release/dev differential (${{ matrix.shard }}/5)
env:
SCRIPTC_LEGACY_C_PIPELINE: "0"
run: >-
pnpm test packages/cli/test/runtime-pack.test.ts
--testNamePattern "legacy C pipeline disabled"
- name: LLVM-tier helper object differential (${{ matrix.shard }}/5)
env:
SCRIPTC_LLVM_HELPER_ONLY: "1"
SCRIPTC_TEST_WORKERS: "4"
run: pnpm test tests/harness/llvm-differential.test.ts
- name: Packaged helper contract
Expand Down Expand Up @@ -370,6 +412,7 @@ jobs:
# slash styles, and the default executable must use the .exe suffix.
windows_cli:
name: test (windows CLI smoke)
needs: llvm_artifacts_windows_x64
runs-on: windows-latest
timeout-minutes: 15
env:
Expand All @@ -396,6 +439,10 @@ jobs:
Write-Host "pnpm exited without a diagnostic; retrying once"
pnpm install --frozen-lockfile
}
- uses: actions/download-artifact@v4
with:
name: windows-native-packages
path: packages
- run: pnpm build
- name: Windows path regressions
run: pnpm exec vitest run packages/compiler/test/ts7/program-adapter.test.ts packages/compiler/test/ts7/resolver-parity.test.ts packages/cli/test/paths.test.ts
Expand All @@ -407,7 +454,7 @@ jobs:
shell: pwsh
run: |
zig version
$output = & node packages/cli/dist/main.js run tests/corpus/001-hello.ts --backend c
$output = & node packages/cli/dist/main.js run tests/corpus/001-hello.ts --backend llvm
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
Expand All @@ -426,7 +473,7 @@ jobs:
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
$nativeOutput = & node packages/cli/dist/main.js run tests/corpus/2557-tls-ca-store.ts --backend c
$nativeOutput = & node packages/cli/dist/main.js run tests/corpus/2557-tls-ca-store.ts --backend llvm
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
Expand Down Expand Up @@ -495,17 +542,27 @@ jobs:
node packages/cli/dist/main.js build tests/corpus/001-hello.ts --emit=obj -o "$env:RUNNER_TEMP\hello.obj"
$bytes = [System.IO.File]::ReadAllBytes("$env:RUNNER_TEMP\hello.obj")
if ($bytes[0] -ne 0x64 -or $bytes[1] -ne 0x86) { throw "expected AMD64 COFF object" }
- uses: actions/upload-artifact@v4
with:
name: windows-native-packages
path: |
packages/llvm-win32-x64-msvc/bin
packages/runtime-win32-x64-msvc/artifacts
packages/runtime-win32-x64-msvc/runtime-pack.json
retention-days: 1

# Retain the pre-matrix "test" check for branch protection and badges. It
# passes only when every matrix shard and independent integration job does.
test:
needs: [tests, linux_host_clang, ts7_parity, llvm_artifacts_linux_x64, llvm_artifacts_macos_arm64, llvm_artifacts_macos_x64, windows_cli, llvm_artifacts_windows_x64]
if: always()
needs: [tests, bootstrap, linux_host_clang, ts7_parity, llvm_artifacts_linux_x64, llvm_artifacts_macos_arm64, llvm_artifacts_macos_x64, windows_cli, llvm_artifacts_windows_x64]
# A superseded run must release its concurrency slot immediately.
if: ${{ !cancelled() }}
runs-on: ubuntu-latest
steps:
- name: All lanes green
run: |
test "${{ needs.tests.result }}" = success
test "${{ needs.bootstrap.result }}" = success
test "${{ needs.linux_host_clang.result }}" = success
test "${{ needs.ts7_parity.result }}" = success
test "${{ needs.llvm_artifacts_linux_x64.result }}" = success
Expand Down
45 changes: 43 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,47 @@ jobs:
packages/${{ matrix.runtime }}
retention-days: 1

build-mobile-runtime-packs:
name: Build ${{ matrix.runtime }}
needs: check-release
if: needs.check-release.outputs.should_release == 'true'
strategy:
fail-fast: false
matrix:
include:
- runtime: runtime-ios-arm64
runner: macos-15
- runtime: runtime-ios-simulator-arm64
runner: macos-15
- runtime: runtime-android-arm64
runner: ubuntu-24.04
runs-on: ${{ matrix.runner }}
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24.15.0
- name: Install Android NDK
if: matrix.runtime == 'runtime-android-arm64'
run: |
"$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" "ndk;27.2.12479018"
echo "ANDROID_NDK_ROOT=$ANDROID_HOME/ndk/27.2.12479018" >> "$GITHUB_ENV"
- name: Build and verify mobile runtime pack
run: |
node packages/${{ matrix.runtime }}/scripts/build.mjs
node packages/${{ matrix.runtime }}/scripts/verify.mjs
mkdir -p "$RUNNER_TEMP/mobile-pack/${{ matrix.runtime }}"
cp -R packages/${{ matrix.runtime }}/. "$RUNNER_TEMP/mobile-pack/${{ matrix.runtime }}/"
- uses: actions/upload-artifact@v4
with:
name: native-${{ matrix.runtime }}
path: ${{ runner.temp }}/mobile-pack
retention-days: 1

publish:
name: Publish to npm
needs: [check-release, build-native-packages]
needs: [check-release, build-native-packages, build-mobile-runtime-packs]
if: needs.check-release.outputs.should_release == 'true'
runs-on: macos-15
timeout-minutes: 15
Expand Down Expand Up @@ -233,7 +271,7 @@ jobs:
- name: Check version sync
run: |
VERSION="${{ needs.check-release.outputs.version }}"
for pkg in packages/runtime packages/runtime-darwin-arm64 packages/llvm-darwin-arm64 packages/runtime-linux-x64-gnu packages/llvm-linux-x64-gnu packages/runtime-linux-arm64-gnu packages/llvm-linux-arm64-gnu packages/runtime-linux-x64-musl packages/llvm-linux-x64-musl packages/runtime-linux-arm64-musl packages/llvm-linux-arm64-musl packages/runtime-wasm32-wasi packages/runtime-win32-x64-msvc packages/llvm-win32-x64-msvc packages/compiler packages/cli; do
for pkg in packages/runtime packages/runtime-darwin-arm64 packages/llvm-darwin-arm64 packages/runtime-linux-x64-gnu packages/llvm-linux-x64-gnu packages/runtime-linux-arm64-gnu packages/llvm-linux-arm64-gnu packages/runtime-linux-x64-musl packages/llvm-linux-x64-musl packages/runtime-linux-arm64-musl packages/llvm-linux-arm64-musl packages/runtime-wasm32-wasi packages/runtime-ios-arm64 packages/runtime-ios-simulator-arm64 packages/runtime-android-arm64 packages/runtime-win32-x64-msvc packages/llvm-win32-x64-msvc packages/compiler packages/cli; do
V=$(node -p "require('./$pkg/package.json').version")
if [ "$V" != "$VERSION" ]; then
echo "Version mismatch: $pkg is $V, expected $VERSION"
Expand Down Expand Up @@ -326,6 +364,9 @@ jobs:
publish_dir packages/llvm-linux-x64-musl
publish_dir packages/runtime-linux-arm64-musl
publish_dir packages/llvm-linux-arm64-musl
publish_dir packages/runtime-ios-arm64
publish_dir packages/runtime-ios-simulator-arm64
publish_dir packages/runtime-android-arm64
publish_dir packages/runtime-wasm32-wasi
publish_dir packages/runtime-win32-x64-msvc
publish_dir packages/llvm-win32-x64-msvc
Expand Down
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ new tests should follow this convention.

## Where things live

- `packages/compiler` — the frontend (tsc API to IR), typed IR, validator, serializer, and LLVM and C backends.
- `packages/runtime` — the C runtime compiled into every scriptc binary.
- `packages/compiler` — the frontend (tsc API to IR), typed IR, validator, serializer, and LLVM backend.
- `packages/runtime` — the C runtime distributed as precompiled runtime packs.
- `packages/cli` — `scriptc build | run | coverage`.
- `internal/compatibility` — generated Node.js parity inventory, implementation-owned compatibility manifests, and engineering backlog.
- `tests/` — the differential corpus, diagnostics snapshots, and harness.
Expand Down
2 changes: 0 additions & 2 deletions Dockerfile.sandbox
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ WORKDIR /workspace

COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
COPY packages/cli/package.json packages/cli/package.json
COPY packages/cli/scripts/warm-cache.mjs packages/cli/scripts/warm-cache.mjs
COPY packages/cli/scripts/runtime-pack-host.mjs packages/cli/scripts/runtime-pack-host.mjs
COPY packages/compiler/package.json packages/compiler/package.json
COPY packages/runtime/package.json packages/runtime/package.json

Expand Down
Loading
Loading