Skip to content

Commit

Permalink
update ci based on example by actions-rs
Browse files Browse the repository at this point in the history
  • Loading branch information
mat-kie committed Dec 5, 2024
1 parent a8e25c9 commit 12131c2
Showing 1 changed file with 73 additions and 35 deletions.
108 changes: 73 additions & 35 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Based on https://github.com/actions-rs/meta/blob/master/recipes/quickstart.md
name: Rust CI/CD

on:
Expand All @@ -9,62 +10,99 @@ on:
- main

jobs:
build:
name: Build and Test
check:
name: Check
runs-on: ubuntu-latest

steps:
- name: Checkout Code
- name: Checkout sources
uses: actions/checkout@v4

- name: Cache Cargo
uses: actions/cache@v3
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
profile: minimal
toolchain: stable
override: true

- name: Set up Rust
- name: Run cargo check
uses: actions-rs/cargo@v1
with:
command: check

test:
name: Test Suite
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: x86_64-unknown-linux-gnu
override: true

- name: Run cargo test
uses: actions-rs/cargo@v1
continue-on-error: true # WARNING: only for this example, remove it!
with:
command: test

lints:
name: Lints
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy

- name: Install Dependencies
run: sudo apt install libdbus-1-dev pkg-config && rustup component add clippy rustfmt
- name: Run cargo fmt
uses: actions-rs/cargo@v1
continue-on-error: true # WARNING: only for this example, remove it!
with:
command: fmt
args: --all -- --check

- name: Run Clippy (Linting)
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Run cargo clippy
uses: actions-rs/cargo@v1
continue-on-error: true # WARNING: only for this example, remove it!
with:
command: clippy
args: -- -D warnings
coverage:
name: Rust project
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Run Tests
run: cargo test --all-targets --all-features --verbose
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Run cargo-tarpaulin
uses: actions-rs/tarpaulin@v0.1
with:
version: '0.15.0'
args: '-- --test-threads 1'

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
- name: Upload to codecov.io
uses: codecov/codecov-action@v1.0.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
token: ${{secrets.CODECOV_TOKEN}}

- name: Archive code coverage results
uses: actions/upload-artifact@v3
with:
name: code-coverage-report
path: cobertura.xml

- name: Build Project
run: cargo build --release

# - name: Upload Build Artifacts
# uses: actions/upload-artifact@v3
# with:
# name: hrv-rs-build
# path: target/release/hrv-rs

path: cobertura.xml

0 comments on commit 12131c2

Please sign in to comment.