From f36deb341f464a41c1ed5229b5bca28cf1c6a6ba Mon Sep 17 00:00:00 2001 From: Florent Pruvost <florent.pruvost@inria.fr> Date: Thu, 3 Oct 2024 17:50:18 +0200 Subject: [PATCH] Enable the official Gitlab - Sonarqube integration --- .gitlab-ci.yml | 2 -- .gitlab/sonarqube.yml | 1 + .gitlab/validate.sh | 60 ------------------------------------------- .gitlab/validate.yml | 12 --------- tools/analysis.sh | 5 ++-- 5 files changed, 4 insertions(+), 76 deletions(-) delete mode 100755 .gitlab/validate.sh delete mode 100644 .gitlab/validate.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index da9d013d9..f73b5ad32 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,7 +5,6 @@ stages: - test - coverage - analyze - - validate - deploy # git config --global ahev been added to get around the issue related in @@ -32,7 +31,6 @@ include: - .gitlab/coverage.yml - .gitlab/coverity.yml - .gitlab/sonarqube.yml - - .gitlab/validate.yml - .gitlab/bench_plafrim.yml - .gitlab/pages.yml - .gitlab/release.yml diff --git a/.gitlab/sonarqube.yml b/.gitlab/sonarqube.yml index 75efd53ca..88ef0b068 100644 --- a/.gitlab/sonarqube.yml +++ b/.gitlab/sonarqube.yml @@ -3,6 +3,7 @@ stage: analyze tags: ["docker", "large"] variables: + GIT_DEPTH: "0" VERSION: sonarqube script: - ls -l build*/*.json diff --git a/.gitlab/validate.sh b/.gitlab/validate.sh deleted file mode 100755 index c32e5d118..000000000 --- a/.gitlab/validate.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/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 diff --git a/.gitlab/validate.yml b/.gitlab/validate.yml deleted file mode 100644 index 9a2dbb5d1..000000000 --- a/.gitlab/validate.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- -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 diff --git a/tools/analysis.sh b/tools/analysis.sh index 27be80baa..999f6a0d3 100755 --- a/tools/analysis.sh +++ b/tools/analysis.sh @@ -50,14 +50,15 @@ jq -s 'map(.[])' $PWD/build-*/compile_commands.json > compile_commands.json # create the sonarqube config file cat > sonar-project.properties << EOF 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.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=Dense linear algebra subroutines for heterogeneous and distributed architectures sonar.projectVersion=1.3.0 -- GitLab