Skip to content

Commit

Permalink
Add rapids-check-pr-job-dependencies script (#30)
Browse files Browse the repository at this point in the history
This PR adds a new script, `rapids-check-pr-job-dependencies`.

This script is intended to be used in a new check job in the
`shared-action-workflows` repository.

The script checks the `pr-builder` job in the `pr.yaml` workflow file to
ensure that it depends on all of the other jobs in the workflow file.

This is necessary because our branch protections are configured to
depend on the `pr-builder` job, so it's implied that that job will
depend on all of the other jobs in the workflow.

Depends on rapidsai/ci-imgs#30.
  • Loading branch information
ajschmidt8 authored Dec 31, 2022
1 parent 4664eb1 commit ab18a78
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
26 changes: 26 additions & 0 deletions tools/rapids-check-pr-job-dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
# Checks whether a particular GitHub workflow job depends on all of the
# other jobs in the workflow.
#
# This is necessary since the RAPIDS branch protections are configured to require
# the "pr-builder" job to pass for all PRs. It's implied that that job depends
# on all other jobs in the workflow.
set -euo pipefail

export WORKFLOW_FILE=${WORKFLOW_FILE:-".github/workflows/pr.yaml"}
export PR_BUILDER_JOB_NAME=${PR_BUILDER_JOB_NAME:-"pr-builder"}

WORKFLOW_JOBS=$(yq '((.jobs | keys | sort) - [env(PR_BUILDER_JOB_NAME)]) | join(" ")' "${WORKFLOW_FILE}")

PR_BUILDER_JOB_NEEDS=$(yq '(.jobs.[env(PR_BUILDER_JOB_NAME)].needs | sort) | join(" ")' "${WORKFLOW_FILE}")

if [ "${WORKFLOW_JOBS}" != "${PR_BUILDER_JOB_NEEDS}" ]; then
echo "'${PR_BUILDER_JOB_NAME}' is missing a dependency."
echo "Update '${WORKFLOW_FILE}' to include all other jobs for '${PR_BUILDER_JOB_NAME}'"
echo ""
echo "Workflow jobs: ${WORKFLOW_JOBS}"
echo "'${PR_BUILDER_JOB_NAME}' job dependencies: ${PR_BUILDER_JOB_NEEDS}"
exit 1
fi

echo "${PR_BUILDER_JOB_NAME} depends on all other jobs."
2 changes: 1 addition & 1 deletion tools/rapids-retry
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function rapids-retry {
(( retries < max_retries )); do
((retries++))
rapids-logger "rapids-retry: retry ${retries} of ${max_retries} | exit code: (${retcode}) -> sleeping for ${sleep_interval} seconds..."
sleep ${sleep_interval}
sleep "${sleep_interval}"
rapids-logger "rapids-retry: sleep done -> retrying..."

${command} "$@"
Expand Down

0 comments on commit ab18a78

Please sign in to comment.