diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9a24f58ad7329cfa0a7c048a91d0c082e72154ee..bc07e5fea9110ebbc1009a102758a292e609afe8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -155,6 +155,7 @@ variables: GIT_STRATEGY: "clone" GIT_SUBMODULE_STRATEGY: "none" GET_SOURCES_ATTEMPTS: "3" + CI_FETCH_REPO_GIT_STRATEGY: "none" DEBIAN_VERSION: "bullseye" UBI_VERSION: "8.6" CHROME_VERSION: "113" diff --git a/.gitlab/ci/global.gitlab-ci.yml b/.gitlab/ci/global.gitlab-ci.yml index dc006a3ce247ce3512e0f2d2babbd68ade36f2d7..798bcacb36734e4903d2ac62a9fe3e34e347b7f7 100644 --- a/.gitlab/ci/global.gitlab-ci.yml +++ b/.gitlab/ci/global.gitlab-ci.yml @@ -22,6 +22,14 @@ - !reference [.default-utils-before_script, before_script] - source scripts/prepare_build.sh +.repo-from-artifacts: + variables: + GIT_STRATEGY: "${CI_FETCH_REPO_GIT_STRATEGY}" + needs: + # If the job extending this also defines `needs`, make sure to update + # its `needs` to include `clone-gitlab-repo` because it'll be overridden. + - clone-gitlab-repo + .production: variables: RAILS_ENV: "production" diff --git a/.gitlab/ci/rails.gitlab-ci.yml b/.gitlab/ci/rails.gitlab-ci.yml index fd4047373d7b57235f26e069a715e16c6ca44dbd..ad5da0048f923cc8ce59c6a1e36a1cc051f5a208 100644 --- a/.gitlab/ci/rails.gitlab-ci.yml +++ b/.gitlab/ci/rails.gitlab-ci.yml @@ -616,6 +616,7 @@ rspec:predictive:trigger: artifacts: true variables: PARENT_PIPELINE_ID: $CI_PIPELINE_ID + GIT_STRATEGY: $GIT_STRATEGY trigger: strategy: depend forward: @@ -1269,6 +1270,7 @@ rspec-foss-impact:trigger: artifacts: true variables: PARENT_PIPELINE_ID: $CI_PIPELINE_ID + GIT_STRATEGY: $GIT_STRATEGY trigger: strategy: depend forward: diff --git a/.gitlab/ci/rails/rspec-foss-impact.gitlab-ci.yml.erb b/.gitlab/ci/rails/rspec-foss-impact.gitlab-ci.yml.erb index 8a36848b363354eebe3a57d4c3c7644bb640bce4..97abb26ae7f9e02a1cec427e37acb823e01f003a 100644 --- a/.gitlab/ci/rails/rspec-foss-impact.gitlab-ci.yml.erb +++ b/.gitlab/ci/rails/rspec-foss-impact.gitlab-ci.yml.erb @@ -24,6 +24,10 @@ dont-interrupt-me: .base-rspec-foss-impact: extends: .rspec-base-pg14-as-if-foss needs: + <% if repo_from_artifacts %> + - pipeline: $PARENT_PIPELINE_ID + job: clone-gitlab-repo + <% end %> - pipeline: $PARENT_PIPELINE_ID job: detect-tests - pipeline: $PARENT_PIPELINE_ID diff --git a/.gitlab/ci/rails/rspec-predictive.gitlab-ci.yml.erb b/.gitlab/ci/rails/rspec-predictive.gitlab-ci.yml.erb index ddcb335d0ddb73a987d64423a65699784b1b2504..90f1b6fc5a8e1d258bcf84c84b98ae3635212070 100644 --- a/.gitlab/ci/rails/rspec-predictive.gitlab-ci.yml.erb +++ b/.gitlab/ci/rails/rspec-predictive.gitlab-ci.yml.erb @@ -23,6 +23,10 @@ dont-interrupt-me: .base-predictive: needs: + <% if repo_from_artifacts %> + - pipeline: $PARENT_PIPELINE_ID + job: clone-gitlab-repo + <% end %> - pipeline: $PARENT_PIPELINE_ID job: detect-tests - pipeline: $PARENT_PIPELINE_ID diff --git a/.gitlab/ci/rules.gitlab-ci.yml b/.gitlab/ci/rules.gitlab-ci.yml index 31b4dda4368f4912995635999a4f0cebe1fa2735..f2f0d2f4775da61c850d03c934d4bf955034cca3 100644 --- a/.gitlab/ci/rules.gitlab-ci.yml +++ b/.gitlab/ci/rules.gitlab-ci.yml @@ -2784,6 +2784,10 @@ - when: manual allow_failure: true +.setup:rules:clone-gitlab-repo: + rules: + - if: '$CI_FETCH_REPO_GIT_STRATEGY == "none"' + .setup:rules:gitlab_git_test: rules: - <<: *if-merge-request-labels-pipeline-expedite diff --git a/.gitlab/ci/setup.gitlab-ci.yml b/.gitlab/ci/setup.gitlab-ci.yml index a9ed562c9a840b99d59cf178e0cb9b6a1bd3315f..15f3695739248786e2536dc92e7ce086f05fec9b 100644 --- a/.gitlab/ci/setup.gitlab-ci.yml +++ b/.gitlab/ci/setup.gitlab-ci.yml @@ -46,7 +46,7 @@ dont-interrupt-me: clone-gitlab-repo: extends: - .absolutely-predictive-job - # rules: [when: never] # Uncomment this to clone instead of using artifacts + - .setup:rules:clone-gitlab-repo stage: sync script: - echo OK @@ -57,14 +57,6 @@ clone-gitlab-repo: - '*' expire_in: '12 hours' -.repo-from-artifacts: - variables: - GIT_STRATEGY: none - needs: - # If the job extending this also defines `needs`, make sure to update - # its `needs` to include `clone-gitlab-repo` because it'll be overridden. - - clone-gitlab-repo - gitlab_git_test: extends: - .predictive-job diff --git a/scripts/generate_rspec_pipeline.rb b/scripts/generate_rspec_pipeline.rb index 1fc37374ba5f18a97b260760c51bad35e7cac029..70a0c87be35bd5bfbcbbe3dfabb5e162d5da36b4 100755 --- a/scripts/generate_rspec_pipeline.rb +++ b/scripts/generate_rspec_pipeline.rb @@ -93,7 +93,8 @@ def all_rspec_files def erb_binding { rspec_files_per_test_level: rspec_files_per_test_level, - test_suite_prefix: test_suite_prefix + test_suite_prefix: test_suite_prefix, + repo_from_artifacts: ENV['CI_FETCH_REPO_GIT_STRATEGY'] == 'none' } end