forked from nnstreamer/nnstreamer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
github-action: rebuild only if it's required
This adds a workflow routine that checks if rebuild is needed. Then, if there is no changes in source code, skip rebuilding Signed-off-by: MyungJoo Ham <[email protected]>
- Loading branch information
1 parent
daf22f1
commit 664018d
Showing
6 changed files
with
186 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 <[email protected]> | ||
# | ||
# 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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,16 +9,30 @@ jobs: | |
runs-on: macos-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Check if rebuild required | ||
## @todo This should become a reusable workflow. | ||
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/workflows/check_if_rebuild_requires.sh ${tmpfile} rebuild | grep "REBUILD=YES" | wc -l` | ||
echo "Rebuild required: ${rebuild}" | ||
echo "rebuild=${rebuild}" >> "$GITHUB_ENV" | ||
- uses: actions/setup-python@v1 | ||
- name: homebrew | ||
if: env.rebuild == '1' | ||
run: | | ||
# temporarily disabled, because it always fails these days. | ||
# brew update | ||
brew install cask | ||
- name: install minimal requirements | ||
if: env.rebuild == '1' | ||
run: brew install meson ninja pkg-config cmake libffi glib gstreamer numpy json-glib | ||
- uses: BSFishy/[email protected] | ||
if: env.rebuild == '1' | ||
with: | ||
action: build | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,9 +9,21 @@ jobs: | |
runs-on: ubuntu-20.04 | ||
name: Build on Ubuntu 20.04 RISC-V 64 | ||
steps: | ||
- uses: actions/[email protected] | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Check if rebuild required | ||
## @todo This should become a reusable workflow. | ||
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/workflows/check_if_rebuild_requires.sh ${tmpfile} rebuild | grep "REBUILD=YES" | wc -l` | ||
echo "Rebuild required: ${rebuild}" | ||
echo "rebuild=${rebuild}" >> "$GITHUB_ENV" | ||
- uses: nnstreamer/run-on-arch-action@master | ||
name: Run commands | ||
if: env.rebuild == '1' | ||
id: Build | ||
with: | ||
arch: riscv64 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters