Skip to content

Commit

Permalink
chore: rework rust installation (#426)
Browse files Browse the repository at this point in the history
* chore: remove warning from bats test

* ci: fix tool version update issue creation and content

* chore: switch to ubuntu based rustup and cargo-binstall

Rustup is present as apt package in 24.04
cargo-binstall installs binaries for most cargo provided tools

* chore: fix probe-rs installation on aarch64
  • Loading branch information
rjaegers authored May 29, 2024
1 parent d2903c0 commit 5c919db
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 28 deletions.
2 changes: 2 additions & 0 deletions .devcontainer/cpp/test/testsuite.bats
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bats

bats_require_minimum_version 1.5.0

setup_file() {
# Installing the Windows SDK/CRT takes a long time.
# When still valid, use the installation from cache.
Expand Down
34 changes: 11 additions & 23 deletions .devcontainer/rust/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM ubuntu:24.04@sha256:3f85b7caad41a95462cf5b787d8a04604c8262cdcdf9a472b8c52ef83375fe15

ARG BATS_VERSION=1.10.0
ARG CARGO_BINSTALL_VERSION=1.6.8
ARG RUST_VERSION=1.78.0
ARG RUSTUP_INIT_VERSION=1.26.0

ARG DEBIAN_FRONTEND=noninteractive

Expand All @@ -23,17 +23,12 @@ RUN wget -qO /usr/local/share/ca-certificates/Cisco_Umbrella_Root_CA.crt https:/
&& update-ca-certificates

# Install rust
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
ENV CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:"$PATH"
RUN declare -A RUSTUP_SHA \
RUSTUP_SHA["x86_64"]="0b2f6c8f85a3d02fde2efc0ced4657869d73fccfce59defb4e8d29233116e6db" \
RUSTUP_SHA["aarch64"]="673e336c81c65e6b16dcdede33f4cc9ed0f08bde1dbe7a935f113605292dc800" \
&& wget -qO /tmp/rustup-init "https://static.rust-lang.org/rustup/archive/${RUSTUP_INIT_VERSION}/$(uname -m)-unknown-linux-gnu/rustup-init" \
&& echo "${RUSTUP_SHA[$(uname -m)]} /tmp/rustup-init" | sha256sum -c - \
&& chmod +x /tmp/rustup-init \
&& /tmp/rustup-init -y --no-modify-path --default-toolchain=${RUST_VERSION} --component llvm-tools --target thumbv7em-none-eabi \
&& rm -rf /tmp/rustup-init
RUN rustup set profile minimal \
&& rustup default ${RUST_VERSION} \
&& rustup component add clippy llvm-tools rustfmt \
&& rustup target add thumbv7em-none-eabi

# Install bats
RUN batstmp="$(mktemp -d /tmp/bats-core-${BATS_VERSION}.XXXX)" \
Expand All @@ -46,15 +41,8 @@ RUN batstmp="$(mktemp -d /tmp/bats-core-${BATS_VERSION}.XXXX)" \
# Update all tool alternatives to the correct version
RUN update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-13 20

# hadolint ignore=DL3008
RUN apt-get update \
&& apt-get install -y --no-install-recommends libudev-dev \
&& cargo install cargo-binutils \
&& cargo install cargo-mutants \
&& cargo install flip-link \
&& cargo install probe-rs --features cli \
&& rm -rf "$CARGO_HOME/registry" \
&& apt-get purge -y libudev-dev \
&& apt-get autoremove -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Install additional rust tools
RUN wget -qO - "https://github.com/cargo-bins/cargo-binstall/releases/download/v${CARGO_BINSTALL_VERSION}/cargo-binstall-$(uname -m)-unknown-linux-gnu.tgz" | tar xz -C "/usr/bin" \
&& cargo-binstall -y --locked [email protected] [email protected] [email protected] \
# cargo-binstall can't (yet) install probe-rs-tools for aarch64, fall-back to script installation
&& wget -qO - https://github.com/probe-rs/probe-rs/releases/download/v0.24.0/probe-rs-tools-installer.sh | sh
5 changes: 3 additions & 2 deletions .devcontainer/rust/apt-requirements-base.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"git": "1:2.43.0-1ubuntu7",
"gnupg2": "2.4.4-2ubuntu17",
"libc6-dev": "2.39-0ubuntu8.1",
"pkg-config": "1.8.1-2build1",
"wget": "1.21.4-1ubuntu4"
"rustup": "1.26.0-5build1",
"wget": "1.21.4-1ubuntu4",
"xz-utils": "5.6.1+really5.4.5-1"
}
2 changes: 2 additions & 0 deletions .devcontainer/rust/test/testsuite.bats
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bats

bats_require_minimum_version 1.5.0

setup() {
load '/usr/local/bats-support/load'
load '/usr/local/bats-assert/load'
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/issue-creation-tool-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ jobs:
fi
new_issue_url=$(gh issue create \
--title "$TITLE" \
--assignee "$ASSIGNEES" \
--label "$LABELS" \
--body "$BODY")
if [[ $PINNED == true ]]; then
Expand All @@ -38,12 +37,11 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
TITLE: Evaluate tool versions
ASSIGNEES: awesome-embedded-projects
LABELS: scheduled,tool-versions
BODY: |
## Description
This issue is automatically created as a gentle reminder to evaluate and update the tool versions for the container image built from this repository.
This issue is automatically created as a gentle reminder to evaluate and update the tool versions for the container images built from this repository.
The checklist below describes the steps that should be taken, and checked-off before this issue can be closed.
Any decisions about purposefully not updating a tool to a newer version should be logged as issue comment.
The general philosophy is to always include the latest tool versions and the latest [LTS](https://ubuntu.com/about/release-cycle) version of Ubuntu.
Expand All @@ -53,12 +51,20 @@ jobs:
## Checklist
### amp-devcontainer-cpp
- [ ] The [ARM GNU](https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads) toolchain is up to date and matches with the GCC version
- [ ] The [Clang toolchain](https://apt.llvm.org/) is up to date
- [ ] The [Docker cli](https://download.docker.com/linux/static/stable/) is up to date
- [ ] [bats-core](https://github.com/bats-core/bats-core), [bats-support](https://github.com/bats-core/bats-support) and [bats-assert](https://github.com/bats-core/bats-assert) are up to date
- [ ] [Mull](https://github.com/mull-project/mull) is up to date and compatible with the currently installed Clang version
- [ ] [include-what-you-use](https://github.com/include-what-you-use/include-what-you-use) is up to date and compatible with the currently installed Clang version
- [ ] [xwin](https://github.com/Jake-Shadle/xwin) is up to date
### amp-devcontainer-rust
- [ ] The [rust](https://rust-lang.org/) toolchain is up to date
- [ ] [rust-binstall](https://github.com/cargo-bins/cargo-binstall/releases) is up to date
- [ ] [bats-core](https://github.com/bats-core/bats-core), [bats-support](https://github.com/bats-core/bats-support) and [bats-assert](https://github.com/bats-core/bats-assert) are up to date
PINNED: true
CLOSE_PREVIOUS: true

0 comments on commit 5c919db

Please sign in to comment.