Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/cime-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/ctsm-build.yml
Original file line number Diff line number Diff line change
@@ -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
32 changes: 17 additions & 15 deletions unit-testing/Dockerfile
Original file line number Diff line number Diff line change
@@ -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" ]
Expand Down
25 changes: 25 additions & 0 deletions unit-testing/Dockerfile-CIME
Original file line number Diff line number Diff line change
@@ -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" ]
34 changes: 34 additions & 0 deletions unit-testing/container/config_machines.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0"?>
<config_machines>
<machine MACH="fatestestcontainer">
<DESC></DESC>
<OS>linux</OS>
<COMPILERS>gnu</COMPILERS>
<MPILIBS>openmpi,mpi-serial</MPILIBS>
<CIME_OUTPUT_ROOT>/output</CIME_OUTPUT_ROOT>
<DIN_LOC_ROOT>/inputdata</DIN_LOC_ROOT>
<DIN_LOC_ROOT_CLMFORC>/inputdata/atm/datm7</DIN_LOC_ROOT_CLMFORC>
<DOUT_S_ROOT>$CIME_OUTPUT_ROOT/archive/$CASE</DOUT_S_ROOT>
<BASELINE_ROOT>/baselines</BASELINE_ROOT>
<CCSM_CPRNC>$CIMEROOT/tools/cprnc/build/cprnc</CCSM_CPRNC>
<GMAKE>make</GMAKE>
<GMAKE_J>1</GMAKE_J>
<BATCH_SYSTEM>none</BATCH_SYSTEM>
<SUPPORTED_BY>glemieux at lbl dot gov</SUPPORTED_BY>
<MAX_TASKS_PER_NODE>4</MAX_TASKS_PER_NODE>
<MAX_MPITASKS_PER_NODE>1</MAX_MPITASKS_PER_NODE>
<PROJECT_REQUIRED>FALSE</PROJECT_REQUIRED>
<mpirun mpilib="mpi-serial">
<executable></executable>
</mpirun>
<mpirun mpilib="default">
<executable>mpirun</executable>
<arguments>
<arg name="anum_tasks"> -np $TOTALPES</arg>
<arg name="tasks_per_node"> -npernode $MAX_TASKS_PER_NODE</arg>
</arguments>
</mpirun>
<module_system type="none"/>
</machine>

</config_machines>
Loading