Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Improve GitHub actions #669

Merged
merged 1 commit into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/actions/rust/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Rust Setup

inputs:
name:
required: true
type: string
components:
required: false
type: string

runs:
using: 'composite'
steps:
- shell: bash
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends -y libasound2-dev libudev-dev

- shell: bash
run: "git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id"

- uses: actions/cache@v3
with:
path: .git/lfs
key: rust-lfs-${{ inputs.name }}-${{ hashFiles('.lfs-assets-id') }}-v1

- shell: bash
run: git lfs pull

- uses: dtolnay/rust-toolchain@stable
id: rust-toolchain
with:
components: ${{ inputs.components }}

- shell: bash
run: rustc --version && cargo --version

- uses: actions/cache@v3
id: rust-cache
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: rust-cargo-${{ inputs.name }}-${{ steps.rust-toolchain.outputs.cachekey }}-${{ hashFiles('**/Cargo.lock') }}-v1
79 changes: 35 additions & 44 deletions .github/workflows/rust.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Rust
name: Test & Check

on:
push:
Expand All @@ -21,59 +21,50 @@ env:

jobs:
build:
name: Build & Test
name: Build
if: github.event.pull_request.draft == false
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Create LFS file list
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
- name: Restore LFS cache
uses: actions/cache@v3
- name: Checkout
uses: actions/checkout@v3
- uses: ./.github/actions/rust
name: Setup
with:
path: .git/lfs
key: lfs-${{ runner.os }}-${{ hashFiles('.lfs-assets-id') }}-v1
- name: Git LFS Pull
run: git lfs pull
name: test-build
- name: Build
run: cargo build --verbose --all-targets --all-features --locked

- uses: dtolnay/rust-toolchain@stable
clippy:
name: Clippy
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: ./.github/actions/rust
name: Setup
with:
name: clippy
components: clippy

- name: Rust Cache
uses: actions/cache@v3
id: rust-cache
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: tests-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
tests-${{ runner.os }}-

- name: Install Linux Dependencies
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends -y libasound2-dev libudev-dev
- run: rustc --version && cargo --version && cargo clippy --version
- name: Build
run: cargo build --verbose --all-targets --all-features --locked
- name: Clippy
run: cargo clippy --all --all-targets --all-features --workspace -- --deny warnings

test:
name: Test
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: ./.github/actions/rust
name: Setup
with:
name: test
- name: Test
run: cargo test --verbose --all-features --workspace

format:
name: Test Formatting
name: Formatting
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
Expand All @@ -85,7 +76,7 @@ jobs:
- run: cargo +nightly fmt --all -- --check

udeps:
name: Check Unused Dependencies
name: Unused Deps
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
Expand All @@ -110,7 +101,7 @@ jobs:
run: cargo udeps

comments:
name: Check Code Comments
name: Code Comments
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
Loading