2
0
Fork 0
mirror of https://git.asonix.dog/asonix/pict-rs synced 2024-11-20 11:21:14 +00:00

Attempt composite action

This commit is contained in:
asonix 2024-02-07 16:27:23 -06:00
parent 825b355917
commit bfe431f764
2 changed files with 71 additions and 67 deletions

View file

@ -0,0 +1,64 @@
name: Prepare Rust
description: Prepare an environment to build or test rust packages
inputs:
targets:
description: "Targets to add to rustup, comma separated"
required: false
default: ''
runs:
using: "composite"
steps:
-
name: Fetch rust cache
id: cache
uses: https://github.com/actions/cache/restore@v4
with:
paths: |
~/.cargo/bin
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
~/.rustup
target/
key: rust-${{ 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: x86_64-unknown-linux-musl,armv7-unknown-linux-musleabihf,aarch64-unknown-linux-musl
-
name: Install cargo-binstall
if: steps.cache.outputs.cache-hit != 'true'
uses: https://github.com/taiki-e/install-action@v2
with:
tool: cargo-binstall
-
name: Install cargo-zigbuild
run: yes | cargo binstall 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: |
export PATH=$PATH:$HOME/.cargo/bin
export PATH=$PATH:$HOME/.rustup/bin
-
name: Populate rust cache
uses: https://github.com/actions/cache/restore@v4
if: steps.cache.ou.cache-hit != 'true'
with:
paths: |
~/.cargo/bin
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
~/.rustup
target/
key: ${{ steps.cache.outputs.cache-primary-key }}

View file

@ -5,41 +5,7 @@ on:
- main
jobs:
cache-rust:
runs-on: docker
container:
image: docker.io/node:20-bookworm
steps:
-
name: Install rustup and rust
id: rust
uses: https://github.com/dtolnay/rust-toolchain@1.75.0
with:
components: clippy
targets: x86_64-unknown-linux-musl,armv7-unknown-linux-musleabihf,aarch64-unknown-linux-musl
-
name: Install cargo-binstall
uses: https://github.com/taiki-e/install-action@v2
with:
tool: cargo-binstall
-
name: Install cargo-zigbuild
run: yes | cargo binstall cargo-zigbuild
-
name: Populate rust cache
uses: https://github.com/actions/cache/save@v4
with:
path: |
~/.cargo/bin
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
~/.rustup
key: ${{ runner.os }}-cargo-${{ steps.rust.outputs.cacheKey }}
clippy:
needs: [cache-rust]
runs-on: docker
container:
image: docker.io/node:20-bookworm
@ -48,16 +14,8 @@ jobs:
name: Checkout pict-rs
uses: https://github.com/actions/checkout@v4
-
name: Fetch rust cache
uses: https://github.com/actions/cache/restore@v4
with:
path: |
~/.cargo/bin
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
~/.rustup
key: ${{ runner.os }}-cargo-${{ jobs.cache-rust.steps.rust.outputs.cacheKey }}
name: Setup Rust
uses: .forgejo/actions/prepare-rust
-
name: Clippy
run: |
@ -65,7 +23,6 @@ jobs:
cargo clippy --no-default-features --features io-uring -- -D warnings
tests:
needs: [cache-rust]
runs-on: docker
container:
image: docker.io/node:20-bookworm
@ -74,14 +31,13 @@ jobs:
name: Checkout pict-rs
uses: https://github.com/actions/checkout@v4
-
name: Install rustup and rust
uses: https://github.com/dtolnay/rust-toolchain@1.75.0
name: Setup Rust
uses: .forgejo/actions/prepare-rust
-
name: Test
run: cargo test
check:
needs: [cache-rust]
strategy:
matrix:
target:
@ -96,26 +52,10 @@ jobs:
name: Checkout pict-rs
uses: https://github.com/actions/checkout@v4
-
name: Fetch rust cache
uses: https://github.com/actions/cache/restore@v4
name: Setup Rust
uses: .forgejo/actions/prepare-rust
with:
path: |
~/.cargo/bin
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
~/.rustup
key: ${{ runner.os }}-cargo-${{ jobs.cache-rust.steps.rust.outputs.cacheKey }}
-
name: Install cargo-binstall
uses: https://github.com/taiki-e/install-action@v2
with:
tool: cargo-binstall
-
name: Install zig
uses: https://github.com/goto-bus-stop/setup-zig@v2
with:
version: 0.11.0
targets: x86_64-unknown-linux-musl,armv7-unknown-linux-musleabihf,aarch64-unknown-linux-musl
-
name: Debug builds
run: cargo zigbuild --target ${{ matrix.target }}