2024-02-07 22:27:23 +00:00
|
|
|
name: Prepare Rust
|
|
|
|
description: Prepare an environment to build or test rust packages
|
|
|
|
|
|
|
|
inputs:
|
|
|
|
targets:
|
2024-02-08 01:28:12 +00:00
|
|
|
description: "JSON Array of targets to add to rustup"
|
2024-02-07 22:27:23 +00:00
|
|
|
required: false
|
2024-02-08 01:28:12 +00:00
|
|
|
default: '[]'
|
2024-02-08 01:38:28 +00:00
|
|
|
rust-version:
|
|
|
|
description: "Version of rust to install"
|
|
|
|
required: true
|
|
|
|
default: '1.75.0'
|
2024-02-07 22:27:23 +00:00
|
|
|
|
|
|
|
runs:
|
|
|
|
using: "composite"
|
|
|
|
steps:
|
2024-02-07 22:50:17 +00:00
|
|
|
-
|
|
|
|
name: Install zig
|
|
|
|
uses: https://github.com/goto-bus-stop/setup-zig@v2
|
|
|
|
with:
|
|
|
|
version: 0.11.0
|
2024-02-07 22:27:23 +00:00
|
|
|
-
|
|
|
|
name: Fetch rust cache
|
|
|
|
id: cache
|
|
|
|
uses: https://github.com/actions/cache/restore@v4
|
|
|
|
with:
|
2024-02-07 22:31:01 +00:00
|
|
|
path: |
|
2024-02-07 22:27:23 +00:00
|
|
|
~/.cargo/bin
|
|
|
|
~/.cargo/registry/index
|
|
|
|
~/.cargo/registry/cache
|
|
|
|
~/.cargo/git/db
|
|
|
|
~/.rustup
|
|
|
|
target/
|
2024-02-08 01:38:28 +00:00
|
|
|
key: rust-${{ inputs.rust-version }}-${{ join(fromJSON(inputs.targets), '-') }}-${{ hashFiles('Cargo.toml') }}-${{ hashFiles('Cargo.lock')}}
|
2024-02-07 22:27:23 +00:00
|
|
|
-
|
|
|
|
name: Install rustup and rust
|
|
|
|
if: steps.cache.outputs.cache-hit != 'true'
|
2024-02-08 01:38:28 +00:00
|
|
|
uses: https://github.com/dtolnay/rust-toolchain@${{ inputs.rust-version }}
|
2024-02-07 22:27:23 +00:00
|
|
|
with:
|
|
|
|
components: clippy
|
2024-02-08 01:28:12 +00:00
|
|
|
targets: ${{ join(fromJSON(inputs.targets), ',') }}
|
2024-02-07 22:27:23 +00:00
|
|
|
-
|
|
|
|
name: Install cargo-zigbuild
|
2024-02-07 22:45:12 +00:00
|
|
|
if: steps.cache.outputs.cache-hit != 'true'
|
2024-02-08 01:22:56 +00:00
|
|
|
run: cargo install cargo-zigbuild
|
2024-02-07 22:27:23 +00:00
|
|
|
-
|
|
|
|
name: Fetch dependencies
|
|
|
|
if: steps.cache.outputs.cache-hit != 'true'
|
|
|
|
run: cargo fetch
|
|
|
|
-
|
|
|
|
name: Export path
|
|
|
|
if: steps.cache.outputs.cache-hit == 'true'
|
|
|
|
run: |
|
2024-02-08 01:33:53 +00:00
|
|
|
echo "${HOME}/.cargo/bin" >> "${GITHUB_PATH}"
|
|
|
|
echo "${HOME}/.rustup/bin" >> "${GITHUB_PATH}"
|
2024-02-07 22:27:23 +00:00
|
|
|
-
|
|
|
|
name: Populate rust cache
|
2024-02-08 01:29:20 +00:00
|
|
|
if: steps.cache.outputs.cache-hit != 'true'
|
2024-02-07 22:39:53 +00:00
|
|
|
uses: https://github.com/actions/cache/save@v4
|
2024-02-07 22:27:23 +00:00
|
|
|
with:
|
2024-02-07 22:31:01 +00:00
|
|
|
path: |
|
2024-02-07 22:27:23 +00:00
|
|
|
~/.cargo/bin
|
|
|
|
~/.cargo/registry/index
|
|
|
|
~/.cargo/registry/cache
|
|
|
|
~/.cargo/git/db
|
|
|
|
~/.rustup
|
|
|
|
target/
|
|
|
|
key: ${{ steps.cache.outputs.cache-primary-key }}
|