Skip to content

Commit

Permalink
update github build action
Browse files Browse the repository at this point in the history
- add evaluation of python313 dependent packages
- evaluate packages to build and changed dependency folders in build.yml
  to avoid overflow of bash variables (limited to 1024 chars) (fixes SynoCommunity#6284)
  • Loading branch information
hgy59 committed Nov 26, 2024
1 parent 3b29da6 commit 2b552da
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
19 changes: 8 additions & 11 deletions .github/actions/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
# Evaluate packages to build and referenced source files to download.
#
# Functions:
# - Evaluate all packages to build depending on files defined in ${GH_FILES}.
# - Build all packages defined by ${USER_SPK_TO_BUILD} and ${GH_SPK_PACKAGES}
# - Evaluate additional packages to build depending on changed folders defined in ${GH_DEPENDENT_PACKAGES}.
# - synocli-videodriver is moved to head of packages to build first if triggered by its ffmpeg5-7
# - python310-311 and ffmpeg5-7 are moved to head of remaining packages to build when triggered by its own or a dependent.
# - python310-313 and ffmpeg5-7 are moved to head of remaining packages to build when triggered by its own or a dependent.
# - Referenced native and cross packages of the packages to build are added to the download list.

set -o pipefail
Expand All @@ -18,12 +19,8 @@ echo "::group:: ---- find dependent packages"
make setup-synocommunity
DEFAULT_TC=$(grep DEFAULT_TC local.mk | cut -f2 -d= | xargs)

# filter for changes made in the spk directories and take unique package name (without spk folder)
SPK_TO_BUILD+=" "
SPK_TO_BUILD+=$(echo "${GH_FILES}" | tr ' ' '\n' | grep -oP "^spk/\K[^\/]*" | sort -u | tr '\n' ' ')

# filter for changes made in the cross and native directories and take unique package name (including cross or native folder)
DEPENDENT_PACKAGES=$(echo "${GH_FILES}" | tr ' ' '\n' | grep -oP "(cross|native)/[^\/]*" | sort -u | tr '\n' ' ')
# all packages to build from changes or manual definition
SPK_TO_BUILD="${USER_SPK_TO_BUILD} ${GH_SPK_PACKAGES}"

# get dependency list
# dependencies in this list include the cross or native folder (i.e. native/python cross/glib)
Expand All @@ -37,7 +34,7 @@ do
done

# search for dependent spk packages
for package in ${DEPENDENT_PACKAGES}
for package in ${GH_DEPENDENT_PACKAGES}
do
echo "===> Searching for dependent package: ${package}"
packages=$(echo "${DEPENDENCY_LIST}" | grep " ${package} " | grep -o ".*:" | tr ':' ' ' | sort -u | tr '\n' ' ')
Expand Down Expand Up @@ -86,8 +83,8 @@ do
fi
done

# for python (310, 311) find all packages that depend on them
for py in python310 python311; do
# for python (310, 311, 313) find all packages that depend on them
for py in python310 python311 python313; do
python_dependent_packages=$(find spk/ -maxdepth 2 -mindepth 2 -name "Makefile" -exec grep -Ho "PYTHON_PACKAGE = ${py}" {} \; | grep -Po ".*spk/\K[^/]*" | sort | tr '\n' ' ')

# If packages contain a package that depends on python (or is python), then ensure
Expand Down
25 changes: 15 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,26 +97,31 @@ jobs:
fetch-depth: 0
persist-credentials: false

- name: Get changed files for pull request
- name: Get changed spk_packages and dependency_folders for pull request
if: github.event_name == 'pull_request'
id: getfile_pr
id: getchanges_pr
run: |
git diff --no-commit-id --name-only -r origin/master...${{github.event.pull_request.head.sha}} | xargs
echo "files=$(git diff --no-commit-id --name-only -r origin/master...${{github.event.pull_request.head.sha}} | xargs)" >> $GITHUB_OUTPUT
git diff --no-commit-id --name-only -r origin/master...${{github.event.pull_request.head.sha}} | grep -oP "^spk/\K[^\/]*" | sort -u | xargs
echo "spk_packages=$(git diff --no-commit-id --name-only -r origin/master...${{github.event.pull_request.head.sha}} | grep -oP "^spk/\K[^\/]*" | sort -u | xargs)" >> $GITHUB_OUTPUT
git diff --no-commit-id --name-only -r origin/master...${{github.event.pull_request.head.sha}} | grep -oP "(cross|native)/[^\/]*" | sort -u | xargs
echo "dependency_folders=$(git diff --no-commit-id --name-only -r origin/master...${{github.event.pull_request.head.sha}} | grep -oP "(cross|native)/[^\/]*" | sort -u | xargs)" >> $GITHUB_OUTPUT
- name: Get changed files for push
- name: Get changed spk_packages and dependency_folders of last commit for push
if: github.event_name == 'push'
id: getfile
id: getchanges_push
run: |
git diff-tree --no-commit-id --name-only -r ${{ github.sha }} | xargs
echo "files=$(git diff-tree --no-commit-id --name-only -r ${{ github.sha }} | xargs)" >> $GITHUB_OUTPUT
git diff-tree --no-commit-id --name-only -r ${{ github.sha }} | grep -oP "^spk/\K[^\/]*" | sort -u | xargs
echo "spk_packages=$(git diff-tree --no-commit-id --name-only -r ${{ github.sha }} | grep -oP "^spk/\K[^\/]*" | sort -u | xargs)" >> $GITHUB_OUTPUT
git diff-tree --no-commit-id --name-only -r ${{ github.sha }} | grep -oP "(cross|native)/[^\/]*" | sort -u | xargs
echo "dependency_folders=$(git diff-tree --no-commit-id --name-only -r ${{ github.sha }} | grep -oP "(cross|native)/[^\/]*" | sort -u | xargs)" >> $GITHUB_OUTPUT
- name: Evaluate dependencies
id: dependencies
run: ./.github/actions/prepare.sh
env:
GH_FILES: ${{ steps.getfile.outputs.files }} ${{ steps.getfile_pr.outputs.files }}
SPK_TO_BUILD: ${{ github.event.inputs.package }}
GH_SPK_PACKAGES: ${{ steps.getchanges_push.outputs.spk_packages }} ${{ steps.getchanges_pr.outputs.spk_packages }}
GH_DEPENDENCY_FOLDERS: ${{ steps.getchanges_push.outputs.dependency_folders }} ${{ steps.getchanges_pr.outputs.dependency_folders }}
USER_SPK_TO_BUILD: ${{ github.event.inputs.package }}

# Set default values for all builds (manual or automated)
- name: Set default values for generate matrix
Expand Down

0 comments on commit 2b552da

Please sign in to comment.