From 26bd3edfe3ba62745cb5484422b366cccd609aab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20H=C3=B6ppner?= <jonas.hoeppner@garz-fricke.com> Date: Tue, 22 Mar 2022 13:25:38 +0100 Subject: [PATCH] CI: Add common.yml containing common code for manifest and integration. --- common.yml | 45 +++++++++++++++++++++++++++++++ manifest-integration.yml | 34 +++-------------------- manifest.yml | 58 ++++++++++------------------------------ 3 files changed, 63 insertions(+), 74 deletions(-) create mode 100644 common.yml diff --git a/common.yml b/common.yml new file mode 100644 index 0000000..f2f01ae --- /dev/null +++ b/common.yml @@ -0,0 +1,45 @@ +# -------------------------------------------------------------------------------------- +# Common definitions that may be used in all subprojects +# -------------------------------------------------------------------------------------- +--- +variables: + # CI_IMAGES_BASEPATH: Environment variable configure in gitlab + CI_IMAGES_PATH: ${CI_IMAGES_BASEPATH}/ci-images + CI_IMAGES_REV: 44965ccdd847f1e077670f49d546047f8ad0110c + 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}" + # Include git submodules + GIT_SUBMODULE_STRATEGY: recursive + # Reduced depth as checkout of larger projects (like the kernel) + # may take too long + GIT_DEPTH: 1 + # 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 + + +# -------------------------------------------------------------------------------------- +# Common infrastructure settings +# -------------------------------------------------------------------------------------- +.infrastructure: + stage: infrastructure + tags: + - infrastructure + timeout: 5m + image: "${CI_IMAGE_PYTHON}" + needs: [] + variables: + # Include git submodules + GIT_SUBMODULE_STRATEGY: recursive + +yamllint: + extends: .infrastructure + rules: + - if: $CI_COMMIT_REF_NAME != $MASTER_BRANCH_MANIFEST || $CI_PIPELINE_SOURCE == "api" + script: + - yamllint -c .gitlab-ci/.yamllint.yml .*.yml diff --git a/manifest-integration.yml b/manifest-integration.yml index 12d4223..f834401 100644 --- a/manifest-integration.yml +++ b/manifest-integration.yml @@ -2,7 +2,9 @@ # --------------------------------------------------------------------------------------- # Global # --------------------------------------------------------------------------------------- -image: "${CI_IMAGES}/python/3.9:99e363bc5feaa27ff18dbe7731a76ff04d7d0deb" +include: + - local: manifest-build.yml + - local: common.yml stages: - infrastructure @@ -12,17 +14,6 @@ stages: - 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 @@ -30,9 +21,6 @@ variables: # 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: @@ -56,27 +44,13 @@ workflow: - if: $CI_PROJECT_ROOT_NAMESPACE == "SECO-Northern-Europe" && $CI_MERGE_REQUEST_SOURCE_PROJECT_ID == $CI_MERGE_REQUEST_PROJECT_ID -# -------------------------------------------------------------------------------------- -# Common infrastructure settings -# -------------------------------------------------------------------------------------- -.infrastructure: - stage: infrastructure - tags: - - infrastructure - timeout: 5m - image: "${CI_IMAGE_PYTHON}" - needs: [] - variables: - # Include git submodules - GIT_SUBMODULE_STRATEGY: recursive - # --------------------------------------------------------------------------------------- # Stage: prepare # --------------------------------------------------------------------------------------- yamllint: extends: .infrastructure rules: - - if: $CI_COMMIT_REF_NAME != $MASTER_BRANCH + - if: $CI_COMMIT_REF_NAME != $MASTER_BRANCH_MANIFEST script: - yamllint -c .gitlab-ci/.yamllint.yml .*.yml diff --git a/manifest.yml b/manifest.yml index 59ec32b..31ceb8c 100644 --- a/manifest.yml +++ b/manifest.yml @@ -4,6 +4,7 @@ --- include: - local: manifest-build.yml + - local: common.yml stages: - retrigger @@ -14,15 +15,6 @@ stages: - uploadftp variables: - # CI_IMAGES_BASEPATH: Environment variable configure in gitlab - CI_IMAGES_PATH: ${CI_IMAGES_BASEPATH}/ci-images - CI_IMAGES_REV: 44965ccdd847f1e077670f49d546047f8ad0110c - 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. Has to be modified for new branches, e.g. new Yocto - # versions or fix releases. - MASTER_BRANCH: dunfell # Default image and distro CI_PARAM_IMAGE: guf-image CI_PARAM_DISTRO: guf-wayland @@ -44,19 +36,6 @@ workflow: # In all other cases, run the pipeline automatically - when: always -# -------------------------------------------------------------------------------------- -# Common infrastructure settings -# -------------------------------------------------------------------------------------- -.infrastructure: - tags: - - infrastructure - timeout: 10m - image: "${CI_IMAGE_PYTHON}" - needs: [] - variables: - # Include git submodules - GIT_SUBMODULE_STRATEGY: recursive - # -------------------------------------------------------------------------------------- # Stage: retrigger # -------------------------------------------------------------------------------------- @@ -64,7 +43,7 @@ retrigger: extends: .infrastructure stage: retrigger rules: - - if: $CI_COMMIT_REF_NAME == $MASTER_BRANCH && $CI_PIPELINE_SOURCE != "api" + - if: $CI_COMMIT_REF_NAME == $MASTER_BRANCH_MANIFEST && $CI_PIPELINE_SOURCE != "api" script: - PROJECTS=$( .gitlab-ci/get_manifest_projects.py @@ -79,7 +58,7 @@ retrigger: --token=${GITBOT_TOKEN} --project=${PROJECT} --state=opened - --target-branch=${MASTER_BRANCH} + --target-branch=${MASTER_BRANCH_MANIFEST} --job=check ; done @@ -87,20 +66,11 @@ retrigger: # -------------------------------------------------------------------------------------- # Stage: prepare # -------------------------------------------------------------------------------------- -yamllint: - extends: .infrastructure - stage: prepare - rules: - - if: $CI_COMMIT_REF_NAME != $MASTER_BRANCH || $CI_PIPELINE_SOURCE == "api" - script: - - yamllint .*.yml changelog: - stage: prepare + extends: .infrastructure rules: - - if: $CI_COMMIT_REF_NAME != $MASTER_BRANCH || $CI_PIPELINE_SOURCE == "api" - tags: - - infrastructure + - if: $CI_COMMIT_REF_NAME != $MASTER_BRANCH_MANIFEST || $CI_PIPELINE_SOURCE == "api" variables: IMAGE_PATH: ${CI_IMAGES_BASEPATH}/changelog-generator IMAGE_REVISION: 2fd56690a5dabde6eda101182e8359f1c3609664 @@ -108,7 +78,7 @@ changelog: name: "${IMAGE_PATH}:${IMAGE_REVISION}" # set entrypoint to noop to be able to run from script entrypoint: [""] - script: "changelog_generator.py --branch ${MASTER_BRANCH} > changelog.md" + script: "changelog_generator.py --branch ${MASTER_BRANCH_MANIFEST} > changelog.md" artifacts: expire_in: 4 weeks paths: @@ -141,7 +111,7 @@ changelog: - .buildbase - .build 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: [] .buildfng: @@ -156,7 +126,7 @@ build:merge_request: stage: build timeout: 1h rules: - - if: $CI_COMMIT_REF_NAME == $MASTER_BRANCH && $CI_PIPELINE_SOURCE != "api" + - if: $CI_COMMIT_REF_NAME == $MASTER_BRANCH_MANIFEST && $CI_PIPELINE_SOURCE != "api" script: - cd ${CI_PROJECT_DIR} # Get pipeline for merge request @@ -165,7 +135,7 @@ build:merge_request: --token=${GITBOT_TOKEN} --project=${CI_PROJECT_PATH} --commit=${CI_COMMIT_SHA} - --ref=^${MASTER_BRANCH} || true | head -1) + --ref=^${MASTER_BRANCH_MANIFEST} || true | head -1) # If pipeline exists, mirror its result - if [ ! -z "${MR_PIPELINE}" ]; then .gitlab-ci/mirror_pipeline_result.py @@ -179,7 +149,7 @@ build:merge_request: --gitlab-url=${CI_SERVER_URL} --token=${GITBOT_TOKEN} --project=${CI_PROJECT_PATH} - --ref=${MASTER_BRANCH} + --ref=${MASTER_BRANCH_MANIFEST} - fi .buildsdk: @@ -188,7 +158,7 @@ build:merge_request: - .package stage: build 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 allow_failure: true variables: @@ -209,7 +179,7 @@ build:merge_request: - .prepare_test timeout: 1h 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 allow_failure: true variables: @@ -238,7 +208,7 @@ build:merge_request: "Gitlab build test ${CI_PARAM_MACHINE} ${RELEASE} ${CI_PIPELINE_ID}" \ --results-path "results" \ --test-repo ${TESTS_GIT_URL} \ - --test-repo-branch ${MASTER_BRANCH} \ + --test-repo-branch ${MASTER_BRANCH_MANIFEST} \ --test-plan ${CI_PARAM_TEST_SUITE} \ ${CI_PARAM_EXTRA} \ ${CI_PARAM_PLATFORMS} @@ -251,7 +221,7 @@ build:merge_request: - .infrastructure - .package 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 allow_failure: true script: -- GitLab