]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-19489 add CI-task to pre-cache gradle dependencies, use offline mode for all...
authorAurelien Poscia <aurelien.poscia@sonarsource.com>
Tue, 6 Jun 2023 14:22:43 +0000 (16:22 +0200)
committersonartech <sonartech@sonarsource.com>
Mon, 12 Jun 2023 20:02:49 +0000 (20:02 +0000)
.cirrus.yml
build.gradle

index 02e7ed508810d85d0ed1b10c1ad13001ce0424f2..815f8fb7de40de044cbfec27f2b3720a637619fa 100644 (file)
@@ -28,6 +28,9 @@ auto_cancellation: $CIRRUS_BRANCH != $BRANCH_MAIN && $CIRRUS_BRANCH !=~ $BRANCH_
 skip_public_branches_template: &SKIP_PUBLIC_BRANCHES_TEMPLATE
   skip: $CIRRUS_BRANCH =~ $BRANCH_PATTERN_PUBLIC
 
+cache_dependencies_dependant_task_template: &CACHE_DEPENDENCIES_DEPENDANT_TASK_TEMPLATE
+  depends_on: cache_dependencies
+
 build_dependant_task_template: &BUILD_DEPENDANT_TASK_TEMPLATE
   depends_on: build
 
@@ -35,10 +38,10 @@ nightly_task_template: &NIGHTLY_TASK_TEMPLATE
   only_if: $CIRRUS_BRANCH == $BRANCH_NIGHTLY
 
 master_and_nightly_task_template: &MASTER_AND_NIGHTLY_TASK_TEMPLATE
-    only_if: $CIRRUS_BRANCH == $BRANCH_NIGHTLY || $CIRRUS_BRANCH == $BRANCH_MAIN
+  only_if: $CIRRUS_BRANCH == $BRANCH_NIGHTLY || $CIRRUS_BRANCH == $BRANCH_MAIN
 
 master_or_nightly_or_maintenance_task_template: &MASTER_OR_NIGHTLY_OR_MAINTENANCE_TASK_TEMPLATE
-    only_if: $CIRRUS_BRANCH == $BRANCH_NIGHTLY || $CIRRUS_BRANCH == $BRANCH_MAIN || $CIRRUS_BRANCH =~ $BRANCH_PATTERN_MAINTENANCE
+  only_if: $CIRRUS_BRANCH == $BRANCH_NIGHTLY || $CIRRUS_BRANCH == $BRANCH_MAIN || $CIRRUS_BRANCH =~ $BRANCH_PATTERN_MAINTENANCE
 
 except_nightly_task_template: &EXCEPT_ON_NIGHTLY_TASK_TEMPLATE
   only_if: $CIRRUS_BRANCH != $BRANCH_NIGHTLY
@@ -139,7 +142,7 @@ yarn_cache_template: &YARN_CACHE_TEMPLATE
 gradle_cache_template: &GRADLE_CACHE_TEMPLATE
   gradle_cache:
     folder: "~/.gradle/caches"
-    fingerprint_script: find -type f \( -name "*.gradle*" -or -name "gradle*.properties" \) -exec cat {} +
+    fingerprint_script: find -type f \( -name "*.gradle*" -or -name "gradle*.properties" \) | sort | xargs cat
 
 jar_cache_template: &JAR_CACHE_TEMPLATE
   jar_cache:
@@ -185,11 +188,23 @@ default_template: &DEFAULT_TEMPLATE
   env:
     FETCH_DEPTH: --depth=1
 
+cache_dependencies_task:
+  <<: *DEFAULT_TEMPLATE
+  <<: *GRADLE_CACHE_TEMPLATE
+  eks_container:
+    <<: *CONTAINER_TEMPLATE
+    cpu: 7.5
+    memory: 8Gb
+  script:
+    - ./private/cirrus/cirrus-cache-dependencies.sh
+  <<: *DEFAULT_ARTIFACTS_TEMPLATE
+
 build_task:
   <<: *DEFAULT_TEMPLATE
   <<: *GRADLE_CACHE_TEMPLATE
   <<: *YARN_CACHE_TEMPLATE
   <<: *JAR_CACHE_TEMPLATE
+  <<: *CACHE_DEPENDENCIES_DEPENDANT_TASK_TEMPLATE
   eks_container:
     <<: *CONTAINER_TEMPLATE
     cpu: 7.5
@@ -220,6 +235,7 @@ yarn_lint_task:
   <<: *GRADLE_CACHE_TEMPLATE
   <<: *YARN_CACHE_TEMPLATE
   <<: *ESLINT_REPORT_CACHE_TEMPLATE
+  <<: *CACHE_DEPENDENCIES_DEPENDANT_TASK_TEMPLATE
   eks_container:
     <<: *CONTAINER_TEMPLATE
     cpu: 3
@@ -232,6 +248,7 @@ yarn_check_task:
   <<: *DEFAULT_TEMPLATE
   <<: *GRADLE_CACHE_TEMPLATE
   <<: *YARN_CACHE_TEMPLATE
+  <<: *CACHE_DEPENDENCIES_DEPENDANT_TASK_TEMPLATE
   eks_container:
     <<: *CONTAINER_TEMPLATE
     cpu: 3
@@ -246,6 +263,7 @@ yarn_validate_task:
   <<: *GRADLE_CACHE_TEMPLATE
   <<: *YARN_CACHE_TEMPLATE
   <<: *JEST_REPORT_CACHE_TEMPLATE
+  <<: *CACHE_DEPENDENCIES_DEPENDANT_TASK_TEMPLATE
   eks_container:
     <<: *CONTAINER_TEMPLATE
     cpu: 7.5
@@ -258,6 +276,7 @@ junit_task:
   <<: *DEFAULT_TEMPLATE
   <<: *GRADLE_CACHE_TEMPLATE
   <<: *JUNIT_REPORT_CACHE_TEMPLATE
+  <<: *CACHE_DEPENDENCIES_DEPENDANT_TASK_TEMPLATE
   eks_container:
     <<: *CONTAINER_TEMPLATE
     cpu: 7.5
@@ -289,6 +308,7 @@ sq_analysis_task:
 qa_task:
   <<: *DEFAULT_TEMPLATE
   <<: *BUILD_DEPENDANT_TASK_TEMPLATE
+  <<: *CACHE_DEPENDENCIES_DEPENDANT_TASK_TEMPLATE
   <<: *GRADLE_CACHE_TEMPLATE
   <<: *JAR_CACHE_TEMPLATE
   eks_container:
@@ -416,6 +436,7 @@ qa_performance_task:
 # GitLab QA is executed in a dedicated task in order to not slow down the pipeline, as a GitLab on-prem server docker image is required.
 qa_gitlab_task:
   <<: *DEFAULT_TEMPLATE
+  <<: *BUILD_DEPENDANT_TASK_TEMPLATE
   <<: *JAR_CACHE_TEMPLATE
   <<: *GRADLE_CACHE_TEMPLATE
   depends_on:
index c0abf8676599772d4a1dba6e14a398ddfd1e07c1..58b00997ab5acaad7ba2a806d52327b4af283200 100644 (file)
@@ -48,6 +48,18 @@ allprojects {
       version = (version.toString().count('.') == 1 ? "${version}.0.${ext.buildNumber}" : "${version}.${ext.buildNumber}").toString()
   }
 
+
+  task cacheDependencies {
+    doLast {
+      configurations.each { conf ->
+        if (conf.isCanBeResolved()) {
+          if (conf.getName() != 'appZip')
+            conf.resolve()
+        }
+      }
+    }
+  }
+
   ext {
     release = project.hasProperty('release') && project.getProperty('release')
     official = project.hasProperty('official') && project.getProperty('official')
@@ -446,6 +458,7 @@ subprojects {
     }
   }
 
+
   gradle.buildFinished {
     if (!failedTests.empty) {
       println "\nFailed tests:"