Repository navigation
319 lines (283 loc) · 11.7 KB
/
Copy pathpackages.yml
File metadata and controls
319 lines (283 loc) · 11.7 KB
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
name: "📦 Workspace packages"
# Stage 2 of ROADMAP.md (outcome 2): loop_common/loop_interpolation live under
# packages/ as independent uv-workspace members so the interpolation code is
# usable outside the LoopStructural framework. Stage 4 (outcomes 5, 7) added
# loopstructural_visualisation (packages-test matrix, below) and map2loop
# (map2loop-test, its own job: map2loop hard-depends on GDAL bindings, which
# aren't pip-installable on Windows/macOS the way this matrix installs
# everything else, so it only runs on ubuntu with an apt-installed libgdal —
# matching map2loop's own upstream CI, which uses conda for the same reason).
# This job installs and tests packages on their own, separately from the root
# LoopStructural test suite in tester.yml. loopstructural-test waits on both
# jobs (needs:) so the root suite only runs once every workspace package is
# confirmed working.
#
# On a pull request, only the jobs whose code changed run (see the `changes`
# job). A change in a package also runs the packages and the root suite that
# depend on it:
#
# loop_common -> loop_interpolation, LoopStructural, visualisation
# loop_interpolation -> LoopStructural, visualisation
# LoopStructural -> visualisation
# map2loop -> (nothing; it does not depend on the others)
#
# A change in uv.lock or in this file runs everything. A push to master and a
# manual run always run everything.
on:
push:
branches:
- master
paths:
- 'packages/**'
- 'LoopStructural/**'
- 'tests/**'
- pyproject.toml
- uv.lock
- .github/workflows/packages.yml
pull_request:
branches:
- master
paths:
- 'packages/**'
- 'LoopStructural/**'
- 'tests/**'
- pyproject.toml
- uv.lock
- .github/workflows/packages.yml
workflow_dispatch:
permissions:
contents: read
jobs:
changes:
# Decides which test jobs run. It writes one flag for each job group and
# the list of workspace packages for the packages-test matrix.
name: Changed code
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
outputs:
packages: ${{ steps.decide.outputs.packages }}
map2loop: ${{ steps.decide.outputs.map2loop }}
root: ${{ steps.decide.outputs.root }}
steps:
- uses: actions/checkout@v4
- name: Find the changed paths
id: filter
uses: dorny/paths-filter@v3
with:
filters: |
common:
- 'packages/loop_common/**'
interpolation:
- 'packages/loop_interpolation/**'
visualisation:
- 'packages/loopstructural_visualisation/**'
map2loop:
- 'packages/map2loop/**'
root:
- 'LoopStructural/**'
- 'tests/**'
- 'pyproject.toml'
shared:
- 'uv.lock'
- '.github/workflows/packages.yml'
- name: Decide which tests run
id: decide
env:
EVENT: ${{ github.event_name }}
COMMON: ${{ steps.filter.outputs.common }}
INTERPOLATION: ${{ steps.filter.outputs.interpolation }}
VISUALISATION: ${{ steps.filter.outputs.visualisation }}
MAP2LOOP: ${{ steps.filter.outputs.map2loop }}
ROOT: ${{ steps.filter.outputs.root }}
SHARED: ${{ steps.filter.outputs.shared }}
run: |
set -euo pipefail
is() { [ "$1" = "true" ]; }
# Everything runs for a push, a manual run, and a shared change.
everything=false
if [ "$EVENT" != "pull_request" ] || is "$SHARED"; then everything=true; fi
run_common=$everything
run_interpolation=$everything
run_visualisation=$everything
run_map2loop=$everything
run_root=$everything
# A change runs the code that depends on it (see the header comment).
if is "$COMMON"; then
run_common=true; run_interpolation=true; run_root=true; run_visualisation=true
fi
if is "$INTERPOLATION"; then
run_interpolation=true; run_root=true; run_visualisation=true
fi
if is "$ROOT"; then run_root=true; run_visualisation=true; fi
if is "$VISUALISATION"; then run_visualisation=true; fi
if is "$MAP2LOOP"; then run_map2loop=true; fi
packages=""
add() {
packages="${packages:+$packages,}{\"name\":\"$1\",\"dir\":\"$2\"}"
}
if is "$run_common"; then add loop_common loop_common; fi
if is "$run_interpolation"; then add loop_interpolation loop_interpolation; fi
if is "$run_visualisation"; then add loopstructuralvisualisation loopstructural_visualisation; fi
packages="[$packages]"
{
echo "packages=$packages"
echo "map2loop=$run_map2loop"
echo "root=$run_root"
} >> "$GITHUB_OUTPUT"
echo "packages=$packages map2loop=$run_map2loop root=$run_root"
packages-test:
needs: changes
if: needs.changes.outputs.packages != '[]'
# matrix.package.name is the uv/PyPI package name (as declared in each
# package's pyproject.toml `[project] name`); matrix.package.dir is its
# directory under packages/. These differ for loopstructuralvisualisation:
# its published/import name has no separator, but its directory uses an
# underscore, and `uv --package` matches on the declared name (with only
# hyphen/underscore treated as equivalent, not a missing separator).
name: ${{ matrix.package.name }} (python ${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
package: ${{ fromJSON(needs.changes.outputs.packages) }}
os: ${{ fromJSON(vars.BUILD_OS)}}
python-version: ${{ fromJSON(vars.PYTHON_VERSIONS)}}
steps:
- uses: actions/checkout@v4
- name: Set up uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Install package with test extras
run: |
uv sync --package ${{ matrix.package.name }} --extra tests --python ${{ matrix.python-version }}
- name: pytest
run: |
uv run --package ${{ matrix.package.name }} pytest packages/${{ matrix.package.dir }}/tests
map2loop-test:
needs: changes
if: needs.changes.outputs.map2loop == 'true'
# Separate job (not part of the packages-test matrix above): map2loop
# imports osgeo/gdal at module load time, which has no pip-installable
# wheel on Windows/macOS (confirmed: building GDAL from the PyPI sdist
# fails without system libgdal headers). Scoped to ubuntu-latest only,
# installing libgdal via apt, mirroring how map2loop's own upstream CI
# special-cases GDAL per-OS (it uses conda-forge everywhere). Revisit
# widening the OS matrix if/when a reliable cross-platform GDAL install
# path is found.
name: map2loop (python ${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ${{ fromJSON(vars.PYTHON_VERSIONS) }}
steps:
- uses: actions/checkout@v4
- name: Install GDAL system libraries
run: |
sudo apt-get update
sudo apt-get install -y gdal-bin libgdal-dev
echo "CPLUS_INCLUDE_PATH=/usr/include/gdal" >> "$GITHUB_ENV"
echo "C_INCLUDE_PATH=/usr/include/gdal" >> "$GITHUB_ENV"
- name: Set up uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Install package with test extras
run: |
uv sync --package map2loop --extra tests --python ${{ matrix.python-version }}
GDAL_VERSION=$(gdal-config --version)
uv pip install setuptools
uv pip install "gdal==${GDAL_VERSION}" --no-build-isolation-package gdal
- name: pytest
run: |
uv run --package map2loop pytest packages/map2loop/tests
loop-link-test:
# Separate job (not part of the packages-test matrix above): packages/loop_link
# is listed in the uv workspace `exclude` list, so `uv sync --package loop-link`
# cannot resolve it as a workspace member. Install it into its own venv with
# uv pip instead. The package needs Python 3.10 or later.
name: loop-link (python ${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ${{ fromJSON(vars.BUILD_OS) }}
python-version: ["3.10", "3.11", "3.12"]
# The real-codec test (tests/test_codec_real.py) needs the private geoviewer repository.
# The secret GEOVIEWER_READ_TOKEN gives read access to it. If the secret does not exist
# (for example in a pull request from a fork), the steps for geoviewer do not run and the
# real-codec test skips. All other tests run in both cases.
env:
GEOVIEWER_REPO_TOKEN: ${{ secrets.GEOVIEWER_READ_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Set up uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Create virtual environment
run: uv venv --python ${{ matrix.python-version }} .venv-loop-link
- name: Install package with test extras
run: |
uv pip install --python .venv-loop-link -e "packages/loop_link[tests]" -e packages/loop_common
- name: Check out geoviewer (for the real-codec test)
if: env.GEOVIEWER_REPO_TOKEN != ''
uses: actions/checkout@v4
with:
repository: lachlangrose/geoviewer
token: ${{ secrets.GEOVIEWER_READ_TOKEN }}
path: geoviewer-src
ref: b938de0ff522a6cba7b79cf2bb4b3739bb88efc0
- name: Set up Rust (geoviewer needs Rust 1.95)
if: env.GEOVIEWER_REPO_TOKEN != ''
uses: dtolnay/rust-toolchain@stable
- name: Cache the codec validator build
if: env.GEOVIEWER_REPO_TOKEN != ''
uses: actions/cache@v4
with:
path: packages/loop_link/.codec-validator-build/target
key: codec-validator-${{ runner.os }}-b938de0ff522a6cba7b79cf2bb4b3739bb88efc0
- name: pytest
env:
LOOP_LINK_GEOVIEWER_REPO: ${{ env.GEOVIEWER_REPO_TOKEN != '' && format('{0}/geoviewer-src', github.workspace) || '' }}
run: |
uv run --no-project --python .venv-loop-link python -m pytest packages/loop_link/tests
loopstructural-test:
name: LoopStructural (python ${{ matrix.python-version }})
needs: [changes, packages-test, map2loop-test]
# always(): a skipped job in `needs` would otherwise skip this job too. The
# root suite still waits for the jobs that ran, and stops if one failed.
if: >-
${{ always()
&& needs.changes.outputs.root == 'true'
&& !contains(needs.*.result, 'failure')
&& !contains(needs.*.result, 'cancelled') }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ${{ fromJSON(vars.BUILD_OS)}}
python-version: ${{ fromJSON(vars.PYTHON_VERSIONS)}}
steps:
- uses: actions/checkout@v4
- name: Set up uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Install package with test extras
run: |
uv sync --extra tests --python ${{ matrix.python-version }}
- name: pytest
run: |
uv run pytest tests