Build Rust CI Image #3
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build Rust CI Image | |
| on: | |
| workflow_dispatch: {} | |
| # Create a GitHub-hosted larger image-generation runner with this label before | |
| # running this workflow. After it succeeds, configure linux-extra-beefy to use | |
| # the generated `macro-rust-ci` custom image. | |
| jobs: | |
| build-rust-ci-image: | |
| runs-on: linux-extra-beefy-image-generation | |
| snapshot: | |
| image-name: macro-rust-ci | |
| version: 1.* | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Install system packages | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| build-essential \ | |
| curl \ | |
| jq \ | |
| libssl-dev \ | |
| lld \ | |
| pkg-config \ | |
| postgresql-client \ | |
| unzip \ | |
| zstd | |
| - name: Install Rust toolchain | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| if ! command -v rustup >/dev/null 2>&1; then | |
| curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal | |
| echo "$HOME/.cargo/bin" >> "$GITHUB_PATH" | |
| export PATH="$HOME/.cargo/bin:$PATH" | |
| fi | |
| toolchain="$(grep -E '^\s*channel\s*=' rust/rust-toolchain.toml | sed -E 's/.*"([^"]+)".*/\1/')" | |
| rustup toolchain install "$toolchain" --profile minimal --component clippy --component rustfmt | |
| rustup default "$toolchain" | |
| rustc --version | |
| cargo --version | |
| cargo clippy --version | |
| cargo fmt --version | |
| - name: Install Rust CI tools | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| cargo install cargo-nextest --locked | |
| cargo install just --locked | |
| cargo install sqlx-cli --locked | |
| cargo nextest --version | |
| just --version | |
| sqlx --version | |
| - name: Install sccache | |
| shell: bash | |
| env: | |
| SCCACHE_VERSION: v0.15.0 | |
| run: | | |
| set -euo pipefail | |
| archive="sccache-${SCCACHE_VERSION}-x86_64-unknown-linux-musl.tar.gz" | |
| basename="${archive%.tar.gz}" | |
| tmp_dir="$(mktemp -d)" | |
| trap 'rm -rf "$tmp_dir"' EXIT | |
| curl -fsSL "https://github.com/mozilla/sccache/releases/download/${SCCACHE_VERSION}/${archive}" \ | |
| | tar -xz -C "$tmp_dir" | |
| sudo install -m 0755 "$tmp_dir/$basename/sccache" /usr/local/bin/sccache | |
| sccache --version | |
| - name: Install Nix | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | \ | |
| sh -s -- install linux --no-confirm --init none \ | |
| --extra-conf "experimental-features = nix-command flakes" \ | |
| --extra-conf "trusted-users = root runner" | |
| # Make nix discoverable in non-login shells (GHA default). | |
| echo 'PATH="/nix/var/nix/profiles/default/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"' \ | |
| | sudo tee /etc/environment >/dev/null | |
| - name: Configure cachix substituter | |
| shell: bash | |
| env: | |
| CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }} | |
| run: | | |
| set -euo pipefail | |
| . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh | |
| nix profile install nixpkgs#cachix | |
| cachix authtoken "$CACHIX_AUTH_TOKEN" | |
| cachix use macro-inc | |
| - name: Materialize dev shell into /nix/store | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh | |
| sudo mkdir -p /var/cache/nix | |
| sudo chown runner:runner /var/cache/nix | |
| nix develop --profile /var/cache/nix/dev-shell --command true | |
| - name: Verify image contents | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh | |
| rustc --version | |
| cargo --version | |
| cargo clippy --version | |
| cargo fmt --version | |
| cargo nextest --version | |
| just --version | |
| sqlx --version | |
| sccache --version | |
| ld.lld --version | |
| nix --version | |
| test -L /var/cache/nix/dev-shell |