Skip to content

Merge pull request #4883 from billsacks/update_cprnc #1477

Merge pull request #4883 from billsacks/update_cprnc

Merge pull request #4883 from billsacks/update_cprnc #1477

Workflow file for this run

name: cime testing
on:
push:
branches:
- master
paths:
- 'CIME/**'
- 'scripts/**'
- 'tools/**'
- 'utils/**'
- 'docker/**'
pull_request:
branches:
- master
paths:
- 'CIME/**'
- 'scripts/**'
- 'tools/**'
- 'utils/**'
- 'docker/**'
workflow_dispatch:
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read # to fetch code (actions/checkout)
packages: read
jobs:
build-containers:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository }}
permissions:
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/ESMCI/cime
tags: |
type=raw,value=latest,enable=${{ github.event_name == 'push' }}
type=ref,event=pr,enable=${{ github.event_name == 'pull_request' }}
type=sha,format=long
- name: Build and push
uses: docker/build-push-action@v6
with:
target: base
context: docker/
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
pre-commit:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' && ! cancelled() }}
timeout-minutes: 2
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Runs pre-commit
run: |
pip install pre-commit
pre-commit run -a
# Runs unit testing under different python versions.
unit-testing:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' && always() && ! cancelled() }}
needs: build-containers
container:
image: ghcr.io/esmci/cime:${{ github.event.pull_request.head.repo.full_name == github.repository && format('sha-{0}', github.sha) || 'latest' }}
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.10", "3.12"]
steps:
- name: Checkout model code
uses: actions/checkout@v4
with:
repository: ESCOMP/CESM
path: cesm # $GITHUB_WORKSPACE/${{ matrix.model.name }}
ref: cesm3.0-alphabranch
- name: Get ccs_config dependency
working-directory: cesm
run: |
# Need these for machine files
./bin/git-fleximod update ccs_config
# Remove CIME to checkout
rm -rf cime/
git status
git submodule status
- name: Checkout code
uses: actions/checkout@v4
with:
path: cesm/cime
submodules: "true"
- name: Run tests
shell: bash
working-directory: cesm/cime
env:
CIME_MODEL: "cesm"
CIME_DRIVER: "nuopc"
CIME_TEST_PLATFORM: "ubuntu-latest"
SKIP_ENTRYPOINT: "true"
run: |
source /opt/conda/etc/profile.d/conda.sh
conda activate cesm
mamba install -y 'python=${{ matrix.python-version }}'
pip install -r test-requirements.txt
# GitHub runner home is different than container
cp -rf /home/cime/.cime /github/home/
pytest -vvv --cov=CIME --cov-branch --cov-report=xml --machine docker CIME/tests/test_unit*
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
# Run system tests
system-testing:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' && always() && ! cancelled() }}
needs: build-containers
container:
image: ghcr.io/esmci/cime:${{ github.event.pull_request.head.repo.full_name == github.repository && format('sha-{0}', github.sha) || 'latest' }}
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
options: --hostname docker
strategy:
# allow all jobs to finish
fail-fast: false
matrix:
model:
- name: "e3sm"
repo: E3SM-Project/e3sm
branch: master
- name: "cesm"
repo: ESCOMP/CESM
branch: cesm3.0-alphabranch
driver: ["mct", "nuopc"]
exclude:
# exclude nuopc driver when running e3sm tests
- model: { name: "e3sm" }
driver: "nuopc"
# exclude mct driver when running cesm tests
- model: { name: "cesm" }
driver: "mct"
steps:
- name: Checkout model code
uses: actions/checkout@v4
with:
repository: ${{ matrix.model.repo }}
path: ${{ matrix.model.name }} # $GITHUB_WORKSPACE/${{ matrix.model.name }}
ref: ${{ matrix.model.branch }}
- name: Check out model dependencies
shell: bash
working-directory: ${{ matrix.model.name }}
run: |
# need https for submodules
sed -i"" "s/\(.*\)url = [email protected]:\(.*\)/\1url = https:\/\/github.com\/\2/g" .gitmodules
if [[ "${{ matrix.model.name }}" == "e3sm" ]]; then
git submodule update --init
else
./bin/git-fleximod update
fi
# remove cime so it can be checkedout
rm -rf cime/
git status
git submodule status
- name: Checkout CIME
uses: actions/checkout@v4
with:
path: ${{ matrix.model.name }}/cime
submodules: 'true'
- name: Cache inputdata
uses: actions/cache@v3
with:
path: /home/cime/inputdata
key: inputdata-2
- name: Run tests
shell: bash
working-directory: ${{ matrix.model.name }}/cime
env:
CIME_MODEL: ${{ matrix.model.name }}
CIME_DRIVER: ${{ matrix.driver }}
CIME_TEST_PLATFORM: ubuntu-latest
SKIP_ENTRYPOINT: "true"
run: |
source /opt/conda/etc/profile.d/conda.sh
conda activate ${{ matrix.model.name }}
pip install -r test-requirements.txt
source /entrypoint.sh
if [[ "${{ matrix.model.name }}" == "e3sm" ]]; then
fix_mct_makefiles ../externals/mct
fi
# GitHub runner home is different than container
cp -rf /home/cime/.cime /github/home/
if [[ "${CIME_MODEL}" == "e3sm" ]]; then
ln -sf /github/home/.cime/config_machines.v2.xml /github/home/.cime/config_machines.xml
else
ln -sf /github/home/.cime/config_machines.v3.xml /github/home/.cime/config_machines.xml
fi
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
pytest -vvv --cov=CIME --cov-branch --cov-report=xml --machine docker --no-fortran-run --no-teardown CIME/tests/test_sys*
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
- uses: mxschmitt/action-tmate@v3
if: ${{ !always() }}
with:
limit-access-to-actor: true
- name: Create testing log archive
if: ${{ failure() }}
shell: bash
run: tar -czvf /testing-logs-${GITHUB_RUN_NUMBER}-${{ matrix.model.name }}-${{ matrix.driver }}.tar.gz /home/cime/cases /home/cime/baselines /home/cime/archive
# How to download artifacts:
# https://docs.github.com/en/actions/managing-workflow-runs/downloading-workflow-artifacts
- name: Upload testing logs
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: testing-logs-${{ github.run_number }}-${{ matrix.model.name }}-${{ matrix.driver }}
path: /testing-logs-${{ github.run_number}}-${{ matrix.model.name }}-${{ matrix.driver }}.tar.gz
retention-days: 4