From 2d881aaa144efb621feb8f84d3347af1cbf5d133 Mon Sep 17 00:00:00 2001 From: Zygmunt Krynicki <zygmunt.krynicki@huawei.com> Date: Thu, 18 Mar 2021 14:21:35 +0100 Subject: [PATCH] Add experimental build pipeline This pipeline allows aggregation content from other repositories that participate in our development manifest, performs a local test build and if successful, exports the content into a new "aggregated docs" repository at https://git.ostc-eu.org/OSTC/infrastructure/openharmony-readthedocs-aggregated That repository is compatible with readthedocs build system and only needs a webhook to trigger automatic builds that show up on the correct readthedocs subdomain. The webhook needs to be set up separately by whoever owns the "openharmony" project on readthedocs. Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@huawei.com> --- .gitlab-ci.yml | 97 ++++++++++++++++++++++++++++ conf.py | 2 +- experimental/.rst-aggregator | 1 + experimental/.rst-aggregator.license | 2 + experimental/Makefile | 17 +++++ experimental/conf.py | 1 + experimental/index.rst | 12 ++++ experimental/readthedocs.yml | 1 + experimental/requirements.txt | 1 + requirements.txt | 3 +- 10 files changed, 135 insertions(+), 2 deletions(-) create mode 100644 .gitlab-ci.yml create mode 100644 experimental/.rst-aggregator create mode 100644 experimental/.rst-aggregator.license create mode 100644 experimental/Makefile create mode 120000 experimental/conf.py create mode 100644 experimental/index.rst create mode 120000 experimental/readthedocs.yml create mode 120000 experimental/requirements.txt diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..1be0705 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,97 @@ +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: Huawei Inc. + +stages: + - compliance + - test + - build + - deploy + +include: + - project: 'OSTC/infrastructure/pipelines' + file: + - 'dco.yaml' + - 'reuse.yaml' + +dco: + extends: .dco + rules: + - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' + +reuse: + extends: .reuse + allow_failure: true + rules: + - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' + +.doc-workspace: + image: + name: registry.ostc-eu.org/ostc/containers/ostc-docs-builder + tags: [large-disk] + variables: + OHOS_MANIFEST_URL: https://git.ostc-eu.org/OSTC/OHOS/manifest + OHOS_MANIFEST_BRANCH: develop + OHOS_MANIFEST_NAME: develop.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 + - test -d sources || ( + echo "assumption violated - expected the workspace to contain the sources directory" + && ls "$SCRATCH_DIR" + && exit 1 ) + - ( cd "$SCRATCH_DIR"/sources/"$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"/sources/docs + # Aggregate content from other places + - make -C experimental aggregate + +build: + extends: .doc-workspace + stage: build + script: + - *doc-workspace-do + - make -C experimental build + - mv experimental/build "$CI_PROJECT_DIR" + artifacts: + paths: + - build + rules: + - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' + +deploy: + extends: .doc-workspace + stage: deploy + script: + - *doc-workspace-do + - git clone https://user:$OHOS_AGGREGATED_DOCS_TOKEN@git.ostc-eu.org/OSTC/infrastructure/openharmony-readthedocs-aggregated.git + - cd openharmony-readthedocs-aggregated + - git checkout test # TODO: switch to main / master + - find . -name '*.rst' -delete || true + - tar -c --dereference -C ../experimental . | tar -x + # Clean up files we don't want in the aggregated view + - rm -f .rst-aggregator Makefile + # Commit and push back, if something changed. + - git config --local user.name "OpenHarmony Docs Build System" + - git config --local user.email "nobody@example.org" + - git add . + - | + if ! git status; then + git commit -sm "Automatic snapshot update"; + git push origin test; + fi + rules: + - if: '$CI_COMMIT_BRANCH == "master"' diff --git a/conf.py b/conf.py index 033c06d..347abeb 100644 --- a/conf.py +++ b/conf.py @@ -24,13 +24,13 @@ author = 'OSTC' # The full version, including alpha/beta/rc tags release = '1.0' - # -- General configuration --------------------------------------------------- # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ + 'recommonmark' ] # Add any paths that contain templates here, relative to this directory. diff --git a/experimental/.rst-aggregator b/experimental/.rst-aggregator new file mode 100644 index 0000000..70fe695 --- /dev/null +++ b/experimental/.rst-aggregator @@ -0,0 +1 @@ +meta-ohos-acts.md:../../meta-ohos/meta-ohos-acts/README.md diff --git a/experimental/.rst-aggregator.license b/experimental/.rst-aggregator.license new file mode 100644 index 0000000..4f5900b --- /dev/null +++ b/experimental/.rst-aggregator.license @@ -0,0 +1,2 @@ +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: Huawei Inc. diff --git a/experimental/Makefile b/experimental/Makefile new file mode 100644 index 0000000..827af93 --- /dev/null +++ b/experimental/Makefile @@ -0,0 +1,17 @@ +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: Huawei Inc. + +.PHONY: all +all: build + +.PHONY: clean +clean: + rm -rf build + +.PHONY: aggregate +aggregate: .rst-aggregator + rst-aggregator + +build: $(shell find -name *.rst) + rst-aggregator + sphinx-build -W . $@ diff --git a/experimental/conf.py b/experimental/conf.py new file mode 120000 index 0000000..d026d1f --- /dev/null +++ b/experimental/conf.py @@ -0,0 +1 @@ +../conf.py \ No newline at end of file diff --git a/experimental/index.rst b/experimental/index.rst new file mode 100644 index 0000000..1bfa0ea --- /dev/null +++ b/experimental/index.rst @@ -0,0 +1,12 @@ +.. SPDX-FileCopyrightText: Huawei Inc. +.. SPDX-License-Identifier: CC-BY-4.0 + +Welcome to OpenHarmony documentation +#################################### + +Reboot of the documentation system. + +.. toctree:: + :maxdepth: 1 + + meta-ohos-acts diff --git a/experimental/readthedocs.yml b/experimental/readthedocs.yml new file mode 120000 index 0000000..09c11f5 --- /dev/null +++ b/experimental/readthedocs.yml @@ -0,0 +1 @@ +../readthedocs.yml \ No newline at end of file diff --git a/experimental/requirements.txt b/experimental/requirements.txt new file mode 120000 index 0000000..dc833dd --- /dev/null +++ b/experimental/requirements.txt @@ -0,0 +1 @@ +../requirements.txt \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 64c56a3..bfd3554 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -six \ No newline at end of file +six +recommonmark -- GitLab