Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .github/actions/android-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ inputs:
description: target ABI
required: false
default: arm64-v8a
outputs:
result:
value: ${{ steps.ndk-build.outputs.result }}

runs:
using: composite
Expand Down Expand Up @@ -45,6 +48,7 @@ runs:
repository: nnstreamer/nnstreamer-android-resource
path: nnstreamer-android-resource
- name: NDK build
id: ndk-build
run: |
echo "NDK build, ${{ github.workspace }}"
export GSTREAMER_ROOT_ANDROID=~/android/gst_root_android/
Expand All @@ -63,7 +67,10 @@ runs:
result=$?
if [[ ${result} -ne 0 ]]; then
echo "NDK build failed"
exit 1
echo "result=failure" >> $GITHUB_OUTPUT
else
echo "NDK build success"
echo "result=success" >> $GITHUB_OUTPUT
fi
shell: bash
env:
Expand Down
40 changes: 40 additions & 0 deletions .github/actions/gitpush/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: 'Push to github.io'
description: 'Update the github action result to nnstreamer.github.io'
inputs:
source:
description: 'source path of the file or directory to be copied'
required: true
dest:
description: 'destination directory in nnstreamer.github.io repository'
required: true
message:
description: 'commit message'
required: false
default: 'Update the result from nnstreamer github action.'
taos_account:
required: true
taos_account_token:
required: true

runs:
using: "composite"
steps:
- name: update the result
run: |
git clone https://${{ inputs.taos_account }}:${{ inputs.taos_account_token }}@github.com/nnstreamer/nnstreamer.github.io.git
pushd nnstreamer.github.io
mkdir -p ${{ inputs.dest }}
cp -r ${{ inputs.source }} ${{ inputs.dest }}
git diff > git_diff.txt
DIFF_SIZE=$(stat -c%s git_diff.txt)
if [[ $DIFF_SIZE -ne 0 ]]; then
git config user.email "nnsuite@samsung.com"
git config user.name "nnsuite"
git add *
git commit -s -m "${{ inputs.message }}"
git push origin main -f
else
echo "Nothing to commit. Skip the push operation."
fi
popd
shell: bash
34 changes: 34 additions & 0 deletions .github/actions/s3_upload/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: 'upload to release.nnstreamer.com'
inputs:
source:
description: 'source path of the file or directory to be copied'
required: true
dest:
description: 'destination directory in release.nnstreamer.com repository'
required: true
s3_id:
required: true
s3_key:
required: true
s3_option:
required: false
default: ""

runs:
using: "composite"
steps:
- name: get date
id: get-date
run: |
echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
shell: bash

- name: update the result to s3
env:
AWS_ACCESS_KEY_ID: ${{ inputs.s3_id }}
AWS_SECRET_ACCESS_KEY: ${{ inputs.s3_key }}
AWS_EC2_METADATA_DISABLED: true
run: |
aws s3 cp --region ap-northeast-2 ${{ inputs.source }} s3://nnstreamer-release/nnstreamer/${{ steps.get-date.outputs.date }}/${{ inputs.dest }} ${{ inputs.s3_option }}
aws s3 cp --region ap-northeast-2 ${{ inputs.source }} s3://nnstreamer-release/nnstreamer/latest/${{ inputs.dest }} ${{ inputs.s3_option }}
shell: bash
61 changes: 47 additions & 14 deletions .github/workflows/daily-build-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,62 @@ on:
jobs:
build:
runs-on: ubuntu-22.04
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_S3_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }}
AWS_EC2_METADATA_DISABLED: true
steps:
- uses: actions/checkout@v4
- name: Prepare Android build

- name: build
id: android-build
uses: ./.github/actions/android-build

- name: get date
if: always()
id: get-date
run: |
echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT

- name: Release daily build result
if: steps.android-build.outputs.result == 'success'
uses: ./.github/actions/s3_upload
with:
source: ${{ github.workspace }}/android_lib/
dest: android/
s3_id: ${{ secrets.AWS_S3_ACCESS_KEY_ID }}
s3_key: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }}
s3_option: --recursive

- name: Generate badge
run: |
aws s3 cp --recursive --region ap-northeast-2 ${{ github.workspace }}/android_lib/ s3://nnstreamer-release/nnstreamer/${{ steps.get-date.outputs.date }}/android/
aws s3 rm s3://nnstreamer-release/nnstreamer/latest/android/
aws s3 cp --recursive --region ap-northeast-2 ${{ github.workspace }}/android_lib/ s3://nnstreamer-release/nnstreamer/latest/android/
- name: Publish javadoc
pip install pybadges setuptools
mkdir -p ~/daily_build
if [ '${{ steps.android-build.outputs.result }}' == 'success' ]; then
python3 -m pybadges --left-text=test --right-text=success --right-color=green > ~/daily_build/android_build_result.svg
else
python3 -m pybadges --left-text=test --right-text=failure --right-color=red > ~/daily_build/android_build_result.svg
fi

- name: update daily result badge
uses: ./.github/actions/gitpush
with:
source: ~/daily_build/android_build_result.svg
dest: testresult
message: "Update android daily build result."
taos_account: ${{ secrets.TAOS_ACCOUNT }}
taos_account_token: ${{ secrets.TAOS_ACCOUNT_TOKEN }}

- name: Generate javadoc
if: steps.android-build.outputs.result == 'success'
run: |
echo "Publish javadoc, ${{ github.workspace }}"
mkdir ~/javadoc_dir
echo "Generate javadoc, ${{ github.workspace }}"
mkdir -p ~/javadoc_dir
sed -i "s|@BUILD_ANDROID@|//|" ${{ github.workspace }}/java/android/nnstreamer/src/main/java/org/nnsuite/nnstreamer/*.java
javadoc -d ~/javadoc_dir -public -splitindex -Xdoclint:none --ignore-source-errors java/android/nnstreamer/src/main/java/org/nnsuite/nnstreamer/*
aws s3 cp --recursive --region ap-northeast-2 ~/javadoc_dir/ s3://nnstreamer-release/nnstreamer/${{ steps.get-date.outputs.date }}/java_html/
aws s3 rm s3://nnstreamer-release/nnstreamer/latest/java_html/
aws s3 cp --recursive --region ap-northeast-2 ~/javadoc_dir/ s3://nnstreamer-release/nnstreamer/latest/java_html/

- name: Publish javatoc to release.nnstreamer.com
if: steps.android-build.outputs.result == 'success'
uses: ./.github/actions/s3_upload
with:
source: ~/javadoc_dir/
dest: java_html/
s3_id: ${{ secrets.AWS_S3_ACCESS_KEY_ID }}
s3_key: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }}
s3_option: --recursive
81 changes: 81 additions & 0 deletions .github/workflows/daily-build-gbs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: gbs daily build and test

on:
schedule:
# 05:00 AM (KST) Mon-Fri
- cron: "00 20 * * 0-4"

# Allow manually triggering the workflow
workflow_dispatch:

jobs:
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: "--define \"unit_test 1\" --define \"testcoverage 1\""
- gbs_build_arch: "i586"
gbs_build_option: "--define \"unit_test 1\""
- gbs_build_arch: "armv7l"
gbs_build_option: "--define \"unit_test 1\""
- gbs_build_arch: "aarch64"
gbs_build_option: "--define \"unit_test 1\""

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: run GBS
id: gbs-build
run: gbs build ${{ matrix.gbs_build_option }} --define "_skip_debug_rpm 1" -A ${{ matrix.gbs_build_arch }}

- name: save gbs cache
uses: actions/cache/save@v4
if: ${{ always() && github.ref == 'refs/heads/main' }}
with:
path: ~/GBS-ROOT/local/cache
key: gbs-cache-${{ matrix.gbs_build_arch }}-${{ steps.get-date.outputs.date }}

- if: matrix.gbs_build_arch == 'x86_64' && steps.gbs-build.outcome == 'success'
name: extract test coverage result
run: |
pip install pybadges beautifulsoup4 setuptools
mkdir -p ~/testresult/
pushd ~/testresult/
cp ~/GBS-ROOT/local/repos/tizen/x86_64/RPMS/*-coverage*.rpm .
rpm2cpio *-coverage*.rpm | cpio -idv
popd
python3 .github/workflows/gen_coverage_badge.py ~/testresult/usr/share/ml-api/unittest/result/index.html ~/testresult/usr/share/ml-api/unittest/result/coverage_badge.svg

- if: matrix.gbs_build_arch == 'x86_64' && steps.gbs-build.outcome == 'success'
name: update test coverage result to github.io
uses: ./.github/actions/gitpush
with:
source: ~/testresult/usr/share/ml-api/unittest/result/*
dest: testresult/ml-api
message: "${{ steps.get-date.outputs.date }} : Update test coverage result."
taos_account: ${{ secrets.TAOS_ACCOUNT }}
taos_account_token: ${{ secrets.TAOS_ACCOUNT_TOKEN }}
79 changes: 79 additions & 0 deletions .github/workflows/gen_coverage_badge.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/usr/bin/env python3
##
# SPDX-License-Identifier: LGPL-2.1-only
# Copyright (C) 2024 Samsung Electronics
#
# @file gen_github_badge_svg.py
# @brief A tool for generating a github badge image in svg format
# @author Wook Song <wook16.song@samsung.com>
# @author Gichan Jang <gichan2.jang@samsung.com>
# @note
# usage : python gen_badge.py {gcov-index-file} {output.svg}
#
import sys
import os
from bs4 import BeautifulSoup
from pybadges import badge

##
# @brief Get a gradient colorcode from green to red of given value (scaled)
# @param[in] val A value to be conveted to a gradient colorcode (i.e., #FFFFFF)
# @param[in] scale A limit for the val, 0 <= val <= scale
def get_code_g_y_r(val, scale):
"""get_code_g_y_r(val, scale) -> str"""
if val <= 50:
red = 255
green = val * (255 / (float(scale) / 2))
else:
green = 255 * val / scale
red = 255 - (val - 50) * (255 / (float(scale) / 2))

rgb = (int(red), int(green), int(0))

return '#%02x%02x%02x' % rgb

##
# @brief Generate a github badge svg file representing code coverage
# @param[in] html A concatenated string of the whole contents in index.html that is the result of LCOV
# @param[in] path A file path to save the svg file
def gen_coverage_badge(html, path):
#parse LCOV html
soup = BeautifulSoup(html, 'html.parser')
lines, line_hits, funcs, func_hits = \
soup.find('table').find_all('td', {'class': 'headerCovTableEntry'})
line_hits = float(line_hits.text)
lines = float(lines.text)
line_coverage = line_hits / lines
rgb_code = get_code_g_y_r(line_coverage * 100, 100)
coverage_str = str(format(line_coverage * 100, '.2f')) + '%'
s = badge(left_text='coverage', right_text=coverage_str, right_color=rgb_code)

file = open(path, "w")
file.write(s)
file.close()


if __name__ == '__main__':
# argv[1]: [url/file] a path or url of LCOV html to get information for badge generation
# argv[2]: [file] a file path to save the generated svg file
if len(sys.argv) < 3:
exit(1)

str_html = ''
if os.path.isfile(sys.argv[1]):
with open(sys.argv[1], 'r') as f:
str_html = f.read()
if not BeautifulSoup(str_html, "html.parser").find():
exit(1)
else:
exit(1)

path_out_svg=''
if not os.access(os.path.dirname(sys.argv[2]) or os.getcwd(), os.W_OK):
exit(1)
else:
path_out_svg = os.path.abspath(sys.argv[2])
if os.path.isdir(path_out_svg) or os.path.islink(path_out_svg):
exit(1)

gen_coverage_badge(str_html, path_out_svg)
Loading
Loading