Add composite action for setting up Rust environment and create test workflow
This commit is contained in:
53
.github/actions/setup-rust/action.yml
vendored
Normal file
53
.github/actions/setup-rust/action.yml
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
name: 'Setup Rust environment'
|
||||
description: 'Composite action to checkout the repo, restore cargo caches and set up the Rust toolchain. Use this from job steps to keep setup DRY across jobs.'
|
||||
inputs:
|
||||
toolchain:
|
||||
description: 'Rust toolchain to install'
|
||||
required: false
|
||||
default: 'stable'
|
||||
override:
|
||||
description: 'Whether to override the default toolchain'
|
||||
required: false
|
||||
default: 'true'
|
||||
components:
|
||||
description: 'Comma-separated list of additional rust components to install'
|
||||
required: false
|
||||
default: 'clippy, rustfmt'
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Cache cargo registry
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.cargo/registry
|
||||
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
- name: Cache cargo index
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.cargo/index
|
||||
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
- name: Cache cargo build (target)
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: target
|
||||
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
- name: Set up rust toolchain
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
toolchain: ${{ inputs.toolchain }}
|
||||
override: ${{ inputs.override }}
|
||||
components: ${{ inputs.components }}
|
||||
Reference in New Issue
Block a user