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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/build-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: metacall-rust-toolchain-${{ matrix.distro }}
path: dist/rust-toolchain.tar.gz
retention-days: 1
path: |
dist/rust-toolchain-runtime.tar.gz
dist/rust-toolchain-dev.tar.gz
retention-days: 7
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ FROM ${RUST_TOOLCHAIN_IMAGE} AS validate

WORKDIR /workspace

COPY --from=pack /rust-toolchain.tar.gz /
COPY --from=pack /rust-toolchain-runtime.tar.gz /
COPY --from=pack /rust-toolchain-dev.tar.gz /

COPY scripts/validate.sh /validate.sh

Expand Down
3 changes: 2 additions & 1 deletion release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ docker buildx build \
--load \
-t metacall/rust-toolchain .
docker run --name metacall-rust-toolchain metacall/rust-toolchain
docker cp metacall-rust-toolchain:/rust-toolchain.tar.gz ./dist/
docker cp metacall-rust-toolchain:/rust-toolchain-runtime.tar.gz ./dist/
docker cp metacall-rust-toolchain:/rust-toolchain-dev.tar.gz ./dist/
docker rm metacall-rust-toolchain
17 changes: 12 additions & 5 deletions scripts/pack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,25 @@ function generate_tarball() {

# List of components
triplet=$(rustc -vV | grep host | awk '{print $2}')
components=(
runtime_components=(
"cargo-nightly-${triplet}"
"rust-std-nightly-${triplet}"
"rustc-nightly-${triplet}"
)

dev_components=(
"clippy-nightly-${triplet}"
"rust-analysis-nightly-${triplet}"
"rust-analyzer-nightly-${triplet}"
"rust-std-nightly-${triplet}"
"rustc-nightly-${triplet}"
"rustc-dev-nightly-${triplet}"
"rustfmt-nightly-${triplet}"
"rust-src-nightly"
)

# generate runtime tarball
generate_tarball "${runtime_components[@]}"
mv /rust-toolchain.tar.gz /rust-toolchain-runtime.tar.gz

# Generate dev tarball
generate_tarball "${components[@]}"
# mv /rust-toolchain.tar.gz /rust-toolchain-dev.tar.gz
generate_tarball "${dev_components[@]}"
mv /rust-toolchain.tar.gz /rust-toolchain-dev.tar.gz
84 changes: 41 additions & 43 deletions scripts/validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,50 @@ function error() {
exit 1
}

function validate_runtime() {

# runtime validation check
rustc -Vv | grep "1.94.0-nightly"|| error "rustc not found in runtime tarball"
cargo -V | grep "1.94.0" || error "cargo not found in runtime tarball"

which rustc || error "rustc not found in runtime tarball"
which cargo || error "cargo not found in runtime tarball"

rm -rf /tmp/runtime-test
mkdir -p /tmp/runtime-test
cd /tmp/runtime-test

cargo new hello-world
cd hello-world
cargo build || error "the program couldn't build"
cargo run | grep "Hello, world!" || error "the program couldn't run"

}

function validate_dev() {

# dev validation check
cargo clippy --version || error "clippy not found in dev tarball"
rustfmt --version || error "rustfmt not found in dev tarball"

which cargo-clippy | grep "/usr/local/bin"|| error "clippy not found in dev tarball"
which rustfmt | grep "/usr/local/bin" || error "rustfmt not found in dev tarball"

cargo clippy -- -D warnings || error "clippy failed"
cargo fmt --check || error "cargo fmt check failed"
}

# Install dependencies
apt update && apt install -y --no-install-recommends \
gcc \
libc6-dev \
libssl-dev

# Uncompress toolchain
tar -xzf /rust-toolchain.tar.gz -C /

# Validate
which rustc
which cargo

rustc -Vv
cargo -V

find /usr/local -name "librustc_driver*.so" 2>/dev/null
find /usr/local -name "rustc_middle*" 2>/dev/null
find /usr/local -name "rustc_hir*" 2>/dev/null
find /usr/local -name "rustc_interface*" 2>/dev/null
find /usr/local -name "*clippy*" 2>/dev/null
find /usr/local -name "*rustfmt*" 2>/dev/null

ls /usr/local/lib/rustlib/ 2>/dev/null

rustc -Vv | grep "1.94.0-nightly" || error "wrong rustc version"
cargo -V | grep "1.94.0" || error "wrong cargo version"
rustfmt --version | grep "nightly" || error "wrong rustfmt version"
rustc -Vv || error "rustc validation failed"
cargo -V || error "cargo validation failed"
cargo clippy --version || error "clippy validation failed"
rustfmt --version || error "rustfmt validation failed"

which rustc | grep "/usr/local/bin" || error "rustc not using installed toolchain"
which cargo | grep "/usr/local/bin" || error "cargo not using installed toolchain"
which cargo-clippy | grep "/usr/local/bin" || error "clippy not using installed toolchain"
which rustfmt | grep "/usr/local/bin" || error "rustfmt not using installed toolchain"

# Compile a program
mkdir /tmp/toolchain-test
cd /tmp/toolchain-test

cargo new hello-world
cd hello-world

cargo build || error "cargo build failed"
cargo clippy -- -D warnings || error "clippy failed"
cargo fmt --check || error "cargo fmt check failed"
cargo run | grep "Hello, world!" || error "cargo run failed"
# Uncompress toolchain runtime tarball
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong, if you want to test both you need to uncompress one, test that one, uncompress the other then, test the other, doing runtime first and then dev.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My recommendation is to encapsulate the testing, use a function for test the runtime, and then another function for test the dev that first calls to the runtime test function.

Then you uncompress one, call runtime validation, then the other, call the dev validation...

tar -xzf /rust-toolchain-runtime.tar.gz -C /
validate_runtime

# Uncompress toolchain dev tarball
tar -xzf /rust-toolchain-dev.tar.gz -C /
validate_dev

Loading