-
Notifications
You must be signed in to change notification settings - Fork 0
217 lines (204 loc) · 7.9 KB
/
main.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
207
208
209
210
211
212
213
214
215
216
217
name: Testing
on:
push:
branches:
- main
pull_request:
concurrency:
# For a given workflow, if we push to the same branch, cancel all previous builds on that branch except on main.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
permissions:
contents: read
jobs:
black:
name: Code linting
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
files.pythonhosted.org:443
github.com:443
proxy.golang.org:443
pypi.org:443
storage.googleapis.com:443
sum.golang.org:443
- name: Checkout Repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Python3
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: "3.x"
cache: "pip"
- name: Run pre-commit hooks
uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
build-windows:
name: Python${{ matrix.python-version }} (Windows, conda=${{ matrix.conda }})
needs: black
runs-on: 'windows-latest'
strategy:
fail-fast: false
matrix:
python-version: [ "3.9", "3.13" ]
conda: [ true, false ]
defaults:
run:
shell: bash -l {0}
steps:
# Harden Runner does not support Windows virtual environments
- name: Checkout Repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
submodules: true
- name: Setup Python${{ matrix.python-version }}
if: ${{ !matrix.conda }}
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Set up Python${{ matrix.python-version }} with NetCDF4 (conda)
if: ${{ matrix.conda }}
uses: mamba-org/setup-micromamba@06375d89d211a1232ef63355742e9e2e564bc7f7 # v2.0.2
with:
cache-downloads: true
cache-environment: true
environment-file: environment.yml
create-args: >-
python=${{ matrix.python-version }}
post-cleanup: 'all'
- name: Install raven-hydro
if: ${{ !matrix.conda }}
run: |
python -m pip install --editable . -C cmake.define.USE_NETCDF=false
- name: Install raven-hydro
if: ${{ matrix.conda }}
run: |
python -m pip install --editable .
- name: Check versions
run: |
python -m pip list
python -m pip check
- name: Test raven-hydro
run: |
python -c "import raven_hydro; print(f'Description: {raven_hydro.__doc__}')"
python -c "import raven_hydro; print(f'Built with netcdf: {raven_hydro.__netcdf__}')"
python -c "import raven_hydro; print(f'RavenHydroFramework version: {raven_hydro.__raven_version__}')"
python -c "import raven_hydro; print(f'raven_hydro version: {raven_hydro.__version__}')"
- name: Test raven
run: |
raven -v
build-unix:
name: Python${{ matrix.python-version }} (${{ matrix.os }}, conda=${{ matrix.conda }}, args=${{ matrix.install_args }})
needs: black
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
os:
- ubuntu-latest
# - macos-latest # macOS with Apple Silicon is not supported yet
conda: [ true, false ]
install_args: [ "" ]
include:
- python-version: "3.12"
os: ubuntu-latest
conda: false
install_args: "-C cmake.define.USE_NETCDF=false"
defaults:
run:
shell: bash -l {0}
steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: block
allowed-endpoints: >
api.github.com:443
azure.archive.ubuntu.com:80
conda.anaconda.org:443
esm.ubuntu.com:443
files.pythonhosted.org:443
github.com:443
motd.ubuntu.com:443
objects.githubusercontent.com:443
packages.microsoft.com:443
pypi.org:443
repo.anaconda.com:443
- name: Checkout Repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
submodules: true
- name: Setup Python${{ matrix.python-version }}
if: ${{ !matrix.conda }}
id: pyinstalled
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Set up Python${{ matrix.python-version }} with NetCDF4 (conda)
if: ${{ matrix.conda }}
uses: mamba-org/setup-micromamba@06375d89d211a1232ef63355742e9e2e564bc7f7 # v2.0.2
with:
cache-downloads: true
cache-environment: true
environment-file: environment.yml
create-args: >-
python=${{ matrix.python-version }}
- name: Install NetCDF4 (Ubuntu/apt)
if: (matrix.os == 'ubuntu-latest') && (!matrix.install_args) && (!matrix.conda)
run: |
sudo apt-get update
sudo apt-get install libnetcdf-dev
- name: Install NetCDF4 (macOS/homebrew)
if: (matrix.os == 'macos-latest') && (!matrix.conda)
uses: tecolicom/actions-use-homebrew-tools@b9c066b79607fa3d71e0be05d7003bb75fd9ff34 # v1.3.0
with:
tools: netcdf
cache: "yes"
- name: Check for OPeNDAP Support
if: (!matrix.install_args)
run: |
nc-config --has-dap
- name: Install raven-hydro
if: ${{ !matrix.conda }}
run: |
${{ steps.pyinstalled.outputs.python-path }} -m pip install --editable . ${{ matrix.install_args }}
- name: Check versions
if: ${{ !matrix.conda }}
run: |
${{ steps.pyinstalled.outputs.python-path }} -m pip list
${{ steps.pyinstalled.outputs.python-path }} -m pip check || true
- name: Test raven-hydro
if: ${{ !matrix.conda }}
run: |
${{ steps.pyinstalled.outputs.python-path }} -c "import raven_hydro; print(f'Description: {raven_hydro.__doc__}')"
${{ steps.pyinstalled.outputs.python-path }} -c "import raven_hydro; print(f'Built with netcdf: {raven_hydro.__netcdf__}')"
${{ steps.pyinstalled.outputs.python-path }} -c "import raven_hydro; print(f'RavenHydroFramework version: {raven_hydro.__raven_version__}')"
${{ steps.pyinstalled.outputs.python-path }} -c "import raven_hydro; print(f'raven_hydro version: {raven_hydro.__version__}')"
- name: Install raven-hydro (conda)
if: ${{ matrix.conda }}
run: |
python -m pip install --editable . ${{ matrix.install_args }}
- name: Check versions
if: ${{ matrix.conda }}
run: |
micromamba list
python -m pip list
python -m pip check || true
- name: Test raven-hydro (conda)
if: ${{ matrix.conda }}
run: |
python -c "import raven_hydro; print(f'Description: {raven_hydro.__doc__}')"
python -c "import raven_hydro; print(f'Built with netcdf: {raven_hydro.__netcdf__}')"
python -c "import raven_hydro; print(f'RavenHydroFramework version: {raven_hydro.__raven_version__}')"
python -c "import raven_hydro; print(f'raven_hydro version: {raven_hydro.__version__}')"
- name: Test raven
run: |
raven -v