-
Notifications
You must be signed in to change notification settings - Fork 2
58 lines (48 loc) · 1.98 KB
/
coverage.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
name: Generate SonarCloud code coverage
on:
workflow_dispatch:
env:
PACKAGES: g++ protobuf-compiler libspdlog-dev libpcap-dev libprotobuf-dev libgmock-dev
jobs:
code_coverage:
runs-on: ubuntu-latest
env:
TOOLCHAIN: "g++ protobuf-compiler"
LIBRARIES: "libspdlog-dev libpcap-dev libprotobuf-dev"
BUILD_WRAPPER_OUT_DIR: "$HOME/.build_wrapper_out"
SONAR_SERVER_URL: "https://sonarcloud.io"
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_PROJECT_KEY: "uweseimet/scsi2pi"
SONAR_ORGANIZATION: "uweseimet"
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up Python for gcovr
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install C++ dependencies
run: sudo apt install --yes ${{ env.PACKAGES }}
- name: Install gcovr
run: pip install gcovr==5.0 # 5.1 is not supported
- name: Install sonar-scanner and build-wrapper
uses: SonarSource/sonarcloud-github-c-cpp@v1
- name: Run build-wrapper
run: |
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} make -j $(nproc) -C cpp coverage
- name: Generate coverage data
run: gcovr --sonarqube > coverage.xml
- name: Run sonar-scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
sonar-scanner \
--define sonar.host.url=${{ env.SONAR_SERVER_URL }} \
--define sonar.projectKey=${{ env.SONAR_PROJECT_KEY }} \
--define sonar.organization=${{ env.SONAR_ORGANIZATION }} \
--define sonar.cfamily.build-wrapper-output=${{ env.BUILD_WRAPPER_OUT_DIR }} \
--define sonar.coverageReportPaths=coverage.xml \
--define sonar.coverage.exclusions="cpp/**/test/**" \
--define sonar.cpd.exclusions="cpp/**/test/**"