diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3e098dd675a4a81ea06c4b7ed85afc9ae7403790..8b203089976ea38290999c419533854253159a0a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -50,7 +50,7 @@ yamllint: stage: analyze timeout: 2m script: - - yamllint -c .yamllint.yml .*.yml + - yamllint -c .yamllint.yml *.yml .*.yml # --------------------------------------------------------------------------------------- diff --git a/foobar-manifest-integration.yml b/foobar-manifest-integration.yml new file mode 100644 index 0000000000000000000000000000000000000000..6ebf3279707beeeed8d2de678ddb8f8d87d41ed6 --- /dev/null +++ b/foobar-manifest-integration.yml @@ -0,0 +1,133 @@ +--- +# ------------------------------------------------------------------------------------- +# CI steps needed to integrate a sub project change into the manifest project +# foobar variant which is used for testing the CI +# ------------------------------------------------------------------------------------- + +image: "${CI_IMAGES}/python/3.9:99e363bc5feaa27ff18dbe7731a76ff04d7d0deb" + +variables: + # CI_IMAGES_BASEPATH: Environment variable configure in gitlab + CI_IMAGES: ${CI_IMAGES_BASEPATH}/ci-images + # Include git submodules + GIT_SUBMODULE_STRATEGY: recursive + # FIXME: due to a missing feature in GitLab, we cannot use this variable in the build + # stage further down this file. If it ever changes, it has to be changed there too. + # (https://gitlab.com/gitlab-org/gitlab/-/issues/249583) + MANIFEST_PROJECT: "${CI_PROJECT_ROOT_NAMESPACE}/yocto/infrastructure/\ + ci-test/minimal-manifest" + # The master branch is hardcoded here, because it cannot be determined automatically. + # Has to be modified for new branches, e.g. new Yocto versions or fix releases. + MASTER_BRANCH: master + +stages: + - prepare + - integrate + - merge + - build + - check + +workflow: + rules: + # Do not run pipelines on forked projects + - if: $CI_PROJECT_ROOT_NAMESPACE == "SECO-Northern-Europe" + && $CI_MERGE_REQUEST_SOURCE_PROJECT_ID == $CI_MERGE_REQUEST_PROJECT_ID + +# --------------------------------------------------------------------------------------- +# Stage: prepare +# --------------------------------------------------------------------------------------- +yamllint: + stage: prepare + rules: + - if: $CI_COMMIT_REF_NAME != $MASTER_BRANCH + tags: + - infrastructure + timeout: 2m + script: + - yamllint -c .gitlab-ci/.yamllint.yml .*.yml + +# --------------------------------------------------------------------------------------- +# Stage: integrate +# --------------------------------------------------------------------------------------- +integrate: + stage: integrate + rules: + # We have to make sure that the pipeline runs for the current manifest master at + # the time a merge request is created. Otherwise we cannot guarantee a green + # master after merging. + - if: $CI_MERGE_REQUEST_IID + tags: + - infrastructure + timeout: 2m + cache: + policy: push + script: + - cd ${CI_PROJECT_DIR} + - .gitlab-ci/integrate_into_manifest.py + --gitlab-url=${CI_SERVER_URL} + --token=${GITBOT_TOKEN} + --manifest-project=${MANIFEST_PROJECT} + --integration-base=${MASTER_BRANCH} + --project=${CI_PROJECT_PATH} + --merge-request=${CI_MERGE_REQUEST_IID} + --save-revision-to=manifest_revision + artifacts: + paths: + - manifest_revision + +# -------------------------------------------------------------------------------------- +# Stage: merge +# -------------------------------------------------------------------------------------- +merge: + stage: merge + rules: + - if: $CI_COMMIT_BRANCH == $MASTER_BRANCH + tags: + - infrastructure + timeout: 3m + script: + - cd ${CI_PROJECT_DIR} + - .gitlab-ci/merge_into_manifest.py + --gitlab-url=${CI_SERVER_URL} + --token=${GITBOT_TOKEN} + --manifest-project=${MANIFEST_PROJECT} + --master-branch=${MASTER_BRANCH} + --project=${CI_PROJECT_PATH} + --commit=${CI_COMMIT_SHA} + --save-revision-to=manifest_revision + artifacts: + paths: + - manifest_revision + +# -------------------------------------------------------------------------------------- +# Stage: build +# -------------------------------------------------------------------------------------- +build: + stage: build + rules: + - if: $CI_MERGE_REQUEST_IID + trigger: + project: SECO-Northern-Europe/yocto/infrastructure/ci-test/minimal-manifest + branch: "integrate/${CI_PROJECT_NAME}/${CI_COMMIT_REF_NAME}" + strategy: depend + +# -------------------------------------------------------------------------------------- +# Stage: check +# -------------------------------------------------------------------------------------- +check: + stage: check + rules: + - if: $CI_MERGE_REQUEST_IID + needs: ["integrate"] + tags: + - infrastructure + timeout: 2m + script: + - cd ${CI_PROJECT_DIR} + - .gitlab-ci/check_if_integration_branch_is_up_to_date.py + --gitlab-url=${CI_SERVER_URL} + --token=${GITBOT_TOKEN} + --manifest-project=${MANIFEST_PROJECT} + --integration-base=${MASTER_BRANCH} + --project=${CI_PROJECT_PATH} + --merge-request=${CI_MERGE_REQUEST_IID}