Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sonarcloud pipelines and badge #179

Merged
merged 5 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/backend-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,28 @@ jobs:
cd ${{ env.RESC_BACKEND_DIR }}
tox -e lint

- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
with:
projectBaseDir: ${{ env.RESC_BACKEND_DIR }}
args: >
-Dsonar.organization=abnamro-resc
-Dsonar.projectKey=abnamro-resc_resc-backend
-Dsonar.python.coverage.reportPaths=coverage.xml
-Dsonar.sourceEncoding=UTF-8
-Dsonar.projectName=resc-backend
-Dsonar.groupid=resc
-Dsonar.sources=src/
-Dsonar.inclusions=**/*.py
-Dsonar.exclusions=**/*yml,**/*.xml,**/*.txt,**/*.html,**/*.js
-Dsonar.tests=tests/
-Dsonar.cpd.exclusions=**/*yml,**/*.xml,**/*.txt,**/*.html,**/*.js
-Dsonar.coverage.exclusions=**/*yml,**/*.xml,**/*.txt,**/*.html,**/*.js
-Dsonar.pdf.skip=true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.__SONAR_TOKEN_BACKEND__ }}

- name: Get Branch Name
id: extract_branch
run: |
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/frontend-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,44 @@ jobs:
cd ${{ env.RESC_FRONTEND_DIR }}
npx auditjs@latest ossi -q || true

- name: Running Jest and Coverage
run: |
cd ${{ env.RESC_FRONTEND_DIR }}
yarn jest --coverage || true
npm install jest-sonar-reporter --save-dev

## Removing the dir paths and making them relative paths.
- name: Fix coverage report
run: |
cd ${{ env.RESC_FRONTEND_DIR }}
sed -i "s+/home/runner/work/repository-scanner/repository-scanner/components/resc-frontend/++g" tests/unit/reports/coverage/lcov.info
cat tests/unit/reports/coverage/lcov.info

- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
with:
projectBaseDir: ${{ env.RESC_FRONTEND_DIR }}
args: >
-Dsonar.organization=abnamro-resc
-Dsonar.projectKey=abnamro-resc_resc-frontend
-Dsonar.sourceEncoding=UTF-8
-Dsonar.projectName=resc-frontend
-Dsonar.groupid=resc
-Dsonar.sources=src/
-Dsonar.inclusions=**/*
-Dsonar.exclusions=**/__mocks__/*
-Dsonar.tests=tests/
-Dsonar.cpd.exclusions=**/*.example.js,**/*.spec.js,**/*.?spec.js
-Dsonar.coverage.exclusions=**/*.html,**/*.json,**/*.spec.js,**/*.?spec.js,**/main.*,**/i18n.js,**/router/index.js,**/configuration/*.js
-Dsonar.javascript.jstest.reportsPath=tests/unit/reports/coverage
-Dsonar.javascript.lcov.reportPaths=tests/unit/reports/coverage/lcov.info
-Dsonar.pdf.skip=true
-Dsonar.branch.target=*
-Dsonar.branch.name=*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.__SONAR_TOKEN_BACKEND__ }}

- id: getversion
name: Get package version
run: |
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/vcs-scanner-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,28 @@ jobs:
cd ${{ env.RESC_VCS_SCANNER_DIR }}
tox -e lint

- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
with:
projectBaseDir: ${{ env.RESC_VCS_SCANNER_DIR }}
args: >
-Dsonar.organization=abnamro-resc
-Dsonar.projectKey=abnamro-resc_resc-vcs-scanner
-Dsonar.python.coverage.reportPaths=coverage.xml
-Dsonar.sourceEncoding=UTF-8
-Dsonar.projectName=resc-vcs-scanner
-Dsonar.groupid=resc
-Dsonar.sources=src/
-Dsonar.inclusions=**/*.py
-Dsonar.exclusions=**/*yml,**/*.xml,**/*.txt,**/*.html,**/*.js
-Dsonar.tests=tests/
-Dsonar.cpd.exclusions=**/*yml,**/*.xml,**/*.txt,**/*.html,**/*.js
-Dsonar.coverage.exclusions=**/*yml,**/*.xml,**/*.txt,**/*.html,**/*.js
-Dsonar.pdf.skip=true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.__SONAR_TOKEN_BACKEND__ }}

- name: Get Branch Name
id: extract_branch
run: |
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/vcs-scraper-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,28 @@ jobs:
cd ${{ env.RESC_VCS_SCRAPER_DIR }}
tox -e lint

- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
with:
projectBaseDir: ${{ env.RESC_VCS_SCRAPER_DIR }}
args: >
-Dsonar.organization=abnamro-resc
-Dsonar.projectKey=abnamro-resc_resc-vcs-scraper
-Dsonar.python.coverage.reportPaths=coverage.xml
-Dsonar.sourceEncoding=UTF-8
-Dsonar.projectName=resc-vcs-scraper
-Dsonar.groupid=resc
-Dsonar.sources=src/
-Dsonar.inclusions=**/*.py
-Dsonar.exclusions=**/*yml,**/*.xml,**/*.txt,**/*.html,**/*.js
-Dsonar.tests=tests/
-Dsonar.cpd.exclusions=**/*yml,**/*.xml,**/*.txt,**/*.html,**/*.js
-Dsonar.coverage.exclusions=**/*yml,**/*.xml,**/*.txt,**/*.html,**/*.js
-Dsonar.pdf.skip=true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.__SONAR_TOKEN_BACKEND__ }}

- name: Get Branch Name
id: extract_branch
run: |
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
<a href="https://www.bestpractices.dev/projects/7799">
<img src="https://www.bestpractices.dev/projects/7799/badge">
</a>
<a href="https://github.com/abnamro/repository-scanner/actions">
<img src="https://sonarcloud.io/api/project_badges/measure?project=abnamro-resc_resc-backend&metric=alert_status">
</a>
</h3>
</div>

Expand Down
5 changes: 4 additions & 1 deletion components/resc-backend/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Repository Scanner Backend (RESC-Backend)
<h3>
<a href="https://github.com/abnamro/repository-scanner/actions">
<img src="https://img.shields.io/github/actions/workflow/status/abnamro/repository-scanner/backend-ci.yaml?style=for-the-badge&logo=github">
<img src="https://img.shields.io/github/actions/workflow/status/abnamro/repository-scanner/backend-ci.yaml?logo=github">
</a>
<a href="https://sonarcloud.io/summary/new_code?id=abnamro-resc_resc-backend">
<img src="https://sonarcloud.io/api/project_badges/measure?project=abnamro-resc_resc-backend&metric=alert_status">
</a>
</h3>

Expand Down
1 change: 1 addition & 0 deletions components/resc-backend/test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ tox==4.11.1
pylint==2.17.5
pytest-asyncio==0.21.1
httpx==0.24.1
coverage==7.3.1
11 changes: 9 additions & 2 deletions components/resc-backend/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,12 @@ skipsdist = true
skip_install = true
passenv = PIP_CONFIG_FILE
commands = pip install -r test-requirements.txt
pip install -e .
pytest -v --cov=src --cov-config=.coveragerc tests
pip install -e .
coverage run -m pytest
coverage report -m
coverage xml --data-file=.coverage

[coverage:run]
relative_files = True
source = src/
branch = True
5 changes: 4 additions & 1 deletion components/resc-frontend/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Repository Scanner Frontend (RESC-Frontend)
<h3>
<a href="https://github.com/abnamro/repository-scanner/actions">
<img src="https://img.shields.io/github/actions/workflow/status/abnamro/repository-scanner/frontend-ci.yaml?style=for-the-badge&logo=github">
<img src="https://img.shields.io/github/actions/workflow/status/abnamro/repository-scanner/frontend-ci.yaml?logo=github">
</a>
<a href="https://sonarcloud.io/summary/new_code id=abnamro-resc_resc-frontend">
<img src="https://sonarcloud.io/api/project_badges/measure?project=abnamro-resc_resc-frontend&metric=alert_status">
</a>
</h3>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</b-form-group>
</div>
<div class="col-md-5">
<small><a href="https://semver.org/" target="_blank">semver</a></small>
<small><a href="https://semver.org/" target="_blank" rel="noopener">semver</a></small>
<small> Example: 1.0.0</small>
</div>
</div>
Expand Down
5 changes: 4 additions & 1 deletion components/resc-vcs-scanner/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Repository Scanner Version Control System Scanner (RESC-VCS-SCANNER)
<h3>
<a href="https://github.com/abnamro/repository-scanner/actions">
<img src="https://img.shields.io/github/actions/workflow/status/abnamro/repository-scanner/vcs-scanner-ci.yaml?style=for-the-badge&logo=github">
<img src="https://img.shields.io/github/actions/workflow/status/abnamro/repository-scanner/vcs-scanner-ci.yaml?logo=github">
</a>
<a href="https://sonarcloud.io/summary/new_code?id=abnamro-resc_resc-vcs-scanner">
<img src="https://sonarcloud.io/api/project_badges/measure?project=abnamro-resc_resc-vcs-scanner&metric=alert_status">
</a>
</h3>

Expand Down
3 changes: 2 additions & 1 deletion components/resc-vcs-scanner/test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ pytest==7.4.1
mock==5.1.0
pytest-cov==4.1.0
tox==4.11.1
pylint==2.17.5
pylint==2.17.5
coverage==7.3.1
9 changes: 8 additions & 1 deletion components/resc-vcs-scanner/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,11 @@ passenv = PIP_CONFIG_FILE
commands = pip install -r test-requirements.txt
pip install -e ../resc-backend
pip install -e .
pytest -v --cov=src --cov-config=.coveragerc tests
coverage run -m pytest
coverage report -m
coverage xml --data-file=.coverage

[coverage:run]
relative_files = True
source = src/
branch = True
5 changes: 4 additions & 1 deletion components/resc-vcs-scraper/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Repository Scanner Version Control System Scraper (RESC-VCS-SCRAPER)
<h3>
<a href="https://github.com/abnamro/repository-scanner/actions">
<img src="https://img.shields.io/github/actions/workflow/status/abnamro/repository-scanner/vcs-scraper-ci.yaml?style=for-the-badge&logo=github">
<img src="https://img.shields.io/github/actions/workflow/status/abnamro/repository-scanner/vcs-scraper-ci.yaml?logo=github">
</a>
<a href="https://sonarcloud.io/summary/new_code?id=abnamro-resc_resc-vcs-scraper">
<img src="https://sonarcloud.io/api/project_badges/measure?project=abnamro-resc_resc-vcs-scraper&metric=alert_status">
</a>
</h3>

Expand Down
1 change: 1 addition & 0 deletions components/resc-vcs-scraper/test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ mock==5.1.0
pytest-cov==4.1.0
tox==4.11.1
pylint==2.17.5
coverage==7.3.1
9 changes: 8 additions & 1 deletion components/resc-vcs-scraper/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,11 @@ setenv = PYTHONPATH = {toxinidir}:{toxinidir}/src
passenv = PIP_CONFIG_FILE
commands = pip install -r test-requirements.txt --quiet
pip install -e .
pytest -v --cov=src --cov-config=.coveragerc tests
coverage run -m pytest
coverage report -m
coverage xml --data-file=.coverage

[coverage:run]
relative_files = True
source = src/
branch = True