From dd93b649170cde29f3096ba43f93b7c608ae3643 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Flores?= <raphael.flores@inrae.fr> Date: Wed, 14 Aug 2024 10:14:33 +0200 Subject: [PATCH 1/5] Init sonar analysis following tutorial. --- .gitlab-ci.yml | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a7f52743..d102753e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -84,6 +84,10 @@ test-and-sonarqube: # SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache # GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task ES_JAVA_OPTS: "-Xms2g -Xmx2g" + cache: + key: "${CI_JOB_NAME}" + paths: + - .sonar/cache # cache: # key: "${CI_COMMIT_REF_NAME}" # policy: pull-push @@ -92,7 +96,7 @@ test-and-sonarqube: # - .sonar/cache script: # - ls -lshR /builds/urgi-is/faidare/.gradle/wrapper/dists/gradle-7.4.1-bin/58kw26xllvsiedyf3nujyarhn - - ./gradlew clean test + - ./gradlew clean test # jacocoTestReport -s sonarqube artifacts: reports: @@ -103,6 +107,22 @@ test-and-sonarqube: interruptible: true allow_failure: false +sonarqube-check: + image: gradle:jre11-slim + variables: + SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache + GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task + cache: + key: "${CI_JOB_NAME}" + paths: + - .sonar/cache + script: gradle sonar -x test + allow_failure: true + only: + - merge_requests + - master + - branches + # BUILD build: tags: -- GitLab From 37d52f7a702ff2f45a24ec2c55ff868d38d262b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Flores?= <raphael.flores@inrae.fr> Date: Wed, 14 Aug 2024 10:15:58 +0200 Subject: [PATCH 2/5] Fix stage --- .gitlab-ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d102753e..5c64e389 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -108,6 +108,9 @@ test-and-sonarqube: allow_failure: false sonarqube-check: + tags: + - openstack + stage: test image: gradle:jre11-slim variables: SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache -- GitLab From 36b32ae7bff9f3a479ac970072ce2670e7e67073 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Flores?= <raphael.flores@inrae.fr> Date: Wed, 14 Aug 2024 12:03:37 +0200 Subject: [PATCH 3/5] Add job dependency. Use gradlew. --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5c64e389..f7a4d02f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -119,12 +119,13 @@ sonarqube-check: key: "${CI_JOB_NAME}" paths: - .sonar/cache - script: gradle sonar -x test + script: ./gradlew sonar -x test allow_failure: true only: - merge_requests - master - branches + needs: ["test-and-sonarqube"] # BUILD build: -- GitLab From 687d95e519ac42830f94661bf11ab672b994d0ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Flores?= <raphael.flores@inrae.fr> Date: Wed, 14 Aug 2024 12:07:44 +0200 Subject: [PATCH 4/5] Change stage to newly created qualif stage. --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f7a4d02f..705180ef 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,6 +2,7 @@ stages: - pre-build - test + - qualif - build - deploy-beta - deploy-staging @@ -110,7 +111,7 @@ test-and-sonarqube: sonarqube-check: tags: - openstack - stage: test + stage: qualif image: gradle:jre11-slim variables: SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache -- GitLab From 843aa459ddebe6450264bf76b693540fbe91fb36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Flores?= <raphael.flores@inrae.fr> Date: Wed, 14 Aug 2024 12:15:47 +0200 Subject: [PATCH 5/5] Fix jobs rules --- .gitlab-ci.yml | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 705180ef..9d9ec6f7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -60,7 +60,7 @@ build-loader-docker-image: allow_failure: true # TESTS -test-and-sonarqube: +test: # image: circleci/openjdk:11-jdk-browsers stage: test tags: @@ -81,24 +81,13 @@ test-and-sonarqube: # `max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]` command: ["bin/elasticsearch", "-Ediscovery.type=single-node"] variables: - # GRADLE_OPTS: "-Xms512m -Xmx8192m -XX:MaxMetaspaceSize=8192m -Dorg.gradle.daemon=false" - # SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache - # GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task ES_JAVA_OPTS: "-Xms2g -Xmx2g" cache: key: "${CI_JOB_NAME}" paths: - .sonar/cache - # cache: - # key: "${CI_COMMIT_REF_NAME}" - # policy: pull-push - # paths: - # # - ".gradle" - # - .sonar/cache script: - # - ls -lshR /builds/urgi-is/faidare/.gradle/wrapper/dists/gradle-7.4.1-bin/58kw26xllvsiedyf3nujyarhn - ./gradlew clean test - # jacocoTestReport -s sonarqube artifacts: reports: junit: @@ -122,11 +111,9 @@ sonarqube-check: - .sonar/cache script: ./gradlew sonar -x test allow_failure: true - only: - - merge_requests - - master - - branches - needs: ["test-and-sonarqube"] + rules: + - if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + needs: ["test"] # BUILD build: -- GitLab