Skip to content

Commit

Permalink
ci(rust): improve workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
EdJoPaTo committed Apr 22, 2024
1 parent 77418fd commit fe6a24d
Showing 1 changed file with 41 additions and 43 deletions.
84 changes: 41 additions & 43 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ name: Test and Build Rust
on:
push:
pull_request:

env:
RUSTFLAGS: --deny warnings
workflow_dispatch:

jobs:
rustfmt:
Expand All @@ -19,61 +17,60 @@ jobs:
- uses: actions/checkout@v4
- run: cargo fmt --check --verbose

clippy:
name: Clippy ${{ matrix.toolchain }}
runs-on: ubuntu-latest
continue-on-error: ${{ (matrix.toolchain == 'beta') || (matrix.toolchain == 'nightly') }}
strategy:
fail-fast: false
matrix:
toolchain:
- stable
- beta
- nightly
env:
RUSTFLAGS: --deny warnings
steps:
- name: Setup Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
components: clippy
- uses: actions/checkout@v4
- run: cargo fetch --locked
- run: cargo clippy --offline --all-targets
- run: cargo doc --offline --no-deps

test:
name: Test ${{ matrix.toolchain }} ${{ matrix.os }} ${{ matrix.features }}
name: Test ${{ matrix.toolchain }} ${{ matrix.os }}
runs-on: ${{ matrix.os }}
continue-on-error: ${{ (matrix.toolchain == 'beta') || (matrix.toolchain == 'nightly') }}
continue-on-error: ${{ matrix.toolchain == 'nightly' }}
strategy:
fail-fast: false
matrix:
toolchain:
- stable
- beta
- nightly
os:
- ubuntu-latest
- macos-latest
- windows-latest
clippyargs:
- -D clippy::pedantic
features:
- "" # default features
include:
# Check future versions and maybe get some glances on soon to be lints
- toolchain: beta
os: ubuntu-latest
features: --all-features
clippyargs: -D clippy::pedantic -D clippy::nursery
- toolchain: nightly
os: ubuntu-latest
features: --all-features
clippyargs: -D clippy::pedantic
env:
RUSTFLAGS: --allow unknown-lints --deny warnings
steps:
- name: Setup Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
components: clippy

- uses: actions/checkout@v4
- run: cargo fetch --locked
- run: cargo build --offline --all-targets
- run: cargo test --offline

- name: Fetch dependencies
run: cargo fetch --verbose --locked

- name: Check clippy
run: cargo clippy --verbose --locked --all-targets ${{ matrix.features }} -- ${{ matrix.clippyargs }}

- name: Check docs
run: cargo doc --verbose --locked --no-deps ${{ matrix.features }}

- name: Build
run: cargo build --verbose --locked --all-targets ${{ matrix.features }}

- name: Run tests
run: cargo test --verbose --locked ${{ matrix.features }}

github-release:
release:
name: Release ${{ matrix.triple }}
runs-on: ${{ matrix.os }}
needs: test
permissions:
contents: write
strategy:
Expand Down Expand Up @@ -103,6 +100,8 @@ jobs:
os: windows-latest
- triple: aarch64-pc-windows-msvc
os: windows-latest
env:
RUSTFLAGS: --allow unknown-lints --deny warnings
steps:
- name: Setup Rust
uses: dtolnay/rust-toolchain@master
Expand Down Expand Up @@ -131,11 +130,10 @@ jobs:
echo "artifact: $name"
echo "ARTIFACT_NAME=$name" >> $GITHUB_ENV
- name: Fetch dependencies
run: cargo fetch --verbose --locked
- run: cargo fetch --locked

- name: Build
run: ${{ runner.os == 'Linux' && 'cross' || 'cargo' }} build --release --verbose --locked --target ${{ matrix.triple }}
run: ${{ runner.os == 'Linux' && 'cross' || 'cargo' }} build --release --offline --target ${{ matrix.triple }}

- name: Package tar.gz (*nix)
if: runner.os != 'Windows'
Expand All @@ -156,7 +154,7 @@ jobs:
./target/${{ matrix.triple }}/release/project-below.exe
- name: Package deb
if: runner.os == 'Linux'
run: cargo deb --verbose --no-build --no-strip --target ${{ matrix.triple }} --output ${{ env.ARTIFACT_NAME }}.deb
run: cargo deb --no-build --no-strip --target ${{ matrix.triple }} --output ${{ env.ARTIFACT_NAME }}.deb
- name: Package rpm
if: matrix.rpm
run: cargo generate-rpm --auto-req disabled --target ${{ matrix.triple }} --output ${{ env.ARTIFACT_NAME }}.rpm
Expand All @@ -173,7 +171,7 @@ jobs:
- name: Create GitHub release
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
files: |
*.deb
Expand Down

0 comments on commit fe6a24d

Please sign in to comment.