-
-
Notifications
You must be signed in to change notification settings - Fork 2
141 lines (124 loc) · 4.16 KB
/
Copy pathtest_sonarcloud.yml
File metadata and controls
141 lines (124 loc) · 4.16 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: Test SonarCloud
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
# schedule:
# cron: "0 13 * * 1" # Every monday at 13h
env:
SONAR_SCANNER_VERSION: 6.2.1.4610
jobs:
run:
runs-on: ubuntu-latest
steps:
# - name: "Dependencies: APT"
# run: |
# sudo apt update
# sudo apt install -y \
# qt6-base-dev \
# catch2 \
# gcovr \
# texlive-xetex \
# cairosvg \
# imagemagick
# libxml2-utils
- name: 'Dependencies: Nix'
uses: cachix/install-nix-action@v31
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Setup Nix cache
uses: DeterminateSystems/magic-nix-cache-action@v13
- name: "Dependencies: Sonar"
run: |
mkdir -p /tmp/sonar
wget \
https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip \
-O /tmp/sonar/build-wrapper-linux-x86.zip
unzip \
-o /tmp/sonar/build-wrapper-linux-x86.zip \
-d /tmp/sonar/
# - name: "Dependencies: Report.CI"
# run: |
# curl https://report.ci/report.py \
# > /tmp/report.py
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build Nix environment
run: nix develop --no-update-lock-file --command true
- name: Configure
run: |
nix develop --no-update-lock-file --command \
cmake \
-S. \
-Bbuild \
-DCMAKE_BUILD_TYPE=Coverage \
-DCMAKE_CXX_COMPILER=g++ \
-DSONAR=ON \
-DCOVERAGE_ERROR=OFF
- name: Build
run: |
nix develop --no-update-lock-file --command \
/tmp/sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64 \
--out-dir build_wrapper_output_directory \
cmake --build build --target all unittest
- name: Coverage
run: |
nix develop --no-update-lock-file --command \
cmake --build build --target coverage
- name: Scan
run: |
nix develop --no-update-lock-file --command \
sonar-scanner \
-Dproject.settings=.sonar-project.properties \
-Dsonar.cfamily.build-wrapper-output=build_wrapper_output_directory \
-Dsonar.host.url="https://sonarcloud.io" \
-Dsonar.token=${{ secrets.SONAR_TOKEN }} \
-Dsonar.cfamily.cache.enabled=false
# - name: Produce test report
# run: |
# build/test/unit/openemsh_unittest \
# -r xml::out=build/test/unit/openemsh_unittest_result.catch.xml \
# || true
#
# - name: Downgrade Catch XML format
# run: |
# sed \
# -i build/test/unit/openemsh_unittest_result.catch.xml \
# -e 's/<Catch2TestRun/<Catch/g' \
# -e '3i\<Group name="openemsh_unittest">' \
# -e "s/^<\/Catch2TestRun>/<\/Group>/"
# cat build/test/unit/openemsh_unittest_result.catch.xml \
# | tail -3 \
# | head -1 \
# >> build/test/unit/openemsh_unittest_result.catch.xml
# sed \
# -i build/test/unit/openemsh_unittest_result.catch.xml \
# -e '$a\</Catch>'
# xmllint \
# build/test/unit/openemsh_unittest_result.catch.xml \
# -o build/test/unit/openemsh_unittest_result.catch.xml \
# --format
#
# - name: Export test report
# run: |
# python /tmp/report.py \
# --name "Unittest"
# --token ${{ secrets.REPORT_CI_TOKEN }} \
# --include-as-catch build/test/unit/*.catch.xml
- name: Produce test report
run: |
nix develop --no-update-lock-file --command bash -c '\
build/test/unit/openemsh_unittest \
-r junit::out=build/test/unit/openemsh_unittest_result.xml \
|| true'
- name: Export test report
uses: dorny/test-reporter@v2
with:
name: Unit tests
path: build/test/unit/openemsh_unittest_result.xml
reporter: java-junit
fail-on-error: false