Add release and test github workflows #16
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tests | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
jobs: | |
fmt: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/cache@v4 | |
id: cache-cargo-fmt | |
- uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
components: rustfmt | |
- name: Rustfmt Check | |
uses: actions-rust-lang/rustfmt@v1 | |
deny: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/cache@v4 | |
id: cache-cargo-deny | |
- uses: actions-rust-lang/setup-rust-toolchain@v1 | |
- uses: taiki-e/install-action@v2 | |
with: | |
tool: cargo-audit | |
- name: Cargo audit | |
run: cargo audit | |
cargo-audit: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/cache@v4 | |
id: cache-cargo-fmt | |
- uses: actions-rust-lang/setup-rust-toolchain@v1 | |
- name: Rustfmt Check | |
uses: actions-rust-lang/rustfmt@v1 | |
- name: Fetch Repository | |
uses: actions/checkout@v4 | |
- name: Install stable toolchain | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
cli-test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions-rust-lang/setup-rust-toolchain@v1 | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
target | |
~/.cargo/bin | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ hashFiles('**/rust-toolchain') }} | |
id: cache-cargo-cli | |
- name: Tests and linting | |
run: | | |
cargo test -p ribboncurls-cli --release | |
lib-test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
target | |
~/.cargo/bin | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ hashFiles('**/rust-toolchain') }} | |
id: cache-cargo-lib | |
- name: Get Rust MSVR from Cargo.toml | |
id: cargo_msvr | |
run: | | |
MSVR=$(cargo metadata --format-version=1 | jq -r 'first(.packages[] | select(.source == null)) | .rust_version' | sed -E 's/^1\.([0-9]{2})$/1\.\1\.0/') | |
if [ -n "$MSVR" ]; then | |
echo "value=$MSVR" >> $GITHUB_ENV | |
echo "::set-output name=value::$MSVR" | |
else | |
echo "MSRV not found or is empty." | |
exit 1 | |
fi | |
- name: Test the Minimum Supported Version of Rust (MSVR) | |
run: | | |
if ! rustup toolchain list | grep -q '${{ steps.cargo_msvr.outputs.value }}'; then \ | |
rustup toolchain install ${{ steps.cargo_msvr.outputs.value }}; \ | |
fi | |
cargo +${{ steps.cargo_msvr.outputs.value }} test -p ribboncurls --verbose --release --color=always -- --color=always |