From a8d58cb324dc1085c7e4ad327688552149bb86cb Mon Sep 17 00:00:00 2001 From: Gichan Jang Date: Tue, 5 Nov 2024 19:33:04 +0900 Subject: [PATCH] TEST OUTPIUT Signed-off-by: Gichan Jang --- .github/workflows/gen_build_result_badge.py | 40 +++++++++ .github/workflows/temp.yml | 89 +++++++++++++++++++++ 2 files changed, 129 insertions(+) create mode 100644 .github/workflows/gen_build_result_badge.py create mode 100644 .github/workflows/temp.yml diff --git a/.github/workflows/gen_build_result_badge.py b/.github/workflows/gen_build_result_badge.py new file mode 100644 index 000000000..2baf76783 --- /dev/null +++ b/.github/workflows/gen_build_result_badge.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 +## +# SPDX-License-Identifier: LGPL-2.1-only +# Copyright (C) 2024 Samsung Electronics +# +# @file gen_build_result_badge.py +# @brief A tool for generating a github badge image in svg format +# @author Gichan Jang +# +import sys +import os +import json +from pybadges import badge + +## +# @brief Generate a github badge svg file representing daily build result +# @param[in] html build result of arch. +# @param[in] path A file path to save the svg file +def gen_build_result_badge(valid_json, out_dir): + for arch in valid_json: + result = valid_json[arch] + color='green' + if result == 'failure': + color='red' + + s = badge(left_text='test', right_text=result, right_color=color) + path = os.path.join(out_dir, arch + '_reuslt.svg') + file = open(path, "w") + file.write(s) + file.close() + + +if __name__ == '__main__': + if len(sys.argv) < 3: + exit(1) + + file = open(sys.argv[1], "r") + json_data = json.load(file) + + gen_build_result_badge (json_data, sys.argv[2]) diff --git a/.github/workflows/temp.yml b/.github/workflows/temp.yml new file mode 100644 index 000000000..c5054bde7 --- /dev/null +++ b/.github/workflows/temp.yml @@ -0,0 +1,89 @@ +name: temp + +on: + # Allow manually triggering the workflow + workflow_dispatch: + +jobs: + cache_gbs_build: + outputs: + x86_64: ${{ steps.gbs-result.outputs.x86_64 }} + i586: ${{ steps.gbs-result.outputs.i586 }} + armv7l: ${{ steps.gbs-result.outputs.armv7l }} + aarch64: ${{ steps.gbs-result.outputs.aarch64 }} + strategy: + fail-fast: false + matrix: + include: + - gbs_build_arch: "x86_64" + gbs_build_option: "success" + - gbs_build_arch: "i586" + gbs_build_option: "success" + - gbs_build_arch: "armv7l" + gbs_build_option: "success" + - gbs_build_arch: "aarch64" + gbs_build_option: "failure" + + runs-on: ubuntu-22.04 + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v1 + + - name: prepare deb sources for GBS + run: echo "deb [trusted=yes] http://download.tizen.org/tools/latest-release/Ubuntu_22.04/ /" | sudo tee /etc/apt/sources.list.d/tizen.list + + - name: install GBS + run: sudo apt-get update && sudo apt-get install -y gbs + + # - name: configure GBS + # run: cp .github/workflows/tizen.gbs.conf ~/.gbs.conf + + # - name: get date + # id: get-date + # run: | + # echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT + + # - name: build and tests on GBS + # id: gbs-build + # run: gbs build --define "_skip_debug_rpm 1" -A ${{ matrix.gbs_build_arch }} + + - name: report GBS build and test result + id: gbs-result + run: echo "${{ matrix.gbs_build_arch }}=${{ matrix.gbs_build_option }}" >> $GITHUB_OUTPUT + # run: echo "output_${{ matrix.gbs_build_arch }}=${{ steps.gbs-build.outcome }}" >> $GITHUB_OUTPUT + + - name: save gbs cache + uses: actions/cache/save@v4 + if: always() + with: + path: ~/GBS-ROOT/local/cache + key: gbs-cache-${{ matrix.gbs_build_arch }}-${{ steps.get-date.outputs.date }} + + print_result: + runs-on: ubuntu-22.04 + needs: [cache_gbs_build] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v1 + + - name: print-result + run: | + mkdir -p ~/testresult + pip install pybadges setuptools + echo "aarch64 result: ${{ needs.cache_gbs_build.outputs.aarch64 }}" + echo "x86_64 result: ${{ needs.cache_gbs_build.outputs.x86_64 }}" + echo "i586 result: ${{ needs.cache_gbs_build.outputs.i586 }}" + echo "armv7l result: ${{ needs.cache_gbs_build.outputs.armv7l }}" + echo '${{ toJSON( needs.cache_gbs_build.outputs) }}' > daily_build_result.json + cat daily_build_result.json + python3 .github/workflows/gen_build_result_badge.py daily_build_result.json ~/testresult + git clone https://${{ secrets.TAOS_ACCOUNT }}:${{ secrets.TAOS_ACCOUNT_TOKEN }}@github.com/nnstreamer/nnstreamer.github.io.git + pushd nnstreamer.github.io + cp -r ~/testresult/*.svg testresult + git config user.email "nnsuite@samsung.com" + git config user.name "nnsuite" + git add * + git commit -s -m "[DEBUG] Update unit test result badge." + git push origin main -f + popd