{{ message }}
Fix and speed up check_submodules.sh#105053
Merged
Algunenano merged 9 commits intoMay 20, 2026
Merged
Conversation
The recursive-submodule check was unreachable: a preceding `[[ url != ... ]] && echo` inside a `cmd | while` block caused the pipeline to exit 1 on the last iteration when all URLs were valid, and `set -e` aborted the script before reaching the recursive check. The recursive check itself also only echoed without exiting. Switch each loop to `while ... done < <(cmd)` and replace the `&&` shorthand with `if ...; then echo; exit 1; fi` so the first violation is reported and exits 1, as intended.
Replace per-submodule `git submodule status -q "$path"` (131 forks, ~3.2s) with a single bulk `git submodule status -q` call (~0.1s). Merge the directory- existence loop with the recursive-submodule check so we iterate the submodule paths once instead of twice.
Contributor
thevar1able
approved these changes
May 15, 2026
Ergus
approved these changes
May 15, 2026
Ergus
left a comment
Member
There was a problem hiding this comment.
I like this change. It fixes two issues by simplifying and optimizing... heart for you @Algunenano
Member
Author
|
Welp, this isn't working because it's not triggering and failing the Style check |
The Style check job did not opt into the submodule cache, so submodule working trees were never populated. With no `contrib/<x>/.gitmodules` present, the recursive-submodule check silently passed even when a submodule pulled in nested submodules (as `contrib/silk` did). Two changes: - Opt `style_check` into `needs_submodules=True` so the cache is restored before the job runs. - Fail the script up front if any registered submodule has no `.git` gitlink file. Using `[ -e "$path/.git" ]` is ~250x faster than parsing `git submodule status` and is the exact signal we need.
This comment was marked as resolved.
This comment was marked as resolved.
The submodule cache restores .git/modules but does not check out the working trees, so check_submodules.sh would fail with "Submodule X is not initialized". Run `git submodule update --init` first.
Reading .gitmodules from each submodule's bare repo at .git/modules/<path> avoids the 93s of working-tree checkout that `git submodule update --init` did on every Style check run. The restored submodule cache already has each bare repo's HEAD pointing at the pinned commit, so `git show HEAD:.gitmodules` is enough. If a submodule isn't initialized, the script still fails fast with a clear message.
Reading .gitmodules from the bare repo's HEAD trusted that HEAD always matches the superproject's gitlink, which can drift if the bare repo gets touched out-of-band. Resolve every submodule's pinned SHA from the superproject up front with a single `git ls-tree HEAD`, then read .gitmodules at that exact SHA from each bare repo. Addresses review feedback on PR ClickHouse#105053.
`git show $sha:.gitmodules | grep -q ...` returns grep's exit code, so a missing pinned commit (incomplete/corrupted cache) silently looked like "no nested submodules". Add an explicit `git cat-file -e` check so a missing commit fails loudly. Addresses review feedback on PR ClickHouse#105053.
The check verifies `.gitmodules` (no recursive submodules, valid URLs, name == path). It requires submodules to be initialized, which made the style check ~20s slower because it had to download the submodule cache. Move it to the arm_tidy build, which already initializes submodules. Addresses ClickHouse#105053 (comment)
maxknv
approved these changes
May 20, 2026
Member
Member
Author
Merged
via the queue into
ClickHouse:master
with commit May 20, 2026
48b7d9f
162 of 166 checks passed
DavidHe-2008
pushed a commit
to DavidHe-2008/ClickHouse
that referenced
this pull request
Jun 1, 2026
The check verifies `.gitmodules` (no recursive submodules, valid URLs, name == path). It requires submodules to be initialized, which made the style check ~20s slower because it had to download the submodule cache. Move it to the arm_tidy build, which already initializes submodules. Addresses ClickHouse#105053 (comment)
DavidHe-2008
pushed a commit
to DavidHe-2008/ClickHouse
that referenced
this pull request
Jun 1, 2026
…ules-recursive Fix and speed up check_submodules.sh
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.


The recursive-submodule check in
ci/jobs/scripts/check_style/check_submodules.shwas unreachable: a preceding[[ url != ... ]] && echoline inside acmd | whileblock caused the pipeline to return 1 on the last iteration when all URLs were valid, andset -eaborted the script before reaching the recursive check. The recursive check itself only echoed without exiting either, so it would not have failed CI even if reached.The script now uses
while ... done < <(cmd)and explicitif ...; then echo; exit 1; fi, so the first violation is reported and the script exits 1. As a side effect it is also ~27× faster (3.2s → 0.12s), by replacing 131 per-submodulegit submodule status -q "$path"calls with a single bulkgit submodule status -q.Depends on #105052 — that PR removes the nested submodules currently sitting in
contrib/silk/contrib. Without it, this check would fail onmaster.Changelog category (leave one):
Version info
26.5.1.901