Run iOS build in CI#2307
Conversation
c94e750 to
9999dfc
Compare
chrisbobbe
left a comment
There was a problem hiding this comment.
Thanks, this should be helpful!
Could #329 be done by basically just adding a check_no_changes call at the end of the new ios suite? That would be another nice win for our CI coverage of iOS.
| - name: Install dependencies | ||
| run: brew install coreutils bash shellcheck |
There was a problem hiding this comment.
Interesting; I guess the need for coreutils and bash is explained in tools/lib/ensure-shell-deps.sh. Would you add a comment about that?
I'm not sure that shellcheck is needed; doesn't that get run in the "analyze, test, generate" job?
| # iOS builds require macOS and Xcode. | ||
| if [ "$(uname -s)" != "Darwin" ]; then | ||
| if_verbose echo "Skipping ios suite (not on macOS)." | ||
| return 0 | ||
| fi |
There was a problem hiding this comment.
In non-verbose mode, I think we'd ideally omit the "Skipping ios suite" and also the "Running ios..." line that precedes it. If omitting "Running ios..." seems complicated, I think it would be better to just log both lines, i.e. cut the if_verbose condition here.
| xcrun swift-format lint --strict \ | ||
| --configuration ios/.swift-format \ | ||
| "${swift_targets[@]}" \ | ||
| || return |
There was a problem hiding this comment.
Could we wire this up such that tools/check ios --fix causes the lint issues to be fixed?
| @@ -34,7 +34,7 @@ default_suites=( | |||
| analyze test | |||
| flutter_version | |||
| build_runner l10n drift pigeon icons | |||
| android # This takes multiple minutes in CI, so do it last. | |||
| android ios # These take multiple minutes in CI, so do them last. | |||
There was a problem hiding this comment.
nit: this file's convention seems to be two spaces before "#"
| // Compile Swift with "-warnings-as-errors"; but only in release builds. | ||
| SWIFT_TREAT_WARNINGS_AS_ERRORS = YES |
There was a problem hiding this comment.
Interesting. Do debug and release builds give different warnings? What's the motivation for only doing this in release builds?
There was a problem hiding this comment.
This is similar to what we currently have for Android:
zulip-flutter/android/app/build.gradle
Lines 94 to 102 in a48fad2
There was a problem hiding this comment.
The motivation is to not get in the way of quick local experiments for debugging? Seems reasonable; let's note that in a code comment if so.
4ac1344 to
5ab714a
Compare
|
Thanks for the review @chrisbobbe! Pushed an update, PTAL. |
chrisbobbe
left a comment
There was a problem hiding this comment.
Not a full review (I'll come back for that soon), but I didn't want to lose track of an idea I had just now 🙂—
| run: tools/ci/clone-flutter-sdk | ||
|
|
||
| - name: Download Flutter SDK artifacts (flutter precache) | ||
| run: flutter precache --universal |
There was a problem hiding this comment.
Can we save time by doing flutter precache --ios instead?
If so, then probably we can do the corresponding thing for the Android-only workflow. (Can we even skip flutter precache for the "analyze, test, generate" workflow, which doesn't do either build?)
There was a problem hiding this comment.
From the output of flutter precache --help there doesn't seem to be an option for android, but actually flutter precache seems unnecessary in CI because Flutter tooling can automatically download only the required SDK artifacts for the invoked command. So, I think we can remove flutter precache step from all the jobs.
5ab714a to
f4bb7df
Compare
|
Thanks! Pushed an update, PTAL. |
chrisbobbe
left a comment
There was a problem hiding this comment.
Thanks! Comments below, mostly small.
| # Required by tools/lib/ensure-shell-deps.sh | ||
| run: brew install coreutils bash |
There was a problem hiding this comment.
The reference in the comment is helpful, because it helps the reader infer why we add this step in the iOS workflow but not the others. The reason is buried in the fourth paragraph of a long comment in tools/lib/ensure-shell-deps.sh, though, which makes it harder to discover:
# So this is really all about macOS, which comes with an ancient
# Bash 3.2.57 dating to 2007 and an '80s-style BSD utility suite.
# […]So let's paraphrase it in the comment here. E.g.:
| # Required by tools/lib/ensure-shell-deps.sh | |
| run: brew install coreutils bash | |
| # Modern Bash and coreutils don't come with macOS; get those. | |
| # (See tools/lib/ensure-shell-deps.sh.) | |
| run: brew install coreutils bash |
| - name: Download Flutter SDK artifacts (flutter precache) | ||
| run: flutter precache --universal |
There was a problem hiding this comment.
git grep precache shows a dangling reference to flutter precache in tools/check.
| "${swift_targets[@]}" \ | ||
| || return | ||
|
|
||
| check_no_changes "changes to swift files (swift-format)" ios/'*'.swift \ |
There was a problem hiding this comment.
nit in dev-facing string:
| check_no_changes "changes to swift files (swift-format)" ios/'*'.swift \ | |
| check_no_changes "changes to Swift files (swift-format)" ios/'*'.swift \ |
(Capitalize the name of the Swift programming language.)
| check_no_changes "changes to ios" ios/ \ | ||
| || return |
There was a problem hiding this comment.
nit: can be clearer that concretely the ios/ directory is meant:
| check_no_changes "changes to ios" ios/ \ | |
| || return | |
| check_no_changes "changes to ios/" ios/ \ | |
| || return |
| if_verbose echo "Checking for style issues in Swift code..." | ||
|
|
||
| check_no_uncommitted_or_untracked ios/'*'.swift \ | ||
| || return |
There was a problem hiding this comment.
If the user accidentally left some uncommitted or untracked changes, then this check_no_uncommitted_or_untracked will fail. But that failure will come right after the tool logs "Checking for style issues in Swift code...", which seems like it would be misleading—there aren't necessarily any style issues, and the style-check hasn't even happened yet.
Probably the fix is to switch the order of these.
| if_verbose echo "Checking for automated changes from Flutter tooling..." | ||
|
|
||
| check_no_uncommitted_or_untracked ios/ \ | ||
| || return |
There was a problem hiding this comment.
Similarly here, about failing right after the log "automated changes from Flutter tooling" when the command that might produce the automated changes hasn't run yet.
| # TODO: Once we have a dedicated code formatting check, | ||
| # move this swift-format check there. | ||
| xcrun swift-format format --in-place \ | ||
| --configuration ios/.swift-format \ | ||
| "${swift_targets[@]}" \ | ||
| || return |
There was a problem hiding this comment.
| # TODO: Once we have a dedicated code formatting check, | |
| # move this swift-format check there. | |
| xcrun swift-format format --in-place \ | |
| --configuration ios/.swift-format \ | |
| "${swift_targets[@]}" \ | |
| || return | |
| # --in-place enables `tools/check --fix ios`; see `check_no_changes`. | |
| # TODO: Once we have a dedicated code formatting check, | |
| # move this swift-format check there. | |
| xcrun swift-format format --in-place \ | |
| --configuration ios/.swift-format \ | |
| "${swift_targets[@]}" \ | |
| || return |
| // Compile Swift with "-warnings-as-errors"; but only in release builds. | ||
| SWIFT_TREAT_WARNINGS_AS_ERRORS = YES |
| if_verbose echo "Checking for automated changes from Flutter tooling..." | ||
|
|
||
| check_no_uncommitted_or_untracked ios/ \ | ||
| || return | ||
|
|
||
| flutter build ios "${codesign_opt[@]}" --config-only \ | ||
| || return | ||
|
|
||
| check_no_changes "changes to ios" ios/ \ | ||
| || return |
There was a problem hiding this comment.
check: In iOS, check for automated changes from Flutter tooling
Fixes-partly #329, for iOS.
I see. "Partly" is just because the issue also says flutter build macos --config-only, and we don't do that here; right?
Would the following work, for that?
| if_verbose echo "Checking for automated changes from Flutter tooling..." | |
| check_no_uncommitted_or_untracked ios/ \ | |
| || return | |
| flutter build ios "${codesign_opt[@]}" --config-only \ | |
| || return | |
| check_no_changes "changes to ios" ios/ \ | |
| || return | |
| if_verbose echo "Checking for automated changes from Flutter tooling..." | |
| check_no_uncommitted_or_untracked ios/ macos/ \ | |
| || return | |
| flutter build ios "${codesign_opt[@]}" --config-only \ | |
| || return | |
| # Check macos/ too, because desktop platforms are supported for dev: | |
| # https://github.com/zulip/zulip-flutter#desktop-support | |
| # (This could live in its own suite. If doing that, we'd probably | |
| # still want to run it in the same GitHub CI workflow as the iOS build, | |
| # since GitHub's macOS-based runners use a lot of our free quota: | |
| # https://github.com/zulip/zulip-flutter/issues/329#issue-1950704934 | |
| # .) | |
| flutter build macos "${codesign_opt[@]}" --config-only \ | |
| || return | |
| check_no_changes "changes to ios" ios/ \ | |
| || return | |
| check_no_changes "changes to macos" macos/ \ | |
| || return |
| check_no_uncommitted_or_untracked ios/ \ | ||
| || return | ||
|
|
||
| flutter build ios "${codesign_opt[@]}" --config-only \ |
There was a problem hiding this comment.
Not sure if we want to pass through the --no-pub option to these flutter build commands, like we do for flutter test and flutter analyze—what do you think?
There was a problem hiding this comment.
Good catch! I think we should pass through --no-pub option, otherwise each flutter build command will unnecessarily run pub get: flutter build ios --config-only, flutter build macos --config-only and finally flutter build ipa.
68911ca to
870670f
Compare
|
Thanks for the review @chrisbobbe! Pushed an update, PTAL. |
1fc6e07 to
169b362
Compare
chrisbobbe
left a comment
There was a problem hiding this comment.
Thanks!
Using Claude's /code-review slash-command, I noticed one wart that Claude claims our other suites don't have: if some Swift code has formatting issues, then tools/check ios --fix will make changes in-place and then immediately fail with the message "Aborting, to avoid losing your work." That could be confusing (the changes aren't "your work"), and it'd be better to not do that.
But this only bites when you pass --fix, and we touch the Swift code relatively infrequently, and we don't pass --fix in CI. so I'll go ahead and merge this to clear #773 and #329, after fixing the one nit below. Then, since I've got some commits from my Claude session to address the --fix wart and a few other small things, I'll send those as a separate PR.
| # it's fast subsequent times.) That's even after Flutter tool's | ||
| # binary artifacts already downloaded (in CI, that's downloaded | ||
| # during `flutter pub get` step). |
There was a problem hiding this comment.
| # it's fast subsequent times.) That's even after Flutter tool's | |
| # binary artifacts already downloaded (in CI, that's downloaded | |
| # during `flutter pub get` step). | |
| # it's fast subsequent times.) That's even when the Flutter tool's | |
| # binary artifacts have already been downloaded (which, in CI, | |
| # happens during the `flutter pub get` step). |
4421708 to
f889302
Compare
This step is unnecessary because Flutter tooling can automatically download only the required SDK artifacts for the invoked command. [chris: tweaked comment for grammar] Co-authored-by: Chris Bobbe <cbobbe@zulip.com>
The suite only runs on macOS; on other platforms it is skipped with an appropriate message logged.
f889302 to
6f4427c
Compare
|
Done, after rebasing atop current |
|
And sent #2333. |
Fixes #773.
Fixes #329.