-
Notifications
You must be signed in to change notification settings - Fork 16
106 lines (104 loc) · 4.11 KB
/
sonarcloud.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
96
97
98
99
100
101
102
103
104
105
106
---
name: SonarCloud
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened]
jobs:
sonarcloud:
runs-on: ubuntu-latest
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
steps:
- name: Login to DockerHub
if: env.SONAR_TOKEN != null
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- uses: actions/[email protected]
if: env.SONAR_TOKEN != null
with:
fetch-depth: 0 # Disabling shallow clone is recommended for improving relevancy of reporting
- name: Install uv
if: env.SONAR_TOKEN != null
uses: astral-sh/setup-uv@v4
with:
version: "0.4.22"
- name: Set up Node
if: env.SONAR_TOKEN != null
uses: actions/[email protected]
with:
node-version: "22"
- name: Collector
if: env.SONAR_TOKEN != null
working-directory: components/collector
run: |
uv venv
ci/pip-install.sh
ci/unittest.sh
export PYTHONPATH=`python -c 'import sys;print(":".join(sys.argv[1:]))' src $PYTHONPATH`
.venv/bin/python -m xmlrunner --output-file build/unittests.xml
- name: Notifier
if: env.SONAR_TOKEN != null
working-directory: components/notifier
run: |
uv venv
ci/pip-install.sh
ci/unittest.sh
export PYTHONPATH=`python -c 'import sys;print(":".join(sys.argv[1:]))' src $PYTHONPATH`
.venv/bin/python -m xmlrunner --output-file build/unittests.xml
- name: API-server
if: env.SONAR_TOKEN != null
working-directory: components/api_server
run: |
uv venv
ci/pip-install.sh
ci/unittest.sh
export PYTHONPATH=`python -c 'import sys;print(":".join(sys.argv[1:]))' src $PYTHONPATH`
.venv/bin/python -m xmlrunner --output-file build/unittests.xml
- name: Shared Code
if: env.SONAR_TOKEN != null
working-directory: components/shared_code
run: |
uv venv
ci/pip-install.sh
ci/unittest.sh
export PYTHONPATH=`python -c 'import sys;print(":".join(sys.argv[1:]))' src $PYTHONPATH`
.venv/bin/python -m xmlrunner --output-file build/unittests.xml
- name: Frontend
if: env.SONAR_TOKEN != null
working-directory: components/frontend
run: |
npm install --ignore-scripts
npm run --ignore-scripts build --if-present
npm test -- --coverage
env:
CI: true
- name: Create packages
if: env.SONAR_TOKEN != null
run: |
touch components/__init__.py
touch components/api_server/__init__.py
touch components/api_server/src/__init__.py
touch components/collector/__init__.py
touch components/collector/src/__init__.py
touch components/notifier/__init__.py
touch components/notifier/src/__init__.py
touch components/shared_code/__init__.py
touch components/shared_code/src/__init__.py
- name: Fix code coverage paths # Needed because the Sonar scanner runs in a container with different file paths
if: env.SONAR_TOKEN != null
run: |
sed -i 's/\/home\/runner\/work\/quality-time\/quality-time\//\/github\/workspace\//g' components/collector/build/unittest-coverage.xml
sed -i 's/\/home\/runner\/work\/quality-time\/quality-time\//\/github\/workspace\//g' components/notifier/build/unittest-coverage.xml
sed -i 's/\/home\/runner\/work\/quality-time\/quality-time\//\/github\/workspace\//g' components/api_server/build/unittest-coverage.xml
sed -i 's/\/home\/runner\/work\/quality-time\/quality-time\//\/github\/workspace\//g' components/shared_code/build/unittest-coverage.xml
- name: Sonarcloud scan
if: env.SONAR_TOKEN != null
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}