Skip to content
Snippets Groups Projects
Commit 25d7cabd authored by Jonas Höppner's avatar Jonas Höppner
Browse files

CI: Harmonize foobar and yocto CI files

Also set yocto deploy job to manual to test merge.
parent 2cdf882e
No related branches found
No related tags found
1 merge request!101CI: Create pipeline to deploy changes in gitlab-ci to all subprojects, include all CI implementations from there.
Pipeline #9041 failed with stages
in 1 minute and 21 seconds
...@@ -89,6 +89,10 @@ yamllint: ...@@ -89,6 +89,10 @@ yamllint:
deploy: deploy:
extends: .deploy extends: .deploy
rules:
# For now to test the merge step
- when: manual
allow_failure: true
variables: variables:
PROJECT_ROOT: PROJECT_ROOT:
${CI_PROJECT_ROOT_NAMESPACE} ${CI_PROJECT_ROOT_NAMESPACE}
......
...@@ -43,3 +43,40 @@ yamllint: ...@@ -43,3 +43,40 @@ yamllint:
- if: $CI_COMMIT_REF_NAME != $MASTER_BRANCH_MANIFEST || $CI_PIPELINE_SOURCE == "api" - if: $CI_COMMIT_REF_NAME != $MASTER_BRANCH_MANIFEST || $CI_PIPELINE_SOURCE == "api"
script: script:
- yamllint -c .gitlab-ci/.yamllint.yml .*.yml - yamllint -c .gitlab-ci/.yamllint.yml .*.yml
# --------------------------------------------------------------------------------------
# Common check job, used in yocto and foobar manifest-integration projects
# --------------------------------------------------------------------------------------
.check:
extends: .infrastructure
stage: check
rules:
- if: $CI_MERGE_REQUEST_IID
# Explicitly allow externally triggered pipelines in every case
- if: $CI_PIPELINE_SOURCE == "pipeline" || $CI_PIPELINE_SOURCE == "api"
needs: ["integrate"]
script:
- cd ${CI_PROJECT_DIR}
# When running in a trigger pipeline the CII_MERGE_REQUEST_IID is not set
# but CI_OPEN_MERGE_REQUESTS. We use the first of this comma separated list
# in this case
- if [ -n "${CI_MERGE_REQUEST_IID}" ];then
MERGE_REQUEST="${CI_MERGE_REQUEST_IID}";
else
MERGE_REQUEST="${CI_OPEN_MERGE_REQUESTS%%,*}";
fi
# The 'parent_merge_request' is passed from the trigger
# in case this check job is part of a gitlab-ci integration
# pipeline. It is only used to display the correct MR to run again
# in a failed check
- if [ -n "${parent_merge_request}" ];then
PARENT_MR="--parent-merge-request=${parent_merge_request}";
fi
- .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_MANIFEST}
--project=${CI_PROJECT_PATH}
--merge-request=${MERGE_REQUEST}
${PARENT_MR}
...@@ -3,14 +3,19 @@ ...@@ -3,14 +3,19 @@
# CI steps needed to integrate a sub project change into the manifest project # CI steps needed to integrate a sub project change into the manifest project
# foobar variant which is used for testing the CI # foobar variant which is used for testing the CI
# ------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------
include:
- local: common.yml
image: "${CI_IMAGES}/python/3.9:99e363bc5feaa27ff18dbe7731a76ff04d7d0deb" image: "${CI_IMAGE_PYTHON}"
stages:
- infrastructure
- integrate
- merge
- build
- check
variables: 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 # 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. # stage further down this file. If it ever changes, it has to be changed there too.
# (https://gitlab.com/gitlab-org/gitlab/-/issues/249583) # (https://gitlab.com/gitlab-org/gitlab/-/issues/249583)
...@@ -18,14 +23,16 @@ variables: ...@@ -18,14 +23,16 @@ variables:
ci-test/minimal-manifest" ci-test/minimal-manifest"
# The master branch is hardcoded here, because it cannot be determined automatically. # 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. # Has to be modified for new branches, e.g. new Yocto versions or fix releases.
MASTER_BRANCH: master MASTER_BRANCH_MANIFEST: master
MASTER_BRANCH_PROJECT: master
stages: # The BB_RECIPE_NAME is used for projects referenced in the SRCREV file
- prepare # to match the repository and the bitbake recipe name.
- integrate # We set it here to none, as every project needing it
- merge # has to specify it in its own gitlab-ci.yml file.
- build # The BB_RECIPE_NAME is passed to the python scripts below anyway, but not
- check # used for projects referenced in the manifest file.
BB_RECIPE_NAME: none
workflow: workflow:
rules: rules:
...@@ -50,38 +57,21 @@ workflow: ...@@ -50,38 +57,21 @@ workflow:
&& $CI_MERGE_REQUEST_SOURCE_PROJECT_ID == $CI_MERGE_REQUEST_PROJECT_ID && $CI_MERGE_REQUEST_SOURCE_PROJECT_ID == $CI_MERGE_REQUEST_PROJECT_ID
# --------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------
# Stage: prepare # integrate
# --------------------------------------------------------------------------------------- # Create a commit in the manifest to pull this change
yamllint:
stage: prepare
rules:
- if: $CI_COMMIT_REF_NAME != $MASTER_BRANCH
tags:
- infrastructure
timeout: 2m
script:
- printenv
- yamllint -c .gitlab-ci/.yamllint.yml .*.yml
# ---------------------------------------------------------------------------------------
# Stage: integrate
# --------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------
integrate: integrate:
stage: integrate extends: .infrastructure
rules: rules:
# We have to make sure that the pipeline runs for the current manifest master at # We have to make sure that the pipeline runs for the current manifest
# the time a merge request is created. Otherwise we cannot guarantee a green # master at the time a merge request is created. Otherwise we cannot
# master after merging. # guarantee a green master after merging.
- if: $CI_MERGE_REQUEST_IID - if: $CI_MERGE_REQUEST_IID
# Explicitly allow externally triggered pipelines in every case # Explicitly allow externally triggered pipelines in every case
- if: $CI_PIPELINE_SOURCE == "pipeline" || $CI_PIPELINE_SOURCE == "api" - if: $CI_PIPELINE_SOURCE == "pipeline" || $CI_PIPELINE_SOURCE == "api"
tags:
- infrastructure
timeout: 2m
cache: cache:
policy: push policy: push
script: script:
- printenv
- cd ${CI_PROJECT_DIR} - cd ${CI_PROJECT_DIR}
- if [ -n "${CI_MERGE_REQUEST_IID}" ];then - if [ -n "${CI_MERGE_REQUEST_IID}" ];then
MERGE_REQUEST="${CI_MERGE_REQUEST_IID}"; MERGE_REQUEST="${CI_MERGE_REQUEST_IID}";
...@@ -92,11 +82,11 @@ integrate: ...@@ -92,11 +82,11 @@ integrate:
--gitlab-url=${CI_SERVER_URL} --gitlab-url=${CI_SERVER_URL}
--token=${GITBOT_TOKEN} --token=${GITBOT_TOKEN}
--manifest-project=${MANIFEST_PROJECT} --manifest-project=${MANIFEST_PROJECT}
--integration-base=${MASTER_BRANCH} --integration-base=${MASTER_BRANCH_MANIFEST}
--project=${CI_PROJECT_PATH} --project=${CI_PROJECT_PATH}
--merge-request=${MERGE_REQUEST} --merge-request=${MERGE_REQUEST}
--save-revision-to=manifest_revision --save-revision-to=manifest_revision
--verbose --recipe-name=${BB_RECIPE_NAME}
artifacts: artifacts:
paths: paths:
- manifest_revision - manifest_revision
...@@ -105,22 +95,22 @@ integrate: ...@@ -105,22 +95,22 @@ integrate:
# Stage: merge # Stage: merge
# -------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------
merge: merge:
extends: .infrastructure
stage: merge stage: merge
rules: rules:
- if: $CI_COMMIT_BRANCH == $MASTER_BRANCH - if: $CI_COMMIT_BRANCH == $MASTER_BRANCH_PROJECT
tags:
- infrastructure
timeout: 3m
script: script:
- cd ${CI_PROJECT_DIR} - cd ${CI_PROJECT_DIR}
- .gitlab-ci/merge_into_manifest.py - .gitlab-ci/merge_into_manifest.py
--gitlab-url=${CI_SERVER_URL} --gitlab-url=${CI_SERVER_URL}
--token=${GITBOT_TOKEN} --token=${GITBOT_TOKEN}
--manifest-project=${MANIFEST_PROJECT} --manifest-project=${MANIFEST_PROJECT}
--master-branch=${MASTER_BRANCH} --master-branch=${MASTER_BRANCH_MANIFEST}
--project=${CI_PROJECT_PATH} --project=${CI_PROJECT_PATH}
--master-branch-project=${MASTER_BRANCH_PROJECT}
--commit=${CI_COMMIT_SHA} --commit=${CI_COMMIT_SHA}
--save-revision-to=manifest_revision --save-revision-to=manifest_revision
--recipe-name=${BB_RECIPE_NAME}
artifacts: artifacts:
paths: paths:
- manifest_revision - manifest_revision
...@@ -144,35 +134,4 @@ build: ...@@ -144,35 +134,4 @@ build:
# Stage: check # Stage: check
# -------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------
check: check:
stage: check extends: .check
rules:
- if: $CI_MERGE_REQUEST_IID
# Explicitly allow externally triggered pipelines in every case
- if: $CI_PIPELINE_SOURCE == "pipeline" || $CI_PIPELINE_SOURCE == "api"
needs: ["integrate"]
tags:
- infrastructure
timeout: 2m
script:
- printenv
- cd ${CI_PROJECT_DIR}
- if [ -n "${CI_MERGE_REQUEST_IID}" ];then
MERGE_REQUEST="${CI_MERGE_REQUEST_IID}";
else
MERGE_REQUEST="${CI_OPEN_MERGE_REQUESTS%%,*}";
fi
- if [ -n "${parent_merge_request}" ];then
PARENT_MR="--parent-merge-request=${parent_merge_request}";
fi
- echo "${parent_merge_request}"
- echo "${PARENT_MR}"
- echo "${MERGE_REQUEST}"
- .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=${MERGE_REQUEST}
--verbose
${PARENT_MR}
---
# -------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------
# Global # Global
# -------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------
--- include:
- local: common.yml
stages: stages:
- retrigger - retrigger
- infrastructure
- build - build
- test - test
variables: variables:
# CI_IMAGES_BASEPATH: Environment variable configure in gitlab
CI_IMAGES_PATH: ${CI_IMAGES_BASEPATH}/ci-images
CI_IMAGES_REV: 835a7096092eef5cecde23fd933209e7a8488637
CI_IMAGE_PYTHON: "${CI_IMAGES_PATH}/python/3.9:${CI_IMAGES_REV}"
CI_IMAGE_YOCTO: "${CI_IMAGES_PATH}/yocto-build/ubuntu-20.04:${CI_IMAGES_REV}"
# The master branch is hardcoded here, because it cannot be determined automatically. # 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. # Has to be modified for new branches, e.g. new Yocto versions or fix releases.
MASTER_BRANCH: master MASTER_BRANCH_MANIFEST: master
MASTER_BRANCH_PROJECT: master
workflow: workflow:
rules: rules:
...@@ -39,16 +39,10 @@ workflow: ...@@ -39,16 +39,10 @@ workflow:
# Stage: retrigger # Stage: retrigger
# -------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------
retrigger: retrigger:
extends: .infrastructure
stage: retrigger stage: retrigger
rules: rules:
- if: $CI_COMMIT_REF_NAME == $MASTER_BRANCH && $CI_PIPELINE_SOURCE != "api" - if: $CI_COMMIT_REF_NAME == $MASTER_BRANCH_MANIFEST && $CI_PIPELINE_SOURCE != "api"
tags:
- infrastructure
timeout: 2m
image: ${CI_IMAGE_PYTHON}
variables:
# Include git submodules
GIT_SUBMODULE_STRATEGY: recursive
script: script:
- PROJECTS=$( - PROJECTS=$(
.gitlab-ci/get_manifest_projects.py .gitlab-ci/get_manifest_projects.py
...@@ -66,7 +60,7 @@ retrigger: ...@@ -66,7 +60,7 @@ retrigger:
--token=${GITBOT_TOKEN} --token=${GITBOT_TOKEN}
--project=${PROJECT} --project=${PROJECT}
--state=opened --state=opened
--target-branch=${MASTER_BRANCH} --target-branch=${MASTER_BRANCH_MANIFEST}
--job=check --job=check
; ;
done done
...@@ -107,7 +101,7 @@ retrigger: ...@@ -107,7 +101,7 @@ retrigger:
build:files: build:files:
stage: build stage: build
rules: rules:
- if: $CI_COMMIT_REF_NAME != $MASTER_BRANCH || $CI_PIPELINE_SOURCE == "api" - if: $CI_COMMIT_REF_NAME != $MASTER_BRANCH_MANIFEST || $CI_PIPELINE_SOURCE == "api"
needs: [] needs: []
tags: tags:
- infrastructure - infrastructure
...@@ -138,7 +132,7 @@ build:files: ...@@ -138,7 +132,7 @@ build:files:
build:echo: build:echo:
stage: build stage: build
rules: rules:
- if: $CI_COMMIT_REF_NAME != $MASTER_BRANCH || $CI_PIPELINE_SOURCE == "api" - if: $CI_COMMIT_REF_NAME != $MASTER_BRANCH_MANIFEST || $CI_PIPELINE_SOURCE == "api"
needs: [] needs: []
tags: tags:
- infrastructure - infrastructure
...@@ -151,7 +145,7 @@ build:echo: ...@@ -151,7 +145,7 @@ build:echo:
build:merge_request: build:merge_request:
stage: build stage: build
rules: rules:
- if: $CI_COMMIT_REF_NAME == $MASTER_BRANCH && $CI_PIPELINE_SOURCE != "api" - if: $CI_COMMIT_REF_NAME == $MASTER_BRANCH_MANIFEST && $CI_PIPELINE_SOURCE != "api"
needs: [] needs: []
tags: tags:
- infrastructure - infrastructure
...@@ -168,7 +162,7 @@ build:merge_request: ...@@ -168,7 +162,7 @@ build:merge_request:
--token=${GITBOT_TOKEN} --token=${GITBOT_TOKEN}
--project=${CI_PROJECT_PATH} --project=${CI_PROJECT_PATH}
--commit=${CI_COMMIT_SHA} --commit=${CI_COMMIT_SHA}
--ref=^${MASTER_BRANCH} || true | head -1) --ref=^${MASTER_BRANCH_MANIFEST} || true | head -1)
# If pipeline exists, mirror its result # If pipeline exists, mirror its result
- if [ ! -z "${MR_PIPELINE}" ]; then - if [ ! -z "${MR_PIPELINE}" ]; then
.gitlab-ci/mirror_pipeline_result.py .gitlab-ci/mirror_pipeline_result.py
...@@ -182,7 +176,7 @@ build:merge_request: ...@@ -182,7 +176,7 @@ build:merge_request:
--gitlab-url=${CI_SERVER_URL} --gitlab-url=${CI_SERVER_URL}
--token=${GITBOT_TOKEN} --token=${GITBOT_TOKEN}
--project=${CI_PROJECT_PATH} --project=${CI_PROJECT_PATH}
--ref=${MASTER_BRANCH} --ref=${MASTER_BRANCH_MANIFEST}
- fi - fi
...@@ -192,7 +186,7 @@ build:merge_request: ...@@ -192,7 +186,7 @@ build:merge_request:
.test: .test:
stage: test stage: test
rules: rules:
- if: $CI_COMMIT_REF_NAME != $MASTER_BRANCH || $CI_PIPELINE_SOURCE == "api" - if: $CI_COMMIT_REF_NAME != $MASTER_BRANCH_MANIFEST || $CI_PIPELINE_SOURCE == "api"
when: manual when: manual
allow_failure: true allow_failure: true
tags: tags:
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
# Global # Global
# --------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------
include: include:
- local: manifest-build.yml
- local: common.yml - local: common.yml
stages: stages:
...@@ -44,16 +43,6 @@ workflow: ...@@ -44,16 +43,6 @@ workflow:
- if: $CI_PROJECT_ROOT_NAMESPACE == "SECO-Northern-Europe" - if: $CI_PROJECT_ROOT_NAMESPACE == "SECO-Northern-Europe"
&& $CI_MERGE_REQUEST_SOURCE_PROJECT_ID == $CI_MERGE_REQUEST_PROJECT_ID && $CI_MERGE_REQUEST_SOURCE_PROJECT_ID == $CI_MERGE_REQUEST_PROJECT_ID
# ---------------------------------------------------------------------------------------
# Stage: prepare
# ---------------------------------------------------------------------------------------
yamllint:
extends: .infrastructure
rules:
- if: $CI_COMMIT_REF_NAME != $MASTER_BRANCH_MANIFEST
script:
- yamllint -c .gitlab-ci/.yamllint.yml .*.yml
# --------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------
# integrate # integrate
# Create a commit in the manifest to pull this change # Create a commit in the manifest to pull this change
...@@ -85,14 +74,13 @@ integrate: ...@@ -85,14 +74,13 @@ integrate:
--merge-request=${MERGE_REQUEST} --merge-request=${MERGE_REQUEST}
--save-revision-to=manifest_revision --save-revision-to=manifest_revision
--recipe-name=${BB_RECIPE_NAME} --recipe-name=${BB_RECIPE_NAME}
--verbose
artifacts: artifacts:
paths: paths:
- manifest_revision - manifest_revision
# --------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------
# Stage: merge # Stage: merge
# --------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------
merge: merge:
extends: .infrastructure extends: .infrastructure
stage: merge stage: merge
...@@ -114,9 +102,9 @@ merge: ...@@ -114,9 +102,9 @@ merge:
paths: paths:
- manifest_revision - manifest_revision
# --------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------
# Stage: build # Stage: build
# --------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------
build: build:
stage: build stage: build
rules: rules:
...@@ -129,35 +117,8 @@ build: ...@@ -129,35 +117,8 @@ build:
branch: "integrate/${CI_PROJECT_NAME}/${CI_COMMIT_REF_NAME}" branch: "integrate/${CI_PROJECT_NAME}/${CI_COMMIT_REF_NAME}"
strategy: depend strategy: depend
# --------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------
# Stage: check # Stage: check
# --------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------
check: check:
extends: .infrastructure extends: .check
rules:
- if: $CI_MERGE_REQUEST_IID
# Explicitly allow externally triggered pipelines in every case
- if: $CI_PIPELINE_SOURCE == "pipeline" || $CI_PIPELINE_SOURCE == "api"
needs: ["integrate"]
script:
- cd ${CI_PROJECT_DIR}
- if [ -n "${CI_MERGE_REQUEST_IID}" ];then
MERGE_REQUEST="${CI_MERGE_REQUEST_IID}";
else
MERGE_REQUEST="${CI_OPEN_MERGE_REQUESTS%%,*}";
fi
- if [ -n "${parent_merge_request}" ];then
PARENT_MR="--parent-merge-request=${parent_merge_request}";
fi
- echo "${parent_merge_request}"
- echo "${PARENT_MR}"
- echo "${MERGE_REQUEST}"
- .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_MANIFEST}
--project=${CI_PROJECT_PATH}
--merge-request=${MERGE_REQUEST}
--verbose
${PARENT_MR}
---
# -------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------
# Global # Global
# -------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------
---
include: include:
- local: manifest-build.yml - local: manifest-build.yml
- local: common.yml - local: common.yml
stages: stages:
- retrigger - retrigger
- prepare - infrastructure
- build - build
- test - test
- deploy - deploy
...@@ -51,6 +51,10 @@ retrigger: ...@@ -51,6 +51,10 @@ retrigger:
--remote=seco-north --remote=seco-north
--concat-namespaces --concat-namespaces
) )
# Add the gitlab-ci project
- PROJECTS="$PROJECTS ${CI_PROJECT_ROOT_NAMESPACE}/yocto/infrastructure/gitlab-ci"
# TODO retrigger gitlab-ci integration also
# Retrigger also project in SRCREV
- echo -e "Projects:\n${PROJECTS}" - echo -e "Projects:\n${PROJECTS}"
- for PROJECT in ${PROJECTS}; do - for PROJECT in ${PROJECTS}; do
.gitlab-ci/retrigger_mr_pipeline_jobs.py .gitlab-ci/retrigger_mr_pipeline_jobs.py
...@@ -64,7 +68,7 @@ retrigger: ...@@ -64,7 +68,7 @@ retrigger:
done done
# -------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------
# Stage: prepare # Stage: infrastructure
# -------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------
changelog: changelog:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment