Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
---
# ---------------------------------------------------------------------------------------
# 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:
# Explicitly allow externally triggered pipelines in every case
- if: $CI_PIPELINE_SOURCE == "pipeline" || $CI_PIPELINE_SOURCE == "api"
# Do not run pipelines for merge requests for integrate/gitlab-ci/ branches
# These are trigger explicitly from the integration pipeline in gitlab-ci repo
- if: $CI_COMMIT_REF_NAME =~ /^integrate\/gitlab-ci\/.*/
when: never
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# 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
# Explicitly allow externally triggered pipelines in every case
- if: $CI_PIPELINE_SOURCE == "pipeline" || $CI_PIPELINE_SOURCE == "api"
tags:
- infrastructure
timeout: 5m
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/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=${MERGE_REQUEST}
--save-revision-to=manifest_revision
--recipe-name=${BB_RECIPE_NAME}
--verbose
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
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:
# execute this in MR only and not for integrate/gitlab-ci/ integrations
# branches. These are build after the integration has been done in all
# projects
- if: $CI_MERGE_REQUEST_IID && $CI_COMMIT_REF_NAME !~ /^integrate\/gitlab-ci\/.*/
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
# Explicitly allow externally triggered pipelines in every case
- if: $CI_PIPELINE_SOURCE == "pipeline" || $CI_PIPELINE_SOURCE == "api"
needs: ["integrate"]
tags:
- infrastructure
timeout: 5m
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}