Repository navigation
ci: run shellcheck on shell scripts [WPB-8645] - #5630
Merged
Merged
Conversation
Fix every finding from shellcheck 0.9.0 and 0.11.0 on tracked shell scripts, keeping behavior the same: - Quote expansions, and use an array for the optional gradle --stacktrace flag in docker-agent/builder.sh. - Split local declarations from assignments. Add `|| true` where `grep -c` ends the pipeline, because it exits 1 on zero matches. - Delete `$?` checks that set -e already made unreachable. - Use read -r, find -print0 | xargs -0, and a glob instead of ls. - Disable a check with a reason where it reports a false positive (trap handler, GITHUB_ENV variables, ls -t mtime sort) or where the fix would change behavior (mktemp failure under set -e).
Run shellcheck on pull requests and in the merge queue. It checks every tracked .sh file and the Git hooks in .githooks/. git ls-files does not descend into the kalium submodule, which runs its own check.
yamilmedina
requested review from
Garzas and
ohassine
and removed request for
a team
December 3, 2026 11:44
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #5630 +/- ##
===========================================
- Coverage 56.99% 56.98% -0.01%
===========================================
Files 818 818
Lines 28491 28491
Branches 4401 4401
===========================================
- Hits 16238 16237 -1
Misses 10837 10837
- Partials 1416 1417 +1 see 1 file with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
Contributor
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
https://wearezeta.atlassian.net/browse/WPB-8645
Pitch me the changes
CI now runs shellcheck on our shell scripts, the same check Kalium added in wireapp/kalium#4836. The scripts that had findings are fixed, so the new check passes from day one, and the scripts behave the same as before.
Ticket: WPB-30201
Problems
.pre-commit-config.yamlalready has a shellcheck hook, but CI never runs it. Ondevelopthe tracked scripts have 51 findings with shellcheck 0.11.0 and 60 with 0.9.0, the version onubuntu-latest.Changes
ShellCheckworkflow runs on pull requests and in the merge queue. It checks every tracked.shfile and the hooks in.githooks/.git ls-filesdoes not go into thekaliumsubmodule, which has its own check.gradlewis generated, so it is left out.read -r,find -print0 | xargs -0, or splitlocal x=$(...)into a declaration and an assignment.Solution
grep -candset -e: inwire-apk-wrapper.sh,grep | wc -lbecamegrep -c ... || true.grep -cexits 1 when nothing matches, and after the declaration split that would stop the script underset -e.$?checks: inwire-apk-wrapper.shthese checks could never run, becauseset -ealready stops the script on the failed command. Exit behavior is the same.docker-agent/builder.shkeeps--stacktraceas an array, so it is still passed as its own argument and dropped when unset.traphandler inrun_ui_tests.shthat shellcheck thinks is unused;TEST_APP_IDandTEST_APK_PATH, which come fromGITHUB_ENV;ls -tthat sorts by modification time;local temp_dir=$(mktemp -d), where splitting would make amktempfailure fatal.Verification
developwith both versions.actionlintis clean on the new workflow.gradlew,apksigner,apktoolandadb. Output and exit codes matched forvalidate_apk_integrity(matching, missing-dex and missing-file APKs),resolve-test-apk-path(0, 1 and 2 APKs), thebuilder.sharguments with and without--stacktrace, andnew-feature-module.shin a scratch repo.develop. It found nothing blocking.scripts/qa/android-uihas 127 tests and 1 failure (http://[invalid]).develophas the same failure.apktool,apksigner,adband Docker agent flows, and the scripts on bash 5. Locally only bash 3.2 was available.Notes
resolve-test-apk-pathno longer prints thels: No such fileline. The error message and exit code are the same.For the reviewer
We already had shellcheck in pre-commit, but nobody was forced to run it, so the scripts piled up warnings. This PR makes CI run it on every PR and cleans up the existing warnings so it starts green. The fixes are mostly "put quotes around variables." Look closest at
scripts/dev/wire-apk-wrapper.sh: it has the most changes, and the|| trueand removed$?checks there are the only spots where the logic moved.