-
Notifications
You must be signed in to change notification settings - Fork 8
191 lines (167 loc) · 6.27 KB
/
conda_pip.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
---
name: "Conda + pip"
# Use login shell everywhere
# https://github.com/mamba-org/setup-micromamba/tree/fcc371cea11af9012e5e916ab2dab44b42acdaaa#about-login-shells
on:
push:
branches:
- "main"
- "master"
paths:
- "**.py"
- ".github/workflows/*.yml"
- "pyproject.toml"
- "poetry.lock"
- "locks/*"
pull_request:
paths:
- "**.py"
- ".github/workflows/*.yml"
- "pyproject.toml"
- "poetry.lock"
- "locks/*"
jobs:
run-linters:
name: "Run linters"
runs-on: "ubuntu-latest"
steps:
- name: "Check out Git repository"
uses: "actions/checkout@v3"
- name: "Set up Python"
uses: "actions/setup-python@v3"
with:
python-version: "3.10"
- name: "Install Python dependencies"
run: "pip install 'black'"
- name: "Run linters"
run: "black --diff ./"
run-tests:
needs: "run-linters"
name: "Test Python ${{ matrix.python }} on ${{ matrix.os }} using ${{ matrix.mpi }}"
runs-on: "${{ matrix.os }}"
strategy:
fail-fast: false
matrix:
# os: [ "ubuntu-latest", "macos-latest" ]
# mpi: [ "mpich", "openmpi" ]
os: ["ubuntu-latest"]
mpi: ["openmpi"]
python: ["3.9", "3.10", "3.11", "3.12"]
env:
SCHISM_ENV: "SCHISM_ENV"
DELFT3D_ENV: "DELFT3D_ENV"
PYPOSEIDON_ENV: "PYPOSEIDON_ENV"
#
SCHISM_LOCK: locks/conda-${{ matrix.os }}-schism_${{ matrix.mpi }}.lock
DELFT3D_LOCK: locks/conda-${{ matrix.os }}-delft3d_${{ matrix.mpi }}.lock
PYPOSEIDON_LOCK: locks/conda-${{ matrix.os }}-binary-p${{ matrix.python }}.lock
REQUIREMENTS_CI: locks/requirements-ci.txt
REQUIREMENTS_VIZ: locks/requirements-viz.txt
defaults:
run:
shell: "bash -elo pipefail {0}"
steps:
- run: "env | sort"
- uses: "actions/checkout@v3"
- name: "Install micromamba"
run: |
mkdir -p ~/.local/bin/
curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj -C ~/.local/bin/ --strip-components=1 bin/micromamba
echo export MAMBA_EXE=$(which micromamba) | tee -a ~/.bashrc
echo export MAMBA_ROOT_PREFIX=~/micromamba | tee -a ~/.bashrc
- run: which micromamba
- name: "Create ~/.condarc"
run: |
rm -rf ~/.condarc
cat << EOF > ~/.condarc
---
auto_activate_base: false
auto_stack: false
channel_priority: strict
channels:
- gbrey
- conda-forge
EOF
- run: cat ~/.condarc
- name: "Cache ${{ env.SCHISM_ENV }}"
uses: actions/cache@v3
id: cache-SCHISM_ENV
with:
path: ~/micromamba/envs/${{ env.SCHISM_ENV }}
key: ${{ matrix.os }}-${{ matrix.mpi }}-${{ env.SCHISM_ENV }}-${{ hashFiles( env.SCHISM_LOCK )}}
restore-keys: |
${{ matrix.os }}-${{ matrix.mpi }}-${{ env.SCHISM_ENV }}-
- name: "Cache ${{ env.DELFT3D_ENV }}"
uses: actions/cache@v3
id: cache-DELFT3D_ENV
with:
path: ~/micromamba/envs/${{ env.DELFT3D_ENV }}
key: ${{ matrix.os }}-${{ matrix.mpi }}-${{ env.DELFT3D_ENV }}-${{ hashFiles( env.DELFT3D_LOCK )}}
restore-keys: |
${{ matrix.os }}-${{ matrix.mpi }}-${{ env.DELFT3D_ENV }}-
- name: "Cache ${{ env.PYPOSEIDON_ENV }}"
uses: actions/cache@v3
id: cache-PYPOSEIDON_ENV
with:
path: ~/micromamba/envs/${{ env.PYPOSEIDON_ENV }}
key: ${{ matrix.os }}-${{ matrix.python }}-${{ env.PYPOSEIDON_ENV }}-${{ hashFiles( env.PYPOSEIDON_LOCK )}}-${{ hashFiles( env.REQUIREMENTS_CI )}}
restore-keys: |
${{ matrix.os }}-${{ matrix.python }}-${{ env.PYPOSEIDON_ENV }}-${{ hashFiles( env.PYPOSEIDON_LOCK )}}
${{ matrix.os }}-${{ matrix.python }}-${{ env.PYPOSEIDON_ENV }}-
- name: Cache tests/data/
uses: actions/cache@v3
env:
# Increase this value to reset cache if files in tests/data have been added/removed
CACHE_NUMBER: 0
with:
path: /home/runner/work/pyPoseidon/pyPoseidon/tests/data
key: tests_data-${{ env.CACHE_NUMBER }}
- name: "Create ${{ env.SCHISM_ENV }}"
if: steps.cache-SCHISM_ENV.outputs.cache-hit != 'true'
run: micromamba create --yes --name ${SCHISM_ENV} -f ${SCHISM_LOCK}
- name: "Create ${{ env.DELFT3D_ENV }}"
if: steps.cache-DELFT3D_ENV.outputs.cache-hit != 'true'
run: micromamba create --yes --name ${DELFT3D_ENV} -f ${DELFT3D_LOCK}
- name: "Create ${{ env.PYPOSEIDON_ENV }}"
if: steps.cache-PYPOSEIDON_ENV.outputs.cache-hit != 'true'
run: micromamba create --yes --name ${PYPOSEIDON_ENV} -f ${PYPOSEIDON_LOCK}
- name: "Check schism version"
run: |
eval "$(micromamba shell hook)"
micromamba activate "${SCHISM_ENV}"
schism -v
- name: "Install python dependencies"
run: |
eval "$(micromamba shell hook)"
micromamba activate --stack "${PYPOSEIDON_ENV}"
python -mpip install -U pip
python -mpip install -r "${REQUIREMENTS_CI}"
python -mpip install ./
- name: "Run tests: Basic"
run: |
eval "$(micromamba shell hook)"
micromamba activate "${SCHISM_ENV}"
micromamba activate --stack "${DELFT3D_ENV}"
micromamba activate --stack "${PYPOSEIDON_ENV}"
make test
# - name: "Run tests: Viz"
# if: matrix.python != '3.11'
# run: |
# eval "$(micromamba shell hook)"
# micromamba activate "${PYPOSEIDON_ENV}"
# python -mpip install -r "${REQUIREMENTS_VIZ}"
# make test_viz
- name: "Run tests: Schism"
run: |
eval "$(micromamba shell hook)"
micromamba activate "${SCHISM_ENV}"
# micromamba activate --stack "${DELFT3D_ENV}"
micromamba activate --stack "${PYPOSEIDON_ENV}"
make test_schism
- name: "Run tests: Delft"
run: |
eval "$(micromamba shell hook)"
# micromamba activate "${SCHISM_ENV}"
micromamba activate --stack "${DELFT3D_ENV}"
micromamba activate --stack "${PYPOSEIDON_ENV}"
make test_delft