From 0c7b4d11835ab204323c4e3598776813f09506ce Mon Sep 17 00:00:00 2001 From: RussTreadon-NOAA <26926959+RussTreadon-NOAA@users.noreply.github.com> Date: Mon, 17 Jun 2024 10:44:37 -0400 Subject: [PATCH] use role.jedipara for hera ci (#1173) One task in #1150 is to move automated CI to role accounts. This PR moves Hera CI to role.jedipara. Fixes #1172 --------- Co-authored-by: Guillaume Vernieres --- README.md | 19 +++++++++++++++++++ ci/driver.sh | 29 +++++++++++++++++++++++++---- ci/gw_driver.sh | 29 +++++++++++++++++++++++++++-- ci/hera.sh | 4 ++-- 4 files changed, 73 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 7ac52d734..9ea507f55 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,25 @@ Global Data Assimilation System Application The one app to rule them all +## Notes to developers + +1 - As a developer, you will have to build the GDASApp againt the `dev/gdasapp` branch of the `global-workflow` + +```bash +git clone --recursive --jobs 8 --branch dev/gdasapp https://github.com/NOAA-EMC/global-workflow.git +``` + +2 - For the most part (boundaries of that terminology is stil TBD), changes to the `global-workflow` related to the `GDASApp` developement will be issued in the `dev/gdasapp` branch. + +3 - If your feature development involves changes to the global-workflow and the GDASApp, you will have to issue a PR in each repository. The GDASApp PR will have to have the same name in order for the GDASApp CI to build and run the correct branches. + +4 - If your work is contained within the `global-workflow` only, you will have to submit a dummy PR in the `GDASApp` with the same branch name. +To submit a dummy PR, just create a branch with an empty commit: +``` +git commit --allow-empty -m "Dummy commit to trigger PR" +``` + + [![Orion](https://github.com/NOAA-EMC/GDASApp/actions/workflows/orion.yaml/badge.svg)](https://github.com/NOAA-EMC/GDASApp/actions/workflows/orion.yaml) [![Hera](https://github.com/NOAA-EMC/GDASApp/actions/workflows/hera.yaml/badge.svg)](https://github.com/NOAA-EMC/GDASApp/actions/workflows/hera.yaml) diff --git a/ci/driver.sh b/ci/driver.sh index 4b0ea550a..ce6372c59 100755 --- a/ci/driver.sh +++ b/ci/driver.sh @@ -60,11 +60,32 @@ repo_url="https://github.com/NOAA-EMC/GDASApp.git" for pr in $open_pr_list; do gh pr edit $pr --remove-label $CI_LABEL --add-label ${CI_LABEL}-Running echo "Processing Pull Request #${pr}" + + # get the branch name used for the PR + gdasapp_branch=$(gh pr view $pr --json headRefName -q ".headRefName") + + # get the fork information + pr_details=$(gh pr view $pr --repo ${repo_url} --json headRepository,headRepositoryOwner,headRefName) + + # extract the necessary info + fork_owner=$(gh pr view $pr --repo ${repo_url} --json headRepositoryOwner --jq '.headRepositoryOwner.login') + fork_name=$(gh pr view $pr --repo ${repo_url} --json headRepository --jq '.headRepository.name') + + # construct the fork URL + gdasapp_url="https://github.com/$fork_owner/${fork_name}.git" + + echo "Fork URL: $gdasapp_url" + echo "Branch Name: $gdasapp_branch" + + # create PR specific directory + if [ -d $GDAS_CI_ROOT/PR/$pr ]; then + rm -rf $GDAS_CI_ROOT/PR/$pr + fi mkdir -p $GDAS_CI_ROOT/PR/$pr cd $GDAS_CI_ROOT/PR/$pr # clone copy of repo - git clone --recursive $repo_url + git clone --recursive --jobs 8 --branch $gdasapp_branch $gdasapp_url cd GDASApp # checkout pull request @@ -94,11 +115,11 @@ for pr in $open_pr_list; do # run build and testing command $my_dir/run_ci.sh -d $GDAS_CI_ROOT/PR/$pr/GDASApp -o $GDAS_CI_ROOT/PR/$pr/output_${commit} ci_status=$? - gh pr comment $pr --body-file $GDAS_CI_ROOT/PR/$pr/output_${commit} + gh pr comment $pr --repo ${repo_url} --body-file $GDAS_CI_ROOT/PR/$pr/output_${commit} if [ $ci_status -eq 0 ]; then - gh pr edit $pr --remove-label ${CI_LABEL}-Running --add-label ${CI_LABEL}-Passed + gh pr edit $pr --repo ${repo_url} --remove-label ${CI_LABEL}-Running --add-label ${CI_LABEL}-Passed else - gh pr edit $pr --remove-label ${CI_LABEL}-Running --add-label ${CI_LABEL}-Failed + gh pr edit $pr --repo ${repo_url} --remove-label ${CI_LABEL}-Running --add-label ${CI_LABEL}-Failed fi done diff --git a/ci/gw_driver.sh b/ci/gw_driver.sh index afbbdf96e..e85684f84 100755 --- a/ci/gw_driver.sh +++ b/ci/gw_driver.sh @@ -61,11 +61,36 @@ workflow_url="https://github.com/NOAA-EMC/global-workflow.git" for pr in $open_pr_list; do gh pr edit $pr --remove-label $CI_LABEL --add-label ${CI_LABEL}-Running echo "Processing Pull Request #${pr}" + + # get the branch name used for the PR + gdasapp_branch=$(gh pr view $pr --json headRefName -q ".headRefName") + + # check for a companion PR in the global-workflow + companion_pr_exists=$(gh pr list --repo ${workflow_url} --head ${gdasapp_branch} --state open) + if [ -n "$companion_pr_exists" ]; then + # get the PR number + companion_pr=$(echo "$companion_pr_exists" | awk '{print $1;}') + + # extract the necessary info + fork_owner=$(gh pr view $companion_pr --repo $workflow_url --json headRepositoryOwner --jq '.headRepositoryOwner.login') + fork_name=$(gh pr view $companion_pr --repo $workflow_url --json headRepository --jq '.headRepository.name') + + # Construct the fork URL + workflow_url="https://github.com/$fork_owner/$fork_name.git" + + echo "Fork URL: $workflow_url" + echo "Branch Name: $gdasapp_branch" + fi + + # create PR specific directory + if [ -d $GDAS_CI_ROOT/workflow/PR/$pr ]; then + rm -rf $GDAS_CI_ROOT/workflow/PR/$pr + fi mkdir -p $GDAS_CI_ROOT/workflow/PR/$pr cd $GDAS_CI_ROOT/workflow/PR/$pr - + # clone global workflow develop branch - git clone --recursive $workflow_url + git clone --recursive --jobs 8 --branch dev/gdasapp $workflow_url # checkout pull request cd $GDAS_CI_ROOT/workflow/PR/$pr/global-workflow/sorc/gdas.cd diff --git a/ci/hera.sh b/ci/hera.sh index 5eb5c4df6..ec3858370 100644 --- a/ci/hera.sh +++ b/ci/hera.sh @@ -1,8 +1,8 @@ -export GDAS_CI_ROOT=/scratch1/NCEPDEV/da/Cory.R.Martin/CI/GDASApp +export GDAS_CI_ROOT=/scratch1/NCEPDEV/da/role.jedipara/CI/GDASApp export GDAS_CI_HOST='hera' export GDAS_MODULE_USE=$GDAS_CI_ROOT/repo/modulefiles export SLURM_ACCOUNT=da-cpu export SALLOC_ACCOUNT=$SLURM_ACCOUNT export SBATCH_ACCOUNT=$SLURM_ACCOUNT export SLURM_QOS=debug -export PATH=$PATH:/scratch1/NCEPDEV/da/Cory.R.Martin/CI/gh/gh_2.46.0_linux_amd64/bin +export PATH=$PATH:/home/role.jedipara/bin