Skip to content

Commit

Permalink
chore: fix get_bench_jobs.sh (#9628)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludamad authored Nov 1, 2024
1 parent cb23cd3 commit abc424a
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions scripts/ci/get_bench_jobs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,31 @@ BRANCH=$1
# support labels with hyphens for backwards compatibility:
LABELS=$(echo $2 | sed 's/-/_/g')

# Function to parse YAML and extract test names
get_test_names() {
yq e '.tests | keys | .[]' yarn-project/end-to-end/scripts/e2e_test_config.yml
}

# Define the allow_list
allow_list=()

# Add labels from input to the allow_list
IFS=',' read -r -a input_labels <<< "$LABELS"
allow_list+=("${input_labels[@]}")

# Generate full list of targets on one line
full_list=$(earthly ls ./yarn-project/end-to-end | grep '+bench' | sed 's/+//' | xargs echo)
# Generate potential list of test targets on one line
test_list=$(get_test_names | grep 'bench' | xargs echo)

# If branch is master or allow_list contains 'bench-all', return full list
if [[ "$BRANCH" == "master" ]] || [[ " ${allow_list[@]} " =~ "bench-all" ]]; then
# print as JSON list
echo "$full_list" | jq -Rc 'split(" ")'
echo "$test_list" | jq -Rc 'split(" ")'
exit 0
fi

# Filter the full_list to include only items in the allow_list
# Filter the test_list to include only items in the allow_list
filtered_list=()
for item in $full_list; do
for item in $test_list; do
for allowed in "${allow_list[@]}"; do
if [[ "$item" == "$allowed" ]]; then
filtered_list+=("$item")
Expand Down

0 comments on commit abc424a

Please sign in to comment.