From 2d64b74a0b0407d01d6f657efa6af9637a131448 Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Wed, 4 Oct 2023 22:33:25 +0000 Subject: [PATCH] CI driver_weekly bugfix deleting new branch if is already on repo (#1899) Bugfix and updates to weekly CI test that deletes the new modified branch if it is already on the repo but now also makes sure that the intermediary branch that creates the PR is coming from emcbot. --- ci/scripts/driver_weekly.sh | 29 +++++++++++++++++++++-------- ci/scripts/run_ci.sh | 2 +- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/ci/scripts/driver_weekly.sh b/ci/scripts/driver_weekly.sh index c78a42d3be..3650f75dfc 100755 --- a/ci/scripts/driver_weekly.sh +++ b/ci/scripts/driver_weekly.sh @@ -22,7 +22,7 @@ set -eux # TODO using static build for GitHub CLI until fixed in HPC-Stack ################################################################# export GH=${HOME}/bin/gh -export REPO_URL=${REPO_URL:-"https://github.com/NOAA-EMC/global-workflow.git"} +export REPO_URL="ssh://git@ssh.github.com:443/NOAA-EMC/global-workflow.git" ################################################################ # Setup the relative paths to scripts and PS4 for better logging @@ -61,7 +61,7 @@ set -x # Create a new branch from develop and move yaml files ######################################################### branch="weekly_ci_$(date +%Y%m%d)" -develop_dir="${GFS_CI_ROOT}/develop_temp" +develop_dir="${GFS_CI_ROOT}/develop_weekly" echo "Creating new branch ${branch} from develop on ${MACHINE_ID} in ${develop_dir}" rm -Rf "${develop_dir}" mkdir -p "${develop_dir}" @@ -73,26 +73,39 @@ git checkout -b "${branch}" ###################################################### # move yaml files from ci/cases/weekly to ci/cases/pr # and push new branch for PR weekly CI tests to GitHub +REPO_OWNER="emcbot" +REPO_NAME="global-workflow" +REMOTE_NAME="${REPO_OWNER}" rm -Rf ci/cases/pr mv ci/cases/weekly ci/cases/pr git add ci/cases git commit -m "Moved weekly cases files into pr for high resolution testing" -git push --set-upstream origin "${branch}" + +git remote add "${REMOTE_NAME}" "git@github.com:${REPO_OWNER}/${REPO_NAME}.git" + +set +e +# Delete the branch if it exists +git ls-remote --exit-code "${REMOTE_NAME}" "${branch}" +ci_status=$? +if [[ "${ci_status}" == '0' ]]; then + git push "${REMOTE_NAME}" --delete "${branch}" +fi +set -e + +git push --set-upstream "${REMOTE_NAME}" "${branch}" #################################################################### # Create Pull Request using GitHub CLI and add labels for CI testing #################################################################### -REPO_OWNER="NOAA-EMC" -REPO_NAME="global-workflow" +HEAD_BRANCH="${REPO_OWNER}:${branch}" BASE_BRANCH="develop" -HEAD_BRANCH="${branch}" -PULL_REQUEST_TITLE="[DO NOT MERGE] Weekly High Resolution CI Tests $(date +'%A %b %d, %Y')" +PULL_REQUEST_TITLE="[DO NOT MERGE] Weekly CI Tests $(date +'%A %b %d, %Y')" PULL_REQUEST_BODY="${PULL_REQUEST_TITLE}" PULL_REQUEST_LABELS=("CI/CD" "CI-Orion-Ready" "CI-Hera-Ready") -"${GH}" repo set-default "${REPO_OWNER}/${REPO_NAME}" +"${GH}" repo set-default "NOAA-EMC/global-workflow" "${GH}" pr create --title "${PULL_REQUEST_TITLE}" --body "${PULL_REQUEST_BODY}" --base "${BASE_BRANCH}" --head "${HEAD_BRANCH}" "${GH}" pr ready --undo diff --git a/ci/scripts/run_ci.sh b/ci/scripts/run_ci.sh index 5740b2955a..0ff3725be9 100755 --- a/ci/scripts/run_ci.sh +++ b/ci/scripts/run_ci.sh @@ -22,7 +22,7 @@ source "${HOMEgfs}/ush/detect_machine.sh" case ${MACHINE_ID} in hera | orion) echo "Running Automated Testing on ${MACHINE_ID}" - source "${HOMEgfs}/ci/platforms/${MACHINE_ID}.sh" + source "${HOMEgfs}/ci/platforms/config.${MACHINE_ID}" ;; *) echo "Unsupported platform. Exiting with error."