Skip to content

Commit

Permalink
PI-1414 use jq to merge and intersect
Browse files Browse the repository at this point in the history
  • Loading branch information
anthony-britton-moj committed Sep 27, 2023
1 parent 384865b commit dd1e3f8
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions .github/workflows/end-to-end-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ on:
# ^ add new projects here
# GitHub Actions doesn't support dynamic choices, we must add each project here to enable manual deployments
# See https://github.com/community/community/discussions/11795
env:
auto_pass_projects: '["manage-offences-and-delius"]'

jobs:
test:
Expand All @@ -82,8 +84,6 @@ jobs:
with:
repository: ministryofjustice/hmpps-probation-integration-e2e-tests
ref: ${{ inputs.test-branch }}
- name: Set auto-passing projects
run: echo 'auto_pass_projects=["manage-offences-and-delius"]' | tee -a "$GITHUB_ENV"
- name: Get tests to run - all tests
if: inputs.projects == '' || inputs.projects == 'All'
run: echo "projects=$(find projects -mindepth 1 -maxdepth 1 -printf "%f\n" | jq --raw-input . | jq --slurp --compact-output .)" | tee -a "$GITHUB_ENV"
Expand Down Expand Up @@ -150,12 +150,9 @@ jobs:
skipped_projects=$(echo "$all_projects" | jq -r '.[]' | while read -r project; do if [ ! -d "tests/$project" ]; then echo $project; fi; done | jq --raw-input . | jq --slurp --compact-output .)
failed_projects=$(jq -r '.suites[].specs[] | select(.ok == false).file' results.json | xargs -n1 dirname | sort -u | jq --raw-input . | jq --slurp --compact-output .)
passed_projects=$(jq --compact-output --null-input --argjson all "$all_projects" --argjson failed "$failed_projects" --argjson skipped "$skipped_projects" '{all: $all, failed: $failed, skipped: $skipped} | .all - .failed - .skipped')
merged=$(echo "$auto_pass_projects $passed_projects" | jq -s 'add')
passed_projects=$(echo "$merged $projects" | jq -sc '.[0] - (.[0] - .[1])')
fi
echo "$auto_pass_projects" | jq -c '.[]' | while read app; do
if [[ $(echo "$projects" | jq "any(.[]; . == $app)") == true ]]
then
passed_projects=$(echo "$passed_projects" | jq ". += [$app]")
fi
done
echo "skipped-projects=${skipped_projects:-'[]'}" | tee -a "$GITHUB_OUTPUT"
echo "failed-projects=${failed_projects:-'[]'}" | tee -a "$GITHUB_OUTPUT"
Expand Down

0 comments on commit dd1e3f8

Please sign in to comment.