From ce750c994fde531a544ef9509aa869c13cd1693b Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 7 Aug 2025 12:21:14 -0700 Subject: [PATCH 1/7] rename the CIME dockerfile --- unit-testing/{Dockerfile => Dockerfile-CIME} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename unit-testing/{Dockerfile => Dockerfile-CIME} (100%) diff --git a/unit-testing/Dockerfile b/unit-testing/Dockerfile-CIME similarity index 100% rename from unit-testing/Dockerfile rename to unit-testing/Dockerfile-CIME From 6d42a5281f9f4a212846d18452de0cdba05d13e1 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 7 Aug 2025 12:21:51 -0700 Subject: [PATCH 2/7] Add ctsm build workflow with necessary files --- .github/workflows/ctsm-build.yml | 47 ++++++++++++++++++++++ unit-testing/Dockerfile | 27 +++++++++++++ unit-testing/container/config_machines.xml | 34 ++++++++++++++++ 3 files changed, 108 insertions(+) create mode 100644 .github/workflows/ctsm-build.yml create mode 100644 unit-testing/Dockerfile create mode 100644 unit-testing/container/config_machines.xml diff --git a/.github/workflows/ctsm-build.yml b/.github/workflows/ctsm-build.yml new file mode 100644 index 0000000..6eb7e90 --- /dev/null +++ b/.github/workflows/ctsm-build.yml @@ -0,0 +1,47 @@ +name: Build and Push CTSM Container + +on: + workflow_dispatch: + pull_request: + branches: [main] + paths: + - 'unit-testing/Dockerfile' + - '.github/workflows/ctsm-build.yml' + +jobs: + build-and-push: + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + buildkitd-flags: --debug + + - name: Lowercase the github.repository name + # This step addresses https://github.com/orgs/community/discussions/25768 + run: | + echo "REPO_NAME=`echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]'`" >> $GITHUB_ENV + + - name: Build and push image + uses: docker/build-push-action@v6 + with: + context: ./unit-testing/ + push: true + tags: ghcr.io/${{ env.REPO_NAME}}/unit-test-ctsm:latest + cache-from: type=gha + cache-to: type=gha,mode=max \ No newline at end of file diff --git a/unit-testing/Dockerfile b/unit-testing/Dockerfile new file mode 100644 index 0000000..5459e93 --- /dev/null +++ b/unit-testing/Dockerfile @@ -0,0 +1,27 @@ +FROM ghcr.io/ngeet/containers/spack-env:latest + +# Manually update the ctsm version here +ARG CTSM_VERSION=ctsm5.3.065 + +# Set runtime environment variables for branch name and URL +ENV BRANCH_NAME="" +ENV BRANCH_URL="" + +# Install wget and git +RUN apt-get update && apt-get install -y wget git + +# Clone CTSM and checkout the specified version with git-fleximod +RUN git clone https://github.com/ESCOMP/CTSM.git && \ + cd CTSM && \ + git checkout ${CTSM_VERSION} && \ + ./bin/git-fleximod update + +# Overwrite the container configuration files in ccs_config +COPY container/ /ctsm/ccs_config/container/ + +# Modify the .gitmodules file to take an environment variable from the container runtime command +RUN sed -i '/\[submodule "fates"\]/,/\[submodule /{s|^\(url *= *\).*|url = '"\${BRANCH_URL}"'|; s|^\(fxtag *= *\).*|fxtag = '"\${BRANCH_NAME}"'|}' /CTSM/.gitmodules + +# Make sure that the entrypoint defined in the spack-env image is used +ENTRYPOINT [ "/entrypoint.sh" ] +CMD [ "/bin/bash" ] \ No newline at end of file diff --git a/unit-testing/container/config_machines.xml b/unit-testing/container/config_machines.xml new file mode 100644 index 0000000..7655eb7 --- /dev/null +++ b/unit-testing/container/config_machines.xml @@ -0,0 +1,34 @@ + + + + + linux + gnu + openmpi,mpi-serial + /output + /inputdata + /inputdata/atm/datm7 + $CIME_OUTPUT_ROOT/archive/$CASE + /baselines + $CIMEROOT/tools/cprnc/build/cprnc + make + 1 + none + glemieux at lbl dot gov + 4 + 1 + FALSE + + + + + mpirun + + -np $TOTALPES + -npernode $MAX_TASKS_PER_NODE + + + + + + From 13ae42fcf8e5f31a45386a73d1a08b51f12df8a4 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 7 Aug 2025 12:27:12 -0700 Subject: [PATCH 3/7] update cime build to use specific dockerfile and trigger on the workflow change only --- .github/workflows/cime-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cime-build.yml b/.github/workflows/cime-build.yml index 907692d..06679be 100644 --- a/.github/workflows/cime-build.yml +++ b/.github/workflows/cime-build.yml @@ -5,7 +5,6 @@ on: pull_request: branches: [main] paths: - - 'unit-testing/Dockerfile' - '.github/workflows/cime-build.yml' jobs: @@ -41,6 +40,7 @@ jobs: uses: docker/build-push-action@v6 with: context: ./unit-testing/ + dockerfile: Dockerfile-CIME push: true tags: ghcr.io/${{ env.REPO_NAME}}/unit-testing:latest cache-from: type=gha From 432b5dae8b22b9d121a3bc793713b77582f98c49 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 7 Aug 2025 12:27:50 -0700 Subject: [PATCH 4/7] change ctsm build to only trigger on workflow --- .github/workflows/ctsm-build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ctsm-build.yml b/.github/workflows/ctsm-build.yml index 6eb7e90..73605e7 100644 --- a/.github/workflows/ctsm-build.yml +++ b/.github/workflows/ctsm-build.yml @@ -5,7 +5,6 @@ on: pull_request: branches: [main] paths: - - 'unit-testing/Dockerfile' - '.github/workflows/ctsm-build.yml' jobs: From 9fb8b2cf141c1d4d7f8575428fccb1be92d03e6d Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 7 Aug 2025 12:29:45 -0700 Subject: [PATCH 5/7] add comment about triggering from ctsm repo tag event --- .github/workflows/ctsm-build.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ctsm-build.yml b/.github/workflows/ctsm-build.yml index 73605e7..36f8252 100644 --- a/.github/workflows/ctsm-build.yml +++ b/.github/workflows/ctsm-build.yml @@ -1,6 +1,9 @@ name: Build and Push CTSM Container on: + # We could have ctsm send out a trigger for this workflow + # repository_dispatch: + # types: [new-tag] workflow_dispatch: pull_request: branches: [main] From 25e0f9b390eb068fc43ba4a80f4b5276151ce86b Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 7 Aug 2025 12:43:09 -0700 Subject: [PATCH 6/7] update cime workflow to only trigger on workflow_dispatch --- .github/workflows/cime-build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cime-build.yml b/.github/workflows/cime-build.yml index 06679be..2aedefe 100644 --- a/.github/workflows/cime-build.yml +++ b/.github/workflows/cime-build.yml @@ -2,10 +2,10 @@ name: Build and Push CIME Container on: workflow_dispatch: - pull_request: - branches: [main] - paths: - - '.github/workflows/cime-build.yml' + # pull_request: + # branches: [main] + # paths: + # - '.github/workflows/cime-build.yml' jobs: build-and-push: From 65922f59a4680425de9818e4277b51a95d05139a Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 7 Aug 2025 12:52:22 -0700 Subject: [PATCH 7/7] add python to the install --- unit-testing/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unit-testing/Dockerfile b/unit-testing/Dockerfile index 5459e93..39b057f 100644 --- a/unit-testing/Dockerfile +++ b/unit-testing/Dockerfile @@ -7,8 +7,8 @@ ARG CTSM_VERSION=ctsm5.3.065 ENV BRANCH_NAME="" ENV BRANCH_URL="" -# Install wget and git -RUN apt-get update && apt-get install -y wget git +# Install dependencies not associated with the spack environment +RUN apt-get update && apt-get install -y wget git python3 # Clone CTSM and checkout the specified version with git-fleximod RUN git clone https://github.com/ESCOMP/CTSM.git && \