From 59ce0ad8b62eeb76fca30e4ff9a547df88227830 Mon Sep 17 00:00:00 2001 From: Tim Jaacks <tim.jaacks@garz-fricke.com> Date: Tue, 2 Aug 2022 17:51:15 +0200 Subject: [PATCH] Remove hard coded project and branch variables MANIFEST_PROJECT, MASTER_BRANCH_MANIFEST, MASTER_BRANCH_PROJECT --- build-common.yml | 2 +- build-jobs-yocto.jinja2 | 4 ++-- common.yml | 2 +- docs/automatic-manifest-integration.md | 1 - manifest-integration-ci-test.yml | 15 --------------- manifest-integration-jobs.yml.jinja2 | 20 ++++++++++---------- manifest-integration-pipelines.yml.jinja2 | 6 +++--- manifest-integration-yocto.yml | 15 --------------- manifest-pipeline-ci-test.yml | 3 +-- manifest-pipeline.yml | 10 +++++----- scripts/deploy_gitlab_ci.py | 7 +------ 11 files changed, 24 insertions(+), 61 deletions(-) delete mode 100644 manifest-integration-ci-test.yml delete mode 100644 manifest-integration-yocto.yml diff --git a/build-common.yml b/build-common.yml index 4737f29e..c3b1225e 100644 --- a/build-common.yml +++ b/build-common.yml @@ -84,7 +84,7 @@ workflow: 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" - TEST_REPO_BRANCH: ${MASTER_BRANCH_MANIFEST} + TEST_REPO_BRANCH: ${MASTER_BRANCH} artifacts: when: always paths: diff --git a/build-jobs-yocto.jinja2 b/build-jobs-yocto.jinja2 index c6e8cc34..42295ef0 100644 --- a/build-jobs-yocto.jinja2 +++ b/build-jobs-yocto.jinja2 @@ -21,7 +21,7 @@ stages: - uploadftp variables: - MASTER_BRANCH_MANIFEST: {{ MASTER_BRANCH_MANIFEST }} + MASTER_BRANCH: {{ MASTER_BRANCH }} # -------------------------------------------------------------------------------------- # Stage: infrastructure @@ -30,7 +30,7 @@ changelog: extends: .infrastructure script: .gitlab-ci/scripts/changelog_generator.py --token=${GITBOT_TOKEN} - --branch=${MASTER_BRANCH_MANIFEST} + --branch=${MASTER_BRANCH} > changelog.md artifacts: expire_in: 4 weeks diff --git a/common.yml b/common.yml index 61a01f0a..0d3f2fef 100644 --- a/common.yml +++ b/common.yml @@ -36,7 +36,7 @@ variables: - if: $CI_PIPELINE_SOURCE == "parent_pipeline" when: never # Usually run this job only on non-master branches, i.e. in merge requests - - if: $CI_COMMIT_REF_NAME != $MASTER_BRANCH_MANIFEST + - if: $CI_COMMIT_REF_NAME != $MASTER_BRANCH # Additionally run this job if pipeline was triggered by the API, which happens e.g. # when no pipeline has run in a merge request, so a full build pipeline is needed on # the master diff --git a/docs/automatic-manifest-integration.md b/docs/automatic-manifest-integration.md index 038128af..c018c631 100644 --- a/docs/automatic-manifest-integration.md +++ b/docs/automatic-manifest-integration.md @@ -188,7 +188,6 @@ the git revision in the `SRCREV.conf` file on project changes. 2. Add an approriate `.gitlab-ci.yml` file. For example, copy it from the repository [egalxi2c][8]. Modify the following variables in the file: - * `MASTER_BRANCH_PROJECT`: Set the project master branch * `BB_RECIPE_NAME`: Set the name of the bitbake recipe 3. Create a corresponding entry in the `SRCREV.conf` file of the manifest repo:\ diff --git a/manifest-integration-ci-test.yml b/manifest-integration-ci-test.yml deleted file mode 100644 index 63e0764f..00000000 --- a/manifest-integration-ci-test.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -include: - - local: manifest-integration.yml - -variables: - # FIXME: This variable is used in the manifest-integration's build stage for the - # trigger project. Due to a missing feature in GitLab, we cannot use any variables - # here and have to hard-code 'seco-ne' instead of using CI_PROJECT_ROOT_NAMESPACE. - # (https://gitlab.com/gitlab-org/gitlab/-/issues/249583) - MANIFEST_PROJECT: seco-ne/yocto/infrastructure/ci-test/minimal-manifest - - # 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_MANIFEST: master - MASTER_BRANCH_PROJECT: master diff --git a/manifest-integration-jobs.yml.jinja2 b/manifest-integration-jobs.yml.jinja2 index 7f7253d8..19eb22d7 100644 --- a/manifest-integration-jobs.yml.jinja2 +++ b/manifest-integration-jobs.yml.jinja2 @@ -40,9 +40,9 @@ integrate: - .gitlab-ci/scripts/integrate_into_manifest.py --gitlab-url=${CI_SERVER_URL} --token=${GITBOT_TOKEN} - --manifest-project=${MANIFEST_PROJECT} + --manifest-project=${TARGET_PROJECT} --manifest-file=${MANIFEST_FILE} - --integration-base=${MASTER_BRANCH_MANIFEST} + --integration-base=${TARGET_BRANCH} --project=${CI_PROJECT_PATH} --merge-request=${MERGE_REQUEST} --save-revision-to=manifest_revision @@ -61,16 +61,16 @@ merge: extends: .infrastructure stage: merge rules: - - if: $CI_COMMIT_BRANCH == $MASTER_BRANCH_PROJECT + - if: $CI_COMMIT_BRANCH == $SOURCE_BRANCH script: - cd ${CI_PROJECT_DIR} - .gitlab-ci/scripts/merge_into_manifest.py --gitlab-url=${CI_SERVER_URL} --token=${GITBOT_TOKEN} - --manifest-project=${MANIFEST_PROJECT} - --master-branch=${MASTER_BRANCH_MANIFEST} + --manifest-project=${TARGET_PROJECT} + --master-branch=${TARGET_BRANCH} --project=${CI_PROJECT_PATH} - --master-branch-project=${MASTER_BRANCH_PROJECT} + --master-branch-project=${SOURCE_BRANCH} --commit=${CI_COMMIT_SHA} --save-revision-to=manifest_revision --recipe-name=${BB_RECIPE_NAME} @@ -90,9 +90,9 @@ build: - if: $CI_MERGE_REQUEST_IID trigger: # FIXME: see FIXME comments in manifest-integration-pipelines.yml.jinja2 - # project: $MANIFEST_PROJECT + # project: $TARGET_PROJECT project: {{ TARGET_PROJECT }} - branch: "integrate/${CI_PROJECT_NAME}/${CI_COMMIT_REF_NAME}/into/${MASTER_BRANCH_MANIFEST}" + branch: "integrate/${CI_PROJECT_NAME}/${CI_COMMIT_REF_NAME}/into/${TARGET_BRANCH}" strategy: depend # -------------------------------------------------------------------------------------- @@ -128,8 +128,8 @@ check: - .gitlab-ci/scripts/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} + --manifest-project=${TARGET_PROJECT} + --integration-base=${TARGET_BRANCH} --project=${CI_PROJECT_PATH} --merge-request=${MERGE_REQUEST} --verbose diff --git a/manifest-integration-pipelines.yml.jinja2 b/manifest-integration-pipelines.yml.jinja2 index 6f8406dc..dab38b55 100644 --- a/manifest-integration-pipelines.yml.jinja2 +++ b/manifest-integration-pipelines.yml.jinja2 @@ -56,9 +56,9 @@ generate: needs: - generate variables: - MASTER_BRANCH_PROJECT: {{ SOURCE_BRANCH }} - MANIFEST_PROJECT: {{ TARGET_PROJECT }} - MASTER_BRANCH_MANIFEST: {{ TARGET_BRANCH }} + SOURCE_BRANCH: {{ SOURCE_BRANCH }} + TARGET_PROJECT: {{ TARGET_PROJECT }} + TARGET_BRANCH: {{ TARGET_BRANCH }} GITLAB_CI_REVISION: {{ GITLAB_CI_REVISION }} MANIFEST_FILE: {{ MANIFEST_FILE }} BB_RECIPE_NAME: {{ BB_RECIPE_NAME }} diff --git a/manifest-integration-yocto.yml b/manifest-integration-yocto.yml deleted file mode 100644 index e094eb75..00000000 --- a/manifest-integration-yocto.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -include: - - local: manifest-integration.yml - -variables: - # FIXME: This variable is used in the manifest-integration's build stage for the - # trigger project. Due to a missing feature in GitLab, we cannot use any variables - # here and have to hard-code 'seco-ne' instead of using CI_PROJECT_ROOT_NAMESPACE. - # (https://gitlab.com/gitlab-org/gitlab/-/issues/249583) - MANIFEST_PROJECT: seco-ne/yocto/manifest - - # 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_MANIFEST: dunfell - MASTER_BRANCH_PROJECT: dunfell diff --git a/manifest-pipeline-ci-test.yml b/manifest-pipeline-ci-test.yml index c5b9f7d6..9ecd5a27 100644 --- a/manifest-pipeline-ci-test.yml +++ b/manifest-pipeline-ci-test.yml @@ -20,5 +20,4 @@ variables: # 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_MANIFEST: master - MASTER_BRANCH_PROJECT: master + MASTER_BRANCH: master diff --git a/manifest-pipeline.yml b/manifest-pipeline.yml index 05dcf812..77877579 100644 --- a/manifest-pipeline.yml +++ b/manifest-pipeline.yml @@ -33,7 +33,7 @@ workflow: rules: # Run the full build pipeline on non-master branches (i.e. in the merge request) # or if explicitly triggered by the API or the web button. - - if: $CI_COMMIT_REF_NAME != $MASTER_BRANCH_MANIFEST + - if: $CI_COMMIT_REF_NAME != $MASTER_BRANCH - if: $CI_PIPELINE_SOURCE == "api" - if: $CI_PIPELINE_SOURCE == "pipeline" - if: $CI_PIPELINE_SOURCE == "web" @@ -49,7 +49,7 @@ workflow: when: never - if: $CI_PIPELINE_SOURCE == "web" when: never - - if: $CI_COMMIT_REF_NAME == $MASTER_BRANCH_MANIFEST + - if: $CI_COMMIT_REF_NAME == $MASTER_BRANCH # -------------------------------------------------------------------------------------- # Stage: retrigger @@ -77,7 +77,7 @@ retrigger: --token=${GITBOT_TOKEN} --project=${PROJECT} --state=opened - --target-branch=${MASTER_BRANCH_MANIFEST} + --target-branch=${MASTER_BRANCH} --job=check ; done @@ -137,7 +137,7 @@ build:merge_request: --token=${GITBOT_TOKEN} --project=${CI_PROJECT_PATH} --commit=${CI_COMMIT_SHA} - --ref=^${MASTER_BRANCH_MANIFEST} || true | head -1) + --ref=^${MASTER_BRANCH} || true | head -1) # If pipeline exists, mirror its result - if [ ! -z "${MR_PIPELINE}" ]; then .gitlab-ci/scripts/mirror_pipeline_result.py @@ -151,5 +151,5 @@ build:merge_request: --gitlab-url=${CI_SERVER_URL} --token=${GITBOT_TOKEN} --project=${CI_PROJECT_PATH} - --ref=${MASTER_BRANCH_MANIFEST} + --ref=${MASTER_BRANCH} - fi diff --git a/scripts/deploy_gitlab_ci.py b/scripts/deploy_gitlab_ci.py index a24b45ae..b05e7707 100755 --- a/scripts/deploy_gitlab_ci.py +++ b/scripts/deploy_gitlab_ci.py @@ -26,17 +26,12 @@ def read_keys_from_gitlab_ci_yml(gitlab_ci_yml): data = yaml.load(gitlab_ci_yml) logging.debug("Yaml: %s", data) - try: - masterbranch = data["variables"]["MASTER_BRANCH_PROJECT"] - logging.debug("Masterbranch %s", masterbranch) - except KeyError: - masterbranch = None try: recipe = data["variables"]["BB_RECIPE_NAME"] logging.debug("Recipe %s", recipe) except KeyError: recipe = None - return {"recipe": recipe, "masterbranch": masterbranch} + return {"recipe": recipe} def integrate_submodule_into( -- GitLab