From 778c83017fbf656f4bc85b64ca4ff6720cd9ef44 Mon Sep 17 00:00:00 2001 From: Zygmunt Krynicki <zygmunt.krynicki@huawei.com> Date: Thu, 8 Apr 2021 16:03:10 +0000 Subject: [PATCH] gitlab-ci.yml: use new jobs from the manifest repo The .workspace and .build-docs allow simplification of the two similar jobs present into this repository. The .workspace job completely replaces the local copy, with a single configuration variable to enable testing of incoming changes. The build job becomes build-docs and extends both the .workspace job and the .build-docs job, reusing both the scripts to perform everything that was formerly specified explicitly. The deploy job now extends the .workspace job but is otherwise unchanged. Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@huawei.com> --- .gitlab-ci.yml | 62 +++++++++++++++++++------------------------------- 1 file changed, 24 insertions(+), 38 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3cc1248..17b127c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,6 +12,8 @@ include: file: - 'dco.yaml' - 'reuse.yaml' + - project: 'OSTC/OHOS/manifest' + file: '.ostc-ci/build-generic.yaml' dco: extends: .dco @@ -24,52 +26,36 @@ reuse: rules: - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' -.doc-workspace: - image: - name: registry.ostc-eu.org/ostc/containers/ostc-docs-builder - tags: [large-disk] +# Customize the .workspace job to set the path of the git repository to deviate +# from what the git-repo manifest prepares. This effectively allows testing +# incoming changes that match the repository holding this CI pipeline. +.workspace: variables: - OHOS_MANIFEST_URL: https://git.ostc-eu.org/OSTC/OHOS/manifest - OHOS_MANIFEST_BRANCH: develop - OHOS_MANIFEST_NAME: default.xml OHOS_GIT_REPO_PATH: docs - before_script: &doc-workspace-before - - test ! -e "$CI_PROJECT_DIR"/.scratch-dir-name || ( - echo "precondition failed - concurrent modification of $CI_PROJECT_DIR" - && env | grep CI_ | sort - && ls -l - && exit 1 ) - - SCRATCH_DIR="$(mktemp -p /tmp -d workspace.XXXXXXXXXX)" - - echo "$SCRATCH_DIR" > "$CI_PROJECT_DIR"/.scratch-dir-name - - cd "$SCRATCH_DIR" - - repo init --reference - /var/shared/pub/git-repo-mirrors/ostc-develop - --manifest-url "$OHOS_MANIFEST_URL" - --manifest-name "$OHOS_MANIFEST_NAME" - --manifest-branch "$OHOS_MANIFEST_BRANCH" - - time repo sync --no-clone-bundle - - ( cd "$SCRATCH_DIR"/"$OHOS_GIT_REPO_PATH" && git checkout "$CI_COMMIT_SHA" ) - script: &doc-workspace-do - - SCRATCH_DIR="$(cat "$CI_PROJECT_DIR"/.scratch-dir-name)" - - cd "$SCRATCH_DIR"/docs -build: - extends: .doc-workspace - stage: build - script: - - *doc-workspace-do - - make BUILD_DIR="$CI_PROJECT_DIR/build" - artifacts: - paths: - - build +# Disable all the bitbake jobs, since we are not building any code here. +.bitbake-workspace: rules: - - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' + - when: never + +# Define a build-docs job that extends both the .workspace, for the general +# workspace setup, and .build-docs, for the documentation build logic. The +# script first assembles the workspace and then proceeds to build the +# documentation. +# +# The job extends more than one parent, with the order being relevant for, +# among others, the "rules" section. +build-docs: + extends: [.workspace, .build-docs] + script: + - !reference [.workspace, script] + - !reference [.build-docs, script] deploy: - extends: .doc-workspace + extends: .workspace stage: deploy script: - - *doc-workspace-do + - !reference [.workspace, script] - git clone https://user:$OHOS_AGGREGATED_DOCS_TOKEN@git.ostc-eu.org/OSTC/infrastructure/openharmony-readthedocs-aggregated.git - cd openharmony-readthedocs-aggregated - git checkout origin/main # only main for now - needs to match the rules -- GitLab