Mentions légales du service

Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • solverstack/hqr
  • faverge/hqr
  • sylvand/hqr
  • fpruvost/hqr
4 results
Show changes
Commits on Source (2)
......@@ -5,7 +5,6 @@ stages:
- build
- test
- analyze
- validate
before_script:
- git config --global --add safe.directory $CI_PROJECT_DIR
......@@ -160,6 +159,8 @@ sonarqube:
when: manual
allow_failure: true
needs: [hqr_build_linux,hqr_test_linux]
variables:
GIT_DEPTH: "0"
script:
- ./.gitlab/analysis.sh
artifacts:
......@@ -172,15 +173,3 @@ sonarqube:
- sonar-project.properties
- sonar.log
when: always
validate:
stage: validate
tags: ["docker", "large"]
extends: .only-mr
needs: [sonarqube]
parallel:
matrix:
- METRIC: [BUG, COVERAGE]
script:
- ./.gitlab/validate.sh $METRIC
allow_failure: true
......@@ -39,12 +39,14 @@ rats -w 3 --xml `cat filelist.txt` > hqr-rats.xml
cat > sonar-project.properties << EOF
sonar.host.url=https://sonarqube.inria.fr/sonarqube
sonar.projectKey=solverstack_hqr_AZJSz1v4sbMNg1jXgm3B
sonar.qualitygate.wait=true
sonar.links.homepage=$CI_PROJECT_URL
sonar.links.scm=$CI_REPOSITORY_URL
sonar.links.ci=$CI_PROJECT_URL/pipelines
sonar.links.issue=$CI_PROJECT_URL/issues
sonar.projectKey=${CI_PROJECT_NAMESPACE}:${CI_PROJECT_NAME}
sonar.projectDescription=Library for hierarchical QR/LQ reduction trees
sonar.projectVersion=0.1
......@@ -69,4 +71,4 @@ sonar.cxx.rats.reportPaths=hqr-rats.xml
EOF
# run sonar analysis + publish on sonarqube
sonar-scanner -X -Dsonar.login=$SONARQUBE_LOGIN > sonar.log
sonar-scanner -X > sonar.log
#!/usr/bin/env bash
###
#
# @file validate.sh
# @copyright 2023-2023 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
# Univ. Bordeaux. All rights reserved.
#
# @version 1.0.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