diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 72b66385b8e2f4070a44db641323882fbccd5b27..6acc55721372f4d2e9eea0b402bc930b8328f12a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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 diff --git a/.gitlab/analysis.sh b/.gitlab/analysis.sh index dc200689d5fc4eaef6aa5f58cc095a2afb86b569..0bdd2fdc2fb1d0179e615ff75e9d06715a547e6c 100755 --- a/.gitlab/analysis.sh +++ b/.gitlab/analysis.sh @@ -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 diff --git a/.gitlab/validate.sh b/.gitlab/validate.sh deleted file mode 100755 index d25daba994cb5bc21d6af0533c53fac07bbd66a1..0000000000000000000000000000000000000000 --- a/.gitlab/validate.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/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