@@ -28,10 +28,16 @@ if [ "$TOOLCHAIN" = "nightly" ] ; then
2828 rustup component add rust-src
2929fi
3030
31+ # Print GHA workflow commands
32+ echo_if_ci () {
33+ # Discard stderr so the "set -x" trace doesn't show up
34+ { [ -n " ${CI:- } " ] && echo " $1 " ; } 2> /dev/null
35+ }
36+
3137# Run the tests for a specific target
3238test_target () {
33- target=" ${1} "
34- no_dist=" ${2 :- 0} "
39+ target=" $1 "
40+ no_dist=" $2 "
3541
3642 RUSTFLAGS=" ${RUSTFLAGS:- } "
3743
@@ -265,7 +271,13 @@ case "$rust" in
265271 * ) supports_wasi_pn=0 ;;
266272esac
267273
268- for target in $targets ; do
274+ some_tests_run=0
275+
276+ # Apply the `FILTER` variable, do OS-specific tasks, and run a target
277+ filter_and_run () {
278+ target=" $1 "
279+ no_dist=" ${2:- 0} "
280+
269281 if echo " $target " | grep -q " $filter " ; then
270282 if [ " $os " = " windows" ]; then
271283 TARGET=" $target " ./ci/install-rust.sh
@@ -278,27 +290,28 @@ for target in $targets; do
278290
279291 # `wasm32-wasip2` only exists in recent versions of Rust
280292 if [ " $target " = " wasm32-wasip2" ] && [ " $supports_wasi_pn " = " 0" ]; then
281- continue
293+ return
282294 fi
283295
284- test_target " $target "
285- test_run =1
296+ test_target " $target " " $no_dist "
297+ some_tests_run =1
286298 fi
299+ }
300+
301+ for target in $targets ; do
302+ echo_if_ci " ::group::Target: $target "
303+ filter_and_run " $target "
304+ echo_if_ci " ::endgroup::"
287305done
288306
289307for target in ${no_dist_targets:- } ; do
290- if echo " $target " | grep -q " $filter " ; then
291- if [ " $os " = " windows" ]; then
292- TARGET=" $target " ./ci/install-rust.sh
293- fi
294-
295- test_target " $target " 1
296- test_run=1
297- fi
308+ echo_if_ci " ::group::Target: $target "
309+ filter_and_run " $target " 1
310+ echo_if_ci " ::endgroup::"
298311done
299312
300313# Make sure we didn't accidentally filter everything
301- if [ " ${test_run :- } " != 1 ]; then
314+ if [ " $some_tests_run " != 1 ]; then
302315 echo " No tests were run"
303316 exit 1
304317fi
0 commit comments