Some checks failed
Test / test-frontend (pull_request) Successful in 43s
Test / lint-frontend (pull_request) Successful in 47s
Verify / get-ci-image (pull_request) Successful in 47s
Test / frontend-build (pull_request) Successful in 1m29s
Verify / verify-generated-db-entities (pull_request) Has been cancelled
Test / test-crates (pull_request) Has been cancelled
Test / lint-crates (pull_request) Has been cancelled
75 lines
2.5 KiB
YAML
75 lines
2.5 KiB
YAML
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'
|
|
skip_cache:
|
|
description: 'Whether to skip restoring and uploading caches (useful for testing the workflow without cache interference)'
|
|
required: false
|
|
default: 'false'
|
|
runs:
|
|
using: 'composite'
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Cache cargo registry
|
|
uses: actions/cache@v4
|
|
if: inputs.skip_cache != 'true'
|
|
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@v4
|
|
if: inputs.skip_cache != 'true'
|
|
with:
|
|
path: ~/.cargo/index
|
|
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
|
|
|
|
- name: Sanitize components input
|
|
shell: bash
|
|
run: echo "SANITIZED_COMPONENTS=${{ inputs.components }}" | sed -E 's/, ?| /-/g' >> $GITHUB_ENV
|
|
|
|
- name: Cache Rust toolchain
|
|
uses: actions/cache@v3
|
|
if: inputs.skip_cache != 'true'
|
|
with:
|
|
path: ~/.rustup
|
|
# Key includes the OS and the toolchain version (e.g., 'stable')
|
|
key: ${{ runner.os }}-rustup-${{ hashFiles('rust-toolchain.toml') }}-v1-${{ inputs.toolchain }}-${{ env.SANITIZED_COMPONENTS }}
|
|
restore-keys: |
|
|
${{ runner.os }}-rustup-
|
|
|
|
- name: Cache cargo build (target)
|
|
uses: actions/cache@v3
|
|
if: inputs.skip_cache != 'true'
|
|
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 }}
|