diff options
author | Daniel P. Berrangé <berrange@redhat.com> | 2022-03-11 13:56:40 +0000 |
---|---|---|
committer | Daniel P. Berrangé <berrange@redhat.com> | 2022-05-11 13:22:21 +0100 |
commit | 46e91d9d2d5e2a355df9245ab5b3c29100db76e7 (patch) | |
tree | efda40c7c3da22d7c8de545ba56fd62a9768d192 | |
parent | b3e65580ce7b78871976b91c07a4b195b2c5985d (diff) | |
download | libvirt-ci-46e91d9d2d5e2a355df9245ab5b3c29100db76e7.zip libvirt-ci-46e91d9d2d5e2a355df9245ab5b3c29100db76e7.tar.gz libvirt-ci-46e91d9d2d5e2a355df9245ab5b3c29100db76e7.tar.bz2 |
lcitool/manifest: split gitlab build template jobs into separate file
Currently ci/gitlab.yml contains all the generated build logic.
This continues from the previous commit by splitting the build template
jobs into a separate file called 'ci/gitlab/build-templates.yml'
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
-rw-r--r-- | guests/lcitool/lcitool/manifest.py | 12 | ||||
-rw-r--r-- | guests/lcitool/tests/data/manifest/out/ci/gitlab.yml | 41 | ||||
-rw-r--r-- | guests/lcitool/tests/data/manifest/out/ci/gitlab/build-templates.yml | 38 | ||||
-rw-r--r-- | guests/lcitool/tests/test_manifest.py | 1 |
4 files changed, 48 insertions, 44 deletions
diff --git a/guests/lcitool/lcitool/manifest.py b/guests/lcitool/lcitool/manifest.py index 944cb8f..39425be 100644 --- a/guests/lcitool/lcitool/manifest.py +++ b/guests/lcitool/lcitool/manifest.py @@ -284,12 +284,16 @@ class Manifest: includes.append(path) if gitlabinfo["builds"]: + path = Path(gitlabdir, "build-templates.yml") + content = [] if have_native: - gitlabcontent.append(gitlab.native_build_template()) + content.append(gitlab.native_build_template()) if have_cross: - gitlabcontent.append(gitlab.cross_build_template()) - if gitlabinfo["cirrus"]: - gitlabcontent.append(gitlab.cirrus_template(self.cidir)) + content.append(gitlab.cross_build_template()) + if gitlabinfo["cirrus"]: + content.append(gitlab.cirrus_template(self.cidir)) + self._replace_file(content, path, dryrun) + includes.append(path) if jobinfo["check-dco"]: gitlabcontent.append(gitlab.check_dco_job(namespace)) diff --git a/guests/lcitool/tests/data/manifest/out/ci/gitlab.yml b/guests/lcitool/tests/data/manifest/out/ci/gitlab.yml index 77aded2..28bbb2e 100644 --- a/guests/lcitool/tests/data/manifest/out/ci/gitlab.yml +++ b/guests/lcitool/tests/data/manifest/out/ci/gitlab.yml @@ -1,45 +1,6 @@ include: - local: 'ci/gitlab/container-templates.yml' - -.gitlab_native_build_job: - image: $CI_REGISTRY_IMAGE/ci-$NAME:latest - stage: builds - - -.gitlab_cross_build_job: - image: $CI_REGISTRY_IMAGE/ci-$NAME-cross-$CROSS:latest - stage: builds - - -.cirrus_build_job: - stage: builds - image: registry.gitlab.com/libvirt/libvirt-ci/cirrus-run:master - needs: [] - script: - - source ci/cirrus/$NAME.vars - - sed -e "s|[@]CI_REPOSITORY_URL@|$CI_REPOSITORY_URL|g" - -e "s|[@]CI_COMMIT_REF_NAME@|$CI_COMMIT_REF_NAME|g" - -e "s|[@]CI_COMMIT_SHA@|$CI_COMMIT_SHA|g" - -e "s|[@]CIRRUS_VM_INSTANCE_TYPE@|$CIRRUS_VM_INSTANCE_TYPE|g" - -e "s|[@]CIRRUS_VM_IMAGE_SELECTOR@|$CIRRUS_VM_IMAGE_SELECTOR|g" - -e "s|[@]CIRRUS_VM_IMAGE_NAME@|$CIRRUS_VM_IMAGE_NAME|g" - -e "s|[@]UPDATE_COMMAND@|$UPDATE_COMMAND|g" - -e "s|[@]UPGRADE_COMMAND@|$UPGRADE_COMMAND|g" - -e "s|[@]INSTALL_COMMAND@|$INSTALL_COMMAND|g" - -e "s|[@]PATH@|$PATH_EXTRA${PATH_EXTRA:+:}\$PATH|g" - -e "s|[@]PKG_CONFIG_PATH@|$PKG_CONFIG_PATH|g" - -e "s|[@]PKGS@|$PKGS|g" - -e "s|[@]MAKE@|$MAKE|g" - -e "s|[@]PYTHON@|$PYTHON|g" - -e "s|[@]PIP3@|$PIP3|g" - -e "s|[@]PYPI_PKGS@|$PYPI_PKGS|g" - -e "s|[@]XML_CATALOG_FILES@|$XML_CATALOG_FILES|g" - <ci/cirrus/build.yml >ci/cirrus/$NAME.yml - - cat ci/cirrus/$NAME.yml - - cirrus-run -v --show-build-log always ci/cirrus/$NAME.yml - rules: - - if: "$CIRRUS_GITHUB_REPO && $CIRRUS_API_TOKEN" - + - local: 'ci/gitlab/build-templates.yml' check-dco: stage: sanity_checks diff --git a/guests/lcitool/tests/data/manifest/out/ci/gitlab/build-templates.yml b/guests/lcitool/tests/data/manifest/out/ci/gitlab/build-templates.yml new file mode 100644 index 0000000..805ecc5 --- /dev/null +++ b/guests/lcitool/tests/data/manifest/out/ci/gitlab/build-templates.yml @@ -0,0 +1,38 @@ +.gitlab_native_build_job: + image: $CI_REGISTRY_IMAGE/ci-$NAME:latest + stage: builds + + +.gitlab_cross_build_job: + image: $CI_REGISTRY_IMAGE/ci-$NAME-cross-$CROSS:latest + stage: builds + + +.cirrus_build_job: + stage: builds + image: registry.gitlab.com/libvirt/libvirt-ci/cirrus-run:master + needs: [] + script: + - source ci/cirrus/$NAME.vars + - sed -e "s|[@]CI_REPOSITORY_URL@|$CI_REPOSITORY_URL|g" + -e "s|[@]CI_COMMIT_REF_NAME@|$CI_COMMIT_REF_NAME|g" + -e "s|[@]CI_COMMIT_SHA@|$CI_COMMIT_SHA|g" + -e "s|[@]CIRRUS_VM_INSTANCE_TYPE@|$CIRRUS_VM_INSTANCE_TYPE|g" + -e "s|[@]CIRRUS_VM_IMAGE_SELECTOR@|$CIRRUS_VM_IMAGE_SELECTOR|g" + -e "s|[@]CIRRUS_VM_IMAGE_NAME@|$CIRRUS_VM_IMAGE_NAME|g" + -e "s|[@]UPDATE_COMMAND@|$UPDATE_COMMAND|g" + -e "s|[@]UPGRADE_COMMAND@|$UPGRADE_COMMAND|g" + -e "s|[@]INSTALL_COMMAND@|$INSTALL_COMMAND|g" + -e "s|[@]PATH@|$PATH_EXTRA${PATH_EXTRA:+:}\$PATH|g" + -e "s|[@]PKG_CONFIG_PATH@|$PKG_CONFIG_PATH|g" + -e "s|[@]PKGS@|$PKGS|g" + -e "s|[@]MAKE@|$MAKE|g" + -e "s|[@]PYTHON@|$PYTHON|g" + -e "s|[@]PIP3@|$PIP3|g" + -e "s|[@]PYPI_PKGS@|$PYPI_PKGS|g" + -e "s|[@]XML_CATALOG_FILES@|$XML_CATALOG_FILES|g" + <ci/cirrus/build.yml >ci/cirrus/$NAME.yml + - cat ci/cirrus/$NAME.yml + - cirrus-run -v --show-build-log always ci/cirrus/$NAME.yml + rules: + - if: "$CIRRUS_GITHUB_REPO && $CIRRUS_API_TOKEN" diff --git a/guests/lcitool/tests/test_manifest.py b/guests/lcitool/tests/test_manifest.py index cbdd60d..34a4691 100644 --- a/guests/lcitool/tests/test_manifest.py +++ b/guests/lcitool/tests/test_manifest.py @@ -115,6 +115,7 @@ def test_generate(monkeypatch, custom_projects): # Verify content of files we expect to be created assert_write(Path("ci", "gitlab.yml")) assert_write(Path("ci", "gitlab", "container-templates.yml")) + assert_write(Path("ci", "gitlab", "build-templates.yml")) assert_write(Path("ci", "cirrus", "freebsd-current.vars")) assert_write(Path("ci", "cirrus", "macos-11.vars")) assert_write(Path("ci", "containers", "centos-stream-9.Dockerfile")) |