From 4879e41decac084e53a3f21c99188720859aaac1 Mon Sep 17 00:00:00 2001
From: Chase Qi <chase.qi@linaro.org>
Date: Thu, 5 May 2022 12:58:38 +0800
Subject: [PATCH] .oniro-ci: add build-zephyr-image job to publish elf and bin
 images

Signed-off-by: Chase Qi <chase.qi@linaro.org>
---
 .oniro-ci/build-generic.yaml               |  7 +++++++
 .oniro-ci/machines-and-flavours.yaml       |  8 ++++----
 docs/ci/hidden-jobs/build-zephyr-image.rst | 18 ++++++++++++++++++
 docs/ci/hidden-jobs/index.rst              |  3 ++-
 4 files changed, 31 insertions(+), 5 deletions(-)
 create mode 100644 docs/ci/hidden-jobs/build-zephyr-image.rst

diff --git a/.oniro-ci/build-generic.yaml b/.oniro-ci/build-generic.yaml
index aa1b1b5d..9e809117 100644
--- a/.oniro-ci/build-generic.yaml
+++ b/.oniro-ci/build-generic.yaml
@@ -316,6 +316,13 @@
   script:
     - !reference [.build-image, script]
 
+.build-zephyr-image:
+  extends: .build-image
+  variables:
+    CI_ONIRO_JOB_ARTIFACTS: "*.elf *.bin"
+  script:
+    - !reference [.build-image, script]
+
 # 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.
 .build:
diff --git a/.oniro-ci/machines-and-flavours.yaml b/.oniro-ci/machines-and-flavours.yaml
index ed835326..c7c078d2 100644
--- a/.oniro-ci/machines-and-flavours.yaml
+++ b/.oniro-ci/machines-and-flavours.yaml
@@ -83,7 +83,7 @@ linux-raspberrypi4-64:
     CI_ONIRO_RECIPE_NAME: oniro-image-base-tests
 
 zephyr-qemu-x86:
-  extends: .build-image
+  extends: .build-zephyr-image
   variables:
     MACHINE: qemu-x86
     # See the note on linux-qemu-x86.
@@ -94,7 +94,7 @@ zephyr-qemu-x86:
     CI_ONIRO_INSTANCE_SIZE: s3.large.2
 
 zephyr-qemu-cortex-m3:
-  extends: .build-image
+  extends: .build-zephyr-image
   variables:
     MACHINE: qemu-cortex-m3
     # See the note on linux-qemu-x86.
@@ -105,7 +105,7 @@ zephyr-qemu-cortex-m3:
     CI_ONIRO_INSTANCE_SIZE: s3.large.2
 
 zephyr-96b-nitrogen:
-  extends: .build-image
+  extends: .build-zephyr-image
   variables:
     MACHINE: 96b-nitrogen
     CI_ONIRO_RECIPE_NAME: zephyr-philosophers
@@ -113,7 +113,7 @@ zephyr-96b-nitrogen:
     CI_ONIRO_INSTANCE_SIZE: s3.large.2
 
 zephyr-96b-nitrogen-tests:
-  extends: .build-image
+  extends: .build-zephyr-image
   variables:
     MACHINE: 96b-nitrogen
     CI_ONIRO_RECIPE_NAME: zephyr-kernel-test-all
diff --git a/docs/ci/hidden-jobs/build-zephyr-image.rst b/docs/ci/hidden-jobs/build-zephyr-image.rst
new file mode 100644
index 00000000..2d1b41b9
--- /dev/null
+++ b/docs/ci/hidden-jobs/build-zephyr-image.rst
@@ -0,0 +1,18 @@
+.. SPDX-FileCopyrightText: Huawei Inc.
+..
+.. SPDX-License-Identifier: CC-BY-4.0
+
+===================
+.build-zephyr-image
+===================
+
+The ``.build-zephyr-image`` job extends the :doc:`build-image` job to collect only
+the `*.bin` and `*.elf` files and remove all the other files that would
+normally be collected by the artifact system. It is recommended for Zephyr
+builds which produce bin and elf images.
+
+Usage Guide
+===========
+
+This job is configured exactly the same as :doc:`build-image` and
+:doc:`build-recipe`.
diff --git a/docs/ci/hidden-jobs/index.rst b/docs/ci/hidden-jobs/index.rst
index 04d5083f..5267997c 100644
--- a/docs/ci/hidden-jobs/index.rst
+++ b/docs/ci/hidden-jobs/index.rst
@@ -13,7 +13,7 @@ implementation details.
 
 .. toctree::
    :maxdepth: 1
-      
+
    workspace
    bitbake-workspace
    build-linux
@@ -23,6 +23,7 @@ implementation details.
    build-recipe
    build-image
    build-wic-image
+   build-zephyr-image
    build-rauc-bundle
    build-docs
    lava-test
-- 
GitLab