From 28b96554f78f203ce32978bac202447590ef6aab Mon Sep 17 00:00:00 2001 From: Chase Qi <chase.qi@linaro.org> Date: Mon, 20 Dec 2021 14:35:49 +0800 Subject: [PATCH] ci: generate lava-test badge lava-test badge shows success rate for on device testing in lava. Signed-off-by: Chase Qi <chase.qi@linaro.org> --- .gitlab-ci.yml | 4 ++++ .oniro-ci/test-generic.yaml | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0e77bbba..6af6dd6b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -186,6 +186,10 @@ lava-report: needs: [lava-qemu-x86, lava-qemu-x86_64, lava-zephyr-96b-nitrogen-tests, lava-zephyr-qemu-cortex-m3, lava-zephyr-qemu-x86] extends: .lava-report +lava-badge: + needs: [lava-report] + extends: .lava-badge + .build-with-kaniko: stage: build image: diff --git a/.oniro-ci/test-generic.yaml b/.oniro-ci/test-generic.yaml index 59bf0c2e..f668589f 100644 --- a/.oniro-ci/test-generic.yaml +++ b/.oniro-ci/test-generic.yaml @@ -125,3 +125,27 @@ # Run the build when a tag is placed. - if: '$CI_COMMIT_TAG' when: manual + +.lava-badge: + interruptible: true + image: + name: registry.booting.oniroproject.org/distro/oniro/bitbake-builder:latest + stage: report + variables: + GIT_STRATEGY: none + script: + - | + set -x + curl --silent "$CI_API_V4_URL/projects/$CI_PROJECT_ID/pipelines/$CI_PIPELINE_ID/test_report" > test-report.json + total_count="$(jq '.total_count' test-report.json)" + success_count="$(jq '.success_count' test-report.json)" + success_rate=$(( 100 * success_count / total_count )) + anybadge --label=lava-test --value=${success_rate} --suffix='%' --file=lava-test.svg 50=red 60=orange 80=yellow 100=green + set +x + artifacts: + when: always + paths: + - lava-test.svg + rules: + # Run the build when it is scheduled. + - if: $CI_PIPELINE_SOURCE == "schedule" -- GitLab