-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (79 loc) · 2.64 KB
/
code-quality.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: Code Quality
on:
workflow_call:
secrets:
sonarcloud_token:
required: true
env:
CARGO_TERM_COLOR: always
jobs:
Template:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Environment
run: |
echo "SONAR_ORGANIZATION=${{ github.repository_owner }}" >> $GITHUB_ENV
echo "SONAR_PROJECT_KEY=${{ github.repository_owner }}_${{ github.event.repository.name }}" >> $GITHUB_ENV
- name: Cache `cargo` Registry
uses: actions/cache@v2
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-
- name: Cache `cargo` Index
uses: actions/cache@v2
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-index-
- name: Cache `cargo` Build
uses: actions/cache@v2
with:
path: target
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-build-
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
components: rustfmt, clippy
- name: Install Tools
run: |
cargo install cargo-audit
cargo install cargo-udeps
cargo install cargo-sonar
- name: Run `clippy`
run: cargo clippy --message-format=json > clippy.json || true
- name: Run `cargo-audit`
run: cargo audit --json > audit.json || true
- name: Run `cargo-udeps`
run: cargo +nightly udeps --quiet --workspace --output json > udeps.json || true
- name: Run `cargo-sonar`
run: cargo sonar --clippy --audit --udeps
- name: Upload to sonarcloud.io
uses: sonarsource/sonarqube-scan-action@v2.3.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.sonarcloud_token }}
SONAR_ORGANIZATION: ${{ env.SONAR_ORGANIZATION }}
SONAR_PROJECT_KEY: ${{ env.SONAR_PROJECT_KEY }}
with:
args: >
-Dsonar.host.url=https://sonarcloud.io
-Dsonar.projectKey=${{ env.SONAR_PROJECT_KEY }}
-Dsonar.organization=${{ env.SONAR_ORGANIZATION }}
-Dsonar.sources=src
-Dsonar.language=rust
-Dsonar.externalIssuesReportPaths=sonar-issues.json
- name: Archive Results
uses: actions/upload-artifact@v3
with:
name: code-quality-report
path: sonar-issues.json