From 6eb7407eb4e33c474ef73b96852a550f1d72fb1f Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 7 Aug 2025 11:21:18 -0700 Subject: [PATCH 01/15] create initial sketch of a github workflow to run fates tests --- .github/workflows/unittest-ctsm.yml | 32 +++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/unittest-ctsm.yml diff --git a/.github/workflows/unittest-ctsm.yml b/.github/workflows/unittest-ctsm.yml new file mode 100644 index 0000000000..24aee58059 --- /dev/null +++ b/.github/workflows/unittest-ctsm.yml @@ -0,0 +1,32 @@ +name: Run fates unit tests with ctsm as the host land model + +on: + pull_request: + +jobs: + ctsm-unit-test: + runs-on: ubuntu-latest + container: + image: ghcr.io/ngeet/unit-test-ctsm:latest + env: + BRANCH_NAME: ${{ github.head_ref }} + BRANCH_URL: ${{ github.event.pull_request.head.repo.html_url }} + + steps: + - name: Checkout code with git-fleximod + run: | + ./git-fleximod --optional update + + - name: Run fates unit tests + run: | + . /opt/spack-environment/activate.sh + python -m pip install matplotlib + echo "HOSTNAME: $HOSTNAME" + echo "HOME: $HOME" + echo "CIMEROOT: $CIMEROOT" + echo "NETCDF_FORTRAN_PATH: $NETCDF_FORTRAN_PATH" + echo "NETCDF_C_PATH: $NETCDF_C_PATH" + cd testing/ + python run_unit_tests.py --make-j 2 --test-list all + + From 9170d50119801a13ae6f47d18e0da84f14d3cda2 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 7 Aug 2025 11:22:59 -0700 Subject: [PATCH 02/15] remove optional as we don't really need this --- .github/workflows/unittest-ctsm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unittest-ctsm.yml b/.github/workflows/unittest-ctsm.yml index 24aee58059..61fe4e65d9 100644 --- a/.github/workflows/unittest-ctsm.yml +++ b/.github/workflows/unittest-ctsm.yml @@ -15,7 +15,7 @@ jobs: steps: - name: Checkout code with git-fleximod run: | - ./git-fleximod --optional update + ./git-fleximod update - name: Run fates unit tests run: | From 28e545ad286f4be4455c834653a556c7975efba3 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 7 Aug 2025 13:45:01 -0700 Subject: [PATCH 03/15] update unit testing to setup conda environment from the testing.yml --- .github/workflows/unittest-ctsm.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/unittest-ctsm.yml b/.github/workflows/unittest-ctsm.yml index 61fe4e65d9..6d6bd40295 100644 --- a/.github/workflows/unittest-ctsm.yml +++ b/.github/workflows/unittest-ctsm.yml @@ -1,4 +1,4 @@ -name: Run fates unit tests with ctsm as the host land model +name: Run fates unit tests with ctsm as the hos land model on: pull_request: @@ -15,18 +15,25 @@ jobs: steps: - name: Checkout code with git-fleximod run: | + cd /CTSM ./git-fleximod update - - name: Run fates unit tests + - name: Set up conda environment + uses: conda-incubator/setup-miniconda@v2 + with: + activate-environment: testing + environment-file: testing/testing.yml + channels: conda-forge, defaults + + - name: Activate spack environment and run tests run: | . /opt/spack-environment/activate.sh - python -m pip install matplotlib echo "HOSTNAME: $HOSTNAME" echo "HOME: $HOME" echo "CIMEROOT: $CIMEROOT" echo "NETCDF_FORTRAN_PATH: $NETCDF_FORTRAN_PATH" echo "NETCDF_C_PATH: $NETCDF_C_PATH" cd testing/ - python run_unit_tests.py --make-j 2 --test-list all + python run_unit_tests.py --test-list fire_fuel From d9f97bbe9fa40ab048c2f49bc5560dec61e5063c Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 7 Aug 2025 14:05:38 -0700 Subject: [PATCH 04/15] add missing container repo name --- .github/workflows/unittest-ctsm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unittest-ctsm.yml b/.github/workflows/unittest-ctsm.yml index 6d6bd40295..28dbc6f12a 100644 --- a/.github/workflows/unittest-ctsm.yml +++ b/.github/workflows/unittest-ctsm.yml @@ -7,7 +7,7 @@ jobs: ctsm-unit-test: runs-on: ubuntu-latest container: - image: ghcr.io/ngeet/unit-test-ctsm:latest + image: ghcr.io/ngeet/containers/unit-test-ctsm:latest env: BRANCH_NAME: ${{ github.head_ref }} BRANCH_URL: ${{ github.event.pull_request.head.repo.html_url }} From 30c45a5aae6a52b223b1d45c6e094dca9df5adca Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 7 Aug 2025 14:10:21 -0700 Subject: [PATCH 05/15] add missing bin statement for fleximod call --- .github/workflows/unittest-ctsm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unittest-ctsm.yml b/.github/workflows/unittest-ctsm.yml index 28dbc6f12a..92166da7ca 100644 --- a/.github/workflows/unittest-ctsm.yml +++ b/.github/workflows/unittest-ctsm.yml @@ -16,7 +16,7 @@ jobs: - name: Checkout code with git-fleximod run: | cd /CTSM - ./git-fleximod update + ./bin/git-fleximod update - name: Set up conda environment uses: conda-incubator/setup-miniconda@v2 From cdf13aa3177231524b85aacbbbc1dd8ac94b32cb Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 7 Aug 2025 14:13:05 -0700 Subject: [PATCH 06/15] add miniconda version to ensure installation --- .github/workflows/unittest-ctsm.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/unittest-ctsm.yml b/.github/workflows/unittest-ctsm.yml index 92166da7ca..6e1aec1370 100644 --- a/.github/workflows/unittest-ctsm.yml +++ b/.github/workflows/unittest-ctsm.yml @@ -1,4 +1,4 @@ -name: Run fates unit tests with ctsm as the hos land model +name: Run unit tests with ctsm on: pull_request: @@ -21,6 +21,7 @@ jobs: - name: Set up conda environment uses: conda-incubator/setup-miniconda@v2 with: + miniconda-version: 'latest' activate-environment: testing environment-file: testing/testing.yml channels: conda-forge, defaults From d4c70f721de3bb54ce84b0202053d99c46159f0e Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 7 Aug 2025 15:08:31 -0700 Subject: [PATCH 07/15] add container environment to simplify calls --- .github/workflows/unittest-ctsm.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/unittest-ctsm.yml b/.github/workflows/unittest-ctsm.yml index 6e1aec1370..a660523f32 100644 --- a/.github/workflows/unittest-ctsm.yml +++ b/.github/workflows/unittest-ctsm.yml @@ -9,6 +9,7 @@ jobs: container: image: ghcr.io/ngeet/containers/unit-test-ctsm:latest env: + TESTING_DIR: /CTSM/src/fates/testing/ BRANCH_NAME: ${{ github.head_ref }} BRANCH_URL: ${{ github.event.pull_request.head.repo.html_url }} @@ -16,25 +17,27 @@ jobs: - name: Checkout code with git-fleximod run: | cd /CTSM - ./bin/git-fleximod update + ./bin/git-fleximod updateA + + - name: Echo some output + run: | + echo "HOSTNAME: $HOSTNAME" + echo "HOME: $HOME" - name: Set up conda environment uses: conda-incubator/setup-miniconda@v2 with: miniconda-version: 'latest' activate-environment: testing - environment-file: testing/testing.yml + environment-file: ${{env.TESTING_DIR}}/testing.yml channels: conda-forge, defaults - name: Activate spack environment and run tests run: | . /opt/spack-environment/activate.sh - echo "HOSTNAME: $HOSTNAME" - echo "HOME: $HOME" - echo "CIMEROOT: $CIMEROOT" echo "NETCDF_FORTRAN_PATH: $NETCDF_FORTRAN_PATH" echo "NETCDF_C_PATH: $NETCDF_C_PATH" - cd testing/ + cd ${{env.TESTING_DIR}} python run_unit_tests.py --test-list fire_fuel From 0906ea8aa18af8688040995f0ff5cd1fa55abb63 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 7 Aug 2025 15:10:56 -0700 Subject: [PATCH 08/15] fix typo --- .github/workflows/unittest-ctsm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unittest-ctsm.yml b/.github/workflows/unittest-ctsm.yml index a660523f32..93a7c7ab05 100644 --- a/.github/workflows/unittest-ctsm.yml +++ b/.github/workflows/unittest-ctsm.yml @@ -17,7 +17,7 @@ jobs: - name: Checkout code with git-fleximod run: | cd /CTSM - ./bin/git-fleximod updateA + ./bin/git-fleximod update - name: Echo some output run: | From bdb74b20b7a143789d6694a3d318de50d13ad3b2 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 7 Aug 2025 15:22:49 -0700 Subject: [PATCH 09/15] remove conda setup as this only works in the runner context NOT the container context --- .github/workflows/unittest-ctsm.yml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/.github/workflows/unittest-ctsm.yml b/.github/workflows/unittest-ctsm.yml index 93a7c7ab05..24e0fa5288 100644 --- a/.github/workflows/unittest-ctsm.yml +++ b/.github/workflows/unittest-ctsm.yml @@ -19,19 +19,6 @@ jobs: cd /CTSM ./bin/git-fleximod update - - name: Echo some output - run: | - echo "HOSTNAME: $HOSTNAME" - echo "HOME: $HOME" - - - name: Set up conda environment - uses: conda-incubator/setup-miniconda@v2 - with: - miniconda-version: 'latest' - activate-environment: testing - environment-file: ${{env.TESTING_DIR}}/testing.yml - channels: conda-forge, defaults - - name: Activate spack environment and run tests run: | . /opt/spack-environment/activate.sh From db9fbf840abb19db5470d7e8804a929472f712a8 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 7 Aug 2025 22:00:24 -0700 Subject: [PATCH 10/15] add temporary comment for next step --- .github/workflows/unittest-ctsm.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/unittest-ctsm.yml b/.github/workflows/unittest-ctsm.yml index 24e0fa5288..2649ef09e1 100644 --- a/.github/workflows/unittest-ctsm.yml +++ b/.github/workflows/unittest-ctsm.yml @@ -19,6 +19,8 @@ jobs: cd /CTSM ./bin/git-fleximod update + # Install conda environment + - name: Activate spack environment and run tests run: | . /opt/spack-environment/activate.sh From 6640eae7c2793d35fa856172ba159bd99f5586d8 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 8 Aug 2025 08:01:52 -0700 Subject: [PATCH 11/15] add conda installation and activation --- .github/workflows/unittest-ctsm.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/unittest-ctsm.yml b/.github/workflows/unittest-ctsm.yml index 2649ef09e1..cc5ae10a0e 100644 --- a/.github/workflows/unittest-ctsm.yml +++ b/.github/workflows/unittest-ctsm.yml @@ -19,11 +19,16 @@ jobs: cd /CTSM ./bin/git-fleximod update - # Install conda environment + # Install conda environment packages + - name: Install conda environment + run: | + conda env create --file -y ${{env.TESTING_DIR}}/testing.yml - - name: Activate spack environment and run tests + - name: Activate spack and conda environments and run tests run: | + conda activate testing . /opt/spack-environment/activate.sh + echo "CONDA_PREFIX: $CONDA_PREFIX" echo "NETCDF_FORTRAN_PATH: $NETCDF_FORTRAN_PATH" echo "NETCDF_C_PATH: $NETCDF_C_PATH" cd ${{env.TESTING_DIR}} From 3e3f87d05dc8f14e3f3f2dfe964ffe77b742a67d Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 8 Aug 2025 08:03:27 -0700 Subject: [PATCH 12/15] fix order of options --- .github/workflows/unittest-ctsm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unittest-ctsm.yml b/.github/workflows/unittest-ctsm.yml index cc5ae10a0e..99f0886000 100644 --- a/.github/workflows/unittest-ctsm.yml +++ b/.github/workflows/unittest-ctsm.yml @@ -22,7 +22,7 @@ jobs: # Install conda environment packages - name: Install conda environment run: | - conda env create --file -y ${{env.TESTING_DIR}}/testing.yml + conda env create --file ${{env.TESTING_DIR}}/testing.yml -y - name: Activate spack and conda environments and run tests run: | From a6a4ffbe867d65c812353b7bef02f45ab6d9f3cf Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 8 Aug 2025 08:09:10 -0700 Subject: [PATCH 13/15] move env variable to job context --- .github/workflows/unittest-ctsm.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/unittest-ctsm.yml b/.github/workflows/unittest-ctsm.yml index 99f0886000..9cc3ccb840 100644 --- a/.github/workflows/unittest-ctsm.yml +++ b/.github/workflows/unittest-ctsm.yml @@ -6,10 +6,11 @@ on: jobs: ctsm-unit-test: runs-on: ubuntu-latest + env: + TESTING_DIR: /CTSM/src/fates/testing/ container: image: ghcr.io/ngeet/containers/unit-test-ctsm:latest env: - TESTING_DIR: /CTSM/src/fates/testing/ BRANCH_NAME: ${{ github.head_ref }} BRANCH_URL: ${{ github.event.pull_request.head.repo.html_url }} From 2736ba3901b8ebea72bef349cd4daa55bcaad152 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 8 Aug 2025 08:13:52 -0700 Subject: [PATCH 14/15] initialize conda for this shell --- .github/workflows/unittest-ctsm.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/unittest-ctsm.yml b/.github/workflows/unittest-ctsm.yml index 9cc3ccb840..431fe9e2e3 100644 --- a/.github/workflows/unittest-ctsm.yml +++ b/.github/workflows/unittest-ctsm.yml @@ -20,6 +20,8 @@ jobs: cd /CTSM ./bin/git-fleximod update + # TODO: Cache conda + # Install conda environment packages - name: Install conda environment run: | @@ -27,6 +29,7 @@ jobs: - name: Activate spack and conda environments and run tests run: | + conda init bash conda activate testing . /opt/spack-environment/activate.sh echo "CONDA_PREFIX: $CONDA_PREFIX" From 27c17cd31016f054ae72e8e0f554098f23a1da08 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 8 Aug 2025 08:19:56 -0700 Subject: [PATCH 15/15] source instead of init conda --- .github/workflows/unittest-ctsm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unittest-ctsm.yml b/.github/workflows/unittest-ctsm.yml index 431fe9e2e3..51062c81ee 100644 --- a/.github/workflows/unittest-ctsm.yml +++ b/.github/workflows/unittest-ctsm.yml @@ -29,7 +29,7 @@ jobs: - name: Activate spack and conda environments and run tests run: | - conda init bash + source /opt/miniconda/etc/profile.d/conda.sh conda activate testing . /opt/spack-environment/activate.sh echo "CONDA_PREFIX: $CONDA_PREFIX"