Mentions légales du service

Skip to content
Snippets Groups Projects
Commit f36deb34 authored by PRUVOST Florent's avatar PRUVOST Florent
Browse files

Enable the official Gitlab - Sonarqube integration

parent 1c550625
No related branches found
No related tags found
1 merge request!490Enable the official Gitlab - Sonarqube integration
...@@ -5,7 +5,6 @@ stages: ...@@ -5,7 +5,6 @@ stages:
- test - test
- coverage - coverage
- analyze - analyze
- validate
- deploy - deploy
# git config --global ahev been added to get around the issue related in # git config --global ahev been added to get around the issue related in
...@@ -32,7 +31,6 @@ include: ...@@ -32,7 +31,6 @@ include:
- .gitlab/coverage.yml - .gitlab/coverage.yml
- .gitlab/coverity.yml - .gitlab/coverity.yml
- .gitlab/sonarqube.yml - .gitlab/sonarqube.yml
- .gitlab/validate.yml
- .gitlab/bench_plafrim.yml - .gitlab/bench_plafrim.yml
- .gitlab/pages.yml - .gitlab/pages.yml
- .gitlab/release.yml - .gitlab/release.yml
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
stage: analyze stage: analyze
tags: ["docker", "large"] tags: ["docker", "large"]
variables: variables:
GIT_DEPTH: "0"
VERSION: sonarqube VERSION: sonarqube
script: script:
- ls -l build*/*.json - ls -l build*/*.json
......
#!/usr/bin/env bash
###
#
# @file validate.sh
# @copyright 2023-2024 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
# Univ. Bordeaux. All rights reserved.
#
# @version 1.2.0
# @author Mathieu Faverge
# @author Florent Pruvost
# @date 2023-09-22
#
###
# Check some metrics on sonarqube (https://sonarqube.inria.fr/sonarqube/)
# and depending on the value return 0 (success) or 1 (failure).
if [ $# -gt 0 ]; then
METRIC=$1
fi
METRIC=${METRIC:-BUG}
if [[ -z $CI_MERGE_REQUEST_IID || -z $CI_PROJECT_NAMESPACE || -z $CI_PROJECT_NAME ]]; then
echo "One of the variables CI_MERGE_REQUEST_IID, CI_PROJECT_NAMESPACE,
CI_PROJECT_NAME is empty. This script must be used during a gitlab merge
request only -> Failure."
exit 1
fi
if [[ -z $SONARQUBE_LOGIN ]]; then
echo "SONARQUBE_LOGIN is empty, please give a valid sonarqube user's token,
with permissions set on the project -> Failure."
exit 1
fi
if [[ $METRIC == "BUG" ]]; then
BUG=`curl -u $SONARQUBE_LOGIN: -X GET "https://sonarqube.inria.fr/sonarqube/api/measures/component?component=${CI_PROJECT_NAMESPACE}%3A${CI_PROJECT_NAME}&pullRequest=${CI_MERGE_REQUEST_IID}&metricKeys=new_bugs" |jq '.component.measures[0].period.value' | sed -e "s#\"##g"`
echo "BUG=$BUG"
if [[ $BUG -gt 0 ]]; then
echo "%{BUG} new bugs detected by Sonarqube -> Failure."
exit 1
else
echo "No new bugs detected by Sonarqube -> Success."
exit 0
fi
elif [[ $METRIC == "COVERAGE" ]]; then
COV=`curl -u $SONARQUBE_LOGIN: -X GET "https://sonarqube.inria.fr/sonarqube/api/measures/component?component=${CI_PROJECT_NAMESPACE}%3A${CI_PROJECT_NAME}&pullRequest=${CI_MERGE_REQUEST_IID}&metricKeys=new_coverage" |jq '.component.measures[0].period.value' | sed -e "s#\"##g" | cut -d "." -f 1`
echo "COV=$COV"
if [[ $COV == "null" || -z $COV ]]; then
echo "Coverage is empty, certainly that there are no lines of new code (considered during the analysis) to compare -> Success."
else
if [[ $COV -lt 80 ]]; then
echo "Coverage on new lines is ${COV}%, which is < 80% -> Failure."
exit 1
else
echo "Coverage on new lines is ${COV}%, which is >= 80% -> Success."
exit 0
fi
fi
fi
---
validate:
stage: validate
tags: ["docker", "large"]
extends: .only-mr
needs: [sonarqube_mr]
parallel:
matrix:
- METRIC: [BUG, COVERAGE]
script:
- ./.gitlab/validate.sh $METRIC
allow_failure: true
\ No newline at end of file
...@@ -50,14 +50,15 @@ jq -s 'map(.[])' $PWD/build-*/compile_commands.json > compile_commands.json ...@@ -50,14 +50,15 @@ jq -s 'map(.[])' $PWD/build-*/compile_commands.json > compile_commands.json
# create the sonarqube config file # create the sonarqube config file
cat > sonar-project.properties << EOF cat > sonar-project.properties << EOF
sonar.host.url=https://sonarqube.inria.fr/sonarqube sonar.host.url=https://sonarqube.inria.fr/sonarqube
sonar.login=$SONARQUBE_LOGIN
sonar.projectKey=solverstack_chameleon_AZJTCfl1sbMNg1jXgm3k
sonar.qualitygate.wait=true
sonar.links.homepage=$CI_PROJECT_URL sonar.links.homepage=$CI_PROJECT_URL
sonar.links.scm=$CI_REPOSITORY_URL sonar.links.scm=$CI_REPOSITORY_URL
sonar.links.ci=$CI_PROJECT_URL/pipelines sonar.links.ci=$CI_PROJECT_URL/pipelines
sonar.links.issue=$CI_PROJECT_URL/issues sonar.links.issue=$CI_PROJECT_URL/issues
sonar.projectKey=${CI_PROJECT_NAMESPACE}:${CI_PROJECT_NAME}
sonar.projectDescription=Dense linear algebra subroutines for heterogeneous and distributed architectures sonar.projectDescription=Dense linear algebra subroutines for heterogeneous and distributed architectures
sonar.projectVersion=1.3.0 sonar.projectVersion=1.3.0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment