GitLab steht wegen Wartungsarbeiten am Montag, den 10. Mai, zwischen 17:00 und 19:00 Uhr nicht zur Verfügung.

Commit cdec91d6 authored by Klaus-Dieter Quibeldey-Cirkel's avatar Klaus-Dieter Quibeldey-Cirkel

Merge branch '213-add-local-sonar-scanner-to-frontend-and-backend' into 'staging'

213 add local sonar scanner to frontend and backend

See merge request !47
parents 31436485 0b6da29e
......@@ -61,3 +61,7 @@ rabbitmq.env
init-mongo.js
mongodb
rabbitmq
# Analysis Folder
.lcov_output
.scannerwork
#### arsnova.click v2 Backend
###### Installation
###### Installation
You can find an Installationguide [here](https://github.com/thm-projects/arsnova.click-v2/blob/master/documentation/Backend-Installationguide.md)
......@@ -63,12 +63,23 @@ are likely faster online. The node server tries to connect every 60 seconds to t
the connection fails when starting the app.
###### Test
Enter `npm test` in the root directory to run the unit tests.
Enter `npm test` in the root directory to run the unit tests.
Note that since is uses a TypeScript runner for Mocha it is not required to build the server app before testing it.
Thus, the server gets started up during the test so the specified port must be available.
Currently the routing and the quiz export is covered by the tests.
Currently the routing and the quiz export is covered by the tests.
The export unit test will generate a random filled Excel export file in the `${rootDir}/test-generated` folder.
###### Code style analysis
For a local code style analysis with docker-compose you'll need docker and docker-compose installed.
To run a local code style check with sonarqube, follow these steps:
1. switch into the analysis folder
`cd analysis`
2. start the sonarqube server
`docker-compose up -d sonarqube`
3. when sonarqube has started, you may run analysis whenever you want with
`docker-compose run --rm analysis`
###### Build (DEV)
Enter `npm run build:DEV` in the root directory to run the dev build.
......
FROM sonarsource/sonar-scanner-cli:4
RUN apk add --no-cache curl
RUN apk add --no-cache chromium
ENV CHROME_BIN=/usr/bin/chromium-browser
version: '3.7'
services:
analysis:
image: localhost/sonarscanner-cli
build:
context: ..
dockerfile: analysis/Dockerfile
working_dir: /click
entrypoint: /click/analysis/entrypoint.sh
depends_on:
- sonarqube
networks:
- sonar
volumes:
- ..:/click
sonarqube:
image: sonarqube:7.9.1-community
environment:
- SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true
ports:
- '9000:9000'
networks:
- sonar
volumes:
- sonar_data:/opt/sonarqube/data
networks:
sonar:
volumes:
sonar_data:
#!/bin/bash
if [[ $(curl -s -o /dev/null -w "%{http_code}" -u admin:admin -X POST http://sonarqube:9000/api/qualitygates/list) != 200 ]]; then
echo "Sonarqube has not finished startup yet."
echo "check http://localhost:9000 for progress."
echo "Please try again later..."
exit 0
fi
if [[ $(curl -s -o /dev/null -w "%{http_code}" -u admin:admin -X POST -F 'id=2' http://sonarqube:9000/api/qualitygates/show) == 404 ]]; then
# quality gate does not yet exist
echo "Quality Gate not yet existing. Going to create..."
# create the gate
curl -s -o /dev/null -w " - Creating gate: %{http_code}\n" \
-u admin:admin -X POST \
-F 'name=cards' \
http://sonarqube:9000/api/qualitygates/create
# create the conditions
curl -s -o /dev/null -w " - Add coverage condition: %{http_code}\n" \
-u admin:admin -X POST \
-F 'error=80' -F 'gateId=2' -F 'metric=coverage' -F 'op=LT' \
http://sonarqube:9000/api/qualitygates/create_condition
curl -s -o /dev/null -w " - Add duplicated lines condition: %{http_code}\n" \
-u admin:admin -X POST \
-F 'error=3' -F 'gateId=2' -F 'metric=duplicated_lines_density' -F 'op=GT' \
http://sonarqube:9000/api/qualitygates/create_condition
curl -s -o /dev/null -w " - Add sqale rating condition: %{http_code}\n" \
-u admin:admin -X POST \
-F 'error=1' -F 'gateId=2' -F 'metric=sqale_rating' -F 'op=GT' \
http://sonarqube:9000/api/qualitygates/create_condition
curl -s -o /dev/null -w " - Add reliability rating condition: %{http_code}\n" \
-u admin:admin -X POST \
-F 'error=1' -F 'gateId=2' -F 'metric=reliability_rating' -F 'op=GT' \
http://sonarqube:9000/api/qualitygates/create_condition
curl -s -o /dev/null -w " - Add security rating condition: %{http_code}\n" \
-u admin:admin -X POST \
-F 'error=1' -F 'gateId=2' -F 'metric=security_rating' -F 'op=GT' \
http://sonarqube:9000/api/qualitygates/create_condition
# set newly created gate as default
curl -s -o /dev/null -w " - Setting newly created gate as default: %{http_code}\n" \
-u admin:admin -X POST \
-F 'id=2' \
http://sonarqube:9000/api/qualitygates/set_as_default
echo "done."
fi
npm i
export NODE_ENV='test'
node_modules/nyc/bin/nyc.js --reporter=text --reporter=lcov --report-dir=.lcov_output node_modules/mocha/bin/mocha
sonar-scanner
Markdown is supported
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