-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
chore(scripts/run-docker): implement dry run simulation to skip launching container if no packages would have been built #24168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,87 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -e -u | ||
|
|
||
| # This script is in '$TERMUX_SCRIPTDIR/scripts/bin/'. | ||
| TERMUX_SCRIPTDIR=$(cd "$(realpath "$(dirname "$0")")"; cd ../..; pwd) | ||
| DRY_RUN_SCRIPT_NAME=$(basename "$0") | ||
| BUILDSCRIPT_NAME="build-package.sh" | ||
| TERMUX_ARCH="aarch64" | ||
| TERMUX_DEBUG_BUILD="false" | ||
| TERMUX_PACKAGES_DIRECTORIES=" | ||
| packages | ||
| root-packages | ||
| x11-packages | ||
| " | ||
|
|
||
| # Please keep synchronized with the logic of lines 468-547 of 'build-package.sh'. | ||
| declare -a PACKAGE_LIST=() | ||
robertkirkman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| while (($# >= 1)); do | ||
| case "$1" in | ||
| *"/$BUILDSCRIPT_NAME") ;; | ||
| -a) | ||
| if [ $# -lt 2 ]; then | ||
| echo "$DRY_RUN_SCRIPT_NAME: Option '-a' requires an argument" | ||
| exit 1 | ||
| fi | ||
| shift 1 | ||
| if [ -z "$1" ]; then | ||
| echo "$DRY_RUN_SCRIPT_NAME: Argument to '-a' should not be empty." | ||
| exit 1 | ||
| fi | ||
| TERMUX_ARCH="$1" | ||
| ;; | ||
| -d) TERMUX_DEBUG_BUILD="true" ;; | ||
| -*) ;; | ||
| *) PACKAGE_LIST+=("$1") ;; | ||
| esac | ||
| shift 1 | ||
| done | ||
|
|
||
| # Please keep synchronized with the logic of lines 592-656 of 'build-package.sh'. | ||
| for ((i=0; i<${#PACKAGE_LIST[@]}; i++)); do | ||
| TERMUX_PKG_NAME=$(basename "${PACKAGE_LIST[i]}") | ||
| TERMUX_PKG_BUILDER_DIR= | ||
| for package_directory in $TERMUX_PACKAGES_DIRECTORIES; do | ||
| if [ -d "${TERMUX_SCRIPTDIR}/${package_directory}/${TERMUX_PKG_NAME}" ]; then | ||
| TERMUX_PKG_BUILDER_DIR="${TERMUX_SCRIPTDIR}/$package_directory/$TERMUX_PKG_NAME" | ||
| break | ||
| fi | ||
| done | ||
| if [ -z "${TERMUX_PKG_BUILDER_DIR}" ]; then | ||
| echo "$DRY_RUN_SCRIPT_NAME: No package $TERMUX_PKG_NAME found in any of the enabled repositories. Are you trying to set up a custom repository?" | ||
| exit 1 | ||
| fi | ||
| TERMUX_PKG_BUILDER_SCRIPT="$TERMUX_PKG_BUILDER_DIR/build.sh" | ||
|
|
||
| # Please keep synchronized with the logic of lines 2-50 of 'scripts/build/termux_step_start_build.sh'. | ||
| if [ "${TERMUX_ARCH}" != "all" ] && \ | ||
| grep -qE "^TERMUX_PKG_EXCLUDED_ARCHES=.*${TERMUX_ARCH}" "$TERMUX_PKG_BUILDER_SCRIPT"; then | ||
| echo "$DRY_RUN_SCRIPT_NAME: Skipping building $TERMUX_PKG_NAME for arch $TERMUX_ARCH" | ||
| continue | ||
| fi | ||
|
|
||
| if [ "${TERMUX_DEBUG_BUILD}" = "true" ] && \ | ||
| grep -qE "^TERMUX_PKG_HAS_DEBUG=.*false" "$TERMUX_PKG_BUILDER_SCRIPT"; then | ||
| echo "$DRY_RUN_SCRIPT_NAME: Skipping building debug build for $TERMUX_PKG_NAME" | ||
| continue | ||
| fi | ||
|
|
||
| echo "$DRY_RUN_SCRIPT_NAME: Ending dry run simulation ($BUILDSCRIPT_NAME would have continued building $TERMUX_PKG_NAME)" | ||
| exit 0 | ||
| done | ||
|
|
||
| if [ ${#PACKAGE_LIST[@]} -gt 0 ]; then | ||
| # At least one package name was parsed, but none of them reached "exit 0", | ||
| # so exit with return value 85 (EX_C__NOOP) to indicate that no packages would have been built. | ||
| echo "$DRY_RUN_SCRIPT_NAME: Ending dry run simulation ($BUILDSCRIPT_NAME would not have built any packages)" | ||
robertkirkman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| exit 85 # EX_C__NOOP | ||
| fi | ||
|
|
||
| # If this point is reached, assume that a combination of arguments | ||
| # that is either invalid or is not implemented in this script | ||
| # has been used, and that the real 'build-package.sh' | ||
| # needs to be run so that its own parser can interpret the arguments | ||
| # and display the appropriate message. | ||
| echo "$DRY_RUN_SCRIPT_NAME: Ending dry run simulation (unknown arguments, pass to the real $BUILDSCRIPT_NAME for more information)" | ||
| exit 0 | ||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume that this would be the appropriate place to enable this in CI.
I have tested this on my own GitHub Actions in this run, on the
eclpackage, which hasTERMUX_PKG_EXCLUDED_ARCHES="i686, x86_64":https://github.com/robertkirkman/termux-packages/actions/runs/16082984132/job/45390315328
It is working. What happens in practice is, for the
i686andx86_64jobs, the "build" workflow step very quickly completes without building anything, but showing a green success mark, not red failed or gray skipped, and an artifact does upload. However, what is in the artifact is just nothing except a.placeholderfile, which is empty, and abuilt_termux-main_packages.txtfile, which contains the list of packages that would have been built if the build were not skipped, in this test "ecl".@twaik do you think this is proper behavior to happen, or should it be adjusted to be different in any way?