Skip to content

Commit

Permalink
Updates checking out CIME branch and using git-fleximod for CESM subm…
Browse files Browse the repository at this point in the history
…odules
  • Loading branch information
jasonb5 committed Jul 3, 2024
1 parent 37c9dba commit c7b9bf3
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 62 deletions.
21 changes: 5 additions & 16 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ jobs:
CIME_MODEL: "cesm"
CIME_DRIVER: "nuopc"
CIME_TEST_PLATFORM: ubuntu-latest
SKIP_MODEL_SETUP: "true"
run: |
export SRC_PATH="${GITHUB_WORKSPACE}"
Expand All @@ -119,8 +120,6 @@ jobs:
# GitHub runner home is different than container
cp -rf /root/.cime /github/home/
git status
pytest -vvv --cov=CIME --machine docker --no-fortran-run CIME/tests/test_unit*
# Run system tests
Expand Down Expand Up @@ -163,27 +162,17 @@ jobs:
CIME_TEST_PLATFORM: ubuntu-latest
run: |
export SRC_PATH="${GITHUB_WORKSPACE}"
export CIME_REMOTE=https://github.com/${{ github.event.pull_request.head.repo.full_name || github.repository }}
export CIME_BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF##*/}}
source /entrypoint.sh
# GitHub runner home is different than container
cp -rf /root/.cime /github/home/
if [[ "${CIME_MODEL}" == "e3sm" ]]; then
git remote set-url origin https://github.com/${{ github.event.pull_request.head.repo.full_name || github.repository }}
git remote set-branches origin "*"
git fetch origin
git checkout ${GITHUB_HEAD_REF:-${GITHUB_REF##*/}}
# sync correct submodules
git submodule update
source /opt/conda/etc/profile.d/conda.sh
conda activate base
fi
source /opt/conda/etc/profile.d/conda.sh
git status
conda activate base
pytest -vvv --cov=CIME --machine docker --no-fortran-run --no-teardown CIME/tests/test_sys*
- uses: mxschmitt/action-tmate@v3
Expand Down
6 changes: 2 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,13 @@ RUN git clone -b ${CIME_BRANCH} ${CIME_REPO} /src/cime
ENV USER=root
ENV LOGNAME=root
ENV ESMFMKFILE=/opt/conda/lib/esmf.mk
ENV SRC_PATH=/src

WORKDIR /src/cime
WORKDIR /src

COPY .cime /root/.cime
COPY entrypoint.sh /entrypoint.sh

# TODO: REMOVE trigger
ENV TRIGGER=0

ENTRYPOINT [ "/entrypoint.sh" ]

FROM base as slurm
Expand Down
91 changes: 49 additions & 42 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,23 @@ SRC_PATH="${SRC_PATH:-`pwd`}"
GIT_FLAGS="${GIT_FLAGS:---filter=tree:0}"
# Shallow submodule checkout
GIT_SUBMODULE_FLAGS="${GIT_SUBMODULE_FLAGS:---recommend-shallow}"
SKIP_MODEL_SETUP="${SKIP_MODEL_CHECKOUT:-false}"
CIME_REMOTE="${CIME_REMOTE:-https://github.com/ESMCI/cime}"
CIME_BRANCH="${CIME_BRANCH:-master}"

echo "DEBUG = ${DEBUG}"
echo "SRC_PATH = ${SRC_PATH}"
echo "GIT_FLAGS = ${GIT_FLAGS}"
echo "GIT_SUBMODULE_FLAGS = ${GIT_SUBMODULE_FLAGS}"
echo "SKIP_MODEL_SETUP = ${SKIP_MODEL_SETUP}"
echo "CIME_REMOTE = ${CIME_REMOTE}"
echo "CIME_BRANCH = ${CIME_BRANCH}"

if [[ "$(echo ${DEBUG} | tr -s '[:upper:]' '[:lower:]')" == "true" ]]
then
function to_lowercase() {
echo "${!1}" | tr -s '[:upper:]' '[:lower:]'
}

if [[ "$(to_lowercase DEBUG)" == "true" ]]; then
set -x
fi

Expand All @@ -22,7 +31,7 @@ fi
#
# TODO need to make an offical PR this is temporary.
#######################################
function fix_mct_arflags {
function fix_mct_arflags() {
local mct_path="${1}"

# TODO make PR to fix
Expand All @@ -48,64 +57,62 @@ function fix_gitmodules() {
sed -i".bak" "s/git@github.com:/https:\/\/github.com\//g" "${1}/.gitmodules"
}

if [[ "${CIME_MODEL}" == "e3sm" ]]
then
echo "Setting up E3SM"

[[ ! -e "${SRC_PATH}/E3SM" ]] && git clone -b ${E3SM_BRANCH:-master} ${GIT_FLAGS} ${E3SM_REPO:-https://github.com/E3SM-Project/E3SM} "${SRC_PATH}/E3SM"

pushd "${SRC_PATH}/E3SM"
if [[ "${SKIP_MODEL_SETUP}" == "false" ]]; then
if [[ "${CIME_MODEL}" == "e3sm" ]]; then
echo "Setting up E3SM"

git config --global --add safe.directory "*"
[[ ! -e "${SRC_PATH}/E3SM" ]] && git clone -b ${E3SM_BRANCH:-master} ${GIT_FLAGS} ${E3SM_REPO:-https://github.com/E3SM-Project/E3SM} "${SRC_PATH}/E3SM"

# fix E3SM gitmodules
fix_gitmodules "${PWD}"
pushd "${SRC_PATH}/E3SM"

git status
git config --global --add safe.directory "*"

# checkout submodules
git submodule update --init "${GIT_SUBMODULE_FLAGS}"
# fix E3SM gitmodules
fix_gitmodules "${PWD}"

# fix mct arflags flags
fix_mct_arflags "${SRC_PATH}/E3SM/externals/mct"
git status

pushd cime
# checkout submodules
git submodule update --init "${GIT_SUBMODULE_FLAGS}"

# fix CIME gitmodules
fix_gitmodules "${PWD}"
# fix mct arflags flags
fix_mct_arflags "${SRC_PATH}/E3SM/externals/mct"

# checkout submodules
git submodule update --init "${GIT_SUBMODULE_FLAGS}"
pushd cime
elif [[ "${CIME_MODEL}" == "cesm" ]]; then
echo "Setting up CESM"

# link v2 config_machines
ln -sf /root/.cime/config_machines.v2.xml /root/.cime/config_machines.xml
elif [[ "${CIME_MODEL}" == "cesm" ]]
then
echo "Setting up CESM"

[[ ! -e "${SRC_PATH}/CESM" ]] && git clone -b ${CESM_BRANCH:-master} ${GIT_FLAGS} ${E3SM_REPO:-https://github.com/ESCOMP/CESM} "${SRC_PATH}/CESM"
[[ ! -e "${SRC_PATH}/CESM" ]] && git clone -b ${CESM_BRANCH:-master} ${GIT_FLAGS} ${E3SM_REPO:-https://github.com/ESCOMP/CESM} "${SRC_PATH}/CESM"

pushd "${SRC_PATH}/CESM"
pushd "${SRC_PATH}/CESM"

git config --global --add safe.directory "*"
git config --global --add safe.directory "*"

# fix CIME gitmodules
fix_gitmodules "${PWD}"
./bin/git-fleximod update

git status
git status

git submodule update --init "${GIT_SUBMODULE_FLAGS}"
git submodule update --init "${GIT_SUBMODULE_FLAGS}" --recursive components/cdeps
pushd cime
fi
fi

pushd cime
# Expect current directory to be CIME
git remote set-url origin "${CIME_REMOTE}"
git remote set-branches origin "*"
git fetch origin
git checkout "${CIME_BRANCH}"

fix_gitmodules "${PWD}"
# Sync submodules
git submodule update --init

# update CIME submodules
git submodule update --init "${GIT_SUBMODULE_FLAGS}"
git status

if [[ "${CIME_MODEL}" == "e3sm" ]]; then
# link v2 config_machines
ln -sf ~/.cime/config_machines.v2.xml ~/.cime/config_machines.xml
elif [[ "${CIME_MODEL}" == "cesm" ]]; then
# link v3 config_machines
ln -sf /root/.cime/config_machines.v3.xml /root/.cime/config_machines.xml
ln -sf ~/.cime/config_machines.v3.xml ~/.cime/config_machines.xml
fi

# load batch specific entrypoint
Expand Down

0 comments on commit c7b9bf3

Please sign in to comment.