Skip to content

Commit

Permalink
Change workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
LeChatP committed Jul 9, 2023
1 parent 5353a0d commit c11cb1f
Show file tree
Hide file tree
Showing 5 changed files with 159 additions and 103 deletions.
19 changes: 18 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,21 @@ jobs:
- name: Build Project
run: sudo make -e install
- name: Run Project
run: sr -h
run: sr -h
rust-build:
runs-on: ubuntu-latest
env:
working-directory: "role-manager"
steps:
- uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Build Project
run: cargo build --release
working-directory: ${{ env.working-directory }}
- name: Run Project
run: cargo run --release -- -h
working-directory: ${{ env.working-directory }}
35 changes: 0 additions & 35 deletions .github/workflows/criterion-test.yml

This file was deleted.

61 changes: 61 additions & 0 deletions .github/workflows/codacy.yml → .github/workflows/quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,64 @@ jobs:
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: results.sarif
rust-quality-gate:
name: Rust Quality Gate
env:
working-directory: "role-manager"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Build code
run: cargo build --all --release
working-directory: ${{ env.working-directory }}

- name: Format code with Rustfmt
run: cargo fmt --all -- --check
working-directory: ${{ env.working-directory }}
continue-on-error: true
id: rustfmt

- name: Run Clippy
run: cargo clippy --all -- -D warnings
working-directory: ${{ env.working-directory }}
continue-on-error: true
id: clippy

- name: Check errors and set workflow status
run: |
if [[ ${{ steps.rustfmt.outcome }} == 'failure' ]]; then
echo "Error: Rustfmt failed."
exit 1
fi
if [[ ${{ steps.clippy.outcome }} == 'failure' ]]; then
echo "Error: Clippy failed."
exit 1
fi
if: ${{ always() }}
rust-security:
name: Rust Security Gate
env:
working-directory: "role-manager"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Cargo audit
run: cargo audit --json | tee cargo-audit.json
working-directory: ${{ env.working-directory }}
id: cargo-audit
67 changes: 0 additions & 67 deletions .github/workflows/rust.yml

This file was deleted.

80 changes: 80 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Criterion Unit Tests

on:
push:
branches:
- '**'
pull_request:
branches: [ main ]

jobs:
criterion:
runs-on: ubuntu-latest

env:
TEST: 1
DEBUG: 1
COV: 1

steps:
- uses: actions/checkout@v2

- name: Update version
run: sudo apt-get update
- name: Install Dependencies
run: sudo -E ./configure.sh
- name: Build Unit Tests
run: make -e build_unit_test
- name: Run Unit Tests
run: ./bin/unit_test
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
gcov: true
rust-coverage:
runs-on: ubuntu-latest
env:
working-directory: role-manager
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Install grcov
working-directory: ${{ env.working-directory }}
run: cargo install grcov

- name: Install llvm-tools-preview
working-directory: ${{ env.working-directory }}
run: rustup component add llvm-tools-preview

- name: Build project
working-directory: ${{ env.working-directory }}
run: cargo build

- name: run tests with coverage
working-directory: ${{ env.working-directory }}
run: cargo test
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: '-Cinstrument-coverage'
LLVM_PROFILE_FILE: 'cargo-test-%p-%m.profraw'

- name: generate report
working-directory: ${{ env.working-directory }}
run: grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o target/debug/role-manager.lcov

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
file: role-manager/target/debug/role-manager.lcov
flags: unittests

0 comments on commit c11cb1f

Please sign in to comment.