[Github Actions] coverage splitted #6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Coverage | |
on: # yamllint disable-line rule:truthy | |
push: | |
branches: ["main"] | |
pull_request: | |
# The branches below must be a subset of the branches above | |
branches: ["main"] | |
workflow_dispatch: | |
jobs: | |
coverage: | |
runs-on: ubuntu-latest | |
env: | |
CARGO_TERM_COLOR: always | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Rust | |
run: rustup update stable | |
- name: Install cargo-llvm-cov | |
uses: taiki-e/install-action@cargo-llvm-cov | |
- name: Install Clippy | |
run: rustup component add clippy | |
- name: Install cargo-sonar and run Clippy | |
run: | | |
cargo install cargo-sonar | |
cargo clippy --message-format json > my-clippy-report.json | |
cargo sonar --clippy --clippy-path my-clippy-report.json | |
- name: Generate code coverage | |
run: > | |
cargo llvm-cov | |
--all-features | |
--workspace | |
--lcov | |
--output-path lcov.info | |
- name: Upload coverage artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-report | |
path: | | |
lcov.info | |
sonar-issues.json | |
codecov: | |
name: Upload to Codecov | |
runs-on: ubuntu-24.04 | |
needs: coverage | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v5 | |
with: | |
fetch-depth: 0 | |
- name: Download coverage artifact | |
uses: actions/download-artifact@v5 | |
with: | |
name: coverage-report | |
- name: Upload coverage reports to Codecov with GitHub Action | |
uses: codecov/codecov-action@v5 | |
with: | |
files: coverage.out | |
token: ${{ secrets.CODECOV_TOKEN }} # required | |
verbose: true # optional (default = false) | |
sonarqube: | |
name: SonarQube | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
- name: SonarCloud Scan | |
uses: SonarSource/sonarcloud-github-action@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
with: | |
args: > | |
-Dsonar.externalIssuesReportPaths=sonar-issues.json | |
-Dcommunity.rust.lcov.reportPaths=lcov.info |