Skip to content

Commit 94c79d8

Browse files
authored
Merge pull request #179 from abnamro/sonarcloud-pipelines-and-badge
Sonarcloud pipelines and badge
2 parents 8ea1c62 + c07d312 commit 94c79d8

File tree

16 files changed

+153
-10
lines changed

16 files changed

+153
-10
lines changed

.github/workflows/backend-ci.yaml

+22
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,28 @@ jobs:
6464
cd ${{ env.RESC_BACKEND_DIR }}
6565
tox -e lint
6666
67+
- name: SonarCloud Scan
68+
uses: SonarSource/sonarcloud-github-action@master
69+
with:
70+
projectBaseDir: ${{ env.RESC_BACKEND_DIR }}
71+
args: >
72+
-Dsonar.organization=abnamro-resc
73+
-Dsonar.projectKey=abnamro-resc_resc-backend
74+
-Dsonar.python.coverage.reportPaths=coverage.xml
75+
-Dsonar.sourceEncoding=UTF-8
76+
-Dsonar.projectName=resc-backend
77+
-Dsonar.groupid=resc
78+
-Dsonar.sources=src/
79+
-Dsonar.inclusions=**/*.py
80+
-Dsonar.exclusions=**/*yml,**/*.xml,**/*.txt,**/*.html,**/*.js
81+
-Dsonar.tests=tests/
82+
-Dsonar.cpd.exclusions=**/*yml,**/*.xml,**/*.txt,**/*.html,**/*.js
83+
-Dsonar.coverage.exclusions=**/*yml,**/*.xml,**/*.txt,**/*.html,**/*.js
84+
-Dsonar.pdf.skip=true
85+
env:
86+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
87+
SONAR_TOKEN: ${{ secrets.__SONAR_TOKEN_BACKEND__ }}
88+
6789
- name: Get Branch Name
6890
id: extract_branch
6991
run: |

.github/workflows/frontend-ci.yaml

+38
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,44 @@ jobs:
6565
cd ${{ env.RESC_FRONTEND_DIR }}
6666
npx auditjs@latest ossi -q || true
6767
68+
- name: Running Jest and Coverage
69+
run: |
70+
cd ${{ env.RESC_FRONTEND_DIR }}
71+
yarn jest --coverage || true
72+
npm install jest-sonar-reporter --save-dev
73+
74+
## Removing the dir paths and making them relative paths.
75+
- name: Fix coverage report
76+
run: |
77+
cd ${{ env.RESC_FRONTEND_DIR }}
78+
sed -i "s+/home/runner/work/repository-scanner/repository-scanner/components/resc-frontend/++g" tests/unit/reports/coverage/lcov.info
79+
cat tests/unit/reports/coverage/lcov.info
80+
81+
- name: SonarCloud Scan
82+
uses: SonarSource/sonarcloud-github-action@master
83+
with:
84+
projectBaseDir: ${{ env.RESC_FRONTEND_DIR }}
85+
args: >
86+
-Dsonar.organization=abnamro-resc
87+
-Dsonar.projectKey=abnamro-resc_resc-frontend
88+
-Dsonar.sourceEncoding=UTF-8
89+
-Dsonar.projectName=resc-frontend
90+
-Dsonar.groupid=resc
91+
-Dsonar.sources=src/
92+
-Dsonar.inclusions=**/*
93+
-Dsonar.exclusions=**/__mocks__/*
94+
-Dsonar.tests=tests/
95+
-Dsonar.cpd.exclusions=**/*.example.js,**/*.spec.js,**/*.?spec.js
96+
-Dsonar.coverage.exclusions=**/*.html,**/*.json,**/*.spec.js,**/*.?spec.js,**/main.*,**/i18n.js,**/router/index.js,**/configuration/*.js
97+
-Dsonar.javascript.jstest.reportsPath=tests/unit/reports/coverage
98+
-Dsonar.javascript.lcov.reportPaths=tests/unit/reports/coverage/lcov.info
99+
-Dsonar.pdf.skip=true
100+
-Dsonar.branch.target=*
101+
-Dsonar.branch.name=*
102+
env:
103+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
104+
SONAR_TOKEN: ${{ secrets.__SONAR_TOKEN_BACKEND__ }}
105+
68106
- id: getversion
69107
name: Get package version
70108
run: |

.github/workflows/vcs-scanner-ci.yaml

+22
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,28 @@ jobs:
6565
cd ${{ env.RESC_VCS_SCANNER_DIR }}
6666
tox -e lint
6767
68+
- name: SonarCloud Scan
69+
uses: SonarSource/sonarcloud-github-action@master
70+
with:
71+
projectBaseDir: ${{ env.RESC_VCS_SCANNER_DIR }}
72+
args: >
73+
-Dsonar.organization=abnamro-resc
74+
-Dsonar.projectKey=abnamro-resc_resc-vcs-scanner
75+
-Dsonar.python.coverage.reportPaths=coverage.xml
76+
-Dsonar.sourceEncoding=UTF-8
77+
-Dsonar.projectName=resc-vcs-scanner
78+
-Dsonar.groupid=resc
79+
-Dsonar.sources=src/
80+
-Dsonar.inclusions=**/*.py
81+
-Dsonar.exclusions=**/*yml,**/*.xml,**/*.txt,**/*.html,**/*.js
82+
-Dsonar.tests=tests/
83+
-Dsonar.cpd.exclusions=**/*yml,**/*.xml,**/*.txt,**/*.html,**/*.js
84+
-Dsonar.coverage.exclusions=**/*yml,**/*.xml,**/*.txt,**/*.html,**/*.js
85+
-Dsonar.pdf.skip=true
86+
env:
87+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
88+
SONAR_TOKEN: ${{ secrets.__SONAR_TOKEN_BACKEND__ }}
89+
6890
- name: Get Branch Name
6991
id: extract_branch
7092
run: |

.github/workflows/vcs-scraper-ci.yaml

+22
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,28 @@ jobs:
6464
cd ${{ env.RESC_VCS_SCRAPER_DIR }}
6565
tox -e lint
6666
67+
- name: SonarCloud Scan
68+
uses: SonarSource/sonarcloud-github-action@master
69+
with:
70+
projectBaseDir: ${{ env.RESC_VCS_SCRAPER_DIR }}
71+
args: >
72+
-Dsonar.organization=abnamro-resc
73+
-Dsonar.projectKey=abnamro-resc_resc-vcs-scraper
74+
-Dsonar.python.coverage.reportPaths=coverage.xml
75+
-Dsonar.sourceEncoding=UTF-8
76+
-Dsonar.projectName=resc-vcs-scraper
77+
-Dsonar.groupid=resc
78+
-Dsonar.sources=src/
79+
-Dsonar.inclusions=**/*.py
80+
-Dsonar.exclusions=**/*yml,**/*.xml,**/*.txt,**/*.html,**/*.js
81+
-Dsonar.tests=tests/
82+
-Dsonar.cpd.exclusions=**/*yml,**/*.xml,**/*.txt,**/*.html,**/*.js
83+
-Dsonar.coverage.exclusions=**/*yml,**/*.xml,**/*.txt,**/*.html,**/*.js
84+
-Dsonar.pdf.skip=true
85+
env:
86+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
87+
SONAR_TOKEN: ${{ secrets.__SONAR_TOKEN_BACKEND__ }}
88+
6789
- name: Get Branch Name
6890
id: extract_branch
6991
run: |

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
<a href="https://www.bestpractices.dev/projects/7799">
3636
<img src="https://www.bestpractices.dev/projects/7799/badge">
3737
</a>
38+
<a href="https://github.com/abnamro/repository-scanner/actions">
39+
<img src="https://sonarcloud.io/api/project_badges/measure?project=abnamro-resc_resc-backend&metric=alert_status">
40+
</a>
3841
</h3>
3942
</div>
4043

components/resc-backend/README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# Repository Scanner Backend (RESC-Backend)
22
<h3>
33
<a href="https://github.com/abnamro/repository-scanner/actions">
4-
<img src="https://img.shields.io/github/actions/workflow/status/abnamro/repository-scanner/backend-ci.yaml?style=for-the-badge&logo=github">
4+
<img src="https://img.shields.io/github/actions/workflow/status/abnamro/repository-scanner/backend-ci.yaml?logo=github">
5+
</a>
6+
<a href="https://sonarcloud.io/summary/new_code?id=abnamro-resc_resc-backend">
7+
<img src="https://sonarcloud.io/api/project_badges/measure?project=abnamro-resc_resc-backend&metric=alert_status">
58
</a>
69
</h3>
710

components/resc-backend/test-requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ tox==4.11.1
1212
pylint==2.17.5
1313
pytest-asyncio==0.21.1
1414
httpx==0.24.1
15+
coverage==7.3.1

components/resc-backend/tox.ini

+9-2
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,12 @@ skipsdist = true
2121
skip_install = true
2222
passenv = PIP_CONFIG_FILE
2323
commands = pip install -r test-requirements.txt
24-
pip install -e .
25-
pytest -v --cov=src --cov-config=.coveragerc tests
24+
pip install -e .
25+
coverage run -m pytest
26+
coverage report -m
27+
coverage xml --data-file=.coverage
28+
29+
[coverage:run]
30+
relative_files = True
31+
source = src/
32+
branch = True

components/resc-frontend/README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# Repository Scanner Frontend (RESC-Frontend)
22
<h3>
33
<a href="https://github.com/abnamro/repository-scanner/actions">
4-
<img src="https://img.shields.io/github/actions/workflow/status/abnamro/repository-scanner/frontend-ci.yaml?style=for-the-badge&logo=github">
4+
<img src="https://img.shields.io/github/actions/workflow/status/abnamro/repository-scanner/frontend-ci.yaml?logo=github">
5+
</a>
6+
<a href="https://sonarcloud.io/summary/new_code id=abnamro-resc_resc-frontend">
7+
<img src="https://sonarcloud.io/api/project_badges/measure?project=abnamro-resc_resc-frontend&metric=alert_status">
58
</a>
69
</h3>
710

components/resc-frontend/src/components/RulePack/RulePackUploadModal.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
</b-form-group>
2929
</div>
3030
<div class="col-md-5">
31-
<small><a href="https://semver.org/" target="_blank">semver</a></small>
31+
<small><a href="https://semver.org/" target="_blank" rel="noopener">semver</a></small>
3232
<small> Example: 1.0.0</small>
3333
</div>
3434
</div>

components/resc-vcs-scanner/README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# Repository Scanner Version Control System Scanner (RESC-VCS-SCANNER)
22
<h3>
33
<a href="https://github.com/abnamro/repository-scanner/actions">
4-
<img src="https://img.shields.io/github/actions/workflow/status/abnamro/repository-scanner/vcs-scanner-ci.yaml?style=for-the-badge&logo=github">
4+
<img src="https://img.shields.io/github/actions/workflow/status/abnamro/repository-scanner/vcs-scanner-ci.yaml?logo=github">
5+
</a>
6+
<a href="https://sonarcloud.io/summary/new_code?id=abnamro-resc_resc-vcs-scanner">
7+
<img src="https://sonarcloud.io/api/project_badges/measure?project=abnamro-resc_resc-vcs-scanner&metric=alert_status">
58
</a>
69
</h3>
710

components/resc-vcs-scanner/test-requirements.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ pytest==7.4.1
99
mock==5.1.0
1010
pytest-cov==4.1.0
1111
tox==4.11.1
12-
pylint==2.17.5
12+
pylint==2.17.5
13+
coverage==7.3.1

components/resc-vcs-scanner/tox.ini

+8-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,11 @@ passenv = PIP_CONFIG_FILE
2424
commands = pip install -r test-requirements.txt
2525
pip install -e ../resc-backend
2626
pip install -e .
27-
pytest -v --cov=src --cov-config=.coveragerc tests
27+
coverage run -m pytest
28+
coverage report -m
29+
coverage xml --data-file=.coverage
30+
31+
[coverage:run]
32+
relative_files = True
33+
source = src/
34+
branch = True

components/resc-vcs-scraper/README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# Repository Scanner Version Control System Scraper (RESC-VCS-SCRAPER)
22
<h3>
33
<a href="https://github.com/abnamro/repository-scanner/actions">
4-
<img src="https://img.shields.io/github/actions/workflow/status/abnamro/repository-scanner/vcs-scraper-ci.yaml?style=for-the-badge&logo=github">
4+
<img src="https://img.shields.io/github/actions/workflow/status/abnamro/repository-scanner/vcs-scraper-ci.yaml?logo=github">
5+
</a>
6+
<a href="https://sonarcloud.io/summary/new_code?id=abnamro-resc_resc-vcs-scraper">
7+
<img src="https://sonarcloud.io/api/project_badges/measure?project=abnamro-resc_resc-vcs-scraper&metric=alert_status">
58
</a>
69
</h3>
710

components/resc-vcs-scraper/test-requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ mock==5.1.0
1010
pytest-cov==4.1.0
1111
tox==4.11.1
1212
pylint==2.17.5
13+
coverage==7.3.1

components/resc-vcs-scraper/tox.ini

+8-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,11 @@ setenv = PYTHONPATH = {toxinidir}:{toxinidir}/src
2424
passenv = PIP_CONFIG_FILE
2525
commands = pip install -r test-requirements.txt --quiet
2626
pip install -e .
27-
pytest -v --cov=src --cov-config=.coveragerc tests
27+
coverage run -m pytest
28+
coverage report -m
29+
coverage xml --data-file=.coverage
30+
31+
[coverage:run]
32+
relative_files = True
33+
source = src/
34+
branch = True

0 commit comments

Comments
 (0)