From 3c4a375bc876c7161ee67869b7ef0ff5eabbdf73 Mon Sep 17 00:00:00 2001 From: Chase Qi <chase.qi@linaro.org> Date: Fri, 22 Apr 2022 19:01:46 +0800 Subject: [PATCH] .oniro-ci: allow build job to customize what artifacts it needs to deploy Introduce variable CI_ONIRO_JOB_ARTIFACTS to allow build job to customize what artifacts it needs to deploy. Signed-off-by: Chase Qi <chase.qi@linaro.org> --- .oniro-ci/build-generic.yaml | 35 +++++++++++++---------- .oniro-ci/machines-and-flavours.yaml | 2 ++ docs/ci/hidden-jobs/bitbake-workspace.rst | 10 +++++++ 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/.oniro-ci/build-generic.yaml b/.oniro-ci/build-generic.yaml index d5cbaa0e..aa1b1b5d 100644 --- a/.oniro-ci/build-generic.yaml +++ b/.oniro-ci/build-generic.yaml @@ -268,11 +268,14 @@ # This job is documented in docs/ci/hidden-jobs/build-image.rst .build-image: extends: .build-recipe + variables: + CI_ONIRO_JOB_ARTIFACTS: "" script: - !reference [.build-recipe, script] # Move artifacts for recovery, which only considers $CI_PROJECT_DIR and # subdirectories. - mkdir -p "$CI_PROJECT_DIR"/artifacts + - rm -rf "$CI_PROJECT_DIR"/artifacts/* # The name of the build-specific tmp directory may vary. Ask bitbake # instead of hard-coding it. This is currently only relevant for Zephyr, # which uses tmp-newlib. @@ -281,35 +284,37 @@ # meta-oniro-core/classes/oniro-image.bbclass as runqemu needs it for local # build and boot. - find "$BITBAKE_TMPDIR"/deploy/images/ -name *.wic -exec rm -rf {} \; - - cp -a "$BITBAKE_TMPDIR"/deploy/images/ "$CI_PROJECT_DIR"/artifacts || true - cp -a "$BITBAKE_TMPDIR"/deploy/licenses/ "$CI_PROJECT_DIR"/artifacts || true + # Only copy the files defined in the CI_ONIRO_JOB_ARTIFACTS variable. Most + # of the remaining files are redundant and quite large. + - | + set -x + if test -n "$CI_ONIRO_JOB_ARTIFACTS" && test -d "$BITBAKE_TMPDIR"/deploy/; then + ( + cd "$BITBAKE_TMPDIR"/deploy/ + for artifact in $CI_ONIRO_JOB_ARTIFACTS; do + find ./ -type f -name "$artifact" -exec cp --parents {} "$CI_PROJECT_DIR"/artifacts \; + done + ) + fi + set +x artifacts: paths: - artifacts/ .build-wic-image: extends: .build-image + variables: + CI_ONIRO_JOB_ARTIFACTS: "*.wic.* *.bmap" script: - !reference [.build-image, script] - # Remove everything _except_ for the .wic.* and *.bmap and ovmf.qcow2 files. - # Most of the remaining files are redundant and quite large. Our Linux - # builds really only care about the wic files and the qemu UEFI firmware. - - echo "Removing non-wic/bmap image files" - - find "$CI_PROJECT_DIR"/artifacts/images/ \( -type f -o -type l \) -a ! \( -name "*.wic.*" -o -name "ovmf.qcow2" \) -print -delete - - echo "Pruning empty directories" - - find "$CI_PROJECT_DIR"/artifacts/ -type d -exec rmdir --verbose --ignore-fail-on-non-empty {} \; 2>/dev/null || true .build-rauc-bundle: extends: .build-image + variables: + CI_ONIRO_JOB_ARTIFACTS: "*.raucb" script: - !reference [.build-image, script] - # Remove everything _except_ for the .raucb.* files. The bundle is - # self-sufficient (aka standalone) and does not need any supporting - # infrastructure. - - echo "Removing non-bundle files" - - find "$CI_PROJECT_DIR"/artifacts/images/ \( -type f -o -type l \) -a ! -name "*.raucb" -print -delete - - echo "Pruning empty directories" - - find "$CI_PROJECT_DIR"/artifacts/ -type d -exec rmdir --verbose --ignore-fail-on-non-empty {} \; 2>/dev/null || true # This job is currently used to customize the behavior in oniro and xts-acts. # It will be removed when that is safe to do so. It is not documented. diff --git a/.oniro-ci/machines-and-flavours.yaml b/.oniro-ci/machines-and-flavours.yaml index cf60c429..d190d1ad 100644 --- a/.oniro-ci/machines-and-flavours.yaml +++ b/.oniro-ci/machines-and-flavours.yaml @@ -19,6 +19,7 @@ linux-qemu-x86: # This is done assuming that there are no non-redistributable or otherwise # tainted build intermediate files, downloads or published artifacts. CI_ONIRO_BB_LOCAL_CONF_BB_GENERATE_MIRROR_TARBALLS: 1 + CI_ONIRO_JOB_ARTIFACTS: "*.wic.* *.bmap ovmf.qcow2" linux-qemu-x86_64: extends: .build-wic-image @@ -29,6 +30,7 @@ linux-qemu-x86_64: # See the note on linux-qemu-x86. CI_ONIRO_BUILD_CACHE: "pub" CI_ONIRO_BB_LOCAL_CONF_BB_GENERATE_MIRROR_TARBALLS: 1 + CI_ONIRO_JOB_ARTIFACTS: "*.wic.* *.bmap ovmf.qcow2" linux-seco-intel-b68: extends: .build-wic-image diff --git a/docs/ci/hidden-jobs/bitbake-workspace.rst b/docs/ci/hidden-jobs/bitbake-workspace.rst index 340f246b..5c53d503 100644 --- a/docs/ci/hidden-jobs/bitbake-workspace.rst +++ b/docs/ci/hidden-jobs/bitbake-workspace.rst @@ -84,6 +84,16 @@ tested. This functionality is useful for testing incoming changes to repositories that contain source code that is already packaged one of the layers. +CI_ONIRO_JOB_ARTIFACTS +---------------------- + +Most of the files generated in the ``tmp/deploy`` directory are redundant. Some +of them are quite large. By default, only the files in the +``tmp/deploy/licenses`` directory are published. + +``CI_ONIRO_JOB_ARTIFACTS`` allows build job to define space-separated list of +build artifacts to publish. Wildcards are supported. + Configuring BitBake =================== -- GitLab