Skip to content

Commit bd0f812

Browse files
committed
ci: use rust-toolchain.toml
1 parent 8059651 commit bd0f812

File tree

4 files changed

+30
-11
lines changed

4 files changed

+30
-11
lines changed

.github/builder/common.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
set -e
77

8-
if [ -z "${RUST_NIGHTLY_VERSION}" ]; then
9-
echo "RUST_NIGHTLY_VERSION not set. It should be defined by ci.yml workflow."
8+
if [ -z "${RUST_NIGHTLY_DATE}" ]; then
9+
echo "RUST_NIGHTLY_DATE not set. It should be defined by ci.yml workflow."
1010
exit 1
1111
fi
1212

@@ -112,8 +112,8 @@ download_and_verify_make() {
112112

113113
download_and_verify_rust() {
114114
RUST_GPG_KEY_URL="https://static.rust-lang.org/rust-key.gpg.ascii"
115-
RUST_URL="https://static.rust-lang.org/dist/${RUST_NIGHTLY_VERSION}/rust-nightly-x86_64-unknown-linux-gnu.tar.xz"
116-
RUST_SIG_URL="https://static.rust-lang.org/dist/${RUST_NIGHTLY_VERSION}/rust-nightly-x86_64-unknown-linux-gnu.tar.xz.asc"
115+
RUST_URL="https://static.rust-lang.org/dist/${RUST_NIGHTLY_DATE}/rust-nightly-x86_64-unknown-linux-gnu.tar.xz"
116+
RUST_SIG_URL="https://static.rust-lang.org/dist/${RUST_NIGHTLY_DATE}/rust-nightly-x86_64-unknown-linux-gnu.tar.xz.asc"
117117

118118
if [ -z "${BUILDER_DIR}" ]; then
119119
echo "BUILDER_DIR not set. Exiting..."

.github/workflows/ci.yml

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ env:
1919
PUBLIC_SIMICS_ISPM_VERSION: "1.8.3"
2020
MINGW_URL: "https://github.com/brechtsanders/winlibs_mingw/releases/download/13.2.0-16.0.6-11.0.0-ucrt-r1/winlibs-x86_64-posix-seh-gcc-13.2.0-llvm-16.0.6-mingw-w64ucrt-11.0.0-r1.7z"
2121
MINGW_VERSION: "13.2.0-16.0.6-11.0.0-ucrt-r1"
22-
RUST_NIGHTLY_VERSION: "2025-02-28"
2322

2423
permissions:
2524
contents: read
@@ -472,9 +471,6 @@ jobs:
472471
chmod -R 0755 tests/rsrc/
473472
474473
- uses: dtolnay/rust-toolchain@83bdede770b06329615974cf8c786f845d824dfb # nightly
475-
with:
476-
toolchain: nightly-${{ env.RUST_NIGHTLY_VERSION }}
477-
components: rustfmt,clippy,miri
478474

479475
- name: Cache SIMICS Dependencies
480476
id: cache-simics-packages
@@ -579,7 +575,7 @@ jobs:
579575
echo "Downloading Rustup"
580576
Invoke-WebRequest -URI https://win.rustup.rs/x86_64 -OutFile C:\rustup-init.exe
581577
echo "Installing Rust"
582-
C:\rustup-init.exe --default-toolchain nightly-${{ env.RUST_NIGHTLY_VERSION }} --default-host x86_64-pc-windows-gnu -y
578+
C:\rustup-init.exe --default-host x86_64-pc-windows-gnu --default-toolchain none
583579
584580
- name: Cache SIMICS
585581
id: cache-simics-packages-windows
@@ -653,10 +649,33 @@ jobs:
653649
path: .github/builder/rsrc
654650
key: "cache-builder-dependencies-${{ hashFiles('.github/builder/common.sh') }}"
655651

652+
# tomllib is available in Python 3.11 and later
653+
- name: Set up Python 3.11
654+
uses: actions/setup-python@v5
655+
with:
656+
python-version: '3.11'
657+
658+
- name: Extract Rust channel from rust-toolchain.toml
659+
id: rust-channel
660+
shell: python3 {0}
661+
run: |
662+
import tomllib
663+
import os
664+
665+
with open('rust-toolchain.toml', 'rb') as f:
666+
data = tomllib.load(f)
667+
channel = data['toolchain']['channel']
668+
date = channel.split("nightly-")[1]
669+
670+
with open(os.environ['GITHUB_OUTPUT'], 'a') as out:
671+
out.write(f'nightly_date={date}\n')
672+
656673
# NOTE: This script only downloads the builder dependencies if they do not already exist,
657674
# but it always verifies them.
658675
- name: Build Distribution Package
659676
run: |
677+
RUST_NIGHTLY_DATE="${{ steps.rust-channel.outputs.nightly_date }}"
678+
export RUST_NIGHTLY_DATE
660679
./scripts/build.sh
661680
662681
- name: Upload Distribution Package

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ RUN dnf -y update && \
6666
isort==5.12.0 \
6767
mypy==1.6.1 \
6868
pylint==3.0.2 && \
69-
curl https://sh.rustup.rs -sSf | bash -s -- -y
69+
curl https://sh.rustup.rs -sSf | bash -s -- --default-toolchain none -y
7070

7171

7272
WORKDIR /workspace

scripts/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ docker build \
2525
docker create --name "${CONTAINER_NAME}" "${IMAGE_NAME}" bash
2626
mkdir -p "${ROOT_DIR}/packages"
2727
docker cp "${CONTAINER_NAME}:/packages" "${ROOT_DIR}/"
28-
docker rm -f "${CONTAINER_NAME}"
28+
docker rm -f "${CONTAINER_NAME}"

0 commit comments

Comments
 (0)