fix(ci): verify pinned rustup before executing installer
This commit is contained in:
@@ -34,10 +34,7 @@ jobs:
|
||||
run: apt-get update && apt-get install -y ca-certificates curl cmake ninja-build g++ python3-numpy
|
||||
- name: Install pinned Rust
|
||||
run: |
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain none
|
||||
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
|
||||
export PATH="$HOME/.cargo/bin:$PATH"
|
||||
rustup toolchain install 1.99.0 --profile minimal --component rustfmt --component clippy
|
||||
scripts/install-pinned-rustup.sh rustup toolchain install 1.99.0 --profile minimal --component rustfmt --component clippy
|
||||
- name: Local checks
|
||||
run: scripts/check-local.sh
|
||||
|
||||
@@ -56,10 +53,7 @@ jobs:
|
||||
run: apt-get update && apt-get install -y ca-certificates curl python3
|
||||
- name: Install pinned Rust nightly with LLVM coverage tools
|
||||
run: |
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain none
|
||||
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
|
||||
export PATH="$HOME/.cargo/bin:$PATH"
|
||||
rustup toolchain install nightly-2026-10-05 --profile minimal --component llvm-tools-preview
|
||||
scripts/install-pinned-rustup.sh rustup toolchain install nightly-2026-10-05 --profile minimal --component llvm-tools-preview
|
||||
- name: Test coverage parser and workflow contract
|
||||
run: python3 scripts/test-changed-scope-coverage.py
|
||||
- name: Run exact changed-production coverage gate
|
||||
@@ -121,11 +115,7 @@ jobs:
|
||||
--image-tag "${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
|
||||
- name: Install pinned Rust and musl target
|
||||
run: |
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain none
|
||||
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
|
||||
export PATH="$HOME/.cargo/bin:$PATH"
|
||||
rustup toolchain install 1.99.0 --profile minimal
|
||||
rustup target add --toolchain 1.99.0 x86_64-unknown-linux-musl
|
||||
scripts/install-pinned-rustup.sh rustup toolchain install 1.99.0 --profile minimal --target x86_64-unknown-linux-musl
|
||||
- name: Assemble actual combined executable and runtime image
|
||||
run: |
|
||||
# Keep resource evidence even if the hosted runner terminates this job.
|
||||
@@ -197,11 +187,7 @@ jobs:
|
||||
run: apt-get update && apt-get install -y ca-certificates curl docker.io musl-tools cmake binutils python3-numpy
|
||||
- name: Install pinned Rust and target
|
||||
run: |
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain none
|
||||
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
|
||||
export PATH="$HOME/.cargo/bin:$PATH"
|
||||
rustup toolchain install 1.99.0 --profile minimal
|
||||
rustup target add --toolchain 1.99.0 x86_64-unknown-linux-musl
|
||||
scripts/install-pinned-rustup.sh rustup toolchain install 1.99.0 --profile minimal --target x86_64-unknown-linux-musl
|
||||
- name: Build static CLI
|
||||
run: cargo build --manifest-path control-plane/Cargo.toml --locked --release --target x86_64-unknown-linux-musl --bin strata-next
|
||||
- name: Verify ELF and checksum
|
||||
@@ -383,11 +369,7 @@ jobs:
|
||||
run: apt-get update && apt-get install -y ca-certificates curl gh musl-tools cmake binutils python3-numpy
|
||||
- name: Install pinned Rust and target
|
||||
run: |
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain none
|
||||
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
|
||||
export PATH="$HOME/.cargo/bin:$PATH"
|
||||
rustup toolchain install 1.99.0 --profile minimal
|
||||
rustup target add --toolchain 1.99.0 x86_64-unknown-linux-musl
|
||||
scripts/install-pinned-rustup.sh rustup toolchain install 1.99.0 --profile minimal --target x86_64-unknown-linux-musl
|
||||
- name: Rebuild release CLI assets on the tag commit
|
||||
run: |
|
||||
cargo build --manifest-path control-plane/Cargo.toml --locked --release --target x86_64-unknown-linux-musl --bin strata-next
|
||||
|
||||
Executable
+61
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Pin the installer independently of rust-toolchain.toml, which pins rustc/cargo.
|
||||
readonly RUSTUP_VERSION="1.29.0"
|
||||
readonly RUSTUP_TARGET="x86_64-unknown-linux-gnu"
|
||||
readonly RUSTUP_INIT_SHA256="4acc9acc76d5079515b46346a485974457b5a79893cfb01112423c89aeb5aa10"
|
||||
readonly RUSTUP_INIT_URL="https://static.rust-lang.org/rustup/archive/${RUSTUP_VERSION}/${RUSTUP_TARGET}/rustup-init"
|
||||
|
||||
# Give each Actions job an isolated installation so a host's rustup cannot
|
||||
# silently override the version pinned here.
|
||||
if [[ -n "${RUNNER_TEMP:-}" && -n "${GITHUB_RUN_ID:-}" ]]; then
|
||||
rustup_home="${RUNNER_TEMP}/strata-rustup-${GITHUB_RUN_ID}-${GITHUB_JOB:-job}"
|
||||
export CARGO_HOME="${rustup_home}/cargo"
|
||||
export RUSTUP_HOME="${rustup_home}/rustup"
|
||||
mkdir -p "$CARGO_HOME"
|
||||
if [[ -n "${GITHUB_ENV:-}" ]]; then
|
||||
printf 'CARGO_HOME=%s\nRUSTUP_HOME=%s\n' "$CARGO_HOME" "$RUSTUP_HOME" >> "$GITHUB_ENV"
|
||||
fi
|
||||
fi
|
||||
|
||||
tmp_dir="$(mktemp -d)"
|
||||
trap 'rm -rf -- "$tmp_dir"' EXIT
|
||||
|
||||
python3 - "$RUSTUP_INIT_URL" "$tmp_dir/rustup-init" <<'PY'
|
||||
import shutil
|
||||
import sys
|
||||
import urllib.request
|
||||
|
||||
request = urllib.request.Request(
|
||||
sys.argv[1], headers={"User-Agent": "strata-next-pinned-rustup-bootstrap/1"}
|
||||
)
|
||||
with urllib.request.urlopen(request, timeout=120) as response:
|
||||
with open(sys.argv[2], "wb") as output:
|
||||
shutil.copyfileobj(response, output)
|
||||
PY
|
||||
|
||||
printf '%s %s\n' "$RUSTUP_INIT_SHA256" "$tmp_dir/rustup-init" | sha256sum --check --status || {
|
||||
echo "rustup-init ${RUSTUP_VERSION} checksum mismatch" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
chmod 0755 "$tmp_dir/rustup-init"
|
||||
"$tmp_dir/rustup-init" -y --no-modify-path \
|
||||
--default-host "$RUSTUP_TARGET" --default-toolchain none --profile minimal
|
||||
|
||||
export PATH="${CARGO_HOME:-$HOME/.cargo}/bin:$PATH"
|
||||
if [[ -n "${GITHUB_PATH:-}" ]]; then
|
||||
printf '%s\n' "${CARGO_HOME:-$HOME/.cargo}/bin" >> "$GITHUB_PATH"
|
||||
fi
|
||||
rustup set auto-self-update disable
|
||||
|
||||
actual_version="$(rustup --version | awk 'NR == 1 { print $2 }')"
|
||||
if [[ "$actual_version" != "$RUSTUP_VERSION" ]]; then
|
||||
echo "expected rustup ${RUSTUP_VERSION}, got ${actual_version:-unknown}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if (( $# > 0 )); then
|
||||
"$@"
|
||||
fi
|
||||
Reference in New Issue
Block a user