Skip to content

Commit 8719d88

Browse files
committed
Fix more issues and only run first 10 tests in PRs
1 parent 8d7d388 commit 8719d88

7 files changed

Lines changed: 79 additions & 22 deletions

File tree

.github/workflows/integration.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,11 @@ jobs:
6161

6262
- name: Run ${{ matrix.variant }} variant on Python ${{ matrix.python }}
6363
env:
64-
# Short timeout for PR previews so the matrix finishes in
65-
# minutes; full timeout for scheduled/dispatch runs.
66-
TIMEOUT_FLAG: ${{ github.event_name == 'pull_request' && '--timeout-test 20' || '' }}
67-
run: python run_integration.py --variant ${{ matrix.variant }} --python ${{ matrix.python }} $TIMEOUT_FLAG
64+
# PR previews limit each package to the first 10 tests so the
65+
# matrix finishes in minutes; conftest.py at the repo root reads
66+
# this env var and truncates the collected items.
67+
PYTEST_LIMIT_N: ${{ github.event_name == 'pull_request' && '10' || '' }}
68+
run: python run_integration.py --variant ${{ matrix.variant }} --python ${{ matrix.python }}
6869

6970
- name: Upload results
7071
if: always()

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,12 @@ whose "Details" link opens the rendered page directly in the
132132
browser.
133133

134134
This means the PR preview reflects *this PR's actual matrix run*,
135-
not last main's data. It's also slower than a render-only preview
136-
would be — expect the same wall-clock as a normal main run, up to
137-
a few hours per push. Concurrency cancels in-progress PR runs when
138-
a new push lands, so only the latest push consumes CI time.
135+
not last main's data. To keep PR feedback fast, each package is
136+
capped at the first 10 collected tests (via `PYTEST_LIMIT_N=10`,
137+
applied by the repo-level `conftest.py`); the preview is a smoke
138+
check of layout, install resolution, and the workflow itself, not
139+
a full regression signal. Concurrency cancels in-progress PR runs
140+
when a new push lands, so only the latest push consumes CI time.
139141

140142
`preview-link.yml` lives at `.github/workflows/preview-link.yml`
141143
and must be on the default branch for its `workflow_run` trigger

build_dashboard.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,11 @@ def build(results_dir, output_dir, templates_dir):
168168
variants_meta = [_variant_meta(v, p, by_combo.get((v, p)))
169169
for p in pythons for v in VARIANTS]
170170

171-
# If any variant ran with an unusually short test timeout, surface
172-
# it in a banner; that's typical for PR preview runs.
173-
timeouts = {d.get("timeout_test_seconds") for d in by_combo.values()
174-
if d and d.get("timeout_test_seconds")}
175-
short_timeout = min((t for t in timeouts if t and t < 600), default=None)
171+
# If any variant ran with a per-package test limit, surface it in
172+
# a banner; PR previews use this to keep wall time bounded.
173+
limits = {d.get("pytest_limit_n") for d in by_combo.values()
174+
if d and d.get("pytest_limit_n")}
175+
pytest_limit = min(limits) if limits else None
176176

177177
(output_dir / "index.html").write_text(
178178
env.get_template("index.html").render(
@@ -181,7 +181,7 @@ def build(results_dir, output_dir, templates_dir):
181181
variants_meta=variants_meta,
182182
tier_groups=tier_groups,
183183
failures=failures,
184-
short_timeout=short_timeout,
184+
pytest_limit=pytest_limit,
185185
)
186186
)
187187
print(f"Wrote {output_dir}/index.html")

conftest.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""Repo-level pytest plugin used during PR-preview runs.
2+
3+
When the env var `PYTEST_LIMIT_N` is set to a positive integer, pytest
4+
collects normally and then truncates the test list to the first N
5+
items. This lets the PR matrix surface a fast smoke signal per
6+
package (typically 10 tests each) without per-package configuration.
7+
8+
Discovered automatically by pytest because cwd is the repo root for
9+
every `pytest --pyargs <module>` invocation in the runner.
10+
"""
11+
12+
import os
13+
14+
15+
def pytest_collection_modifyitems(config, items):
16+
raw = os.environ.get("PYTEST_LIMIT_N")
17+
if not raw:
18+
return
19+
try:
20+
n = int(raw)
21+
except ValueError:
22+
return
23+
if n > 0 and len(items) > n:
24+
del items[n:]

packages.yaml

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@ packages:
9494

9595
- pypi_name: APLpy
9696
tier: affiliated
97-
module: APLpy
97+
module: aplpy # installed package name is lowercase
9898
repo_url: https://github.com/aplpy/aplpy.git
99+
install_extras: [test]
99100

100101
- pypi_name: astroalign
101102
tier: affiliated
@@ -126,10 +127,13 @@ packages:
126127
tier: affiliated
127128
module: BayesicFitting
128129
repo_url: https://github.com/dokester/BayesicFitting.git
130+
# BayesicFitting ships unittest-style tests as Test*.py (capital T);
131+
# override pytest's default `python_files` glob so it picks them up.
132+
pytest_args: ["-o", "python_files=Test*.py"]
129133

130134
- pypi_name: cluster-lensing
131135
tier: affiliated
132-
module: cluster_lensing
136+
module: clusterlensing # installed package has no underscore
133137
repo_url: https://github.com/jesford/cluster-lensing.git
134138

135139
- pypi_name: corral-pipeline
@@ -166,15 +170,21 @@ packages:
166170
tier: affiliated
167171
module: gammapy
168172
repo_url: https://github.com/gammapy/gammapy.git
173+
install_extras: [test]
169174

170175
- pypi_name: ginga
171176
tier: affiliated
172177
module: ginga
173178
repo_url: https://github.com/ejeschke/ginga.git
179+
# `ginga/tests/test_zarr.py` uses removed zarr 3.x API; ignore it
180+
# so the rest of the suite (256 passing tests) can run.
181+
pytest_args: ["--ignore-glob=*test_zarr.py"]
174182

175183
- pypi_name: glueviz
176184
tier: affiliated
177-
module: glueviz
185+
# glueviz is a meta-package; the actual code (and tests) lives in
186+
# glue-core which it pulls in. Its installed module is `glue`.
187+
module: glue
178188
repo_url: https://github.com/glue-viz/glue.git
179189

180190
- pypi_name: gwcs
@@ -191,6 +201,7 @@ packages:
191201
tier: affiliated
192202
module: hendrics
193203
repo_url: https://github.com/StingraySoftware/HENDRICS.git
204+
install_extras: [test]
194205

195206
- pypi_name: hips
196207
tier: affiliated
@@ -214,23 +225,36 @@ packages:
214225

215226
- pypi_name: ligo.skymap
216227
tier: affiliated
217-
module: ligo_skymap
228+
# PEP 420 namespace package: installed as ligo/skymap/, not ligo_skymap.
229+
module: ligo.skymap
218230
repo_url: https://git.ligo.org/lscsoft/ligo.skymap.git
231+
install_extras: [test]
219232

220233
- pypi_name: linetools
221234
tier: affiliated
222235
module: linetools
223236
repo_url: https://github.com/linetools/linetools.git
237+
install_extras: [test]
238+
# linetools imports pkg_resources (deprecated stdlib alias); pull
239+
# in setuptools so it's available at runtime.
240+
extra_deps: [setuptools]
224241

225242
- pypi_name: marxs
226243
tier: affiliated
227244
module: marxs
228245
repo_url: https://github.com/Chandra-MARX/marxs.git
246+
install_extras: [test]
247+
# Two test files require an external MARX C library we don't have;
248+
# ignoring them lets the rest of the suite collect.
249+
pytest_args:
250+
- "--ignore-glob=*test_hrma.py"
251+
- "--ignore-glob=*test_all_optics.py"
229252

230253
- pypi_name: mocpy
231254
tier: affiliated
232255
module: mocpy
233256
repo_url: https://github.com/cds-astro/mocpy.git
257+
install_extras: [dev]
234258

235259
- pypi_name: naima
236260
tier: affiliated
@@ -256,6 +280,7 @@ packages:
256280
tier: affiliated
257281
module: pydl
258282
repo_url: https://github.com/weaverba137/pydl.git
283+
install_extras: [test]
259284

260285
- pypi_name: pyregion
261286
tier: affiliated
@@ -271,6 +296,7 @@ packages:
271296
tier: affiliated
272297
module: pyvo
273298
repo_url: https://github.com/astropy/pyvo.git
299+
install_extras: [test]
274300

275301
- pypi_name: regularizepsf
276302
tier: affiliated
@@ -291,6 +317,7 @@ packages:
291317
tier: affiliated
292318
module: spectral_cube
293319
repo_url: https://github.com/radio-astro-tools/spectral-cube.git
320+
install_extras: [test]
294321

295322
- pypi_name: spherical-geometry
296323
tier: affiliated

run_integration.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,9 @@ def run_variant(variant, python_version, packages, repo_root, results_dir, timeo
269269
"python_requested": python_version,
270270
"python_version": "",
271271
"timeout_test_seconds": timeouts["test"],
272+
"pytest_limit_n": (int(os.environ["PYTEST_LIMIT_N"])
273+
if (os.environ.get("PYTEST_LIMIT_N") or "").isdigit()
274+
else None),
272275
"fatal_error": "",
273276
"installed_deps": {},
274277
"packages": [],

templates/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
{% block body %}
44
<h1>Astropy ecosystem integration matrix</h1>
55

6-
{% if short_timeout %}
6+
{% if pytest_limit %}
77
<div class="banner">
8-
<strong>Preview run:</strong> per-package test timeout set to <code>{{ short_timeout }}s</code>
9-
for fast PR feedback. Many tests will time out; treat the matrix as a layout/workflow
10-
check, not a real regression signal.
8+
<strong>Preview run:</strong> each package limited to the first
9+
<code>{{ pytest_limit }}</code> tests for fast PR feedback. Treat the matrix as
10+
a smoke check, not a full regression signal.
1111
</div>
1212
{% endif %}
1313

0 commit comments

Comments
 (0)