mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-12-06 04:56:15 +08:00
Pin toolchain downloads by SHA-256 and GitHub Actions by commit
LLVM archives were downloaded without a checksum in CI, in the release jobs and in the LLVM distribution workflow; Node and Zig for the Sandbox image were checked against a checksum list fetched from the same origin as the archive. - scripts/toolchain.sha256 holds the SHA-256 of every toolchain archive that CI, the release jobs and the Sandbox image download (LLVM for Linux x64 and arm64 and for Windows, the LLVM sources, Node, Zig, the LLVM apt key), and scripts/verify-toolchain.sh checks a file against it. Every download runs the check before the file is unpacked; a different digest or a file with no pin fails. - The Linux LLVM cache key is the hash of the pin file, so a cache never outlives the digest its archive was checked against. - Every action is referenced by commit with its version in a comment, and Dependabot proposes the updates once a month. - ci.yml and release.yml get top-level permissions (contents: read); the jobs that publish, read other runs' artifacts or write the GitHub release already declare what they need. - tests/harness/ci-supply-chain.test.ts enforces the three rules. - .dockerignore lets the Sandbox image build see the three scripts its Dockerfile copies. Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -9,3 +9,7 @@
|
||||
!packages/compiler/package.json
|
||||
!packages/runtime/
|
||||
!packages/runtime/package.json
|
||||
!scripts/
|
||||
!scripts/install-zig.sh
|
||||
!scripts/toolchain.sha256
|
||||
!scripts/verify-toolchain.sh
|
||||
|
||||
@@ -27,7 +27,7 @@ runs:
|
||||
env:
|
||||
SCRIPTC_LIBNODE_TOOLCHAIN: ${{ steps.target.outputs.toolchain }}
|
||||
run: node packages/libnode-common/scripts/cache-key.mjs --platform ${{ steps.target.outputs.platform }} >> "$GITHUB_OUTPUT"
|
||||
- uses: actions/cache/restore@v4
|
||||
- uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
||||
id: libnode
|
||||
with:
|
||||
path: .libnode-cache/${{ steps.key.outputs.path }}
|
||||
@@ -42,7 +42,7 @@ runs:
|
||||
node packages/libnode-${{ steps.target.outputs.platform }}/scripts/build.mjs --from-cache
|
||||
node packages/libnode-common/scripts/verify.mjs packages/libnode-${{ steps.target.outputs.platform }}
|
||||
echo "SCRIPTC_LIBNODE=$GITHUB_WORKSPACE/packages/libnode-${{ steps.target.outputs.platform }}" >> "$GITHUB_ENV"
|
||||
- uses: actions/cache@v4
|
||||
- uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
||||
if: steps.libnode.outputs.cache-hit != 'true'
|
||||
id: devpack
|
||||
with:
|
||||
|
||||
@@ -3,11 +3,12 @@ description: Reuse the pinned LLVM development distribution across CI jobs
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- uses: actions/cache/restore@v4
|
||||
- uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
||||
id: llvm
|
||||
with:
|
||||
path: ${{ runner.temp }}/llvm-22.1.8
|
||||
key: llvm-22.1.8-linux-x64-v1
|
||||
# The pin file is part of the key, so a cache never outlives the digest its archive was checked against.
|
||||
key: llvm-22.1.8-linux-x64-${{ hashFiles('scripts/toolchain.sha256') }}
|
||||
- name: Install LLVM system libraries
|
||||
shell: bash
|
||||
run: |
|
||||
@@ -22,6 +23,7 @@ runs:
|
||||
curl -fL --connect-timeout 20 --max-time 300 --speed-limit 102400 --speed-time 30 \
|
||||
--retry 2 --retry-max-time 600 -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
|
||||
sh scripts/verify-toolchain.sh "$RUNNER_TEMP/llvm.tar.xz" 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"
|
||||
- name: Select LLVM
|
||||
@@ -31,7 +33,7 @@ runs:
|
||||
echo "LLVM_DIR=$RUNNER_TEMP/llvm-22.1.8/lib/cmake/llvm" >> "$GITHUB_ENV"
|
||||
echo "$RUNNER_TEMP/llvm-22.1.8/bin" >> "$GITHUB_PATH"
|
||||
# Publish setup work before the long tests, including when a later test fails.
|
||||
- uses: actions/cache/save@v4
|
||||
- uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
||||
if: steps.llvm.outputs.cache-hit != 'true'
|
||||
with:
|
||||
path: ${{ runner.temp }}/llvm-22.1.8
|
||||
|
||||
@@ -7,7 +7,7 @@ inputs:
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version-file: .node-version
|
||||
- name: Install Android NDK
|
||||
|
||||
@@ -19,13 +19,13 @@ runs:
|
||||
if test "$RUNNER_OS" = Linux; then
|
||||
echo "zig=$(zig version)" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
- uses: actions/cache/restore@v4
|
||||
- uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
||||
id: helper
|
||||
if: inputs.helper == 'true'
|
||||
with:
|
||||
path: packages/llvm-${{ inputs.target }}/bin
|
||||
key: helper-v1-${{ inputs.target }}-${{ steps.host.outputs.image }}-${{ steps.host.outputs.zig }}-${{ hashFiles('.node-version', '.github/actions/native-packages/action.yml', '.github/actions/llvm-linux/action.yml', 'native/llvm-codegen/**', 'packages/llvm-*/package.json', 'packages/llvm-*/scripts/**') }}
|
||||
- uses: actions/cache/restore@v4
|
||||
- uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
||||
id: runtime
|
||||
with:
|
||||
path: |
|
||||
@@ -58,12 +58,12 @@ runs:
|
||||
env:
|
||||
SCRIPTC_PACKAGE_TARGET: ${{ inputs.target }}
|
||||
run: node "packages/runtime-$SCRIPTC_PACKAGE_TARGET/scripts/verify.mjs"
|
||||
- uses: actions/cache/save@v4
|
||||
- uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
||||
if: inputs.helper == 'true' && steps.helper.outputs.cache-hit != 'true'
|
||||
with:
|
||||
path: packages/llvm-${{ inputs.target }}/bin
|
||||
key: ${{ steps.helper.outputs.cache-primary-key }}
|
||||
- uses: actions/cache/save@v4
|
||||
- uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
||||
if: steps.runtime.outputs.cache-hit != 'true'
|
||||
with:
|
||||
path: |
|
||||
|
||||
@@ -3,16 +3,16 @@ description: Reuse the verified Zig installation across hosted runners
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- uses: actions/cache/restore@v4
|
||||
- uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
||||
id: zig
|
||||
with:
|
||||
path: ${{ runner.tool_cache }}/zig/0.16.0
|
||||
key: zig-0.16.0-${{ runner.os }}-${{ runner.arch }}-minisign-v1
|
||||
# The installer checks the verified marker and runs `zig version` on hits.
|
||||
- uses: vercel-labs/setup-zig@v1
|
||||
- uses: vercel-labs/setup-zig@83c1594f26b86da8a9a8ddd9b5ee5f3af0f96943 # v1.0.2
|
||||
with:
|
||||
version: 0.16.0
|
||||
- uses: actions/cache/save@v4
|
||||
- uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
||||
if: steps.zig.outputs.cache-hit != 'true'
|
||||
with:
|
||||
path: ${{ runner.tool_cache }}/zig/0.16.0
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
# The actions in the workflows and in the local composite actions are pinned to commits. This keeps the pins
|
||||
# current: once a month, one pull request that moves every pin whose action has a newer release.
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: github-actions
|
||||
directories:
|
||||
- /
|
||||
- /.github/actions/*
|
||||
schedule:
|
||||
interval: monthly
|
||||
groups:
|
||||
actions:
|
||||
patterns:
|
||||
- "*"
|
||||
+106
-94
@@ -30,6 +30,12 @@ concurrency:
|
||||
group: ci-${{ github.event_name == 'schedule' && 'schedule' || github.event_name == 'workflow_dispatch' && format('dispatch-{0}', github.run_id) || github.event.pull_request.number || github.sha }}
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
||||
|
||||
# The token every job gets unless it declares its own: it can read the repository and nothing else. No job here
|
||||
# writes to the repository, comments on a pull request or requests an OIDC token; caches and artifacts do not use
|
||||
# this token.
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
# GitHub recommends stack.base.ref == base.ref for the lowest unmerged PR:
|
||||
# https://docs.github.com/en/pull-requests/how-tos/merge-and-close-pull-requests/optimizing-ci-for-stacked-pull-requests
|
||||
@@ -93,7 +99,7 @@ jobs:
|
||||
bootstrap: ${{ steps.lanes.outputs.bootstrap || 'false' }}
|
||||
profile: ${{ steps.lanes.outputs.profile || 'false' }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
if: github.event_name == 'pull_request'
|
||||
with:
|
||||
fetch-depth: 0
|
||||
@@ -121,11 +127,11 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version-file: .node-version
|
||||
cache: pnpm
|
||||
@@ -149,11 +155,11 @@ jobs:
|
||||
name: build (macOS arm64 native packages)
|
||||
runs-on: macos-15
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version-file: .node-version
|
||||
cache: pnpm
|
||||
@@ -167,7 +173,7 @@ jobs:
|
||||
packages/llvm-darwin-arm64/bin
|
||||
packages/runtime-darwin-arm64/artifacts
|
||||
packages/runtime-darwin-arm64/runtime-pack.json
|
||||
- uses: actions/upload-artifact@v4
|
||||
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: native-darwin-arm64
|
||||
path: ${{ runner.temp }}/native-darwin-arm64.tar.gz
|
||||
@@ -210,17 +216,17 @@ jobs:
|
||||
# sequential), hence the case-sharded steps below.
|
||||
SCRIPTC_TEST_SHARD: ${{ matrix.shard }}/20
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version-file: .node-version
|
||||
cache: pnpm
|
||||
- uses: ./.github/actions/llvm-linux
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- uses: actions/download-artifact@v4
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: native-linux-x64-gnu
|
||||
path: ${{ runner.temp }}
|
||||
@@ -283,16 +289,16 @@ jobs:
|
||||
SCRIPTC_TEST_SHARD: ${{ matrix.shard }}/${{ (github.event_name != 'schedule' && inputs.macos_suite != 'full') && '3' || '10' }}
|
||||
SCRIPTC_CI_SUITE: ${{ (github.event_name != 'schedule' && inputs.macos_suite != 'full') && 'darwin' || 'full' }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version-file: .node-version
|
||||
cache: pnpm
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- uses: actions/download-artifact@v4
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: native-darwin-arm64
|
||||
path: ${{ runner.temp }}
|
||||
@@ -310,11 +316,11 @@ jobs:
|
||||
name: build (Linux x64 native packages)
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version-file: .node-version
|
||||
cache: pnpm
|
||||
@@ -330,7 +336,7 @@ jobs:
|
||||
packages/llvm-linux-x64-gnu/bin
|
||||
packages/runtime-linux-x64-gnu/artifacts
|
||||
packages/runtime-linux-x64-gnu/runtime-pack.json
|
||||
- uses: actions/upload-artifact@v4
|
||||
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: native-linux-x64-gnu
|
||||
path: ${{ runner.temp }}/native-linux-x64-gnu.tar.gz
|
||||
@@ -357,16 +363,16 @@ jobs:
|
||||
SCRIPTC_SAN: ${{ matrix.flavor == 'san' && '1' || '' }}
|
||||
ASAN_OPTIONS: detect_leaks=0
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version-file: .node-version
|
||||
cache: pnpm
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- uses: actions/download-artifact@v4
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: native-linux-x64-gnu
|
||||
path: ${{ runner.temp }}
|
||||
@@ -388,16 +394,16 @@ jobs:
|
||||
ASAN_OPTIONS: detect_leaks=1
|
||||
LSAN_OPTIONS: suppressions=${{ github.workspace }}/tests/harness/lsan.supp:print_suppressions=0
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version-file: .node-version
|
||||
cache: pnpm
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- uses: actions/download-artifact@v4
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: native-linux-x64-gnu
|
||||
path: ${{ runner.temp }}
|
||||
@@ -432,17 +438,17 @@ jobs:
|
||||
SCRIPTC_TEST_WORKERS: "1"
|
||||
ASAN_OPTIONS: detect_leaks=0
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version-file: .node-version
|
||||
cache: pnpm
|
||||
- uses: ./.github/actions/llvm-linux
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- uses: actions/download-artifact@v4
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: native-linux-x64-gnu
|
||||
path: ${{ runner.temp }}
|
||||
@@ -460,11 +466,11 @@ jobs:
|
||||
name: build (Linux x64 native packages, shape overlay)
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version-file: .node-version
|
||||
cache: pnpm
|
||||
@@ -480,7 +486,7 @@ jobs:
|
||||
packages/llvm-linux-x64-gnu/bin
|
||||
packages/runtime-linux-x64-gnu/artifacts
|
||||
packages/runtime-linux-x64-gnu/runtime-pack.json
|
||||
- uses: actions/upload-artifact@v4
|
||||
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: native-linux-x64-gnu-shape-overlay
|
||||
path: ${{ runner.temp }}/native-linux-x64-gnu.tar.gz
|
||||
@@ -502,16 +508,16 @@ jobs:
|
||||
SCRIPTC_EFFECT_TEST_CONCURRENCY: "1"
|
||||
SCRIPTC_TEST_SHARD: ${{ matrix.shard }}/8
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version-file: .node-version
|
||||
cache: pnpm
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- uses: actions/download-artifact@v4
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: native-linux-x64-gnu-shape-overlay
|
||||
path: ${{ runner.temp }}
|
||||
@@ -543,11 +549,11 @@ jobs:
|
||||
env:
|
||||
SCRIPTC_SAN: ${{ matrix.flavor == 'san' && '1' || '' }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version-file: .node-version
|
||||
cache: pnpm
|
||||
@@ -582,7 +588,7 @@ jobs:
|
||||
SCRIPTC_BOOTSTRAP_SEED_DIRECTORY: ${{ runner.temp }}/native-bootstrap
|
||||
- name: Archive seed and compiler artifacts
|
||||
run: tar -C "$RUNNER_TEMP" -cf "$RUNNER_TEMP/bootstrap-seed.tar" native-bootstrap
|
||||
- uses: actions/upload-artifact@v4
|
||||
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: bootstrap-seed-${{ matrix.flavor }}-${{ github.sha }}
|
||||
path: ${{ runner.temp }}/bootstrap-seed.tar
|
||||
@@ -610,11 +616,11 @@ jobs:
|
||||
# The compiler build takes about as long as the seed's on a hosted runner.
|
||||
timeout-minutes: 90
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version-file: .node-version
|
||||
cache: pnpm
|
||||
@@ -654,11 +660,11 @@ jobs:
|
||||
SCRIPTC_SAN: ${{ matrix.flavor == 'san' && '1' || '' }}
|
||||
SCRIPTC_BOOTSTRAP_PHASE: ${{ matrix.phase }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version-file: .node-version
|
||||
cache: pnpm
|
||||
@@ -676,7 +682,7 @@ jobs:
|
||||
target: wasm32-wasi
|
||||
helper: "false"
|
||||
- run: pnpm build
|
||||
- uses: actions/download-artifact@v4
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: bootstrap-seed-${{ matrix.flavor }}-${{ github.sha }}
|
||||
path: ${{ runner.temp }}
|
||||
@@ -718,11 +724,11 @@ jobs:
|
||||
# binary copied from a previous build.
|
||||
SCRIPTC_NO_CACHE: "1"
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version-file: .node-version
|
||||
cache: pnpm
|
||||
@@ -743,11 +749,11 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version-file: .node-version
|
||||
cache: pnpm
|
||||
@@ -767,11 +773,11 @@ jobs:
|
||||
# slow hosted runner, so a 30-minute limit cancels otherwise healthy runs.
|
||||
timeout-minutes: 60
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version-file: .node-version
|
||||
cache: pnpm
|
||||
@@ -795,17 +801,17 @@ jobs:
|
||||
# minutes.
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version-file: .node-version
|
||||
cache: pnpm
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- uses: ./.github/actions/zig
|
||||
- uses: actions/download-artifact@v4
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: native-linux-x64-gnu
|
||||
path: ${{ runner.temp }}
|
||||
@@ -847,18 +853,18 @@ jobs:
|
||||
# host's glibc helper (runtime-unit.mjs), which comes from native_linux.
|
||||
timeout-minutes: 25
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version-file: .node-version
|
||||
cache: pnpm
|
||||
- uses: ./.github/actions/llvm-linux
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- uses: ./.github/actions/zig
|
||||
- uses: actions/download-artifact@v4
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: native-linux-x64-gnu
|
||||
path: ${{ runner.temp }}
|
||||
@@ -890,18 +896,18 @@ jobs:
|
||||
# the WASI smoke tests, which take 6 to 9 minutes.
|
||||
timeout-minutes: 25
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version-file: .node-version
|
||||
cache: pnpm
|
||||
- uses: ./.github/actions/llvm-linux
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- uses: ./.github/actions/zig
|
||||
- uses: actions/download-artifact@v4
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: native-linux-x64-gnu
|
||||
path: ${{ runner.temp }}
|
||||
@@ -933,16 +939,16 @@ jobs:
|
||||
# exercises every LLVM-tier program.
|
||||
SCRIPTC_TEST_SHARD: ${{ matrix.shard }}/5
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version-file: .node-version
|
||||
cache: pnpm
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- uses: actions/download-artifact@v4
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: native-darwin-arm64
|
||||
path: ${{ runner.temp }}
|
||||
@@ -970,16 +976,16 @@ jobs:
|
||||
# Its native CLI build alone can pass 30 minutes on a busy runner.
|
||||
timeout-minutes: 50
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version-file: .node-version
|
||||
cache: pnpm
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- uses: actions/download-artifact@v4
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: native-darwin-arm64
|
||||
path: ${{ runner.temp }}
|
||||
@@ -1037,11 +1043,11 @@ jobs:
|
||||
# The Node island tests take most of it.
|
||||
timeout-minutes: 45
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version-file: .node-version
|
||||
cache: pnpm
|
||||
@@ -1087,12 +1093,12 @@ jobs:
|
||||
SCRIPTC_CC: zigcc
|
||||
SCRIPTC_TARGET: x86_64-windows-gnu
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
- uses: ./.github/actions/zig
|
||||
- uses: pnpm/action-setup@v4
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version-file: .node-version
|
||||
cache: pnpm
|
||||
@@ -1104,7 +1110,7 @@ jobs:
|
||||
Write-Host "pnpm exited without a diagnostic; retrying once"
|
||||
pnpm install --frozen-lockfile
|
||||
}
|
||||
- uses: actions/download-artifact@v4
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: windows-native-packages
|
||||
path: packages
|
||||
@@ -1173,14 +1179,21 @@ jobs:
|
||||
runs-on: windows-2022
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version-file: .node-version
|
||||
cache: pnpm
|
||||
# The archive is checked against its pinned digest (scripts/toolchain.sha256) before anything unpacks it.
|
||||
- name: Download pinned LLVM development distribution
|
||||
shell: bash
|
||||
run: |
|
||||
archive="$RUNNER_TEMP/clang+llvm-22.1.8-x86_64-pc-windows-msvc.tar.xz"
|
||||
curl -fL --retry 3 -o "$archive" https://github.com/llvm/llvm-project/releases/download/llvmorg-22.1.8/clang%2Bllvm-22.1.8-x86_64-pc-windows-msvc.tar.xz
|
||||
sh scripts/verify-toolchain.sh "$archive"
|
||||
- name: Install pinned LLVM development distribution
|
||||
shell: pwsh
|
||||
run: |
|
||||
@@ -1197,7 +1210,6 @@ jobs:
|
||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||
}
|
||||
if (-not (Test-Path $sevenZip)) { throw "7-Zip is unavailable" }
|
||||
curl.exe -fL --retry 3 -o $archive https://github.com/llvm/llvm-project/releases/download/llvmorg-22.1.8/clang%2Bllvm-22.1.8-x86_64-pc-windows-msvc.tar.xz
|
||||
& $sevenZip x -y "-o$expanded" $archive
|
||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||
& $sevenZip x -y "-o$expanded" "$expanded\clang+llvm-22.1.8-x86_64-pc-windows-msvc.tar"
|
||||
@@ -1218,7 +1230,7 @@ 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
|
||||
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: windows-native-packages
|
||||
path: |
|
||||
@@ -1238,7 +1250,7 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
- uses: ./.github/actions/mobile-runtime-pack
|
||||
with:
|
||||
runtime: ${{ matrix.runtime }}
|
||||
@@ -1255,7 +1267,7 @@ jobs:
|
||||
runs-on: macos-15
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
- uses: ./.github/actions/mobile-runtime-pack
|
||||
with:
|
||||
runtime: ${{ matrix.runtime }}
|
||||
|
||||
@@ -68,9 +68,9 @@ jobs:
|
||||
env:
|
||||
SCRIPTC_LIBNODE_TOOLCHAIN: ${{ matrix.toolchain }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version: "24"
|
||||
|
||||
@@ -79,7 +79,7 @@ jobs:
|
||||
run: node packages/libnode-common/scripts/cache-key.mjs --platform ${{ matrix.platform }} >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Restore the libnode build
|
||||
uses: actions/cache@v4
|
||||
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
||||
with:
|
||||
path: .libnode-cache/${{ steps.key.outputs.path }}
|
||||
key: ${{ steps.key.outputs.key }}
|
||||
@@ -129,7 +129,7 @@ jobs:
|
||||
} >> "$GITHUB_STEP_SUMMARY"
|
||||
|
||||
- name: Upload the pack
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: libnode-${{ matrix.platform }}
|
||||
path: |
|
||||
@@ -138,7 +138,7 @@ jobs:
|
||||
retention-days: 30
|
||||
|
||||
- name: Upload compressed libraries
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: libnode-${{ matrix.platform }}-zst
|
||||
path: .libnode-cache/compressed/${{ matrix.platform }}
|
||||
|
||||
@@ -38,11 +38,11 @@ jobs:
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version: "24"
|
||||
cache: pnpm
|
||||
@@ -52,9 +52,11 @@ jobs:
|
||||
sudo apt-get install --yes ninja-build zlib1g-dev libzstd-dev
|
||||
base=https://github.com/llvm/llvm-project/releases/download/llvmorg-22.1.8
|
||||
curl -fL --retry 3 -o "$RUNNER_TEMP/llvm.tar.xz" "$base/${{ matrix.llvm_asset }}.tar.xz"
|
||||
sh scripts/verify-toolchain.sh "$RUNNER_TEMP/llvm.tar.xz" "${{ matrix.llvm_asset }}.tar.xz"
|
||||
tar -xJf "$RUNNER_TEMP/llvm.tar.xz" -C "$RUNNER_TEMP"
|
||||
mv "$RUNNER_TEMP/${{ matrix.llvm_asset }}" "$RUNNER_TEMP/llvm-22.1.8"
|
||||
curl -fL --retry 3 -o "$RUNNER_TEMP/llvm-src.tar.xz" "$base/llvm-project-22.1.8.src.tar.xz"
|
||||
sh scripts/verify-toolchain.sh "$RUNNER_TEMP/llvm-src.tar.xz" llvm-project-22.1.8.src.tar.xz
|
||||
tar -xJf "$RUNNER_TEMP/llvm-src.tar.xz" -C "$RUNNER_TEMP"
|
||||
rm "$RUNNER_TEMP/llvm.tar.xz" "$RUNNER_TEMP/llvm-src.tar.xz"
|
||||
echo "$RUNNER_TEMP/llvm-22.1.8/bin" >> "$GITHUB_PATH"
|
||||
|
||||
@@ -44,14 +44,14 @@ jobs:
|
||||
# profile (below) about as long as the CI profile check's.
|
||||
timeout-minutes: 180
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
ref: main
|
||||
persist-credentials: false
|
||||
- uses: pnpm/action-setup@v4
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version-file: .node-version
|
||||
cache: pnpm
|
||||
|
||||
@@ -8,6 +8,12 @@ on:
|
||||
|
||||
concurrency: ${{ github.workflow }}-${{ github.ref }}
|
||||
|
||||
# The token of a job that declares no permissions of its own (the native and mobile package builds) can read the
|
||||
# repository and nothing else. The jobs that read other runs' artifacts, publish to npm or write the GitHub release
|
||||
# declare what they need.
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
check-release:
|
||||
name: Check for new version
|
||||
@@ -27,12 +33,12 @@ jobs:
|
||||
receipt_run: ${{ steps.reuse.outputs.receipt_run }}
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version: "24"
|
||||
registry-url: "https://registry.npmjs.org"
|
||||
@@ -117,11 +123,11 @@ jobs:
|
||||
permissions:
|
||||
contents: read
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version: "24"
|
||||
cache: pnpm
|
||||
@@ -151,7 +157,7 @@ jobs:
|
||||
run: >-
|
||||
node scripts/refresh-cli-profile.mjs --tsc-ts "$RUNNER_TEMP/tsc-ts" --jobs 4 --context-sensitive
|
||||
--output "$RUNNER_TEMP/cli-profile/cli.profdata.gz" --work "$RUNNER_TEMP/cli-profile-work"
|
||||
- uses: actions/upload-artifact@v4
|
||||
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: cli-profile
|
||||
path: |
|
||||
@@ -234,11 +240,11 @@ jobs:
|
||||
# The Intel macOS build took 24 minutes for 0.3.2, 40 for 0.4.5, and passed 45 for 0.4.6.
|
||||
timeout-minutes: 90
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version: "24"
|
||||
cache: pnpm
|
||||
@@ -255,6 +261,7 @@ jobs:
|
||||
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/${{ matrix.llvm_asset }}.tar.xz"
|
||||
sh scripts/verify-toolchain.sh "$RUNNER_TEMP/llvm.tar.xz" "${{ matrix.llvm_asset }}.tar.xz"
|
||||
tar -xJf "$RUNNER_TEMP/llvm.tar.xz" -C "$RUNNER_TEMP"
|
||||
mv "$RUNNER_TEMP/${{ matrix.llvm_asset }}" "$RUNNER_TEMP/llvm-22.1.8"
|
||||
echo "LLVM_DIR=$RUNNER_TEMP/llvm-22.1.8/lib/cmake/llvm" >> "$GITHUB_ENV"
|
||||
@@ -281,10 +288,18 @@ jobs:
|
||||
else
|
||||
echo "::warning::$asset is not available from release $tag; the helper links LLVM's release archive"
|
||||
fi
|
||||
- uses: vercel-labs/setup-zig@v1
|
||||
- uses: vercel-labs/setup-zig@83c1594f26b86da8a9a8ddd9b5ee5f3af0f96943 # v1.0.2
|
||||
if: matrix.use_zig == true
|
||||
with:
|
||||
version: 0.16.0
|
||||
# The archive is checked against its pinned digest (scripts/toolchain.sha256) before anything unpacks it.
|
||||
- name: Download pinned LLVM development distribution (Windows)
|
||||
if: matrix.platform == 'windows-x64'
|
||||
shell: bash
|
||||
run: |
|
||||
archive="$RUNNER_TEMP/clang+llvm-22.1.8-x86_64-pc-windows-msvc.tar.xz"
|
||||
curl -fL --retry 3 -o "$archive" https://github.com/llvm/llvm-project/releases/download/llvmorg-22.1.8/clang%2Bllvm-22.1.8-x86_64-pc-windows-msvc.tar.xz
|
||||
sh scripts/verify-toolchain.sh "$archive"
|
||||
- name: Install pinned LLVM development distribution (Windows)
|
||||
if: matrix.platform == 'windows-x64'
|
||||
shell: pwsh
|
||||
@@ -301,7 +316,6 @@ jobs:
|
||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||
}
|
||||
if (-not (Test-Path $sevenZip)) { throw "7-Zip is unavailable" }
|
||||
curl.exe -fL --retry 3 -o $archive https://github.com/llvm/llvm-project/releases/download/llvmorg-22.1.8/clang%2Bllvm-22.1.8-x86_64-pc-windows-msvc.tar.xz
|
||||
& $sevenZip x -y "-o$expanded" $archive
|
||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||
& $sevenZip x -y "-o$expanded" "$expanded\clang+llvm-22.1.8-x86_64-pc-windows-msvc.tar"
|
||||
@@ -345,7 +359,7 @@ jobs:
|
||||
id: cli-profile
|
||||
if: matrix.cli != ''
|
||||
continue-on-error: true
|
||||
uses: actions/download-artifact@v4
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: cli-profile
|
||||
path: ${{ runner.temp }}/cli-profile
|
||||
@@ -394,7 +408,7 @@ jobs:
|
||||
TARBALL=$(pnpm --dir packages/llvm-darwin-arm64 pack --pack-destination "$RUNNER_TEMP" --silent)
|
||||
node scripts/verify-llvm-package.mjs "$RUNNER_TEMP/$(basename "$TARBALL")"
|
||||
- name: Upload native packages
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: native-${{ matrix.platform }}
|
||||
path: |
|
||||
@@ -420,7 +434,7 @@ jobs:
|
||||
runs-on: ${{ matrix.runner }}
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
- uses: ./.github/actions/mobile-runtime-pack
|
||||
with:
|
||||
runtime: ${{ matrix.runtime }}
|
||||
@@ -428,7 +442,7 @@ jobs:
|
||||
run: |
|
||||
mkdir -p "$RUNNER_TEMP/mobile-pack/${{ matrix.runtime }}"
|
||||
cp -R packages/${{ matrix.runtime }}/. "$RUNNER_TEMP/mobile-pack/${{ matrix.runtime }}/"
|
||||
- uses: actions/upload-artifact@v4
|
||||
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: native-${{ matrix.runtime }}
|
||||
path: ${{ runner.temp }}/mobile-pack
|
||||
@@ -453,10 +467,10 @@ jobs:
|
||||
uploads: ${{ steps.publish.outputs.uploads }}
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
|
||||
- name: Download native packages
|
||||
uses: actions/download-artifact@v4
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
pattern: native-*
|
||||
path: native-artifacts
|
||||
@@ -483,12 +497,12 @@ jobs:
|
||||
done
|
||||
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version: "24"
|
||||
registry-url: "https://registry.npmjs.org"
|
||||
@@ -650,7 +664,7 @@ jobs:
|
||||
|
||||
- name: Save accepted upload receipts
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: npm-accepted-${{ needs.check-release.outputs.version }}-${{ github.run_attempt }}
|
||||
path: |
|
||||
@@ -675,10 +689,10 @@ jobs:
|
||||
contents: read
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version: "24"
|
||||
registry-url: "https://registry.npmjs.org"
|
||||
@@ -705,15 +719,15 @@ jobs:
|
||||
actions: read
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
|
||||
with:
|
||||
version: 11.1.3
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version: "24"
|
||||
|
||||
@@ -739,7 +753,7 @@ jobs:
|
||||
echo "Extracted release notes for $VERSION ($LINES lines)"
|
||||
|
||||
- name: Download native distributions and runtime packs
|
||||
uses: actions/download-artifact@v4
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
pattern: native-*
|
||||
path: packages
|
||||
|
||||
@@ -251,3 +251,7 @@ NEXT_DIST_DIR=.next-check pnpm check
|
||||
## Releases
|
||||
|
||||
Releases are maintainer-run; see [RELEASING.md](./RELEASING.md).
|
||||
|
||||
## Pinned downloads and actions
|
||||
|
||||
Every toolchain archive that CI, the release jobs or the Sandbox image download (LLVM, Node, Zig, the LLVM apt key) has its SHA-256 in `scripts/toolchain.sha256`, and the code that downloads it runs `scripts/verify-toolchain.sh` on the file before using it. A version bump adds the new archive's digest to that file, taken from the publisher's signed checksum list and checked against a download. GitHub Actions are referenced by commit with the version in a trailing comment (`uses: owner/action@<40 hex digits> # v1.2.3`); Dependabot proposes the updates. Every workflow sets top-level `permissions`, and a job that needs more than reading the repository declares it. `tests/harness/ci-supply-chain.test.ts` enforces all three.
|
||||
|
||||
+11
-11
@@ -7,11 +7,17 @@ ARG ZIG_VERSION=0.16.0
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# Every download below is checked against the pinned digests before it is used.
|
||||
COPY scripts/toolchain.sha256 scripts/verify-toolchain.sh scripts/install-zig.sh /tmp/toolchain/
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install --yes --no-install-recommends \
|
||||
ca-certificates curl gnupg \
|
||||
&& curl --fail --silent --show-error --location https://apt.llvm.org/llvm-snapshot.gpg.key \
|
||||
| gpg --dearmor --output /usr/share/keyrings/llvm-snapshot.gpg \
|
||||
--output /tmp/llvm-snapshot.gpg.key \
|
||||
&& sh /tmp/toolchain/verify-toolchain.sh /tmp/llvm-snapshot.gpg.key \
|
||||
&& gpg --dearmor --output /usr/share/keyrings/llvm-snapshot.gpg /tmp/llvm-snapshot.gpg.key \
|
||||
&& rm /tmp/llvm-snapshot.gpg.key \
|
||||
&& echo "deb [signed-by=/usr/share/keyrings/llvm-snapshot.gpg] https://apt.llvm.org/noble/ llvm-toolchain-noble-22 main" \
|
||||
> /etc/apt/sources.list.d/llvm22.list \
|
||||
&& apt-get update \
|
||||
@@ -40,18 +46,12 @@ RUN apt-get update \
|
||||
RUN curl --fail --silent --show-error --location \
|
||||
--output /tmp/node.tar.xz \
|
||||
"https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.xz" \
|
||||
&& curl --fail --silent --show-error --location \
|
||||
--output /tmp/SHASUMS256.txt \
|
||||
"https://nodejs.org/dist/v${NODE_VERSION}/SHASUMS256.txt" \
|
||||
&& grep " node-v${NODE_VERSION}-linux-x64.tar.xz$" /tmp/SHASUMS256.txt \
|
||||
| sed 's#node-v[^ ]*-linux-x64.tar.xz#/tmp/node.tar.xz#' \
|
||||
| sha256sum --check --strict - \
|
||||
&& sh /tmp/toolchain/verify-toolchain.sh /tmp/node.tar.xz "node-v${NODE_VERSION}-linux-x64.tar.xz" \
|
||||
&& tar -xJf /tmp/node.tar.xz --directory /usr/local --strip-components=1 \
|
||||
&& rm /tmp/node.tar.xz /tmp/SHASUMS256.txt
|
||||
&& rm /tmp/node.tar.xz
|
||||
|
||||
COPY scripts/install-zig.sh /tmp/install-zig.sh
|
||||
RUN sh /tmp/install-zig.sh "$ZIG_VERSION" \
|
||||
&& rm /tmp/install-zig.sh
|
||||
RUN sh /tmp/toolchain/install-zig.sh "$ZIG_VERSION" \
|
||||
&& rm -r /tmp/toolchain
|
||||
|
||||
RUN npm install --global "pnpm@${PNPM_VERSION}"
|
||||
|
||||
|
||||
+5
-36
@@ -19,42 +19,11 @@ fi
|
||||
temporary=$(mktemp -d)
|
||||
trap 'rm -rf "$temporary"' EXIT HUP INT TERM
|
||||
|
||||
curl --fail --silent --show-error --location \
|
||||
https://ziglang.org/download/index.json \
|
||||
--output "$temporary/index.json"
|
||||
index_size=$(wc -c <"$temporary/index.json" | tr -d ' ')
|
||||
if [ "$index_size" -gt 2097152 ]; then
|
||||
echo "Zig download index exceeds 2 MiB" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
node --input-type=module - "$version" "$target" "$temporary/index.json" >"$temporary/metadata" <<'NODE'
|
||||
import { readFile } from "node:fs/promises";
|
||||
|
||||
const [version, target, indexPath] = process.argv.slice(2);
|
||||
const release = JSON.parse(await readFile(indexPath, "utf8"))[version];
|
||||
const artifact = release?.[target];
|
||||
if (!artifact?.tarball || !artifact?.shasum || !artifact?.size) {
|
||||
throw new Error(`Zig ${version} does not publish ${target}`);
|
||||
}
|
||||
const url = new URL(artifact.tarball);
|
||||
if (url.protocol !== "https:" || !/^[0-9a-f]{64}$/.test(artifact.shasum)) {
|
||||
throw new Error(`Zig ${version} returned invalid ${target} metadata`);
|
||||
}
|
||||
process.stdout.write(`${url.href}\n${artifact.shasum}\n${artifact.size}\n`);
|
||||
NODE
|
||||
|
||||
url=$(sed -n '1p' "$temporary/metadata")
|
||||
sha256=$(sed -n '2p' "$temporary/metadata")
|
||||
expected_size=$(sed -n '3p' "$temporary/metadata")
|
||||
archive="$temporary/zig.tar.xz"
|
||||
curl --fail --silent --show-error --location "$url" --output "$archive"
|
||||
printf '%s %s\n' "$sha256" "$archive" | sha256sum --check --strict -
|
||||
actual_size=$(wc -c <"$archive" | tr -d ' ')
|
||||
if [ "$actual_size" != "$expected_size" ]; then
|
||||
echo "Zig archive size mismatch: expected $expected_size, got $actual_size" >&2
|
||||
exit 1
|
||||
fi
|
||||
# The archive's digest is pinned in toolchain.sha256, beside this script (the Sandbox image copies both).
|
||||
name="zig-$target-$version.tar.xz"
|
||||
archive="$temporary/$name"
|
||||
curl --fail --silent --show-error --location "https://ziglang.org/download/$version/$name" --output "$archive"
|
||||
sh "$(dirname "$0")/verify-toolchain.sh" "$archive"
|
||||
|
||||
as_root() {
|
||||
if [ "$(id -u)" -eq 0 ]; then
|
||||
|
||||
@@ -17,6 +17,8 @@ llvm_distro=${VERSION_CODENAME:?the Sandbox image must identify its Ubuntu relea
|
||||
curl --fail --silent --show-error --location \
|
||||
https://apt.llvm.org/llvm-snapshot.gpg.key \
|
||||
--output /tmp/llvm-snapshot.gpg.key
|
||||
# Every download below is checked against scripts/toolchain.sha256 before it is used.
|
||||
sh scripts/verify-toolchain.sh /tmp/llvm-snapshot.gpg.key
|
||||
gpg --dearmor --yes --output /tmp/llvm-snapshot.gpg /tmp/llvm-snapshot.gpg.key
|
||||
sudo install -D -m 0644 /tmp/llvm-snapshot.gpg /etc/apt/keyrings/llvm-snapshot.gpg
|
||||
echo "deb [signed-by=/etc/apt/keyrings/llvm-snapshot.gpg] https://apt.llvm.org/${llvm_distro}/ llvm-toolchain-${llvm_distro}-22 main" \
|
||||
@@ -49,17 +51,12 @@ node_archive="node-v${node_version}-linux-x64.tar.xz"
|
||||
curl --fail --silent --show-error --location \
|
||||
"https://nodejs.org/dist/v${node_version}/${node_archive}" \
|
||||
--output "/tmp/${node_archive}"
|
||||
curl --fail --silent --show-error --location \
|
||||
"https://nodejs.org/dist/v${node_version}/SHASUMS256.txt" \
|
||||
--output /tmp/node-SHASUMS256.txt
|
||||
grep " ${node_archive}$" /tmp/node-SHASUMS256.txt \
|
||||
| sed "s# ${node_archive}# /tmp/${node_archive}#" \
|
||||
| sha256sum --check --strict -
|
||||
sh scripts/verify-toolchain.sh "/tmp/${node_archive}"
|
||||
sudo tar -xJf "/tmp/${node_archive}" --directory /usr/local --strip-components=1
|
||||
sh scripts/install-zig.sh "$zig_version"
|
||||
sudo npm install --global "pnpm@${pnpm_version}"
|
||||
|
||||
rm -f "/tmp/${node_archive}" /tmp/node-SHASUMS256.txt /tmp/llvm-snapshot.gpg.key /tmp/llvm-snapshot.gpg
|
||||
rm -f "/tmp/${node_archive}" /tmp/llvm-snapshot.gpg.key /tmp/llvm-snapshot.gpg
|
||||
sudo rm -rf /var/lib/apt/lists/*
|
||||
|
||||
node --version
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
# SHA-256 digests of the toolchain archives that CI, the release jobs and the Sandbox image download.
|
||||
#
|
||||
# Every script and workflow that downloads one of these files checks it with scripts/verify-toolchain.sh
|
||||
# before unpacking or running it, and fails when the digest differs or the file has no line here. The format is
|
||||
# sha256sum's: a digest, two spaces and the file name. To move to a new version, change the version where it is
|
||||
# set (the workflow or script, .node-version, Dockerfile.sandbox) and add the new file's digest here, taken from
|
||||
# the publisher's signed checksum list and checked against a download.
|
||||
#
|
||||
# https://github.com/llvm/llvm-project/releases/download/llvmorg-22.1.8/
|
||||
df0e1ecf16caf3489a272a5eea4eec9b0d82878f6477fa309504f918a0006384 LLVM-22.1.8-Linux-X64.tar.xz
|
||||
805efad2bb91cb4967fa569e0881d10c0f69c04461cf671cccbae19f547acc34 LLVM-22.1.8-Linux-ARM64.tar.xz
|
||||
d96c2cc1736f4eb7fa43cb9bbdf56d93551a9ae0a9aadb9c99c3c3b2b712a234 clang+llvm-22.1.8-x86_64-pc-windows-msvc.tar.xz
|
||||
922f1817a0df7b1489272d18134ee0087a8b068828f87ac63b9861b1a9965888 llvm-project-22.1.8.src.tar.xz
|
||||
# https://nodejs.org/dist/v24.22.1/
|
||||
6c172a9ab6718f7b801fb5a7bd486af2ee5e32758086a04b84fcce2aa77095e6 node-v24.22.1-linux-x64.tar.xz
|
||||
# https://ziglang.org/download/0.16.0/
|
||||
70e49664a74374b48b51e6f3fdfbf437f6395d42509050588bd49abe52ba3d00 zig-x86_64-linux-0.16.0.tar.xz
|
||||
ea4b09bfb22ec6f6c6ceac57ab63efb6b46e17ab08d21f69f3a48b38e1534f17 zig-aarch64-linux-0.16.0.tar.xz
|
||||
# https://apt.llvm.org/llvm-snapshot.gpg.key, the key that signs the LLVM apt packages of the Sandbox image
|
||||
8b2a587ffd672c4687e7581dad4b2f6c1bb2ad6b480cd9771ba2ff48e0b8c75d llvm-snapshot.gpg.key
|
||||
Executable
+35
@@ -0,0 +1,35 @@
|
||||
#!/bin/sh
|
||||
# verify-toolchain.sh <file> [<name>]
|
||||
#
|
||||
# Exits 0 only when <file>'s SHA-256 is the digest scripts/toolchain.sha256 pins for <name> (default: the file's
|
||||
# own name). A file with another digest, or with no line in the pin file, fails. It needs only a POSIX shell and
|
||||
# sha256sum or shasum, so it runs before Node is installed and in Git Bash on Windows runners.
|
||||
set -eu
|
||||
|
||||
file=${1:?usage: verify-toolchain.sh <file> [<name>]}
|
||||
name=${2:-$(basename "$file")}
|
||||
pins=${SCRIPTC_TOOLCHAIN_PINS:-$(dirname "$0")/toolchain.sha256}
|
||||
|
||||
expected=$(awk -v name="$name" '!/^#/ && $2 == name { print $1 }' "$pins")
|
||||
case "$expected" in
|
||||
"") echo "verify-toolchain: $pins pins no SHA-256 for $name" >&2; exit 1 ;;
|
||||
*[!0-9a-f]* | *"
|
||||
"*) echo "verify-toolchain: $pins has a malformed or repeated line for $name" >&2; exit 1 ;;
|
||||
esac
|
||||
if [ ${#expected} -ne 64 ]; then
|
||||
echo "verify-toolchain: $pins has a malformed line for $name" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# The digest is read from standard input so the output never carries the file name, which sha256sum escapes
|
||||
# when it holds a backslash.
|
||||
if command -v sha256sum >/dev/null 2>&1; then
|
||||
actual=$(sha256sum <"$file" | cut -d ' ' -f 1)
|
||||
else
|
||||
actual=$(shasum -a 256 <"$file" | cut -d ' ' -f 1)
|
||||
fi
|
||||
if [ "$actual" != "$expected" ]; then
|
||||
echo "verify-toolchain: $name has SHA-256 $actual, pinned $expected" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "verify-toolchain: $name matches its pinned SHA-256"
|
||||
@@ -0,0 +1,153 @@
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { load } from "js-yaml";
|
||||
import { expect, test } from "vitest";
|
||||
|
||||
const root = fileURLToPath(new URL("../..", import.meta.url));
|
||||
const read = (path: string): string => readFileSync(join(root, path), "utf8");
|
||||
const workflows = readdirSync(join(root, ".github", "workflows"))
|
||||
.filter((name) => name.endsWith(".yml"))
|
||||
.map((name) => `.github/workflows/${name}`);
|
||||
const actions = readdirSync(join(root, ".github", "actions")).map(
|
||||
(name) => `.github/actions/${name}/action.yml`,
|
||||
);
|
||||
const pinFile = "scripts/toolchain.sha256";
|
||||
const verifier = join(root, "scripts", "verify-toolchain.sh");
|
||||
|
||||
test("every action is pinned to a commit, with its version in a comment", () => {
|
||||
const unpinned: string[] = [];
|
||||
for (const path of [...workflows, ...actions]) {
|
||||
for (const [index, line] of read(path).split("\n").entries()) {
|
||||
const uses = /^\s*(?:- )?uses:\s*(.*)$/.exec(line)?.[1];
|
||||
if (uses === undefined || uses.startsWith("./")) continue;
|
||||
// owner/repo[/path]@<40 hex digits> # v<version>
|
||||
if (!/^[\w.-]+\/[\w.-]+(?:\/[\w./-]+)?@[0-9a-f]{40} # v\d+(?:\.\d+){0,2}$/.test(uses)) {
|
||||
unpinned.push(`${path}:${index + 1}: ${uses}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
expect(unpinned).toEqual([]);
|
||||
});
|
||||
|
||||
test("every workflow limits the default token", () => {
|
||||
for (const path of workflows) {
|
||||
const workflow = load(read(path)) as { permissions?: Record<string, string> };
|
||||
expect(workflow.permissions, `${path} needs top-level permissions`).toBeDefined();
|
||||
}
|
||||
// CI and the release's build jobs only read the repository. Publishing, artifact reuse and the GitHub release
|
||||
// ask for more in their own jobs.
|
||||
for (const path of [".github/workflows/ci.yml", ".github/workflows/release.yml"]) {
|
||||
const workflow = load(read(path)) as { permissions: Record<string, string> };
|
||||
expect(workflow.permissions, path).toEqual({ contents: "read" });
|
||||
}
|
||||
const release = load(read(".github/workflows/release.yml")) as {
|
||||
jobs: Record<string, { permissions?: Record<string, string> }>;
|
||||
};
|
||||
expect(release.jobs["publish"]!.permissions).toMatchObject({
|
||||
"id-token": "write",
|
||||
actions: "read",
|
||||
});
|
||||
expect(release.jobs["github-release"]!.permissions).toMatchObject({ contents: "write" });
|
||||
});
|
||||
|
||||
test("the pin file has one well-formed line per archive", () => {
|
||||
const names: string[] = [];
|
||||
for (const line of read(pinFile).split("\n")) {
|
||||
if (line === "" || line.startsWith("#")) continue;
|
||||
const match = /^([0-9a-f]{64}) {2}(\S+)$/.exec(line);
|
||||
expect(match, line).not.toBeNull();
|
||||
names.push(match![2]!);
|
||||
}
|
||||
expect(new Set(names).size).toBe(names.length);
|
||||
// The versions the fetching code names today.
|
||||
const node = read(".node-version").trim();
|
||||
const zig = /^ARG ZIG_VERSION=(.+)$/m.exec(read("Dockerfile.sandbox"))![1]!;
|
||||
expect(names).toEqual(
|
||||
expect.arrayContaining([
|
||||
`node-v${node}-linux-x64.tar.xz`,
|
||||
`zig-x86_64-linux-${zig}.tar.xz`,
|
||||
`zig-aarch64-linux-${zig}.tar.xz`,
|
||||
"llvm-snapshot.gpg.key",
|
||||
]),
|
||||
);
|
||||
});
|
||||
|
||||
test("every download of a toolchain archive is checked against the pin file", () => {
|
||||
// A file that fetches from one of these origins must also run the verifier.
|
||||
const origins =
|
||||
/github\.com\/llvm\/llvm-project\/releases\/download|nodejs\.org\/dist\/.*\.tar|ziglang\.org\/download|apt\.llvm\.org\/llvm-snapshot\.gpg\.key/;
|
||||
const scripts = ["scripts/sandbox-bootstrap.sh", "scripts/install-zig.sh", "Dockerfile.sandbox"];
|
||||
const fetching = [...workflows, ...actions, ...scripts].filter((path) =>
|
||||
origins.test(read(path)),
|
||||
);
|
||||
expect(fetching).toEqual(
|
||||
expect.arrayContaining([
|
||||
".github/workflows/ci.yml",
|
||||
".github/workflows/release.yml",
|
||||
".github/workflows/llvm-dist.yml",
|
||||
".github/actions/llvm-linux/action.yml",
|
||||
...scripts,
|
||||
]),
|
||||
);
|
||||
for (const path of fetching) {
|
||||
const text = read(path);
|
||||
const downloads = text.split("\n").filter((line) => origins.test(line)).length;
|
||||
const checks = text.split("verify-toolchain.sh").length - 1;
|
||||
expect(checks, `${path}: ${downloads} downloads`).toBeGreaterThanOrEqual(
|
||||
path === "scripts/install-zig.sh" ? 1 : Math.min(downloads, 1),
|
||||
);
|
||||
// Nothing trusts a checksum list fetched from the same place as the archive.
|
||||
expect(text, path).not.toContain("SHASUMS256.txt");
|
||||
}
|
||||
// Every LLVM archive name a workflow can download has a pin.
|
||||
const pinned = read(pinFile);
|
||||
for (const name of [
|
||||
"LLVM-22.1.8-Linux-X64.tar.xz",
|
||||
"LLVM-22.1.8-Linux-ARM64.tar.xz",
|
||||
"clang+llvm-22.1.8-x86_64-pc-windows-msvc.tar.xz",
|
||||
"llvm-project-22.1.8.src.tar.xz",
|
||||
]) {
|
||||
expect(pinned).toContain(` ${name}\n`);
|
||||
}
|
||||
const assets = [...read(".github/workflows/release.yml").matchAll(/llvm_asset: (\S+)/g)];
|
||||
for (const asset of assets) expect(pinned).toContain(` ${asset[1]}.tar.xz\n`);
|
||||
});
|
||||
|
||||
test("the verifier accepts the pinned digest and rejects any other file", () => {
|
||||
const directory = mkdtempSync(join(tmpdir(), "scriptc-toolchain-pins-"));
|
||||
try {
|
||||
const pins = join(directory, "pins.sha256");
|
||||
// sha256("hello\n")
|
||||
const digest = "5891b5b522d5df086d0ff0b110fbd9d21bb4fc7163af34d08286a2e846f6be03";
|
||||
writeFileSync(
|
||||
pins,
|
||||
`# comment\n${digest} good.txt\n${digest} twice.txt\n${digest} twice.txt\nzz bad.txt\n`,
|
||||
);
|
||||
const verify = (file: string, content: string, name?: string) => {
|
||||
writeFileSync(join(directory, file), content);
|
||||
return spawnSync(
|
||||
"sh",
|
||||
[verifier, join(directory, file), ...(name === undefined ? [] : [name])],
|
||||
{
|
||||
encoding: "utf8",
|
||||
env: { ...process.env, SCRIPTC_TOOLCHAIN_PINS: pins },
|
||||
},
|
||||
);
|
||||
};
|
||||
expect(verify("good.txt", "hello\n").status).toBe(0);
|
||||
expect(verify("download.bin", "hello\n", "good.txt").status).toBe(0);
|
||||
const tampered = verify("good.txt", "hello!\n");
|
||||
expect(tampered.status).toBe(1);
|
||||
expect(tampered.stderr).toContain(`pinned ${digest}`);
|
||||
const unknown = verify("other.txt", "hello\n");
|
||||
expect(unknown.status).toBe(1);
|
||||
expect(unknown.stderr).toContain("pins no SHA-256 for other.txt");
|
||||
expect(verify("twice.txt", "hello\n").status).toBe(1);
|
||||
expect(verify("bad.txt", "hello\n").status).toBe(1);
|
||||
} finally {
|
||||
rmSync(directory, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user