Skip to content

Commit

Permalink
Rollup merge of rust-lang#92214 - ehuss:submodule-bg-exit, r=Mark-Sim…
Browse files Browse the repository at this point in the history
…ulacrum

Error if submodule fetch fails.

In CI, if fetching a submodule fails, the script would exit successfully. Later parts of the build will fail due to the missing files, but it is a bit confusing, and I think it would be better to error out earlier.

The reason is that in bash, `wait` without arguments will exit 0 even if a background job exits with an error. The solution here is to wait on each individual job, which will return the exit code of the job.

This was encountered in rust-lang#92177.
  • Loading branch information
matthiaskrgr committed Feb 28, 2022
2 parents 427cf81 + 1233ab7 commit dc97586
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/ci/init_repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ for i in ${!modules[@]}; do
url=${urls[$i]}
url=${url/\.git/}
fetch_github_commit_archive $module "$url/archive/$commit.tar.gz" &
bg_pids[${i}]=$!
continue
else
use_git="$use_git $module"
Expand All @@ -70,4 +71,9 @@ done
retry sh -c "git submodule deinit -f $use_git && \
git submodule sync && \
git submodule update -j 16 --init --recursive $use_git"
wait
STATUS=0
for pid in ${bg_pids[*]}
do
wait $pid || STATUS=1
done
exit ${STATUS}

0 comments on commit dc97586

Please sign in to comment.