2
0
Fork 0
mirror of https://git.asonix.dog/asonix/pict-rs synced 2024-11-01 18:19:56 +00:00
pict-rs/.forgejo/actions/prepare-rust/action.yaml
2024-02-07 19:33:53 -06:00

64 lines
1.8 KiB
YAML

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