Skip to content

Commit 8769f4e

Browse files
committed
Auto merge of #92214 - ehuss:submodule-bg-exit, r=Mark-Simulacrum
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 #92177.
2 parents 08504c6 + 43f83bc commit 8769f4e

File tree

3 files changed

+25
-14
lines changed

3 files changed

+25
-14
lines changed

.github/workflows/ci.yml

+9-9
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ jobs:
104104
- name: disable git crlf conversion
105105
run: src/ci/scripts/disable-git-crlf-conversion.sh
106106
if: success() && !env.SKIP_JOB
107+
- name: checkout submodules
108+
run: src/ci/scripts/checkout-submodules.sh
109+
if: success() && !env.SKIP_JOB
107110
- name: install MSYS2
108111
run: src/ci/scripts/install-msys2.sh
109112
if: success() && !env.SKIP_JOB
@@ -119,9 +122,6 @@ jobs:
119122
- name: disable git crlf conversion
120123
run: src/ci/scripts/disable-git-crlf-conversion.sh
121124
if: success() && !env.SKIP_JOB
122-
- name: checkout submodules
123-
run: src/ci/scripts/checkout-submodules.sh
124-
if: success() && !env.SKIP_JOB
125125
- name: ensure line endings are correct
126126
run: src/ci/scripts/verify-line-endings.sh
127127
if: success() && !env.SKIP_JOB
@@ -502,6 +502,9 @@ jobs:
502502
- name: disable git crlf conversion
503503
run: src/ci/scripts/disable-git-crlf-conversion.sh
504504
if: success() && !env.SKIP_JOB
505+
- name: checkout submodules
506+
run: src/ci/scripts/checkout-submodules.sh
507+
if: success() && !env.SKIP_JOB
505508
- name: install MSYS2
506509
run: src/ci/scripts/install-msys2.sh
507510
if: success() && !env.SKIP_JOB
@@ -517,9 +520,6 @@ jobs:
517520
- name: disable git crlf conversion
518521
run: src/ci/scripts/disable-git-crlf-conversion.sh
519522
if: success() && !env.SKIP_JOB
520-
- name: checkout submodules
521-
run: src/ci/scripts/checkout-submodules.sh
522-
if: success() && !env.SKIP_JOB
523523
- name: ensure line endings are correct
524524
run: src/ci/scripts/verify-line-endings.sh
525525
if: success() && !env.SKIP_JOB
@@ -615,6 +615,9 @@ jobs:
615615
- name: disable git crlf conversion
616616
run: src/ci/scripts/disable-git-crlf-conversion.sh
617617
if: success() && !env.SKIP_JOB
618+
- name: checkout submodules
619+
run: src/ci/scripts/checkout-submodules.sh
620+
if: success() && !env.SKIP_JOB
618621
- name: install MSYS2
619622
run: src/ci/scripts/install-msys2.sh
620623
if: success() && !env.SKIP_JOB
@@ -630,9 +633,6 @@ jobs:
630633
- name: disable git crlf conversion
631634
run: src/ci/scripts/disable-git-crlf-conversion.sh
632635
if: success() && !env.SKIP_JOB
633-
- name: checkout submodules
634-
run: src/ci/scripts/checkout-submodules.sh
635-
if: success() && !env.SKIP_JOB
636636
- name: ensure line endings are correct
637637
run: src/ci/scripts/verify-line-endings.sh
638638
if: success() && !env.SKIP_JOB

src/ci/github-actions/ci.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ x--expand-yaml-anchors--remove:
169169
run: src/ci/scripts/disable-git-crlf-conversion.sh
170170
<<: *step
171171

172+
- name: checkout submodules
173+
run: src/ci/scripts/checkout-submodules.sh
174+
<<: *step
175+
172176
- name: install MSYS2
173177
run: src/ci/scripts/install-msys2.sh
174178
<<: *step
@@ -194,10 +198,6 @@ x--expand-yaml-anchors--remove:
194198
run: src/ci/scripts/disable-git-crlf-conversion.sh
195199
<<: *step
196200

197-
- name: checkout submodules
198-
run: src/ci/scripts/checkout-submodules.sh
199-
<<: *step
200-
201201
- name: ensure line endings are correct
202202
run: src/ci/scripts/verify-line-endings.sh
203203
<<: *step

src/ci/init_repo.sh

+12-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ function fetch_github_commit_archive {
4343
curl -f -sSL -o $cached $2"
4444
mkdir $module
4545
touch "$module/.git"
46+
# On Windows, the default behavior is to emulate symlinks by copying
47+
# files. However, that ends up being order-dependent while extracting,
48+
# which can cause a failure if the symlink comes first. This env var
49+
# causes tar to use real symlinks instead, which are allowed to dangle.
50+
export MSYS=winsymlinks:nativestrict
4651
tar -C $module --strip-components=1 -xf $cached
4752
rm $cached
4853
}
@@ -62,6 +67,7 @@ for i in ${!modules[@]}; do
6267
url=${urls[$i]}
6368
url=${url/\.git/}
6469
fetch_github_commit_archive $module "$url/archive/$commit.tar.gz" &
70+
bg_pids[${i}]=$!
6571
continue
6672
else
6773
use_git="$use_git $module"
@@ -70,4 +76,9 @@ done
7076
retry sh -c "git submodule deinit -f $use_git && \
7177
git submodule sync && \
7278
git submodule update -j 16 --init --recursive $use_git"
73-
wait
79+
STATUS=0
80+
for pid in ${bg_pids[*]}
81+
do
82+
wait $pid || STATUS=1
83+
done
84+
exit ${STATUS}

0 commit comments

Comments
 (0)