Skip to content

Commit

Permalink
fix: amend numbering so it's reflective of the workspace being used t…
Browse files Browse the repository at this point in the history
…o execute
  • Loading branch information
johnrwatson committed Oct 9, 2024
1 parent 354fb1b commit 6b6dea0
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions .github/workflows/run-api-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,24 @@ jobs:
run: |
# Find .ts files, remove ./ prefix, and format as JSON array
files=$(find "." -mindepth 1 -maxdepth 1 -type f -name "*.ts" | sed -r "s/\.\/(.*)\.ts/\1/")
# Get the number of tests
test_count=$(echo "$files" | wc -l)
# Get the list of workspace IDs from the environment variable
workspace_ids="${{ vars.API_TEST_WORKSPACE_IDS }}"
echo "workspace_ids found to be ${{ vars.API_TEST_WORKSPACE_IDS }}"
echo "workspace_ids found to be $workspace_ids"
workspace_count=$(echo "$workspace_ids" | tr ',' '\n' | wc -l)
# Validate that the number of workspace IDs matches the number of tests
if [ "$test_count" -ne "$workspace_count" ]; then
echo "Error: The number of workspace IDs ($workspace_count) does not match the number of tests ($test_count)."
exit 1
echo "Error: The number of workspace IDs ($workspace_count) does not match the number of tests ($test_count)."
exit 1
fi
# Format files as JSON array and output the result
indexed_files=$(echo "$files" | awk '{print "{\"name\": \"" $0 "\", \"index\": " NR-1 "}"}' | jq -s .)
# Format files as JSON array with correct numbering
indexed_files=$(echo "$files" | nl -w1 -s': ' | awk '{print "{\"name\": \"" substr($0, index($0,$2)) "\", \"index\": " $1-1 "}"}' | jq -s .)
# Ensure indexed_files are formatted correctly
test_output=$(echo "$indexed_files" | jq -c '.')
echo "tests=$test_output" >> "$GITHUB_OUTPUT"
echo "$test_output"
Expand Down

0 comments on commit 6b6dea0

Please sign in to comment.