Setup a specific Rust toolchain with extra features like problem matchers
Go to file
Jonas Bushart 40e33d4912 Install newer bash on macOS
The code snippets are written with bash newer than 2014 in mind. This
works fine on Linux and Windows, but not macOS.
2023-02-13 23:28:57 +01:00
.github Run CI on more platforms 2023-02-13 23:28:43 +01:00
CHANGELOG.md Bump version to 1.4.0 2023-02-13 21:09:16 +01:00
LICENSE Initial commit 2022-04-17 21:06:51 +02:00
README.md Add an option to disable configuring Rust cache 2022-07-30 20:01:50 +02:00
action.yml Install newer bash on macOS 2023-02-13 23:28:57 +01:00
rust.json Create rust.json 2022-04-17 21:11:26 +02:00

README.md

Install Rust Toolchain

This GitHub Action installs a Rust toolchain using rustup. It further integrates into the ecosystem. Caching for Rust tools and build artifacts is enabled. Environment variables are set to optimize the cache hits. Problem Matchers are provided for build messages (cargo, clippy) and formatting (rustfmt).

The action is heavily inspired by dtolnay's https://github.com/dtolnay/rust-toolchain and extends it with further features.

Example workflow

name: "Test Suite"
on:
  push:
  pull_request:

jobs:
  test:
    name: cargo test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions-rust-lang/setup-rust-toolchain@v1
      - run: cargo test --all-features
 
  # Check formatting with rustfmt
  formatting:
    name: cargo fmt
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      # Ensure rustfmt is installed and setup problem matcher
      - uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          components: rustfmt
      - name: Rustfmt Check
        uses: actions-rust-lang/rustfmt@v1

Inputs

All inputs are optional. If a toolchain file (i.e., rust-toolchain or rust-toolchain.toml) is found in the root of the repository, it takes precedence. All input values are ignored if a toolchain file exists.

Name Description Default
toolchain Rustup toolchain specifier e.g. stable, nightly, 1.42.0. stable
target Additional target support to install e.g. wasm32-unknown-unknown
components Comma-separated string of additional components to install e.g. clippy, rustfmt
cache Automatically configure Rust cache (using Swatinem/rust-cache) true

Outputs

Name Description
rustc-version Version as reported by rustc --version
cargo-version Version as reported by cargo --version
rustup-version Version as reported by rustup --version

License

The scripts and documentation in this project are released under the MIT License.