-
Notifications
You must be signed in to change notification settings - Fork 207
206 lines (184 loc) · 6.66 KB
/
testing.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
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@v3
- name: Set up python
uses: actions/setup-python@v2
with:
python-version: 3.9
- 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:
matrix:
python-version: ['3.8', '3.9', '3.10']
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Run tests
shell: bash
env:
CIME_MODEL: "cesm"
CIME_DRIVER: "nuopc"
CIME_TEST_PLATFORM: ubuntu-latest
run: |
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
# from 'entrypoint.sh', create and activate new environment
create_environment ${{ matrix.python-version }}
pip install -r test-requirements.txt
# GitHub runner home is different than container
cp -rf /root/.cime /github/home/
pytest -vvv --cov=CIME --machine docker --no-fortran-run CIME/tests/test_unit*
# 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: ["e3sm", "cesm"]
driver: ["mct", "nuopc"]
exclude:
# exclude nuopc driver when running e3sm tests
- model: "e3sm"
driver: "nuopc"
# exclude mct driver when running cesm tests
- model: "cesm"
driver: "mct"
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Cache inputdata
uses: actions/cache@v2
with:
path: /storage/inputdata
key: inputdata-2
- name: Run tests
shell: bash
env:
CIME_MODEL: ${{ matrix.model }}
CIME_DRIVER: ${{ matrix.driver }}
CIME_TEST_PLATFORM: ubuntu-latest
run: |
pip install -r test-requirements.txt
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/
source /opt/conda/etc/profile.d/conda.sh
conda activate base
# container libnetcdf is 4.9.2 as cesm requires esmf >8.6.1
# e3sm scorpio incompatible with 4.9.2, downgrade to 4.9.1
# only reference found about scorpio incompatibility with 4.9.2 (https://github.com/E3SM-Project/scorpio/issues/554#issuecomment-1877361470)
# TODO open scorpio issue, possible solutions; 1. support two conda environments in container 2. maybe move from conda to spack? build all libraries in image
if [[ "${CIME_MODEL}" == "e3sm" ]]; then
mamba install -y 'libnetcdf=4.9.1'
fi
pytest -vvv --cov=CIME --machine docker --no-fortran-run --no-teardown CIME/tests/test_sys*
- 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 }}-${{ matrix.driver }}.tar.gz /storage/cases/
# 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@v3
with:
name: testing-logs-${{ github.run_number }}-${{ matrix.model }}-${{ matrix.driver }}
path: /testing-logs-${{ github.run_number}}-${{ matrix.model }}-${{ matrix.driver }}.tar.gz
retention-days: 4