Skip to content

Commit

Permalink
adding new code-quality ci steps
Browse files Browse the repository at this point in the history
  • Loading branch information
alanmmolina committed Jul 14, 2024
1 parent 0d69346 commit 1e4674d
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 33 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Code Coverage

on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]

env:
CARGO_TERM_COLOR: always

jobs:
check:
name: Check
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true

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

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

- name: Archive Results
uses: actions/upload-artifact@v1
with:
name: code-coverage-report
path: cobertura.xml
40 changes: 13 additions & 27 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ on:
pull_request:
types: [opened, synchronize, reopened]

env:
CARGO_TERM_COLOR: always

jobs:
rust:
name: Custom Tools for Rust
name: Check
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -47,39 +50,22 @@ jobs:
components: rustfmt, clippy

- name: Install Tools
env:
CARGO_TERM_COLOR: always
run: |
cargo install --force cargo-audit
cargo install --force cargo-deny
cargo install --force cargo-outdated
cargo install cargo-audit
cargo install cargo-udeps
cargo install cargo-sonar
- name: Run `clippy`
env:
CARGO_TERM_COLOR: always
run: cargo clippy --message-format=json > clippy.json
run: cargo clippy --message-format=json > clippy.json || true

- name: Run `cargo-audit`
env:
CARGO_TERM_COLOR: always
run: cargo audit --json > audit.json

- name: Run `cargo-deny`
env:
CARGO_TERM_COLOR: always
run: cargo deny --format json check 2> deny.json
run: cargo audit --json > audit.json || true

- name: Run `cargo-outdated`
env:
CARGO_TERM_COLOR: always
run: cargo outdated --workspace --depth 1 --format json > outdated.json
- name: Run `cargo-udeps`
run: cargo +nightly udeps --quiet --workspace --output json > udeps.json || true

- name: Convert to Report
env:
CARGO_TERM_COLOR: always
run: |
cargo install cargo-sonar
cargo sonar --clippy --audit --deny --outdated
- name: Run `cargo-sonar`
run: cargo sonar --clippy --audit --udeps

- name: Upload Report Artifact
uses: actions/upload-artifact@v2
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
name: Unit tests
name: Unit Tests

on:
pull_request:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]

env:
CARGO_TERM_COLOR: always

jobs:
test:
name: coverage
name: Coverage
runs-on: ubuntu-latest
container:
image: xd009642/tarpaulin:develop-nightly
options: --security-opt seccomp=unconfined
steps:
- name: Checkout repository
- name: Checkout Repository
uses: actions/checkout@v2

- name: Generate code coverage
- name: Generate Code Coverage
run: |
cargo +nightly tarpaulin --verbose --all-features --workspace --timeout 120 --out xml --fail-under 50
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
sonar.host.url=https://sonarcloud.io
sonar.projectKey=postech-5soat-grupo-25_tech-challenge-pedido-produto
sonar.organization=postech-5soat-grupo-25
sonar.sources=src
sonar.host.url=https://sonarcloud.io
sonar.language=rust
sonar.externalIssuesReportPaths=sonar-issues.json

0 comments on commit 1e4674d

Please sign in to comment.