Skip to content

Commit

Permalink
actions: gbs build test
Browse files Browse the repository at this point in the history
Run gbs build for x64/x86/aarch64/armv7l Tizen.
This is imported from nnstreamer.git.

Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
  • Loading branch information
myungjoo committed Jun 4, 2024
1 parent ea26fdf commit a5b8860
Show file tree
Hide file tree
Showing 4 changed files with 212 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/actions/check-rebuild/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Check if rebuild required
description:

inputs:
mode:
description: build mode to be checked
required: false
default: build

runs:
using: composite
steps:
- run: |
tmpfile=$(mktemp)
git show --pretty="format:" --name-only --diff-filter=AMRC ${{ github.event.pull_request.head.sha}} -${{ github.event.pull_request.commits }} | sort | uniq | awk NF > ${tmpfile}
echo "changed_file_list=${tmpfile}" >> "$GITHUB_ENV"
rebuild=`bash .github/actions/check-rebuild/check_if_rebuild_requires.sh ${tmpfile} ${{ inputs.mode }} | grep "REBUILD=YES" | wc -l`
echo "Rebuild required: ${rebuild}"
echo "rebuild=${rebuild}" >> "$GITHUB_ENV"
shell: sh
83 changes: 83 additions & 0 deletions .github/actions/check-rebuild/check_if_rebuild_requires.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/usr/bin/env bash

##
# Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved.
#
# @file: check_if_rebuild_requires.sh
# @brief Check if rebuild & unit-test is required with the given PR.
# @see https://github.com/nnstreamer/nnstreamer
# @author MyungJoo Ham <myungjoo.ham@samsung.com>
#
# Argument 1 ($1): the file containing list of files to be checked.
# Argument 2 ($2): build mode to be checked
# gbs: check if Tizen GBS build is required
# debian: check if pdebuild is required
# android: check if jni rebuild is required
# build (default): check if general meson rebuild is required.

if [ -z $1 ]; then
echo "::error The argument (file path) is not given."
exit 1
fi

if [ -z $2 ]; then
mode="build"
else
mode=$2
fi

rebuild=0
regbs=0
redebian=0
reandroid=0

for file in `cat $1`; do
case $file in
*.md|*.png|*.webp|*.css|*.html )
;;
packaging/* )
regbs='1'
;;
debian/* )
redebian='1'
;;
jni/* )
reandroid='1'
;;
* )
rebuild='1'
regbs='1'
redebian='1'
reandroid='1'
;;
esac
done

case $mode in
gbs)
if [[ "$regbs" == "1" ]]; then
echo "REBUILD=YES"
exit 0
fi
;;
debian)
if [[ "$redebian" == "1" ]]; then
echo "REBUILD=YES"
exit 0
fi
;;
android)
if [[ "$reandroid" == "1" ]]; then
echo "REBUILD=YES"
exit 0
fi
;;
*)
if [[ "$rebuild" == "1" ]]; then
echo "REBUILD=YES"
exit 0
fi
;;
esac

echo "REBUILD=NO"
88 changes: 88 additions & 0 deletions .github/workflows/gbs_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Build and unit test/ Tizen/GBS

# ${{ github.event.pull_request.commits }} : # commits in this PR
# - changed_file_list in GITHUB_ENV: the list of files updated in this pull-request.

on:
pull_request:
branches: [ main ]

jobs:
build:
name: Tizen GBS build on Ubuntu
strategy:
matrix:
include:
- gbs_build_arch: "x86_64"
gbs_build_option: "--define \"unit_test 1\""
- gbs_build_arch: "i586"
gbs_build_option: "--define \"unit_test 1\""
- gbs_build_arch: "armv7l"
gbs_build_option: "--define \"unit_test 0\""
- gbs_build_arch: "aarch64"
gbs_build_option: "--define \"unit_test 0\""

runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: -${{ github.event.pull_request.commits }}
- name: Check if rebuild required
uses: ./.github/actions/check-rebuild
with:
mode: gbs
- uses: actions/setup-python@v1

- name: prepare GBS
if: env.rebuild == '1'
run: |
echo "deb [trusted=yes] http://download.tizen.org/tools/latest-release/Ubuntu_22.04/ /" | sudo tee /etc/apt/sources.list.d/tizen.list
sudo apt-get update && sudo apt-get install -y gbs
cp .github/workflows/tizen.gbs.conf ~/.gbs.conf
- name: get date
id: get-date
run: |
echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: restore gbs cache from main branch
if: env.rebuild == '1'
uses: actions/cache/restore@v4
with:
path: ~/GBS-ROOT/local/cache
key: gbs-cache-${{ matrix.gbs_build_arch }}-${{ steps.get-date.outputs.date }}
restore-keys: |
gbs-cache-${{ matrix.gbs_build_arch }}-
- name: run GBS
if: env.rebuild == '1'
run: |
gbs build --skip-srcrpm --define "_skip_debug_rpm 1" -A ${{ matrix.gbs_build_arch }} ${{ matrix.gbs_build_option }}
- name: get ML API
if: env.rebuild == '1'
uses: actions/checkout@v4
with:
repository: nnstreamer/api
path: api
- name: get ML Agent
if: env.rebuild == '1'
uses: actions/checkout@v4
with:
repository: nnstreamer/deviceMLOps.MLAgent
path: mlagent
- name: run ml-api and ml-agent build
if: env.rebuild == '1'
run: |
pushd api
echo "::group::Build and run unit-tests for ML API"
gbs build --skip-srcrpm --define "_skip_debug_rpm 1" -A ${{ matrix.gbs_build_arch }} ${{ matrix.gbs_build_option }}
echo "::endgroup::"
popd
pushd mlagent
echo "::group::Build and run unit-tests for ML Agent (deviceMLOps.MLAgent)"
gbs build --skip-srcrpm --define "_skip_debug_rpm 1" -A ${{ matrix.gbs_build_arch }} ${{ matrix.gbs_build_option }}
echo "::endgroup::"
popd
21 changes: 21 additions & 0 deletions .github/workflows/tizen.gbs.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[general]
profile = profile.tizen
tmpdir = /var/tmp
packaging_branch = tizen
workdir = .

[profile.tizen]
url = https://api.tizen.org
obs = obs.tizen

repos = repo.base, repo.unified
buildroot = ~/GBS-ROOT/

[obs.tizen]
url = https://api.tizen.org

[repo.base]
url = http://download.tizen.org/snapshots/TIZEN/Tizen/Tizen-Base/reference/repos/standard/packages/

[repo.unified]
url = http://download.tizen.org/snapshots/TIZEN/Tizen/Tizen-Unified/reference/repos/standard/packages/

0 comments on commit a5b8860

Please sign in to comment.