From bb2d3d77e95adb2021e771fa0129f19336ceef61 Mon Sep 17 00:00:00 2001 From: Alex Huszagh Date: Thu, 2 Jun 2022 13:26:57 -0500 Subject: [PATCH] Add support for multiple bors targets. Allow using `bors try --target ... --target ...`, allowing multiple arguments rather than just a single one. --- .github/workflows/ci.yml | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8b4a074eb..8ef6a1441 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -92,11 +92,26 @@ jobs: declare -a "bors_args=(${bors_args})" fi - if [[ "${bors_args[0]-}" == --target ]]; then - echo "Only running targets matching '${bors_args[1]}'." - matrix="$( - target="${bors_args[1]}" yq --output-format json '[.[] | select(.target | test(env(target)))]' <<< "${matrix}" - )" + targets=() + index=0 + while [[ "${bors_args[$index]-}" == --target ]]; do + index=$(expr $index + 1) + targets+=("${bors_args[$index]}") + index=$(expr $index + 1) + done + + selects=() + for target in "${targets[@]}"; do + selects+=(".target == \"${target}\"") + done + query=$(printf " or %s" "${selects[@]}") + query="${query:4}" + + if [[ "${#targets[@]}" != "0" ]]; then + echo "Only running targets matching '${targets[@]}'." + matrix=$( + yq --output-format json '[.[] | select('"${query}"')]' <<< "${matrix}")" + ) else echo 'Running all targets.' matrix="$(yq --output-format json <<< "${matrix}")"