diff --git a/.gitlab/ci/as-if-foss.gitlab-ci.yml b/.gitlab/ci/as-if-foss.gitlab-ci.yml index 110b20bb080bc6cb3fe02a601b0480e34425771c..5686be6deea58d2f04767460a8526672cef2e1b2 100644 --- a/.gitlab/ci/as-if-foss.gitlab-ci.yml +++ b/.gitlab/ci/as-if-foss.gitlab-ci.yml @@ -84,6 +84,7 @@ start-as-if-foss: ENABLE_COMPILE_PRODUCTION_ASSETS: $ENABLE_COMPILE_PRODUCTION_ASSETS ENABLE_COMPILE_STORYBOOK: $ENABLE_COMPILE_STORYBOOK ENABLE_COMPILE_TEST_ASSETS: $ENABLE_COMPILE_TEST_ASSETS + ENABLE_CACHE_ASSETS: $ENABLE_CACHE_ASSETS ENABLE_ESLINT: $ENABLE_ESLINT ENABLE_GENERATE_APOLLO_GRAPHQL_SCHEMA: $ENABLE_GENERATE_APOLLO_GRAPHQL_SCHEMA ENABLE_GRAPHQL_SCHEMA_DUMP: $ENABLE_GRAPHQL_SCHEMA_DUMP diff --git a/.gitlab/ci/rules.gitlab-ci.yml b/.gitlab/ci/rules.gitlab-ci.yml index 394ae2fa5adeb03a4ecf900142a709a201f9b407..c78f5e8f54756a80cb7d0a6747b50750ec58cbd2 100644 --- a/.gitlab/ci/rules.gitlab-ci.yml +++ b/.gitlab/ci/rules.gitlab-ci.yml @@ -140,6 +140,9 @@ .if-foss-default-branch: &if-foss-default-branch if: '$CI_PROJECT_PATH == "gitlab-org/gitlab-foss" && $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH' +.if-not-dot-com-gitlab-org-and-not-jihulab: &if-not-dot-com-gitlab-org-and-not-jihulab + if: '($CI_SERVER_HOST != "gitlab.com" || $CI_PROJECT_NAMESPACE != "gitlab-org") && ($CI_SERVER_HOST != "jihulab.com" || $CI_PROJECT_NAMESPACE != "gitlab-cn")' + .if-dot-com-gitlab-org-schedule: &if-dot-com-gitlab-org-schedule if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAMESPACE == "gitlab-org" && $CI_PIPELINE_SOURCE == "schedule"' @@ -1044,7 +1047,7 @@ # The new strategy to cache assets as generic packages is experimental and can be disabled by removing the `CACHE_ASSETS_AS_PACKAGE` variable - if: '$CACHE_ASSETS_AS_PACKAGE != "true"' when: never - - <<: *if-not-ee + - <<: *if-not-dot-com-gitlab-org-and-not-jihulab when: never # That would run for any project that has a "maintenance" pipeline schedule # but in fact, the cache package is only uploaded for gitlab.com/gitlab-org/gitlab and jihulab.com/gitlab-cn/gitlab @@ -1058,6 +1061,9 @@ - "lib/tasks/gitlab/assets.rake" when: manual allow_failure: true + - if: '$ENABLE_CACHE_ASSETS == "true"' + when: manual + allow_failure: true .caching:rules:cache-assets-as-if-foss: rules: diff --git a/scripts/gitlab_component_helpers.sh b/scripts/gitlab_component_helpers.sh index 3d9f996e7c034ed916fd07dcca066a85042624ef..e16770760ff8c8f9be884a67ca887493165caee1 100644 --- a/scripts/gitlab_component_helpers.sh +++ b/scripts/gitlab_component_helpers.sh @@ -8,13 +8,19 @@ source scripts/packages/helpers.sh export CURL_TOKEN_HEADER="${CURL_TOKEN_HEADER:-"JOB-TOKEN"}" export GITLAB_COM_CANONICAL_PROJECT_ID="278964" # https://gitlab.com/gitlab-org/gitlab +export GITLAB_COM_CANONICAL_FOSS_PROJECT_ID="13083" # https://gitlab.com/gitlab-org/gitlab-foss export JIHULAB_COM_CANONICAL_PROJECT_ID="13953" # https://jihulab.com/gitlab-cn/gitlab export CANONICAL_PROJECT_ID="${GITLAB_COM_CANONICAL_PROJECT_ID}" # By default, we only want to store/retrieve packages from GitLab.com... export API_V4_URL="https://gitlab.com/api/v4" -# Unless we're in the JiHu project, which needs to use its own package registry +# If it's a FOSS repository, it needs to use FOSS package registry +if [[ ! -d "ee/" ]]; then + export CANONICAL_PROJECT_ID="${GITLAB_COM_CANONICAL_FOSS_PROJECT_ID}" +fi + +# If it's in the JiHu project, it needs to use its own package registry if [[ "${CI_SERVER_HOST}" = "jihulab.com" ]]; then export API_V4_URL="${CI_API_V4_URL}" export CANONICAL_PROJECT_ID="${JIHULAB_COM_CANONICAL_PROJECT_ID}" diff --git a/scripts/setup/generate-as-if-foss-env.rb b/scripts/setup/generate-as-if-foss-env.rb index e0a3dbddd74a9af18b68c2203a399fb0b033c515..71db2101f0c927277b7cbddc611d0600decee1aa 100755 --- a/scripts/setup/generate-as-if-foss-env.rb +++ b/scripts/setup/generate-as-if-foss-env.rb @@ -74,13 +74,15 @@ def detect_rspec(job) end def detect_other_jobs(job) + # rubocop:disable Lint/AssignmentInCondition -- More clear without this cop if FOSS_JOBS.member?(job.name) other_jobs << job.name - else - jest_type = job.name[%r{^(jest(?:-\w+)?)(?: \d+/\d+)?$}, 1] - - other_jobs << jest_type if jest_type + elsif jest_type = job.name[%r{^(jest(?:-\w+)?)(?: \d+/\d+)?$}, 1] + other_jobs << jest_type + elsif cache_assets_type = job.name[%r{^(cache-assets)\b}, 1] + other_jobs << cache_assets_type end + # rubocop:enable Lint/AssignmentInCondition end def rspec_variables diff --git a/spec/scripts/setup/generate_as_if_foss_env_spec.rb b/spec/scripts/setup/generate_as_if_foss_env_spec.rb index bafe306bbe5bf1c786a6a434f228299e98b01dce..94c87c445d09dd01ebac9711885b60338abd028f 100644 --- a/spec/scripts/setup/generate_as_if_foss_env_spec.rb +++ b/spec/scripts/setup/generate_as_if_foss_env_spec.rb @@ -36,6 +36,7 @@ 'compile-production-assets', 'compile-storybook', 'compile-test-assets', + 'cache-assets:test', 'eslint', 'generate-apollo-graphql-schema', 'graphql-schema-dump', @@ -82,6 +83,7 @@ ENABLE_COMPILE_PRODUCTION_ASSETS: 'true', ENABLE_COMPILE_STORYBOOK: 'true', ENABLE_COMPILE_TEST_ASSETS: 'true', + ENABLE_CACHE_ASSETS: 'true', ENABLE_ESLINT: 'true', ENABLE_GENERATE_APOLLO_GRAPHQL_SCHEMA: 'true', ENABLE_GRAPHQL_SCHEMA_DUMP: 'true', @@ -118,6 +120,7 @@ ENABLE_COMPILE_PRODUCTION_ASSETS=true ENABLE_COMPILE_STORYBOOK=true ENABLE_COMPILE_TEST_ASSETS=true + ENABLE_CACHE_ASSETS=true ENABLE_ESLINT=true ENABLE_GENERATE_APOLLO_GRAPHQL_SCHEMA=true ENABLE_GRAPHQL_SCHEMA_DUMP=true