Skip to content

Commit

Permalink
refactor(wip): function
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg O'Grady committed Nov 15, 2024
1 parent 0844b73 commit d0a45e9
Showing 1 changed file with 15 additions and 23 deletions.
38 changes: 15 additions & 23 deletions src/jobs/e2e/collect-e2e-logs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,30 +84,22 @@ steps:
- run:
name: Wait for smoke test jobs to complete
command: |
FILTER=$(cat \<<EOF
(\$jobstr | split(",")) as \$jobs |
.items
| sort_by(.status, .started_at, .name)[]
| select(
.name as \$name |
\$jobs | index(\$name)
JOBS=$(paste -sd '|' \<<<"<< parameters.smoke-test-jobs >>")
function running_jobs() {
DATE=$(date -u)
FILTERED_JOBS=$(
curl "https://circleci.com/api/v2/workflow/$CIRCLE_WORKFLOW_ID/job" \
--silent \
--location \
--request GET \
--header "Circle-Token: $CIRCLE_TOKEN"
| jq -cr ".items[] | { status, started_at, name }"
| grep -E "\"name\": \"($JOBS)\""
)
| { status, started_at, name }
EOF
)
while [[ $(
date -u >job-status.log ; \
curl "https://circleci.com/api/v2/workflow/$CIRCLE_WORKFLOW_ID/job" \
--silent \
--location \
--request GET \
--header "Circle-Token: $CIRCLE_TOKEN" \
| jq -cr --arg jobstr "<< parameters.smoke-test-jobs >>" "$FILTER" \
| tee -a job-status.log \
| jq -sr 'map(select(.status == "running")) | length'
) -gt 0 ]]; do
cat job-status.log
echo "$DATE - \n${FILTERED_JOBS}"
return grep -qE '"status": "running"' \<<<"$FILTERED_JOBS"
}
while running_jobs ; do
sleep 5
done
Expand Down

0 comments on commit d0a45e9

Please sign in to comment.