.as-if-foss-variables: variables: AS_IF_FOSS_BRANCH: "as-if-foss/${CI_COMMIT_REF_NAME}" FOSS_REPOSITORY: "https://dummy:${AS_IF_FOSS_TOKEN}@gitlab.com/${CI_PROJECT_NAMESPACE}/gitlab-foss.git" prepare-as-if-foss-branch: extends: - .as-if-foss:rules:start-as-if-foss - .as-if-foss-variables stage: prepare needs: [] timeout: 10m environment: name: "as-if-foss/${CI_MERGE_REQUEST_IID}" on_stop: delete-as-if-foss-branch before_script: - git clone --single-branch --branch master "${FOSS_REPOSITORY}" gitlab-foss - git -C gitlab-foss checkout -b "${AS_IF_FOSS_BRANCH}" master - git -C gitlab-foss rev-parse HEAD - rm -r .git/ - mv gitlab-foss/.git . - rm -r gitlab-foss script: # See: https://gitlab.com/gitlab-org/merge-train/-/blob/041d942ae1b5615703b7a786982340b61620e7c5/bin/merge-train#L228-239 - git checkout VERSION - rm -rf ee - rm -rf qa/spec/ee - rm -rf qa/qa/specs/features/ee - rm -rf qa/qa/ee - rm -f qa/qa/ee.rb - rm -f CHANGELOG-EE.md - rm -f changelogs/*-ee.md - git add -A # --allow-empty accounts for the edge case where FOSS matchess EE repository # and a merge request only contains EE related changes. - git commit -m 'Update from merge request' --allow-empty # TODO: Mark which SHA we add - git push -f "${FOSS_REPOSITORY}" "${AS_IF_FOSS_BRANCH}" prepare-as-if-foss-env: extends: - .as-if-foss:rules:start-as-if-foss - .fast-no-clone-job stage: prepare needs: [] variables: BUILD_ENV: build.env FILES_TO_DOWNLOAD: > scripts/setup/generate-as-if-foss-env.rb script: - install_gitlab_gem - ruby scripts/setup/generate-as-if-foss-env.rb | tee "${BUILD_ENV}" artifacts: expire_in: 3 days reports: dotenv: $BUILD_ENV paths: - $BUILD_ENV start-as-if-foss: extends: - .as-if-foss:rules:start-as-if-foss stage: prepare needs: - prepare-as-if-foss-branch - prepare-as-if-foss-env inherit: variables: false # Otherwise variables will be messed up variables: START_AS_IF_FOSS: $START_AS_IF_FOSS RUBY_VERSION: $RUBY_VERSION # Variables for `detect-tests` to work in FOSS FIND_CHANGES_MERGE_REQUEST_PROJECT_PATH: $FIND_CHANGES_MERGE_REQUEST_PROJECT_PATH FIND_CHANGES_MERGE_REQUEST_IID: $FIND_CHANGES_MERGE_REQUEST_IID # Enabling each individual jobs ENABLE_RSPEC: $ENABLE_RSPEC ENABLE_RSPEC_FAST_SPEC_HELPER: $ENABLE_RSPEC_FAST_SPEC_HELPER ENABLE_RSPEC_PRAEFECT: $ENABLE_RSPEC_PRAEFECT ENABLE_RSPEC_SINGLE_DB: $ENABLE_RSPEC_SINGLE_DB ENABLE_RSPEC_SINGLE_DB_CI_CONNECTION: $ENABLE_RSPEC_SINGLE_DB_CI_CONNECTION ENABLE_RSPEC_SINGLE_REDIS: $ENABLE_RSPEC_SINGLE_REDIS ENABLE_RSPEC_UNIT: $ENABLE_RSPEC_UNIT ENABLE_RSPEC_INTEGRATION: $ENABLE_RSPEC_INTEGRATION ENABLE_RSPEC_SYSTEM: $ENABLE_RSPEC_SYSTEM ENABLE_RSPEC_MIGRATION: $ENABLE_RSPEC_MIGRATION ENABLE_RSPEC_BACKGROUND_MIGRATION: $ENABLE_RSPEC_BACKGROUND_MIGRATION ENABLE_RSPEC_FRONTEND_FIXTURE: $ENABLE_RSPEC_FRONTEND_FIXTURE ENABLE_BUILD_ASSETS_IMAGE: $ENABLE_BUILD_ASSETS_IMAGE ENABLE_BUILD_QA_IMAGE: $ENABLE_BUILD_QA_IMAGE 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_DETECT_TESTS: $ENABLE_DETECT_TESTS ENABLE_ESLINT: $ENABLE_ESLINT ENABLE_GENERATE_APOLLO_GRAPHQL_SCHEMA: $ENABLE_GENERATE_APOLLO_GRAPHQL_SCHEMA ENABLE_GRAPHQL_SCHEMA_DUMP: $ENABLE_GRAPHQL_SCHEMA_DUMP ENABLE_JEST: $ENABLE_JEST ENABLE_JEST_INTEGRATION: $ENABLE_JEST_INTEGRATION ENABLE_JEST_PREDICTIVE: $ENABLE_JEST_PREDICTIVE ENABLE_RSPEC_PREDICTIVE_PIPELINE_GENERATE: $ENABLE_RSPEC_PREDICTIVE_PIPELINE_GENERATE ENABLE_RSPEC_PREDICTIVE_TRIGGER: $ENABLE_RSPEC_PREDICTIVE_TRIGGER ENABLE_RSPEC_PREDICTIVE_TRIGGER_SINGLE_DB: $ENABLE_RSPEC_PREDICTIVE_TRIGGER_SINGLE_DB ENABLE_RSPEC_PREDICTIVE_TRIGGER_SINGLE_DB_CI_CONNECTION: $ENABLE_RSPEC_PREDICTIVE_TRIGGER_SINGLE_DB_CI_CONNECTION ENABLE_RUBOCOP: $ENABLE_RUBOCOP ENABLE_QA_INTERNAL: $ENABLE_QA_INTERNAL ENABLE_QA_SELECTORS: $ENABLE_QA_SELECTORS ENABLE_STATIC_ANALYSIS: $ENABLE_STATIC_ANALYSIS trigger: project: ${CI_PROJECT_NAMESPACE}/gitlab-foss branch: as-if-foss/${CI_COMMIT_REF_NAME} strategy: depend delete-as-if-foss-branch: extends: - .as-if-foss:rules:start-as-if-foss:allow-failure:manual - .as-if-foss-variables image: name: alpine/git entrypoint: [""] stage: prepare timeout: 10m needs: - prepare-as-if-foss-branch environment: name: "as-if-foss/${CI_MERGE_REQUEST_IID}" action: stop variables: GIT_STRATEGY: "none" script: - | git init git push -d "${FOSS_REPOSITORY}" "${AS_IF_FOSS_BRANCH}" # We can only delete the environment after it's stopped, therefore # we need to use another job to delete the environment, not in the # job where it's stopping the environment. See: # https://docs.gitlab.com/ee/ci/environments/#delete-an-environment delete-as-if-foss-environment: extends: - .as-if-foss:rules:start-as-if-foss:allow-failure image: alpine:latest stage: prepare needs: - delete-as-if-foss-branch variables: GIT_STRATEGY: "none" ESCAPED_ENVIRONMENT_NAME: "as-if-foss%2f${CI_MERGE_REQUEST_IID}" ENVIRONMENT_API_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/environments" before_script: - apk add jq curl script: - | ENV_ID=$(curl --silent --fail --request GET --header "Private-Token: ${PROJECT_TOKEN_FOR_CI_SCRIPTS_API_USAGE}" "${ENVIRONMENT_API_URL}?name=${ESCAPED_ENVIRONMENT_NAME}" | jq '.[0].id') curl --silent --request DELETE --header "Private-Token: $PROJECT_TOKEN_FOR_CI_SCRIPTS_API_USAGE" "${ENVIRONMENT_API_URL}/${ENV_ID}"