name: Rust plugin toolchain description: >- Native checks and optional Windows GNU cross-compilation in Node's Debian container. Restores the Rust toolchain, Cargo registry, and the caller's build directories from the runner cache, and saves them after the job. inputs: windows: description: Install the Windows cross compiler default: "false" cache-name: description: Distinguishes build-directory caches of different jobs required: true target-paths: description: Build directories to cache, one per line, relative to the workspace default: target runs: using: composite steps: - name: Cache keys id: keys shell: bash run: | # A new ISO week starts fresh caches, so stale build output cannot grow forever # and the stable toolchain is refreshed regularly. echo "week=$(date -u +%G-%V)" >> "$GITHUB_OUTPUT" - name: Restore Rust toolchain and Cargo registry uses: https://github.com/actions/cache@v4 with: path: | .cargo-ci/bin .cargo-ci/registry/index .cargo-ci/registry/cache .cargo-ci/git/db .rustup-ci key: rust-${{ inputs.windows }}-${{ steps.keys.outputs.week }}-${{ hashFiles('Cargo.lock', 'plugins/*/plugin/Cargo.lock', 'tools/editor-check/Cargo.lock') }} restore-keys: | rust-${{ inputs.windows }}-${{ steps.keys.outputs.week }}- - name: Restore build directories uses: https://github.com/actions/cache@v4 with: path: ${{ inputs.target-paths }} # One entry per job, week, and dependency set: compiled dependencies are # reused, and only this repository's crates rebuild on each push. key: build-${{ inputs.cache-name }}-${{ steps.keys.outputs.week }}-${{ hashFiles('Cargo.lock', 'plugins/*/plugin/Cargo.lock', 'tools/editor-check/Cargo.lock') }} restore-keys: | build-${{ inputs.cache-name }}-${{ steps.keys.outputs.week }}- - name: Install build prerequisites shell: bash run: | apt-get update apt-get install -y --no-install-recommends python3 curl ca-certificates pkg-config libgl1-mesa-dev libx11-dev libxcursor-dev libx11-xcb-dev libxcb1-dev libxcb-dri2-0-dev libxcb-icccm4-dev libxkbcommon-x11-dev if [ "${{ inputs.windows }}" = "true" ]; then apt-get install -y --no-install-recommends gcc-mingw-w64-x86-64 fi - name: Install Rust shell: bash run: | if [ ! -x "$CARGO_HOME/bin/rustup" ]; then curl --proto '=https' --tlsv1.2 -fsSL https://sh.rustup.rs -o /tmp/rustup-init.sh sh /tmp/rustup-init.sh -y --profile minimal --default-toolchain none --no-modify-path fi echo "$CARGO_HOME/bin" >> "$GITHUB_PATH" # No-op when the restored toolchain is already current. "$CARGO_HOME/bin/rustup" toolchain install stable --profile minimal -c rustfmt -c clippy "$CARGO_HOME/bin/rustup" default stable if [ "${{ inputs.windows }}" = "true" ]; then "$CARGO_HOME/bin/rustup" target add x86_64-pc-windows-gnu fi "$CARGO_HOME/bin/rustc" --version