Unverified Commit a194a615 authored by Carsten Heidmann's avatar Carsten Heidmann Committed by GitHub
Browse files

ci-test: add SonarQube integration to the project

**Motivation:**

* automatically execute checks with SonarQube after each commit in CI

**Modification:**

* modified package.json to execute checks and added the necessary configuration

**Result:**

* SonarQubeChecks are executed automatically

**Additional Remarks:**

This is a new PR after cleaning up my fork and adressing the changes requested in PR #2 (https://github.com/helmholtz-marketplace/helmholtz-marketplace-webapp/pull/2). In detail, I changed the following:

* moved SonarQube access token to a environment variable which is created from a Github secret (see `README.md` for this)
* limited changes in `package.json` to the single added line `"sonarqube-scanner": "^2.6.0"`

I did not change the script in `package.json` starting with `"posttest"` this is valid according to the docs and I tried using `"test:post` which is not executed. 

The comment on the first line in `ci-analysis.js` is necessary, because otherwise eslint complains about extraneous dependencies.
parent bf3d7ef1
......@@ -15,4 +15,6 @@ jobs:
with:
node-version: 12
- run: npm install
- run: npm test
\ No newline at end of file
- run: npm test
env:
SONAR_AUTH_TOKEN: ${{secrets.SONAR_AUTH_TOKEN}}
......@@ -2,4 +2,8 @@ HIFIS Marketplace
===================
![](https://github.com/hifis-cloud/hifis-marketplace/workflows/CI/badge.svg)
An entry point web application for scientific related services from various vendors.
\ No newline at end of file
An entry point web application for scientific related services from various vendors.
### Running the CI in your fork
If you want to run the SonarQube tests in your fork, you will have to create a GitHub secret with the name `SONAR_AUTH_TOKEN` in your repository. You can get the necessary token in SonarQube via "My Account" -> "Security" -> "Tokens".
\ No newline at end of file
const sonarqubeScanner = require('sonarqube-scanner'); // eslint-disable-line import/no-extraneous-dependencies
sonarqubeScanner(
{
serverUrl: 'https://sonar.desy.de',
token: process.env.SONAR_AUTH_TOKEN,
options: {
'sonar.projectKey': 'hifis-ui',
'sonar.sources': 'src',
'sonar.projectVersion': '0.0.1',
'sonar.language': 'js',
'sonar.sourceEncoding': 'UTF-8',
'sonar.exclusions': 'src/**/*.spec.js',
'sonar.test.inclusions': 'src/**/*.spec.js',
'sonar.coverage.exclusions':
'src/**/*.spec.js,src/**/*.mock.js,node_modules/*,coverage/lcov-report/*',
},
},
() => process.exit(),
);
......@@ -9,6 +9,7 @@
"test": "karma start",
"test:coverage": "karma start --coverage",
"test:watch": "karma start --auto-watch=true --single-run=false",
"posttest": "node ci-analysis.js",
"start": "es-dev-server --app-index index.html --node-resolve --open --watch"
},
"devDependencies": {
......@@ -20,7 +21,8 @@
"@open-wc/testing-karma": "^3.0.0",
"deepmerge": "^3.2.0",
"@open-wc/testing": "^2.0.0",
"es-dev-server": "^1.5.0"
"es-dev-server": "^1.5.0",
"sonarqube-scanner": "^2.6.0"
},
"eslintConfig": {
"extends": [
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment