Skip to content

use . instead of source which is not available in all shells #601

use . instead of source which is not available in all shells

use . instead of source which is not available in all shells #601

Workflow file for this run

name: cime testing
on:
push:
branches:
- master
pull_request:
branches:
- master
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
pre-commit:
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up python
uses: actions/setup-python@v2
with:
python-version: 3.9
# Offical action is deprecated in favor of pre-commit.ci
# Should evaulate switching or just running manually.
# - name: Runs pre-commit action
# # Do not run if using act tooling (https://github.com/nektos/act)
# if: ${{ !env.ACT }}
# uses: pre-commit/action@v2.0.3
- name: Runs pre-commit
run: |
pip install pre-commit
pre-commit run -a
# Check if there has been a change to any file under docker/
check-dockerfile-changed:
runs-on: ubuntu-latest
outputs:
all_changed_and_modified_files: ${{ steps.get-changed-files.outputs.all_changed_and_modified_files }}
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Get changed files
id: get-changed-files
uses: tj-actions/changed-files@v17.2
with:
files: docker/*
# Only build container if there has been a change.
# Only upload container when merging into master and there has been a change.
build-containers:
runs-on: ubuntu-latest
needs: check-dockerfile-changed
if: ${{ needs.check-dockerfile-changed.outputs.all_changed_and_modified_files != '' }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: jasonb87/cime
tags: |
type=raw,value=latest
type=sha,prefix={{ date 'YYYYMMDD' }}_,format=short
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
with:
target: base
context: docker/
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# Runs unit testing under different python versions.
unit-testing:
runs-on: ubuntu-latest
needs: build-containers
if: ${{ always() }}
container: jasonb87/cime:latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Run tests
shell: bash
env:
INIT: "false"
CIME_MODEL: "cesm"
CIME_DRIVER: "mct"
UPDATE_CIME: "true"
GIT_SHALLOW: "true"
CIME_TEST_PLATFORM: ubuntu-latest
run: |
export INSTALL_PATH="${PWD}"
export CIME_REPO=https://github.com/${{ github.event.pull_request.head.repo.full_name || github.repository }}
export CIME_BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF##*/}}
mamba install -y python=${{ matrix.python-version }}
source /entrypoint.sh
init_cime
pytest -vvv --machine docker --no-fortran-run CIME/tests/test_unit*
# Run system tests
system-testing:
runs-on: ubuntu-latest
needs: build-containers
if: ${{ always() }}
container: jasonb87/cime:latest
strategy:
matrix:
model: ["e3sm", "cesm"]
driver: ["mct", "nuopc"]
exclude:
# exclude nuopc driver when running e3sm tests
- model: "e3sm"
driver: "nuopc"
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Cache inputdata
if: ${{ ! env.ACT }}
uses: actions/cache@v2
with:
path: /storage/inputdata
key: inputdata-2
- name: Run tests
shell: bash
env:
INIT: "false"
CIME_MODEL: ${{ matrix.model }}
CIME_DRIVER: ${{ matrix.driver }}
UPDATE_CIME: "true"
GIT_SHALLOW: "true"
CIME_TEST_PLATFORM: ubuntu-latest
run: |
export INSTALL_PATH="${PWD}/cime"
export CIME_REPO=https://github.com/${{ github.event.pull_request.head.repo.full_name || github.repository }}
export CIME_BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF##*/}}
source /entrypoint.sh
if [[ "${CIME_MODEL}" == "e3sm" ]]
then
init_e3sm
else
init_cime
fi
source /opt/conda/etc/profile.d/conda.sh
conda activate base
pytest -vvv --machine docker --no-fortran-run CIME/tests/test_sys*