From e0d9a21d6d83c58a77d70745730ac64b741f063c Mon Sep 17 00:00:00 2001 From: robgonzalezpita Date: Wed, 27 Apr 2022 20:37:06 +0000 Subject: [PATCH 1/9] Add github actions workflow to run on self-hosted runner --- .github/workflows/build_SRWA.yml | 89 ++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 .github/workflows/build_SRWA.yml diff --git a/.github/workflows/build_SRWA.yml b/.github/workflows/build_SRWA.yml new file mode 100644 index 000000000..532e69b3a --- /dev/null +++ b/.github/workflows/build_SRWA.yml @@ -0,0 +1,89 @@ +# This workflow Builds the UFS SRWEATHER APP +name: Build SRWA + +on: + push: + branches: [ feature/CI_build_test ] + pull_request: + branches: [ rrfs_ci, feature/CI_build_test ] + +# Use a default login shell which loads intel/oneapi/setvars.sh, and lmod path +defaults: + run: + shell: bash -l {0} + +jobs: + + Clone_rrfs_ci_pcluster: + # Auxillary repository needed to insert env files to run CI tests in the short term + name: Clone RRFS CI repo + # This job will run on AWS Parallel Cluster head node + runs-on: self-hosted + steps: + + - name: Checkout robgonzalezpita/rrfs-ci-pcluster Repo + uses: actions/checkout@v3 + with: + repository: robgonzalezpita/rrfs-ci-pcluster + path: ./rrfs-ci-pcluster + + Configure_SRWA: + name: Checkout SRWA in parent directory + runs-on: self-hosted + needs: [ Clone_rrfs_ci_pcluster ] + + steps: + # Checkout the SRWA - in parent directory, with commit sha-1 in filepath to avoid multiple PR Conflicts, & track builds by commit + # Specify branch used for testing, if there is not a similar named branch in ufs-SRWA + - name: Checkout SRWA + run: | + cd ../ + mkdir ${{ github.sha }} && cd ${{ github.sha }} + git clone https://github.com/NOAA-GSL/ufs-srweather-app.git + cd ufs-srweather-app + exists=`git show-ref ${{ github.ref }}` + if [ -n "$exists" ]; then + echo 'branch exists!' + git checkout ${{ github.ref_name }} + else + git checkout rrfs_ci + fi + git branch + + # This step is needed until NOAA-GSL rrfs_ci branch is updated in ufs-srwa repository + - name: Update scripts + run: | + cd ../${{ github.sha }}/ufs-srweather-app/test/ + sed -i 's/\bwcoss_dell_p3\b/& aws/' build.sh + cd ../env/ + sed -i "99i \ `hostname -f`) MACHINE_ID=aws ;; ### pcluster" detect_machine.sh + cp ../../../regional_workflow/rrfs-ci-pcluster/build_linux_intel.env build_aws_intel.env + cp ../../../regional_workflow/rrfs-ci-pcluster/wflow_linux.env wflow_aws.env + + - name: Checkout Externals & Delete Regional Workflow + run: | + cd ../${{ github.sha }}/ufs-srweather-app + ./manage_externals/checkout_externals + rm -rf regional_workflow + + - name: Checkout this version of Regional Workflow + uses: actions/checkout@v3 + with: + clean: false + + - name: Insert this Version of Regional Workflow + run: | + cp -r ${{ github.workspace }} ../${{ github.sha }}/ufs-srweather-app/regional_workflow + + Build_SRWA: + name: Build SRWA + runs-on: self-hosted + needs: [ Clone_rrfs_ci_pcluster, Configure_SRWA ] + + steps: + - name: Build Short Range Weather App using test/build.sh + run: | + cd ../${{ github.sha }}/ufs-srweather-app/test/ + ./build.sh >& build_test.out + cat build_test* + From fce6085d0c2a5cd2e5eaee9cc57f86d879804aff Mon Sep 17 00:00:00 2001 From: Rob Gonzalez-Pita Date: Wed, 4 May 2022 10:02:22 -0600 Subject: [PATCH 2/9] Checkout base branch of SRWA, modi If corresponding branch is not found in SRWA repository, checkout the base branch. Change how ./build.sh is printed to stdout. --- .github/workflows/build_SRWA.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_SRWA.yml b/.github/workflows/build_SRWA.yml index 532e69b3a..a4818935e 100644 --- a/.github/workflows/build_SRWA.yml +++ b/.github/workflows/build_SRWA.yml @@ -46,7 +46,7 @@ jobs: echo 'branch exists!' git checkout ${{ github.ref_name }} else - git checkout rrfs_ci + git checkout ${{ github.base_ref }} fi git branch @@ -85,5 +85,5 @@ jobs: run: | cd ../${{ github.sha }}/ufs-srweather-app/test/ ./build.sh >& build_test.out - cat build_test* + ./build.sh 2>&1 | tee build_test.out From 648acb5c4bd5ec49fef6d338b56cbb062b3f422e Mon Sep 17 00:00:00 2001 From: Rob Gonzalez-Pita Date: Wed, 4 May 2022 10:04:25 -0600 Subject: [PATCH 3/9] Remove duplicate calling of build.sh --- .github/workflows/build_SRWA.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build_SRWA.yml b/.github/workflows/build_SRWA.yml index a4818935e..24a5cb22c 100644 --- a/.github/workflows/build_SRWA.yml +++ b/.github/workflows/build_SRWA.yml @@ -84,6 +84,5 @@ jobs: - name: Build Short Range Weather App using test/build.sh run: | cd ../${{ github.sha }}/ufs-srweather-app/test/ - ./build.sh >& build_test.out ./build.sh 2>&1 | tee build_test.out From 64ad80f029d1d58e493b5d2207967e5607d37cdf Mon Sep 17 00:00:00 2001 From: robgonzalezpita Date: Tue, 14 Jun 2022 03:34:35 +0000 Subject: [PATCH 4/9] Remove insertion of UFS SRWA env files from seperate repository, print github.refs for debugging on web interface --- .github/workflows/build_SRWA.yml | 49 +++++++++++--------------------- 1 file changed, 17 insertions(+), 32 deletions(-) diff --git a/.github/workflows/build_SRWA.yml b/.github/workflows/build_SRWA.yml index 24a5cb22c..c4a870ef2 100644 --- a/.github/workflows/build_SRWA.yml +++ b/.github/workflows/build_SRWA.yml @@ -2,10 +2,13 @@ name: Build SRWA on: - push: - branches: [ feature/CI_build_test ] +# Enable the ability to manually run this workflow, as well as when the ci-aws-intel-build label is attached + workflow_dispatch: pull_request: - branches: [ rrfs_ci, feature/CI_build_test ] + branches: + - rrfs_ci + types: + - labeled # Use a default login shell which loads intel/oneapi/setvars.sh, and lmod path defaults: @@ -13,27 +16,14 @@ defaults: shell: bash -l {0} jobs: - - Clone_rrfs_ci_pcluster: - # Auxillary repository needed to insert env files to run CI tests in the short term - name: Clone RRFS CI repo - # This job will run on AWS Parallel Cluster head node - runs-on: self-hosted - steps: - - - name: Checkout robgonzalezpita/rrfs-ci-pcluster Repo - uses: actions/checkout@v3 - with: - repository: robgonzalezpita/rrfs-ci-pcluster - path: ./rrfs-ci-pcluster Configure_SRWA: name: Checkout SRWA in parent directory runs-on: self-hosted - needs: [ Clone_rrfs_ci_pcluster ] + if: ${{ github.event.label.name == 'ci-aws-intel-build' }} steps: - # Checkout the SRWA - in parent directory, with commit sha-1 in filepath to avoid multiple PR Conflicts, & track builds by commit + # Checkout the SRWA - in parent directory, with commit sha-1 in filepath to avoid multiple PR Conflicts, & track build tests by commit # Specify branch used for testing, if there is not a similar named branch in ufs-SRWA - name: Checkout SRWA run: | @@ -41,6 +31,11 @@ jobs: mkdir ${{ github.sha }} && cd ${{ github.sha }} git clone https://github.com/NOAA-GSL/ufs-srweather-app.git cd ufs-srweather-app + + echo "Github.ref_name" ${{ github.ref_name }} + echo "Github.base_ref" ${{ github.base_ref }} + echo "Github.head_ref" ${{ github.head_ref }} + exists=`git show-ref ${{ github.ref }}` if [ -n "$exists" ]; then echo 'branch exists!' @@ -48,17 +43,7 @@ jobs: else git checkout ${{ github.base_ref }} fi - git branch - - # This step is needed until NOAA-GSL rrfs_ci branch is updated in ufs-srwa repository - - name: Update scripts - run: | - cd ../${{ github.sha }}/ufs-srweather-app/test/ - sed -i 's/\bwcoss_dell_p3\b/& aws/' build.sh - cd ../env/ - sed -i "99i \ `hostname -f`) MACHINE_ID=aws ;; ### pcluster" detect_machine.sh - cp ../../../regional_workflow/rrfs-ci-pcluster/build_linux_intel.env build_aws_intel.env - cp ../../../regional_workflow/rrfs-ci-pcluster/wflow_linux.env wflow_aws.env + git branch -a - name: Checkout Externals & Delete Regional Workflow run: | @@ -77,12 +62,12 @@ jobs: Build_SRWA: name: Build SRWA + if: ${{ github.event.label.name == 'ci-aws-intel-build' }} runs-on: self-hosted - needs: [ Clone_rrfs_ci_pcluster, Configure_SRWA ] + needs: Configure_SRWA steps: - name: Build Short Range Weather App using test/build.sh run: | cd ../${{ github.sha }}/ufs-srweather-app/test/ - ./build.sh 2>&1 | tee build_test.out - + ./build.sh aws 2>&1 | tee build_test.out From b22ff0fac9fe611df475240ffcfd4acb9bb50dc5 Mon Sep 17 00:00:00 2001 From: robgonzalezpita Date: Thu, 16 Jun 2022 17:39:49 +0000 Subject: [PATCH 5/9] Refactor build_SRWA.yml to clone concurrent PR from the same author and branch name in the SRWA, add final job to display build status in web interface --- .github/workflows/build_SRWA.yml | 111 ++++++++++++++++++++++--------- 1 file changed, 78 insertions(+), 33 deletions(-) diff --git a/.github/workflows/build_SRWA.yml b/.github/workflows/build_SRWA.yml index c4a870ef2..e47a0feba 100644 --- a/.github/workflows/build_SRWA.yml +++ b/.github/workflows/build_SRWA.yml @@ -2,13 +2,13 @@ name: Build SRWA on: -# Enable the ability to manually run this workflow, as well as when the ci-aws-intel-build label is attached +# Enable the ability to manually run this workflow, as well as when the ci-aws-intel-build label is attached to a PR, and if the PR is updated workflow_dispatch: pull_request: branches: - rrfs_ci types: - - labeled + - labeled # Use a default login shell which loads intel/oneapi/setvars.sh, and lmod path defaults: @@ -17,57 +17,102 @@ defaults: jobs: - Configure_SRWA: - name: Checkout SRWA in parent directory + Set_Repo_and_Branch: + name: Set the SRWA repo and branch names runs-on: self-hosted if: ${{ github.event.label.name == 'ci-aws-intel-build' }} - + outputs: + SRWA_REPO: ${{ steps.set_repo.outputs.SRWA_REPO }} + SRWA_BRANCH: ${{ steps.set_repo.outputs.SRWA_BRANCH }} + + # If a developer submits a concurrent PR to the App, set the SRWA_REPO & SRWA_BRANCH env variables to their repo and branch, + # if not, set the outputs to the rrfs_ci branch of NOAA-GSL/ufs-srweather-app steps: - # Checkout the SRWA - in parent directory, with commit sha-1 in filepath to avoid multiple PR Conflicts, & track build tests by commit - # Specify branch used for testing, if there is not a similar named branch in ufs-SRWA - - name: Checkout SRWA + - name: Set Repo and Branch Variables + id: set_repo run: | - cd ../ - mkdir ${{ github.sha }} && cd ${{ github.sha }} - git clone https://github.com/NOAA-GSL/ufs-srweather-app.git - cd ufs-srweather-app - - echo "Github.ref_name" ${{ github.ref_name }} - echo "Github.base_ref" ${{ github.base_ref }} - echo "Github.head_ref" ${{ github.head_ref }} - - exists=`git show-ref ${{ github.ref }}` - if [ -n "$exists" ]; then - echo 'branch exists!' - git checkout ${{ github.ref_name }} + new_branch=`git ls-remote https://github.com/${{ github.actor }}/ufs-srweather-app.git ${{ github.head_ref }}` + if [ -n "$new_branch" ]; then + echo "SRWA_REPO is being set to : ${{ github.actor }}/ufs-srweather-app.git" + echo "::set-output name=SRWA_REPO::${{ github.actor }}/ufs-srweather-app" + echo "SRWA_BRANCH is being set to : " ${{ github.head_ref }} + echo "::set-output name=SRWA_BRANCH::${{ github.head_ref }}" else - git checkout ${{ github.base_ref }} + echo "There is not a head_ref with the same name as this PR in the SRW App, the default SRW App (NOAA-GSL fork) repository will be used." + echo "::set-output name=SRWA_REPO::NOAA-GSL/ufs-srweather-app" + echo "There is not a similar branch name associated with this PR in the SRW App, the default SRWA App branch (rrfs_ci) will be used." + echo "::set-output name=SRWA_BRANCH::rrfs_ci" fi - git branch -a + + # Clone the SRWA - with github.run_id in filepath to avoid multiple PR Conflicts, & track build tests by their run_id + # (Cloning repositories outside of the GITHUB_WORKSPACE directory is not supported with actions/checkout@v3, so it needs to be moved into the parent directory seperately) + Clone_SRWA: + name: Clone SRWA and move into parent directory + runs-on: self-hosted + if: ${{ github.event.label.name == 'ci-aws-intel-build' }} + needs: [ Set_Repo_and_Branch ] + + steps: + - name: Clone SRWA + uses: actions/checkout@v3 + with: + repository: ${{ needs.Set_Repo_and_Branch.outputs.SRWA_REPO }} + ref: ${{ needs.Set_Repo_and_Branch.outputs.SRWA_BRANCH }} + path: ufs-srweather-app-${{ github.run_id }} + - name: Move SRWA + run: | + cp -r ufs-srweather-app-${{ github.run_id }}/. ../ufs-srweather-app-${{ github.run_id }}/ + rm -rf ufs-srweather-app-${{ github.run_id }} + + Configure_SRWA: + name: Checkout_Externals and replace with 'this' version of regional_workflow + runs-on: self-hosted + if: ${{ github.event.label.name == 'ci-aws-intel-build' }} + needs: [ Set_Repo_and_Branch, Clone_SRWA ] + + steps: - name: Checkout Externals & Delete Regional Workflow run: | - cd ../${{ github.sha }}/ufs-srweather-app + cd ../ufs-srweather-app-${{ github.run_id }} ./manage_externals/checkout_externals rm -rf regional_workflow - - - name: Checkout this version of Regional Workflow + + - name: Checkout 'this' version of Regional Workflow uses: actions/checkout@v3 with: clean: false - - - name: Insert this Version of Regional Workflow + + - name: Insert this Version of Regional Workflow in correct location in ufs-srweather-app directory run: | - cp -r ${{ github.workspace }} ../${{ github.sha }}/ufs-srweather-app/regional_workflow + mkdir -p ../ufs-srweather-app-${{ github.run_id }}/regional_workflow + cp -r ${{ github.workspace }}/. ../ufs-srweather-app-${{ github.run_id }}/regional_workflow/ Build_SRWA: name: Build SRWA - if: ${{ github.event.label.name == 'ci-aws-intel-build' }} runs-on: self-hosted - needs: Configure_SRWA - + if: ${{ github.event.label.name == 'ci-aws-intel-build' }} + needs: [ Set_Repo_and_Branch, Clone_SRWA, Configure_SRWA ] steps: - name: Build Short Range Weather App using test/build.sh run: | - cd ../${{ github.sha }}/ufs-srweather-app/test/ + cd ../ufs-srweather-app-${{ github.run_id }}/test/ ./build.sh aws 2>&1 | tee build_test.out + + Build_Status: + name: Check Build Sucess or Failure + runs-on: self-hosted + if: ${{ github.event.label.name == 'ci-aws-intel-build' }} + needs: [ Set_Repo_and_Branch, Clone_SRWA, Configure_SRWA, Build_SRWA ] + + steps: + - name: Get build status + run: | + cd ../ufs-srweather-app-${{ github.run_id }}/test/ + status=`tail -1 build_test.out |cut -d ' ' -f 3-` + if [ $status == PASS ]; then + exit 0 + else + exit 1 + fi + \ No newline at end of file From 31e48dbac738d9ec8fcf5e55469f03434a21340b Mon Sep 17 00:00:00 2001 From: robgonzalezpita Date: Thu, 16 Jun 2022 19:14:52 +0000 Subject: [PATCH 6/9] Add Comment addressing relative file paths, add new line at the end of file --- .github/workflows/build_SRWA.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_SRWA.yml b/.github/workflows/build_SRWA.yml index e47a0feba..bb6382928 100644 --- a/.github/workflows/build_SRWA.yml +++ b/.github/workflows/build_SRWA.yml @@ -46,6 +46,7 @@ jobs: # Clone the SRWA - with github.run_id in filepath to avoid multiple PR Conflicts, & track build tests by their run_id # (Cloning repositories outside of the GITHUB_WORKSPACE directory is not supported with actions/checkout@v3, so it needs to be moved into the parent directory seperately) + # Relative paths are used here to decouple the running of this workflow from the self-hosted runner itself. We'd like to avoid the added complication of setting up the same directory structure for each SH runner. Clone_SRWA: name: Clone SRWA and move into parent directory runs-on: self-hosted @@ -115,4 +116,3 @@ jobs: else exit 1 fi - \ No newline at end of file From c2f1e7c7923ac93f3d57f88e50467d7090f1af6a Mon Sep 17 00:00:00 2001 From: Rob Gonzalez-Pita Date: Fri, 17 Jun 2022 12:13:47 -0600 Subject: [PATCH 7/9] Add more detailed comments --- .github/workflows/build_SRWA.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_SRWA.yml b/.github/workflows/build_SRWA.yml index bb6382928..811fbe4d8 100644 --- a/.github/workflows/build_SRWA.yml +++ b/.github/workflows/build_SRWA.yml @@ -45,8 +45,9 @@ jobs: fi # Clone the SRWA - with github.run_id in filepath to avoid multiple PR Conflicts, & track build tests by their run_id - # (Cloning repositories outside of the GITHUB_WORKSPACE directory is not supported with actions/checkout@v3, so it needs to be moved into the parent directory seperately) # Relative paths are used here to decouple the running of this workflow from the self-hosted runner itself. We'd like to avoid the added complication of setting up the same directory structure for each SH runner. + # (Cloning repositories outside of the GITHUB_WORKSPACE directory is not supported with actions/checkout@v3, so it needs to be moved into the parent directory seperately) + # The SRWA is cloned within the GITHUB_WORKSPACE (default location of where 'run' commands are executed ), we need to move its location up one directory, as the regional_workflow is nested within the SRWA. Clone_SRWA: name: Clone SRWA and move into parent directory runs-on: self-hosted @@ -84,7 +85,7 @@ jobs: with: clean: false - - name: Insert this Version of Regional Workflow in correct location in ufs-srweather-app directory + - name: Replace 'this' Version of Regional Workflow in the correct ufs-srweather-app directory instead of version listed in 'Externals.cfg' and cloned by the checkout externals step above run: | mkdir -p ../ufs-srweather-app-${{ github.run_id }}/regional_workflow cp -r ${{ github.workspace }}/. ../ufs-srweather-app-${{ github.run_id }}/regional_workflow/ From f989f56551742a08a242ed339a65e3ac3501ee84 Mon Sep 17 00:00:00 2001 From: robgonzalezpita Date: Fri, 24 Jun 2022 16:01:54 +0000 Subject: [PATCH 8/9] Try cloning RRFS using actions/checkout within the srwa clone --- .github/workflows/build_SRWA.yml | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build_SRWA.yml b/.github/workflows/build_SRWA.yml index bb6382928..a3523a471 100644 --- a/.github/workflows/build_SRWA.yml +++ b/.github/workflows/build_SRWA.yml @@ -60,11 +60,6 @@ jobs: repository: ${{ needs.Set_Repo_and_Branch.outputs.SRWA_REPO }} ref: ${{ needs.Set_Repo_and_Branch.outputs.SRWA_BRANCH }} path: ufs-srweather-app-${{ github.run_id }} - - - name: Move SRWA - run: | - cp -r ufs-srweather-app-${{ github.run_id }}/. ../ufs-srweather-app-${{ github.run_id }}/ - rm -rf ufs-srweather-app-${{ github.run_id }} Configure_SRWA: name: Checkout_Externals and replace with 'this' version of regional_workflow @@ -75,19 +70,15 @@ jobs: steps: - name: Checkout Externals & Delete Regional Workflow run: | - cd ../ufs-srweather-app-${{ github.run_id }} + cd ufs-srweather-app-${{ github.run_id }} ./manage_externals/checkout_externals rm -rf regional_workflow - name: Checkout 'this' version of Regional Workflow uses: actions/checkout@v3 with: + path: ufs-srweather-app-${{ github.run_id }}/regional_workflow clean: false - - - name: Insert this Version of Regional Workflow in correct location in ufs-srweather-app directory - run: | - mkdir -p ../ufs-srweather-app-${{ github.run_id }}/regional_workflow - cp -r ${{ github.workspace }}/. ../ufs-srweather-app-${{ github.run_id }}/regional_workflow/ Build_SRWA: name: Build SRWA @@ -97,7 +88,7 @@ jobs: steps: - name: Build Short Range Weather App using test/build.sh run: | - cd ../ufs-srweather-app-${{ github.run_id }}/test/ + cd ufs-srweather-app-${{ github.run_id }}/test/ ./build.sh aws 2>&1 | tee build_test.out Build_Status: @@ -109,10 +100,11 @@ jobs: steps: - name: Get build status run: | - cd ../ufs-srweather-app-${{ github.run_id }}/test/ + cd ufs-srweather-app-${{ github.run_id }}/test/ status=`tail -1 build_test.out |cut -d ' ' -f 3-` if [ $status == PASS ]; then exit 0 else exit 1 fi + From 23a66659aa4f71031554c84d177a53868e1cca42 Mon Sep 17 00:00:00 2001 From: robgonzalezpita Date: Fri, 24 Jun 2022 20:17:57 +0000 Subject: [PATCH 9/9] Remove outdated comments --- .github/workflows/build_SRWA.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/build_SRWA.yml b/.github/workflows/build_SRWA.yml index e468f6175..a969abc18 100644 --- a/.github/workflows/build_SRWA.yml +++ b/.github/workflows/build_SRWA.yml @@ -45,9 +45,6 @@ jobs: fi # Clone the SRWA - with github.run_id in filepath to avoid multiple PR Conflicts, & track build tests by their run_id - # Relative paths are used here to decouple the running of this workflow from the self-hosted runner itself. We'd like to avoid the added complication of setting up the same directory structure for each SH runner. - # (Cloning repositories outside of the GITHUB_WORKSPACE directory is not supported with actions/checkout@v3, so it needs to be moved into the parent directory seperately) - # The SRWA is cloned within the GITHUB_WORKSPACE (default location of where 'run' commands are executed ), we need to move its location up one directory, as the regional_workflow is nested within the SRWA. Clone_SRWA: name: Clone SRWA and move into parent directory runs-on: self-hosted