Skip to content
Snippets Groups Projects
Commit 9998c3dd authored by Lorenzo Pagliai's avatar Lorenzo Pagliai
Browse files

Include layers-integration.yml file

* The file is intended to contain all the automation tasks to be
executed by the projects used in the Yocto layers
* The steps are the main steps that this CI file contains:
  - Every time a MR is opened on a project an integration branch is opened
 on the layer which updates the SHA of the commit on the
'conf/SRCREV.conf' file referring to correct bb recipe
  - A MR is automatically opened on the layer master branch, that triggers all the
downstream job of the manifest-integration file, which is left untouched
  - A check job checks that the layer project branch is up-to-date with
the commit revision
  - Once the MR is accepted on the project, the one in the layer is
merged and closed by default after having tried a rebase.
* Minor bug fix on gitlab-ci.yml file
parent 236704a7
No related branches found
No related tags found
No related merge requests found
......@@ -92,7 +92,7 @@ executable:
--manifest-branch=${MANIFEST_BRANCH} \
--submodule=.gitlab-ci \
--revision=${CI_COMMIT_SHA} \
--group=${PROJECT_INTEGRATION} \
--group="${PROJECT_INTEGRATION}" \
--verbose \
${MERGE}
done
......
---
# --------------------------------------------------------------------------------------
# Global
# --------------------------------------------------------------------------------------
include:
- local: common.yml
stages:
- infrastructure
- integrate-into-layer
- create-merge
- check
- accept-merge
variables:
# The BB_RECIPE_NAME is used for projects referenced in the SRCREV file
# to match the repository and the bitbake recipe name.
# We set it here to none, as every project needing it
# has to specify it in its own gitlab-ci.yml file.
# The BB_RECIPE_NAME is passed to the python scripts below anyway, but not
# used for projects referenced in the manifest file.
# FIXME: This is only necessary due to the following GitLab limitation:
# https://gitlab.com/gitlab-org/gitlab/-/issues/209904
# As soon as this gets fixed upstream, the hard-coded branch name should be removed.
MANIFEST_PROJECT: yocto_ng/seco-manifest
MASTER_BRANCH_LAYER: kirkstone/develop
BB_RECIPE_NAME: none
SRCREV_FILE: conf/SRCREV.conf
DEPLOYPATH_TEST: "/artifacts/${CI_JOB_ID}/"
GITLAB_SERVER: "${CI_SERVER_HOST}:${CI_SERVER_SSH_PORT}"
GIT_BASE_URL: "ssh://git@${GITLAB_SERVER}/${CI_PROJECT_ROOT_NAMESPACE}"
TESTS_GIT_URL: "${GIT_BASE_URL}/yocto/tests.git"
# --------------------------------------------------------------------------------------
# Stage: infrastructure
# --------------------------------------------------------------------------------------
integrate-into-layer:
extends: .infrastructure
rules:
# Do not integration pipeline for merge requests for integrate/gitlab-ci/ branches
# The integration is done from the pipeline in gitlab-ci already
- if: $CI_COMMIT_REF_NAME =~ /^integrate\/gitlab-ci\/.*/
when: never
# 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
# Explicitly allow externally triggered pipelines in every case
- if: $CI_PIPELINE_SOURCE == "pipeline" || $CI_PIPELINE_SOURCE == "api"
cache:
policy: push
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
- .gitlab-ci/scripts/integrate_into_layer.py
--gitlab-url=${CI_SERVER_URL}
--token=${GITBOT_TOKEN}
--layer-project=${LAYER_PROJECT_PATH}
--layer-branch=${MASTER_BRANCH_LAYER}
--project=${CI_PROJECT_PATH}
--srcrev-file=${SRCREV_FILE}
--merge-request=${MERGE_REQUEST}
--save-revision-to=srcrev_revision
--recipe-name=${BB_RECIPE_NAME}
--verbose
artifacts:
paths:
- srcrev_revision
- integration_branch_file
# --------------------------------------------------------------------------------------
# Stage: create-merge-request
# --------------------------------------------------------------------------------------
create-merge-request:
stage: create-merge
extends: .infrastructure
rules:
# Do not integration pipeline for merge requests for integrate/gitlab-ci/ branches
# The integration is done from the pipeline in gitlab-ci already
- if: $CI_COMMIT_REF_NAME =~ /^integrate\/gitlab-ci\/.*/
when: never
# 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
- if: $CI_PIPELINE_SOURCE == "pipeline" || $CI_PIPELINE_SOURCE == "api"
cache:
policy: push
script:
- cd ${CI_PROJECT_DIR}
- INTEGRATION_BRANCH=$(cat integration_branch_file)
- .gitlab-ci/scripts/create_merge_request.py
--gitlab-url=${CI_SERVER_URL}
--token=${GITBOT_TOKEN}
--project=${LAYER_PROJECT_PATH}
--source-branch=${INTEGRATION_BRANCH}
--target-branch=${MASTER_BRANCH_LAYER}
needs:
- job: integrate-into-layer
artifacts: true
#yamllint:
# extends: .yamllint
# --------------------------------------------------------------------------------------
# Stage: check
# --------------------------------------------------------------------------------------
check:
extends: .infrastructure
stage: check
rules:
# Do not run check if the "skip build" label is set on the merge request
- if: $CI_MERGE_REQUEST_LABELS =~ /skip build/
when: never
# Do not integration pipeline for merge requests for integrate/gitlab-ci/ branches
# The integration is done from the pipeline in gitlab-ci already
- if: $CI_COMMIT_REF_NAME =~ /^integrate\/gitlab-ci\/.*/
when: never
- if: $CI_MERGE_REQUEST_IID
# Explicitly allow externally triggered pipelines in every case
- if: $CI_PIPELINE_SOURCE == "pipeline" || $CI_PIPELINE_SOURCE == "api"
needs: ["integrate-into-layer"]
allow_failure: true
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
- while read -r integration; do
SOURCE_BRANCH=$(echo $integration | cut -d':' -f1);
TARGET_PROJECT=${LAYER_PROJECT_PATH};
TARGET_BRANCH=$(echo $integration | cut -d':' -f3);
if [[ "$SOURCE_BRANCH" == "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" ]]; then
.gitlab-ci/scripts/check_if_layer_branch_is_up_to_date.py
--gitlab-url=${CI_SERVER_URL}
--token=${GITBOT_TOKEN}
--target-project=${TARGET_PROJECT}
--target-branch=${TARGET_BRANCH}
--source-project=${CI_PROJECT_PATH}
--recipe-name=${BB_RECIPE_NAME}
--merge-request=${CI_MERGE_REQUEST_IID}
;
fi;
done <<< "$INTEGRATION"
merge-into-layer:
extends: .infrastructure
stage: accept-merge
timeout: 4h
rules:
# Do not integration pipeline for merge requests for integrate/gitlab-ci/ branches
# The integration is done from the pipeline in gitlab-ci already
- if: $CI_COMMIT_REF_NAME =~ /^integrate\/gitlab-ci\/.*/
when: never
- if: $CI_COMMIT_BRANCH == $MASTER_BRANCH
when: always
script:
- cd ${CI_PROJECT_DIR}
- echo ${CI_COMMIT_REF_NAME}
- .gitlab-ci/scripts/accept_layer_merge_request.py
--gitlab-url=${CI_SERVER_URL}
--token=${GITBOT_TOKEN}
--project=${CI_PROJECT_PATH}
--layer-project=${LAYER_PROJECT_PATH}
--target-branch=${MASTER_BRANCH}
--layer-target-branch=${MASTER_BRANCH_LAYER}
--recipe-name=${BB_RECIPE_NAME}
--rebase
\ No newline at end of file
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