Skip to content

Commit

Permalink
Updated cron bash ci script to remove weekly CI test PR on success (N…
Browse files Browse the repository at this point in the history
…OAA-EMC#1915)

This PR updates the check CI bash script in cron to remove the PR that is created by
the weekly CI test driver when all the tests has passed on all the platforms.

This is done by the script checking if all other labels for all the platforms for the PR
that has currently been flagged to have run to a successful completion by the check
ci bash script.
  • Loading branch information
TerrenceMcGuinness-NOAA authored Oct 10, 2023
1 parent 2d64b74 commit 51d93e1
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions ci/scripts/check_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ echo "Begin ${scriptname} at $(date -u)" || true
export PS4='+ $(basename ${BASH_SOURCE})[${LINENO}]'

GH=${HOME}/bin/gh
REPO_URL=${REPO_URL:-"https://github.com/NOAA-EMC/global-workflow.git"}
REPO_URL="https://github.com/NOAA-EMC/global-workflow.git"

#########################################################################
# Set up runtime environment varibles for accounts on supproted machines
Expand Down Expand Up @@ -86,7 +86,23 @@ for pr in ${pr_list}; do
sed -i "s/\`\`\`//2g" "${GFS_CI_ROOT}/PR/${pr}/output_${id}"
"${GH}" pr comment "${pr}" --repo "${REPO_URL}" --body-file "${GFS_CI_ROOT}/PR/${pr}/output_${id}"
"${HOMEgfs}/ci/scripts/pr_list_database.py" --remove_pr "${pr}" --dbfile "${pr_list_dbfile}"
# Completely remove the PR and its cloned repo on sucess of all cases
# Check to see if this PR that was opened by the weekly tests and if so close it if it passed on all platforms
weekly_labels=$(${GH} pr view "${pr}" --repo "${REPO_URL}" --json headRefName,labels,author --jq 'select(.author.login | contains("emcbot")) | select(.headRefName | contains("weekly_ci")) | .labels[].name ') || true
if [[ -n "${weekly_labels}" ]]; then
num_platforms=$(find ../platforms -type f -name "config.*")
passed=0
for platforms in ../platforms/config.*; do
machine=$(basename "${platforms}" | cut -d. -f2)
if [[ "${weekly_labels}" == *"CI-${machine^}-Passed"* ]]; then
((passed=passed+1))
fi
done
if [[ "${passed}" == "${num_platforms}" ]]; then
"${GH}" pr close --repo "${REPO_URL}" "${pr}"
fi
fi
# Completely remove the PR and its cloned repo on sucess
# of all cases on this platform
rm -Rf "${pr_dir}"
continue
fi
Expand Down

0 comments on commit 51d93e1

Please sign in to comment.