diff --git a/.github/workflows/cime-build.yml b/.github/workflows/cime-build.yml index 907692d..2aedefe 100644 --- a/.github/workflows/cime-build.yml +++ b/.github/workflows/cime-build.yml @@ -2,11 +2,10 @@ name: Build and Push CIME Container on: workflow_dispatch: - pull_request: - branches: [main] - paths: - - 'unit-testing/Dockerfile' - - '.github/workflows/cime-build.yml' + # pull_request: + # branches: [main] + # paths: + # - '.github/workflows/cime-build.yml' jobs: build-and-push: @@ -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 diff --git a/.github/workflows/ctsm-build.yml b/.github/workflows/ctsm-build.yml new file mode 100644 index 0000000..36f8252 --- /dev/null +++ b/.github/workflows/ctsm-build.yml @@ -0,0 +1,49 @@ +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] + paths: + - '.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 index ab7af74..39b057f 100644 --- a/unit-testing/Dockerfile +++ b/unit-testing/Dockerfile @@ -1,24 +1,26 @@ FROM ghcr.io/ngeet/containers/spack-env:latest -ARG CIME_VERSION=cime6.1.102 -ARG CCS_CONFIG_VERSION=ccs_config_cesm1.0.46 +# Manually update the ctsm version here +ARG CTSM_VERSION=ctsm5.3.065 -# Install wget -RUN apt-get update && apt-get install -y wget +# Set runtime environment variables for branch name and URL +ENV BRANCH_NAME="" +ENV BRANCH_URL="" -# Download and unpack CIME archive for tag cime6.1.102. Rename the directory to cime. -RUN wget -q https://github.com/ESMCI/cime/archive/refs/tags/${CIME_VERSION}.tar.gz \ - && tar -xzf ${CIME_VERSION}.tar.gz \ - && mv cime-${CIME_VERSION} cime \ - && rm ${CIME_VERSION}.tar.gz +# Install dependencies not associated with the spack environment +RUN apt-get update && apt-get install -y wget git python3 -RUN wget -q https://github.com/ESMCI/ccs_config_cesm/archive/refs/tags/${CCS_CONFIG_VERSION}.tar.gz \ - && tar -xzf ${CCS_CONFIG_VERSION}.tar.gz \ - && mv ccs_config_cesm-${CCS_CONFIG_VERSION} ccs_config \ - && rm ${CCS_CONFIG_VERSION}.tar.gz +# 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 -# Copy the cime configuration files in the .cime directory in the container -COPY cime/ /root/.cime/ +# 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" ] diff --git a/unit-testing/Dockerfile-CIME b/unit-testing/Dockerfile-CIME new file mode 100644 index 0000000..ab7af74 --- /dev/null +++ b/unit-testing/Dockerfile-CIME @@ -0,0 +1,25 @@ +FROM ghcr.io/ngeet/containers/spack-env:latest + +ARG CIME_VERSION=cime6.1.102 +ARG CCS_CONFIG_VERSION=ccs_config_cesm1.0.46 + +# Install wget +RUN apt-get update && apt-get install -y wget + +# Download and unpack CIME archive for tag cime6.1.102. Rename the directory to cime. +RUN wget -q https://github.com/ESMCI/cime/archive/refs/tags/${CIME_VERSION}.tar.gz \ + && tar -xzf ${CIME_VERSION}.tar.gz \ + && mv cime-${CIME_VERSION} cime \ + && rm ${CIME_VERSION}.tar.gz + +RUN wget -q https://github.com/ESMCI/ccs_config_cesm/archive/refs/tags/${CCS_CONFIG_VERSION}.tar.gz \ + && tar -xzf ${CCS_CONFIG_VERSION}.tar.gz \ + && mv ccs_config_cesm-${CCS_CONFIG_VERSION} ccs_config \ + && rm ${CCS_CONFIG_VERSION}.tar.gz + +# Copy the cime configuration files in the .cime directory in the container +COPY cime/ /root/.cime/ + +# 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 + + + + + +