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

CI: Add common gitlab-ci file for all yocto repositories.

Create a merged version of the gitlab-ci files from the layers and the
repositoried referenced by the SRCREV file to be included in the
projects, to replace the project-individual implementation.

BCS 746-000646
parent 369e59b3
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.
---
# ---------------------------------------------------------------------------------------
# Global
# ---------------------------------------------------------------------------------------
image: "${CI_IMAGES}/python/3.9:99e363bc5feaa27ff18dbe7731a76ff04d7d0deb"
stages:
- prepare
- integrate
- merge
- build
- check
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/manifest
MASTER_BRANCH_MANIFEST: dunfell
MASTER_BRANCH_PROJECT: dunfell
# 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.
BB_RECIPE_NAME: none
# Reduced depth as checkout of larger projects (like the kernel)
# may take too long
GIT_DEPTH: 5
workflow:
rules:
# Do not run pipelines on forked projects.
# The pipelines would not work anyway because of the users permissions.
# There are two cases catched here:
# 1. The project is forked into someones gitlab namespace and a MR to
# include a change into this forked project is created. In this case
# is the CI_PROJECT_ROOT_NAMESPACE not SECO-Northern-Europe but the
# namespace the fork lives in.
# 2. The MR from the forked project is created to merge the change into this
# the project in the SECO-Northern-Europe namespace (customer sending
# change to us). Here the the IDs used below differ.
#
- 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: 5m
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_MANIFEST}
--project=${CI_PROJECT_PATH}
--merge-request=${CI_MERGE_REQUEST_IID}
--save-revision-to=manifest_revision
--recipe-name=${BB_RECIPE_NAME}
artifacts:
paths:
- manifest_revision
# ---------------------------------------------------------------------------------------
# Stage: merge
# ---------------------------------------------------------------------------------------
merge:
stage: merge
rules:
- if: $CI_COMMIT_BRANCH == $MASTER_BRANCH_PROJECT
tags:
- infrastructure
timeout: 5m
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_MANIFEST}
--project=${CI_PROJECT_PATH}
--master-branch-project=${MASTER_BRANCH_PROJECT}
--commit=${CI_COMMIT_SHA}
--save-revision-to=manifest_revision
--recipe-name=${BB_RECIPE_NAME}
artifacts:
paths:
- manifest_revision
# ---------------------------------------------------------------------------------------
# Stage: build
# ---------------------------------------------------------------------------------------
build:
stage: build
rules:
- if: $CI_MERGE_REQUEST_IID
trigger:
project: SECO-Northern-Europe/yocto/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: 5m
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_MANIFEST}
--project=${CI_PROJECT_PATH}
--merge-request=${CI_MERGE_REQUEST_IID}
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