-
Notifications
You must be signed in to change notification settings - Fork 440
ci: Split Android build from rest #2145
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
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4beb034
check [nfc]: Pull out all_suites array
gnprice 7fb52e9
check [nfc]: Pull out is_suite function
gnprice f81b0fb
check: Add --exclude option, to exclude a particular suite
gnprice 9f62ce0
ci: Split Android suite from the rest
gnprice 62c5065
check: Print the time taken for each suite, when verbose
gnprice 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,6 +65,9 @@ What tests to run: | |
| \`git help revisions\` for many more ways to name a commit.) | ||
| --all In the given suites, run on all files. If no list of suites | ||
| was specified, run all suites. | ||
| --exclude SUITE | ||
| Don't run the given suite, despite \`--all\` | ||
| or the suite appearing as a positional argument. | ||
|
|
||
| Extra things to do, or skip doing: | ||
| --fix Fix issues found, where possible. | ||
|
|
@@ -82,10 +85,27 @@ EOF | |
| exit 2 | ||
| } | ||
|
|
||
| all_suites=( "${default_suites[@]}" "${extra_suites[@]}" ) | ||
|
|
||
| # usage: is_suite PUTATIVE_SUITE | ||
| # | ||
| # Succeeds just if the given argument is the name of a suite. | ||
| is_suite() { | ||
| needle="$1" | ||
| # This logic relies on the fact that the suite names have no spaces. | ||
|
|
||
| ! [[ "${needle}" =~ " " ]] \ | ||
| || return | ||
|
|
||
| # shellcheck disable=SC2076 # matching literally is the point | ||
| [[ " ${all_suites[*]} " =~ " ${needle} " ]] | ||
| } | ||
|
|
||
| orig_cmdline="$0 $*" | ||
|
|
||
| opt_files=branch | ||
| opt_all= | ||
| opt_exclude=() | ||
| opt_fix= | ||
| opt_no_pub= | ||
| opt_output=default | ||
|
|
@@ -95,13 +115,14 @@ while (( $# )); do | |
| --diff) shift; opt_files=diff:"$1"; shift;; | ||
| --all-files) opt_files=all; shift;; | ||
| --all) opt_files=all; opt_all=1; shift;; | ||
| --exclude) shift; if ! is_suite "$1"; then usage; else | ||
| opt_exclude+=("$1"); shift; fi;; | ||
| --fix) opt_fix=1; shift;; | ||
| --no-pub) opt_no_pub=1; shift;; | ||
| --output) shift; opt_output="$1"; shift;; | ||
| --verbose) opt_output=verbose; shift;; | ||
| analyze|test|flutter_version|build_runner|l10n|drift|pigeon|icons|android|shellcheck) | ||
| opt_suites+=("$1"); shift;; | ||
| *) usage;; | ||
| *) if ! is_suite "$1"; then usage; else | ||
| opt_suites+=("$1"); shift; fi;; | ||
| esac | ||
| done | ||
|
|
||
|
|
@@ -115,12 +136,23 @@ esac | |
|
|
||
| if (( ! "${#opt_suites[@]}" )); then | ||
| if [ -n "${opt_all}" ]; then | ||
| opt_suites=( "${default_suites[@]}" "${extra_suites[@]}" ) | ||
| opt_suites=( "${all_suites[@]}" ) | ||
| else | ||
| opt_suites=( "${default_suites[@]}" ) | ||
| fi | ||
| fi | ||
|
|
||
| if (( "${#opt_exclude[@]}" )); then | ||
| # This logic relies on suite names having no spaces nor glob characters. | ||
| suites_str=" ${opt_suites[*]} " | ||
| for suite in "${opt_exclude[@]}"; do | ||
| suites_str="${suites_str/ "$suite" / }" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TIL, neat. |
||
| done | ||
| # shellcheck disable=SC2206 # see comment at top of block | ||
| opt_suites=( ${suites_str} ) | ||
| (( "${#opt_suites[@]}" )) || usage | ||
| fi | ||
|
|
||
| files_base_commit= | ||
| # shellcheck disable=SC2119 # this is a silly warning | ||
| case "$opt_files" in | ||
|
|
@@ -149,6 +181,21 @@ if_verbose() { | |
| fi | ||
| } | ||
|
|
||
| # usage: maybe_time LABEL COMMAND... | ||
| # | ||
| # Run the given command. | ||
| # Then if $opt_verbose, print the command's elapsed time, | ||
| # including the given label. | ||
| maybe_time() { | ||
| label="$1"; shift | ||
| if [ -z "${opt_verbose}" ]; then | ||
| "$@" | ||
| else | ||
| local TIMEFORMAT=$'\n'$"${label} elapsed time: %1lR" | ||
| time "$@" | ||
| fi | ||
| } | ||
|
|
||
| # usage: grep_quiet_hungry GREP_ARGUMENTS... | ||
| # | ||
| # Just like `grep --quiet` aka `grep -q`, except this consumes the | ||
|
|
@@ -533,16 +580,17 @@ for suite in "${opt_suites[@]}"; do | |
| if_verbose echo "${divider_line}" | ||
| echo "Running $suite..." | ||
| case "$suite" in | ||
| analyze) run_analyze ;; | ||
| test) run_test ;; | ||
| flutter_version) run_flutter_version ;; | ||
| build_runner) run_build_runner ;; | ||
| l10n) run_l10n ;; | ||
| drift) run_drift ;; | ||
| pigeon) run_pigeon ;; | ||
| icons) run_icons ;; | ||
| android) run_android ;; | ||
| shellcheck) run_shellcheck ;; | ||
| analyze) maybe_time "$suite" run_analyze ;; | ||
| test) maybe_time "$suite" run_test ;; | ||
| flutter_version) | ||
| maybe_time "$suite" run_flutter_version ;; | ||
| build_runner) maybe_time "$suite" run_build_runner ;; | ||
| l10n) maybe_time "$suite" run_l10n ;; | ||
| drift) maybe_time "$suite" run_drift ;; | ||
| pigeon) maybe_time "$suite" run_pigeon ;; | ||
| icons) maybe_time "$suite" run_icons ;; | ||
| android) maybe_time "$suite" run_android ;; | ||
| shellcheck) maybe_time "$suite" run_shellcheck ;; | ||
| *) echo >&2 "Internal error: unknown suite $suite" ;; | ||
| esac || failed+=( "$suite" ) | ||
| done | ||
|
|
||
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.
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.
Cool. We may do something similar for iOS builds in CI, where the Actions job will run on
macosimage instead.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.
Yeah. That's #773 — probably a good idea to do that soon, given the work you're doing that adds more iOS code. I've moved it up to this milestone (was in the upcoming M9).