diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index f0254fe..cab1acc 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -1,160 +1,29 @@ name: integration-matrix +# Calls the reusable workflow from OpenAstronomy/integration-dashboard, +# which reads `columns:` from packages.yaml to build the matrix, runs +# every column, and publishes the dashboard to gh-pages (or, on pull +# requests, uploads it as a preview artifact for preview-link.yml). +# The name above must stay in sync with `workflows:` in preview-link.yml. + on: schedule: - cron: '0 6 * * 0' # Sundays at 06:00 UTC workflow_dispatch: pull_request: -permissions: - contents: write # to push gh-pages on main / schedule / dispatch - pull-requests: none # explicit: this workflow never touches PRs - -concurrency: - # One in-flight run per PR, one per main/dispatch invocation. - # PR runs cancel previous in-progress ones; main runs queue. - group: integration-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: ${{ github.event_name == 'pull_request' }} +permissions: {} jobs: - # Read the `columns` list from packages.yaml and emit it as the job - # matrix, so the (python, variant) combinations have a single source - # of truth and never need hand-syncing into this workflow. - setup: - runs-on: ubuntu-latest - timeout-minutes: 5 - outputs: - matrix: ${{ steps.columns.outputs.matrix }} - steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 - with: - python-version: '3.12' - - - name: Build matrix from packages.yaml - id: columns - run: | - pip install pyyaml - python -c ' - import json, yaml - cols = yaml.safe_load(open("packages.yaml"))["columns"] - matrix = [{"python": str(c["python"]), "variant": c["variant"]} for c in cols] - print("matrix=" + json.dumps(matrix)) - ' >> "$GITHUB_OUTPUT" - - variant: - needs: setup - strategy: - fail-fast: false - matrix: - # Generated by the `setup` job from `columns:` in packages.yaml; - # each entry is one {python, variant} object. - include: ${{ fromJson(needs.setup.outputs.matrix) }} - runs-on: ubuntu-latest - timeout-minutes: 240 - steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - # This Python only runs the `sunpy-integration` orchestrator CLI; - # the test venv for `matrix.python` is built separately by uv (see - # the `run` step below), so a fixed version is fine here. - - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 - with: - python-version: '3.12' - - - name: Install uv - uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 - with: - # We manage the cache ourselves via actions/cache below; turning - # off setup-uv's own caching avoids it saving a duplicate of the - # same directory under its own key. - enable-cache: false - - - name: Cache ~/.cache/uv - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 - with: - path: ~/.cache/uv - # Primary key uses the run id, so every run writes a fresh - # snapshot (after `uv cache prune --ci` slims it to wheels - # actually used in this run). The restore-keys are prefix - # matches against saved keys, so the first one always finds - # the most recent run's cache for the same (os, variant, - # python) and the next run starts warm. - key: uv-${{ runner.os }}-${{ matrix.variant }}-${{ matrix.python }}-${{ github.run_id }} - restore-keys: | - uv-${{ runner.os }}-${{ matrix.variant }}-${{ matrix.python }}- - uv-${{ runner.os }}-${{ matrix.variant }}- - uv-${{ runner.os }}- - - - run: sudo apt update; sudo apt install libfftw3-dev ffmpeg - - - name: Install sunpy-integration - run: pip install . - - - name: Run ${{ matrix.variant }} variant on Python ${{ matrix.python }} - env: - # PR previews limit each package to the first 10 tests so the - # matrix finishes in minutes; conftest.py at the repo root reads - # this env var and truncates the collected items. - PYTEST_LIMIT_N: ${{ github.event_name == 'pull_request' && '10' || '' }} - run: sunpy-integration run --variant ${{ matrix.variant }} --python ${{ matrix.python }} - - - name: Prune uv cache before save - if: always() - # Strips pre-built sdists and other entries uv won't reuse, so - # the snapshot the cache step uploads stays lean. - run: uv cache prune --ci - - - name: Upload results - if: always() - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 - with: - name: results-${{ matrix.variant }}-${{ matrix.python }} - path: results/${{ matrix.variant }}__${{ matrix.python }}.json - - dashboard: - needs: variant - if: always() - runs-on: ubuntu-latest - timeout-minutes: 15 - steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 - with: - python-version: '3.12' - - - name: Install sunpy-integration - run: pip install . - - - name: Download all variant results - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 - with: - pattern: results-* - merge-multiple: true - path: results/ - - - name: Build dashboard - run: sunpy-integration dashboard - - # PR path: upload index.html as a non-zipped artifact for the - # in-browser preview (linked from a PR check by preview-link.yml). - - name: Upload preview artifact - if: github.event_name == 'pull_request' - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 - with: - name: dashboard-preview - path: site/index.html - archive: false - overwrite: true - - # Main / schedule / dispatch path: publish to gh-pages. - - name: Publish to gh-pages - if: github.event_name != 'pull_request' - uses: peaceiris/actions-gh-pages@84c30a85c19949d7eee79c4ff27748b70285e453 # v4.1.0 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./site - force_orphan: true - commit_message: Update integration dashboard + integration: + permissions: + contents: write # to publish the dashboard to gh-pages + uses: OpenAstronomy/integration-dashboard/.github/workflows/integration.yml@main + with: + config: packages.yaml + # libfftw3-dev for packages that build against FFTW, and ffmpeg + # for tests that write movies (e.g. irispy-lmsal's wobble movie). + libraries: | + apt: + - libfftw3-dev + - ffmpeg diff --git a/README.md b/README.md index a97f2e8..40d95d3 100644 --- a/README.md +++ b/README.md @@ -1,185 +1,119 @@ -Integration testing for the Astropy ecosystem -============================================= +Integration testing for the SunPy ecosystem +=========================================== -[![Integration matrix](https://github.com/astropy/astropy-integration-testing/actions/workflows/integration.yml/badge.svg)](https://github.com/astropy/astropy-integration-testing/actions/workflows/integration.yml) +[![Integration matrix](https://github.com/sunpy/sunpy-integration-testing/actions/workflows/integration.yml/badge.svg)](https://github.com/sunpy/sunpy-integration-testing/actions/workflows/integration.yml) -Cross-ecosystem integration tests for the Astropy core and coordinated -packages. Individual packages should still test against dev/pre-release -astropy in their own CI; the goal here is to catch issues that only -appear when many packages are installed together. +Cross-ecosystem integration tests for sunpy and the packages that depend +on it. Individual packages should still test against dev/pre-release +sunpy in their own CI; the goal here is to catch issues that only appear +when many packages are installed together. The dashboard is published to -[astropy.github.io/astropy-integration-testing](https://astropy.github.io/astropy-integration-testing/) +[sunpy.github.io/sunpy-integration-testing](https://sunpy.github.io/sunpy-integration-testing/) after each scheduled run. -The harness itself is not astropy-specific: `core_package` in -`packages.yaml` defines the ecosystem's core package, so the same code -can drive integration testing for another ecosystem (e.g. sunpy) just -by pointing the config at a different core package and package list. +This repository only holds the sunpy-specific configuration. The harness +that installs the packages, runs their tests and renders the dashboard is +[integration-dashboard](https://github.com/OpenAstronomy/integration-dashboard), +and the CI runs through that project's reusable workflow. See its README +for how the `stable`, `pre` and `dev` variants choose package versions, +and for the full config format. How it works ------------ -The `variant` job runs on a schedule (and on `workflow_dispatch`) as a -matrix over the *columns* configured in `packages.yaml`. Each column is -an independent (Python version, variant) pair — the two axes are not a -cross-product, so you can test e.g. `3.12 + stable`, `3.13 + pre` and -`3.14 + dev` if you want. The three variants are: - -| Variant | Core package | Each package | -|----------|-------------------------------------------------------|----------------------------------------| -| `stable` | Latest non-pre-release on PyPI | Latest non-pre-release on PyPI | -| `pre` | Latest including pre-releases (`--prerelease=allow`) | Latest including pre-releases | -| `dev` | Latest dev wheel from `core_package.dev_index_urls` (or `git+repo_url` if unset) | `git+` (HEAD of main branch) | - -Within each matrix job, a single shared venv is built: the core package -is installed first, then each package one at a time in a deterministic -order (coordinated first, alphabetical within each tier). If a package -can't be installed alongside the existing venv (e.g., it pins -`astropy<7` but we already installed astropy 8), it's skipped and -recorded; the rest of the venv is untouched. After installs, `pytest ---pyargs ` runs for each package that installed successfully. - -A small `setup` job parses `columns:` from `packages.yaml` and emits it -as the workflow matrix, so the column list has a single source of -truth. The `dashboard` job then downloads the per-matrix-job result -JSONs and publishes the dashboard to `gh-pages`. - -What's in the repo ------------------- - -| File | Purpose | -|---------------------------------------|------------------------------------------------------| -| `packages.yaml` | The config: `core_package`, the `columns` to test, and the `packages` list. | -| `astropy_integration/config.py` | Loads and validates `packages.yaml` (shared by `run` and `dashboard`). | -| `astropy_integration/run.py` | Runs one or more columns: resolve specs, install, test, write `results/__.json`. | -| `astropy_integration/dashboard.py` | Reads `results/*.json`, renders `site/index.html` (single self-contained page). | -| `astropy_integration/cli.py` | Console entry point that dispatches the `run` and `dashboard` subcommands. | -| `astropy_integration/status.py` | Shared status vocabulary (used by both `run` and `dashboard`). | -| `astropy_integration/templates/` | HTML/CSS for the dashboard (loaded as package data). | -| `pyproject.toml` | Package metadata; declares the `astropy-integration` console script. | -| `conftest.py` | Repo-root pytest plugin that caps each package to the first `PYTEST_LIMIT_N` tests for PR previews. | -| `.github/workflows/integration.yml` | The matrix workflow (`setup` builds the matrix, `variant` runs each column, `dashboard` publishes). | -| `.github/workflows/preview-link.yml` | Companion that posts the "View dashboard preview" status check on PRs. | -| `sunpy_pytest.ini` | Custom pytest config referenced by sunpy's `pytest_args` (sunpy's own config requires plugins we don't install). | +`.github/workflows/integration.yml` runs on a weekly schedule, on +`workflow_dispatch` and on pull requests. It calls the +integration-dashboard reusable workflow at `@main`, which: + +1. reads `columns:` from `packages.yaml` and expands it into a job + matrix, one job per (Python version, variant) column; +2. in each job, installs the system packages listed in the workflow's + `libraries` input, builds a shared venv with sunpy plus every + package that can be installed alongside it, and runs `pytest --pyargs + ` for each one; +3. collects the results and publishes the dashboard to `gh-pages`. Running locally --------------- ```bash -pip install . +pip install git+https://github.com/OpenAstronomy/integration-dashboard # uv is required; see https://docs.astral.sh/uv/ +# Some packages also need FFTW and ffmpeg, e.g. on Debian/Ubuntu: +# sudo apt-get install libfftw3-dev ffmpeg -# Run one variant. Each variant takes 30-90 min depending on package count. -astropy-integration run --variant stable +# Run from the root of this repo so conftest.py is picked up. +integration-dashboard run --variant stable --python 3.12 # Or a single package, to iterate faster: -astropy-integration run --variant stable --packages reproject +integration-dashboard run --variant stable --python 3.12 --packages ndcube # Or a tier subset (default: all tiers run): -astropy-integration run --variant stable --tiers coordinated,other +integration-dashboard run --variant stable --tiers coordinated # Build the dashboard from whatever results/*.json files exist: -astropy-integration dashboard +integration-dashboard dashboard # Preview locally: python -m http.server -d site 8000 ``` -Results land in `results/__.json`; the dashboard in +Results land in `results/__.json` and the dashboard in `site/`. Both directories are gitignored. -Core package ------------- - -`packages.yaml` has a top-level `core_package` block — the package -installed into the shared venv before everything else: - -```yaml -core_package: - pypi_name: astropy - module: astropy - repo_url: https://github.com/astropy/astropy.git - # dev variant: install nightly wheels from these indexes. - # omit to install the dev version from git+repo_url instead. - dev_index_urls: - - https://pypi.anaconda.org/astropy/simple - - https://pypi.anaconda.org/liberfa/simple -``` - -To retarget the harness at a different ecosystem, point `core_package` -at that ecosystem's core package and replace the `packages` list. -`dashboard_title` (also top-level) sets the dashboard's heading. - -Columns -------- - -`packages.yaml` has a top-level `columns` list. Each column is one -(Python version, variant) pair and becomes one dashboard column; -Python version and variant are independent, so list whatever -combinations you want (uv notation for Python, so `"3.14t"` is the -free-threaded 3.14 build): - -```yaml -columns: - - {python: "3.12", variant: stable} - - {python: "3.13", variant: pre} - - {python: "3.14t", variant: dev} -``` +Configuration +------------- -The runner tests every column; `--variant` / `--python` narrow that to -a subset. The dashboard groups consecutive columns that share a Python -version under a spanning header, so a classic `python x variant` -layout still renders as grouped columns. The CI matrix is generated -from this list by the `setup` job, so there's nothing to keep in sync. +Everything is configured in `packages.yaml`: -Adding or disabling a package ------------------------------ +- `core_package` is sunpy, installed into every venv first, together + with the pytest plugins listed in its `test_deps` (pytest-remotedata, + so `remote_data` tests are skipped). For the `dev` variant it comes + from the nightly wheel indexes in `dev_index_urls`. +- `columns` lists the (Python version, variant) pairs to test, each one + a dashboard column. Use uv notation for Python, so `"3.14t"` is the + free-threaded 3.14 build. The CI matrix is generated from this list. +- `packages` lists the packages to test. -Edit `packages.yaml`. Each entry takes: +To add or disable a package, edit its entry in `packages.yaml`. Each +entry takes: - `pypi_name` (the package's name on PyPI; also used as the row label) -- `tier` (label used for ordering and the `--tiers` filter; conventional - values are `coordinated`, `affiliated`, `pyopensci`, `other`) +- `tier` (`coordinated`, `affiliated` or `provisional`; used for grouping + and the `--tiers` filter. Tiers are shown in the order they first + appear in the file, so keep each tier's packages together) - `module` (the top-level Python module name, for `pytest --pyargs`) - `repo_url` (for the `dev` variant install) -- `install_extras` (list, e.g. `[test, all]`) +- `install_extras` (list, e.g. `[tests]`) - `extra_deps` (optional list of extra packages to add to the install) -- `pytest_args` (optional list passed through to pytest; use `-k "not foo"` to skip tests) +- `pytest_args` (optional list passed through to pytest; use + `-k "not foo"` to skip tests) -Every entry runs by default. Use `--tiers ` on the runner to -restrict to a tier subset (e.g. `--tiers coordinated`). +If a package needs a system library or tool, add it to the +`libraries` input in `.github/workflows/integration.yml`. Triggering a run from GitHub ---------------------------- 1. Actions tab -> `integration-matrix` workflow. 2. "Run workflow" dropdown -> green button. -3. The `setup` job reads `columns:` from `packages.yaml` and the - matrix expands to one parallel `variant` job per column; the - `dashboard` job waits for them and publishes to `gh-pages`. PR previews ----------- -`integration-matrix` also runs on pull requests. Same column matrix -as the scheduled run, just with a different final step: the -`dashboard` job uploads `site/index.html` as a non-zipped artifact -(`actions/upload-artifact@v7` with `archive: false`) instead of -publishing to gh-pages. The companion `preview-link` workflow -attaches a "View dashboard preview" status check to the commit -whose "Details" link opens the rendered page directly in the -browser. - -This means the PR preview reflects *this PR's actual matrix run*, -not last main's data. To keep PR feedback fast, each package is -capped at the first 10 collected tests (via `PYTEST_LIMIT_N=10`, -applied by the repo-level `conftest.py`); the preview is a smoke -check of layout, install resolution, and the workflow itself, not -a full regression signal. Concurrency cancels in-progress PR runs -when a new push lands, so only the latest push consumes CI time. - -`preview-link.yml` lives at `.github/workflows/preview-link.yml` -and must be on the default branch for its `workflow_run` trigger -to fire. The first PR after merging the workflow won't get the -status check. +`integration-matrix` also runs on pull requests, with the same column +matrix as the scheduled run. Instead of publishing to `gh-pages`, it +uploads `site/index.html` as a non-zipped artifact, and the companion +`preview-link` workflow attaches a "View dashboard preview" status +check to the commit that opens the rendered page directly. + +To keep PR feedback fast, each package is capped at the first 10 +collected tests by the repo-root `conftest.py` (which has to live here +because `pytest --pyargs` collects from site-packages). The preview is a +smoke check of layout, install resolution and the workflow itself, not a +full regression signal. A new push to a PR cancels its in-progress run. + +`preview-link.yml` must be on the default branch for its `workflow_run` +trigger to fire, and its `workflows:` entry must match the name of +`integration.yml` (`integration-matrix`). diff --git a/astropy_integration/__init__.py b/astropy_integration/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/astropy_integration/cli.py b/astropy_integration/cli.py deleted file mode 100644 index 39e1e0f..0000000 --- a/astropy_integration/cli.py +++ /dev/null @@ -1,32 +0,0 @@ -"""Console entry point: dispatches `run` and `dashboard` subcommands.""" - -import argparse - -from . import dashboard, run - - -def main(): - parser = argparse.ArgumentParser(prog="astropy-integration") - sub = parser.add_subparsers(dest="cmd", required=True) - - run_p = sub.add_parser( - "run", - help="Run one or more (variant, python) cells of the matrix.", - description=run.__doc__, - formatter_class=argparse.RawDescriptionHelpFormatter, - ) - run.add_arguments(run_p) - - dash_p = sub.add_parser( - "dashboard", - help="Build the dashboard HTML from results/*.json.", - description=dashboard.__doc__, - formatter_class=argparse.RawDescriptionHelpFormatter, - ) - dashboard.add_arguments(dash_p) - - args = parser.parse_args() - if args.cmd == "run": - run.run(args) - elif args.cmd == "dashboard": - dashboard.run(args) diff --git a/astropy_integration/config.py b/astropy_integration/config.py deleted file mode 100644 index 3ea100b..0000000 --- a/astropy_integration/config.py +++ /dev/null @@ -1,69 +0,0 @@ -"""Load and validate the integration-testing config (``packages.yaml``). - -The config has three top-level keys: - - - ``core_package``: the ecosystem's core package (astropy here, but - swap it to retarget the whole harness at another ecosystem). It is - installed into the shared venv before anything else. - - ``columns``: a flat list of ``{python, variant}`` pairs. Each one - is a single run and a single dashboard column; Python version and - variant are fully decoupled. - - ``packages``: the per-package list (one entry = one dashboard row). - -Both ``run`` and ``dashboard`` read this file, so the parsing and -validation live here in one place. -""" - -from pathlib import Path - -import yaml - -from . import status - - -def _load(path): - return yaml.safe_load(Path(path).read_text()) or {} - - -def load_packages(path): - return list(_load(path).get("packages", [])) - - -def load_core_package(path): - """Return the validated ``core_package`` block. - - ``module`` defaults to ``pypi_name`` when not given. - """ - core = _load(path).get("core_package") or {} - if not core.get("pypi_name"): - raise ValueError(f"{path}: 'core_package.pypi_name' is required") - core.setdefault("module", core["pypi_name"]) - return core - - -def load_columns(path): - """Return the validated ``columns`` list as ``[{python, variant}, ...]``. - - Order is preserved: it drives both the run order and the dashboard - column order. - """ - raw = _load(path).get("columns") or [] - columns = [] - for i, col in enumerate(raw): - python = col.get("python") - variant = col.get("variant") - if not python or not variant: - raise ValueError(f"{path}: columns[{i}] needs both 'python' and 'variant'") - if variant not in status.VARIANTS: - raise ValueError( - f"{path}: columns[{i}] has variant '{variant}'; " - f"expected one of {', '.join(status.VARIANTS)}" - ) - columns.append({"python": str(python), "variant": variant}) - if not columns: - raise ValueError(f"{path}: at least one entry under 'columns' is required") - return columns - - -def load_dashboard_title(path): - return _load(path).get("dashboard_title") or "Ecosystem integration matrix" diff --git a/astropy_integration/dashboard.py b/astropy_integration/dashboard.py deleted file mode 100644 index 55b0a2c..0000000 --- a/astropy_integration/dashboard.py +++ /dev/null @@ -1,238 +0,0 @@ -"""Build the single-page integration-matrix dashboard. - -Reads every results/__.json that `astropy-integration run` -wrote and emits a single self-contained `site/index.html` with: - - - one row per package - - one column per configured (python, variant) pair, in config - order; consecutive columns that share a Python version are - grouped under a spanning header - - a "Failure logs" section at the bottom with collapsible
- for every non-passing cell, anchored from the matching badge -""" - -import json -import re -import shutil -from itertools import groupby -from pathlib import Path - -from jinja2 import Environment, PackageLoader, select_autoescape - -from . import config, status - - -def _anchor_id(name, variant, python): - # Anchors are only used inside the page so we just need - # something HTML-id-safe and unique per (pkg, variant, python). - safe_python = re.sub(r"[^A-Za-z0-9]", "_", python) - return f"log-{name}__{variant}__{safe_python}" - - -def _load_results(results_dir): - """Return {(variant, python): data, ...} for every results/*.json found.""" - by_combo = {} - for f in sorted(results_dir.glob("*.json")): - if f.name.startswith("_"): - continue - data = json.loads(f.read_text()) - v = data.get("variant") - p = data.get("python_requested") or data.get("python_version") or "" - if not v or not p: - continue - by_combo[(v, p)] = data - return by_combo - - -def _column_groups(by_combo, config_columns): - """Order the columns that produced results and group them for the header. - - Columns are ordered to match the `columns:` list in the config; any - result not listed there (e.g. a leftover JSON from an old config) is - appended afterwards, sorted. The header groups *consecutive* columns - that share a Python version, so a config that pairs each Python with - a single variant renders as plain columns while the classic - python x variant layout still renders as spanning groups. - - Returns: - columns: flat list of (python, variant) tuples in display order. - groups: list of {"python", "span"} dicts for the top header row. - """ - present = set(by_combo) # {(variant, python), ...} - columns = [] - for col in config_columns: - key = (col["variant"], col["python"]) - if key in present: - columns.append((col["python"], col["variant"])) - present.discard(key) - for variant, python in sorted(present): - columns.append((python, variant)) - - groups = [] - for python, _variant in columns: - if groups and groups[-1]["python"] == python: - groups[-1]["span"] += 1 - else: - groups.append({"python": python, "span": 1}) - return columns, groups - - -def _variant_meta(variant, python, data): - if not data: - return {"variant": variant, "python": python, "has_data": False} - return { - "variant": variant, - "python": python, - "has_data": True, - "core_version": data["core"]["version"], - "extra_index_urls": data["core"].get("extra_index_urls") or [], - "python_version": data.get("python_version") or python, - "started_at": data["started_at"], - "finished_at": data["finished_at"], - "installed_deps": data.get("installed_deps") or {}, - } - - -def _ordered_packages(by_combo): - """Package names in the order they first appear across all results.""" - seen = [] - seen_set = set() - for _, data in by_combo.items(): - for entry in data["packages"]: - if entry["name"] not in seen_set: - seen.append(entry["name"]) - seen_set.add(entry["name"]) - return seen - - -def _make_rows(by_combo, names, columns): - rows = [] - for name in names: - cells = [] - row_tier = None - for python, variant in columns: - data = by_combo.get((variant, python)) - entry = None - if data: - entry = next((e for e in data["packages"] if e["name"] == name), None) - if entry is None: - cells.append( - { - "status": "missing", - "label": "-", - "anchor": "", - "resolved_version": "", - } - ) - continue - if row_tier is None: - row_tier = entry.get("tier", "coordinated") - badge = status.cell_badge(entry) - anchor = ( - _anchor_id(name, variant, python) - if badge["status"] not in ("pass", "missing") - else "" - ) - cells.append( - { - **badge, - "anchor": anchor, - "resolved_version": entry.get("resolved_version", ""), - } - ) - rows.append({"name": name, "tier": row_tier or "coordinated", "cells": cells}) - return rows - - -def _group_rows_by_tier(rows): - """Group rows by tier, preserving order. Returns [(tier, [rows]), ...].""" - return [ - (tier, list(group)) for tier, group in groupby(rows, key=lambda r: r["tier"]) - ] - - -def _failures(by_combo, columns): - """Per-cell failure detail (full logs), ordered by column then row.""" - out = [] - for python, variant in columns: - data = by_combo.get((variant, python)) - if not data: - continue - for entry in data["packages"]: - badge = status.cell_badge(entry) - if badge["status"] in ("pass", "missing"): - continue - out.append( - { - "name": entry["name"], - "variant": variant, - "python": python, - "status": badge["status"], - "label": badge["label"], - "install_error": entry.get("install_error", ""), - "test_output": entry.get("test_output", ""), - "anchor": _anchor_id(entry["name"], variant, python), - } - ) - return out - - -def build(results_dir, output_dir, config_path): - results_dir = Path(results_dir) - output_dir = Path(output_dir) - if output_dir.exists(): - shutil.rmtree(output_dir) - output_dir.mkdir(parents=True) - - env = Environment( - loader=PackageLoader("astropy_integration", "templates"), - autoescape=select_autoescape(["html"]), - ) - - config_columns = config.load_columns(config_path) - core = config.load_core_package(config_path) - title = config.load_dashboard_title(config_path) - - by_combo = _load_results(results_dir) - columns, column_groups = _column_groups(by_combo, config_columns) - names = _ordered_packages(by_combo) - rows = _make_rows(by_combo, names, columns) - tier_groups = _group_rows_by_tier(rows) - failures = _failures(by_combo, columns) - variants_meta = [ - _variant_meta(variant, python, by_combo.get((variant, python))) - for python, variant in columns - ] - - # If any variant ran with a per-package test limit, surface it in - # a banner; PR previews use this to keep wall time bounded. - limits = { - d.get("pytest_limit_n") - for d in by_combo.values() - if d and d.get("pytest_limit_n") - } - pytest_limit = min(limits) if limits else None - - (output_dir / "index.html").write_text( - env.get_template("index.html").render( - title=title, - core_name=core["pypi_name"], - column_groups=column_groups, - columns=columns, - variants_meta=variants_meta, - tier_groups=tier_groups, - failures=failures, - pytest_limit=pytest_limit, - ) - ) - print(f"Wrote {output_dir}/index.html") - - -def add_arguments(ap): - ap.add_argument("--config", default="packages.yaml") - ap.add_argument("--results-dir", default="results") - ap.add_argument("--output", default="site") - - -def run(args): - build(args.results_dir, args.output, args.config) diff --git a/astropy_integration/run.py b/astropy_integration/run.py deleted file mode 100644 index 843e37e..0000000 --- a/astropy_integration/run.py +++ /dev/null @@ -1,550 +0,0 @@ -"""Run one or more columns of the ecosystem integration matrix. - -Creates a single shared venv, installs the core package first then -each package from packages.yaml in order, recording per-package -install outcome (installed / skipped / install-fail / no-spec). Each -install is constrained so it can never downgrade a package already in -the venv; a package needing an older version is reported as skipped. -Then runs `pytest --pyargs ` for each successfully-installed -package. Writes results/__.json with the full venv -freeze and per-package data. - -A "column" is one (python, variant) pair from the config; the two -axes are independent (see `columns:` in packages.yaml). `--variant` -and `--python` narrow the configured columns down to a subset. - -Usage: - astropy-integration run # every configured column - astropy-integration run --variant stable # configured columns with variant=stable - astropy-integration run --variant stable --python 3.12 # one specific column - astropy-integration run --python 3.14t # configured columns with python=3.14t - astropy-integration run --variant stable --packages reproject,sunpy - astropy-integration run --variant stable --tiers coordinated -""" - -import json -import os -import shutil -import subprocess -import sys -import tempfile -import time -import urllib.request -from collections import Counter -from datetime import datetime, timezone -from pathlib import Path - -from packaging.version import InvalidVersion, Version - -from . import config, status - -PYPI_JSON_URL = "https://pypi.org/pypi/{name}/json" - - -def _http_json(url, timeout=20): - with urllib.request.urlopen(url, timeout=timeout) as r: - return json.load(r) - - -def _version_key(v): - try: - return Version(v) - except InvalidVersion: - return Version("0") - - -def _is_prerelease(v): - try: - return Version(v).is_prerelease - except InvalidVersion: - return True - - -def _yanked(files): - return all(f.get("yanked") for f in files) if files else True - - -def latest_pypi(name, include_prereleases): - info = _http_json(PYPI_JSON_URL.format(name=name)) - versions = [] - for ver, files in info["releases"].items(): - if _yanked(files): - continue - if not include_prereleases and _is_prerelease(ver): - continue - versions.append(ver) - if not versions and not include_prereleases: - # Fallback: package has only pre-releases on PyPI - return latest_pypi(name, include_prereleases=True) - if not versions: - return None - return sorted(versions, key=_version_key)[-1] - - -def _extras_suffix(pkg): - extras = pkg.get("install_extras") or [] - return "[" + ",".join(extras) + "]" if extras else "" - - -def resolve_specs(packages, variant, core): - """Resolve the core-package spec and per-package install specs for the variant.""" - core_name = core["pypi_name"] - if variant == "dev": - dev_index_urls = core.get("dev_index_urls") or [] - if dev_index_urls: - # Let uv resolve the latest dev version from the core - # package's nightly channel; we read the installed version - # back after install. No explicit pin avoids the PEP 440 - # local-version segment headaches that nightly wheels have - # (e.g. 8.1.0.dev53+gabcdef). - # - # `--index-strategy unsafe-best-match` is required because - # uv's default ("first-index") only considers a single - # index per package; a nightly channel often hosts the core - # package AND its compiled deps, and its latest wheels - # sometimes don't match the runner platform. - # unsafe-best-match lets uv fall back to PyPI in that case. - core_spec = { - "install": core_name, - "version": "", - "extra_index_urls": dev_index_urls, - "prerelease_strategy": "allow", - "index_strategy": "unsafe-best-match", - } - else: - # No nightly channel configured: install the core package's - # dev version straight from the HEAD of its repository. - core_spec = { - "install": f"{core_name} @ git+{core['repo_url']}", - "version": "", - "extra_index_urls": [], - "prerelease_strategy": "allow", - "index_strategy": None, - } - - def pkg_spec(pkg): - repo = pkg.get("repo_url") - if not repo: - return None, None - return f"{pkg['pypi_name']}{_extras_suffix(pkg)} @ git+{repo}", None - - else: - include_pre = variant == "pre" - core_ver = latest_pypi(core_name, include_prereleases=include_pre) - core_spec = { - "install": f"{core_name}=={core_ver}", - "version": core_ver, - "extra_index_urls": [], - "prerelease_strategy": "allow" - if include_pre - else "if-necessary-or-explicit", - "index_strategy": None, - } - - def pkg_spec(pkg): - ver = latest_pypi(pkg["pypi_name"], include_prereleases=include_pre) - if not ver: - return None, None - return f"{pkg['pypi_name']}{_extras_suffix(pkg)}=={ver}", ver - - pkg_specs = [] - for pkg in packages: - spec, target = pkg_spec(pkg) - pkg_specs.append((pkg, spec, target)) - return core_spec, pkg_specs - - -def _resolver_conflict(stderr): - """True if the install stderr looks like a uv resolver conflict.""" - s = stderr.lower() - keywords = ( - "no solution found", - "incompatible", - "conflict", - "could not find a version", - "no matching distribution", - "no version of", - ) - return any(k in s for k in keywords) - - -def ensure_python(version): - proc = subprocess.run( - ["uv", "python", "find", version], capture_output=True, text=True, timeout=60 - ) - if proc.returncode == 0: - return proc.stdout.strip() - inst = subprocess.run( - ["uv", "python", "install", version], - capture_output=True, - text=True, - timeout=600, - ) - if inst.returncode != 0: - sys.exit(f"uv python install {version}: {inst.stderr.strip()}") - proc = subprocess.run( - ["uv", "python", "find", version], capture_output=True, text=True, timeout=60 - ) - if proc.returncode != 0: - sys.exit(f"uv python find {version}: {proc.stderr.strip()}") - return proc.stdout.strip() - - -def _venv_python_version(python): - proc = subprocess.run( - [ - python, - "-c", - "import sys; print('.'.join(str(x) for x in sys.version_info[:3]))", - ], - capture_output=True, - text=True, - timeout=30, - ) - return proc.stdout.strip() if proc.returncode == 0 else "" - - -def _pkg_version(python, name): - proc = subprocess.run( - [ - python, - "-c", - "import importlib.metadata as md, sys; print(md.version(sys.argv[1]))", - name, - ], - capture_output=True, - text=True, - timeout=30, - ) - return proc.stdout.strip() if proc.returncode == 0 else "" - - -def _freeze(python): - proc = subprocess.run( - ["uv", "pip", "freeze", "--python", python], - capture_output=True, - text=True, - timeout=60, - ) - out = {} - if proc.returncode == 0: - for line in proc.stdout.splitlines(): - line = line.strip() - if not line or line.startswith("#"): - continue - if "==" in line: - n, v = line.split("==", 1) - out[n.lower()] = v - return out - - -def _write_no_downgrade_constraints(python, path): - """Pin every installed package to '>=' its current version. - - Passed as a uv `--constraint` file to later installs so a new package - can pull its deps forward but never downgrade what the shared venv - already has; a package that genuinely needs an older version then - shows up as a resolver conflict (skipped) instead of silently - poisoning the venv for everything tested afterwards. - """ - frozen = _freeze(python) - lines = [] - for name, ver in sorted(frozen.items()): - try: - # Drop any PEP 440 local-version segment (e.g. the '+g1a2b3c4' - # on astropy/pyerfa nightly wheels): uv rejects a '>=' specifier - # with a local segment and would fail to parse the whole file. - public = Version(ver).public - except InvalidVersion: - continue - lines.append(f"{name}>={public}") - Path(path).write_text("\n".join(lines) + ("\n" if lines else "")) - - -# Ordering of tiers when installing/displaying. Unknown tiers sort last. -TIER_RANK = {"coordinated": 0, "affiliated": 1, "pyopensci": 2, "other": 3} - - -def _install_order(packages): - """Coordinated, then affiliated, then pyopensci, then other; alphabetical within each tier.""" - return sorted( - packages, - key=lambda p: ( - TIER_RANK.get(p.get("tier", "coordinated"), 9), - p["pypi_name"].lower(), - ), - ) - - -def _run_install(install_cmd, timeout): - """Wrap subprocess.run with TimeoutExpired catch. Returns (rc, stderr_or_msg).""" - try: - proc = subprocess.run( - install_cmd, capture_output=True, text=True, timeout=timeout - ) - except subprocess.TimeoutExpired: - return None, "timeout during install" - return proc.returncode, (proc.stderr or proc.stdout) - - -def run_variant( - variant, python_version, packages, repo_root, results_dir, timeouts, core -): - core_spec, pkg_specs = resolve_specs(packages, variant, core) - print(f"\n=== Variant: {variant} (Python {python_version}) ===") - print(f" {core['pypi_name']}: {core_spec['install']}") - for pkg, spec, target in pkg_specs: - print(f" {pkg['pypi_name']:<20} {spec or '(no install spec)'}") - - result = { - "variant": variant, - "started_at": datetime.now(timezone.utc).isoformat(timespec="seconds"), - "finished_at": "", - "core": { - "name": core["pypi_name"], - "install_spec": core_spec["install"], - "version": core_spec["version"], - "extra_index_urls": core_spec["extra_index_urls"], - "prerelease_strategy": core_spec["prerelease_strategy"], - }, - "python_requested": python_version, - "python_version": "", - "timeout_test_seconds": timeouts["test"], - "pytest_limit_n": ( - int(os.environ["PYTEST_LIMIT_N"]) - if (os.environ.get("PYTEST_LIMIT_N") or "").isdigit() - else None - ), - "fatal_error": "", - "installed_deps": {}, - "packages": [], - } - out_path = results_dir / f"{variant}__{python_version}.json" - - Path(repo_root, ".tmp").mkdir(exist_ok=True) - tmpdir = tempfile.mkdtemp( - prefix=f"int-{variant}-{python_version}-", - dir=str(Path(repo_root, ".tmp").resolve()), - ) - - try: - py_path = ensure_python(python_version) - venv = os.path.join(tmpdir, "venv") - venv_proc = subprocess.run( - ["uv", "venv", venv, "-p", py_path, "-q"], - capture_output=True, - text=True, - timeout=120, - ) - if venv_proc.returncode != 0: - result["fatal_error"] = f"uv venv: {venv_proc.stderr or venv_proc.stdout}" - return result, out_path - python = os.path.join(venv, "bin", "python") - result["python_version"] = _venv_python_version(python) - constraints_path = os.path.join(tmpdir, "no-downgrade-constraints.txt") - - common = ["uv", "pip", "install", "--python", python, "-q"] - for url in core_spec["extra_index_urls"]: - common += ["--extra-index-url", url] - common += [f"--prerelease={core_spec['prerelease_strategy']}"] - if core_spec.get("index_strategy"): - common += [f"--index-strategy={core_spec['index_strategy']}"] - - print(f"\nInstalling {core['pypi_name']} + pytest...") - # pytest-remotedata registers the `remote_data` marker many - # astropy ecosystem packages use; with the plugin installed but - # `--remote-data` not passed, those tests are skipped automatically - # instead of running and timing out on network calls. - rc, err = _run_install( - common - + [core_spec["install"], "pytest", "pytest-timeout", "pytest-remotedata"], - timeouts["install"], - ) - if rc != 0: - print(f" FATAL: {core['pypi_name']} install failed") - print(err) - result["fatal_error"] = err - return result, out_path - result["core"]["version"] = ( - _pkg_version(python, core["pypi_name"]) or result["core"]["version"] - ) - _write_no_downgrade_constraints(python, constraints_path) - - installed_pkgs = [] - for pkg, install_spec, target_version in pkg_specs: - entry = { - "name": pkg["pypi_name"], - "tier": pkg.get("tier", "coordinated"), - "module": pkg.get("module", pkg["pypi_name"]), - "install_spec": install_spec, - "target_version": target_version, - "resolved_version": "", - "install_status": "", # installed | skipped | install-fail | no-spec - "install_error": "", - "test_status": "", # pass | fail | no-tests | timeout | not-run - "test_output": "", - "duration": 0, - } - if install_spec is None: - entry["install_status"] = status.NO_SPEC - entry["install_error"] = ( - "no install spec (missing repo_url, or no PyPI release)" - ) - result["packages"].append(entry) - continue - - print(f"\nInstalling {pkg['pypi_name']}...") - install_cmd = ( - common - + ["--constraint", constraints_path, install_spec] - + (pkg.get("extra_deps") or []) - ) - rc, err = _run_install(install_cmd, timeouts["install"]) - if rc == 0: - entry["install_status"] = status.INSTALLED - entry["resolved_version"] = _pkg_version(python, pkg["pypi_name"]) - print(f" installed at {entry['resolved_version']}") - installed_pkgs.append((pkg, entry)) - _write_no_downgrade_constraints(python, constraints_path) - else: - entry["install_error"] = err - if _resolver_conflict(err): - entry["install_status"] = status.SKIPPED - print(" skipped (resolver conflict)") - else: - entry["install_status"] = status.INSTALL_FAIL - print(" install failed") - print(err) - result["packages"].append(entry) - - result["installed_deps"] = _freeze(python) - - for pkg, entry in installed_pkgs: - print(f"\nTesting {pkg['pypi_name']}...") - module = entry["module"] - cmd = [python, "-m", "pytest", "--pyargs", module] - cmd += pkg.get("pytest_args", []) - cmd += ["--timeout=120", "-q", "--tb=line", "--no-header"] - - env = {**os.environ, "MPLBACKEND": "Agg", "DISPLAY": ""} - start = time.time() - try: - proc = subprocess.run( - cmd, - capture_output=True, - text=True, - timeout=timeouts["test"], - cwd=repo_root, - env=env, - ) - except subprocess.TimeoutExpired: - entry["test_status"] = status.TIMEOUT - entry["test_output"] = "timeout" - entry["duration"] = round(time.time() - start, 1) - print(f" timeout after {entry['duration']}s") - continue - entry["duration"] = round(time.time() - start, 1) - out = proc.stdout - if proc.stderr: - out += "\n--- stderr ---\n" + proc.stderr - entry["test_output"] = out - - no_module = proc.returncode == 4 and "module or package not found" in ( - proc.stdout + proc.stderr - ) - if proc.returncode == 5 or no_module: - entry["test_status"] = status.NO_TESTS - elif proc.returncode == 0: - entry["test_status"] = status.PASS - else: - entry["test_status"] = status.FAIL - print(f" {entry['test_status']} in {entry['duration']}s") - - finally: - result["finished_at"] = datetime.now(timezone.utc).isoformat(timespec="seconds") - out_path.write_text(json.dumps(result, indent=2)) - shutil.rmtree(tmpdir, ignore_errors=True) - - return result, out_path - - -def _counts(result): - install = Counter(e["install_status"] for e in result["packages"]) - test = Counter(e["test_status"] for e in result["packages"] if e["test_status"]) - return {"install": dict(install), "test": dict(test)} - - -def add_arguments(ap): - ap.add_argument("--config", default="packages.yaml") - ap.add_argument("--results-dir", default="results") - ap.add_argument( - "--variant", - choices=status.VARIANTS, - help="Only run configured columns with this variant; " - "if omitted, every configured column runs.", - ) - ap.add_argument( - "--python", - help="Only run configured columns with this Python version " - "(e.g. '3.12', '3.14t'); if omitted, every configured column runs.", - ) - ap.add_argument("--packages", help="Comma-separated subset of package names to run") - ap.add_argument( - "--tiers", - help="Comma-separated subset of tiers to run (e.g. 'coordinated,other'); " - "default: all tiers", - ) - ap.add_argument("--timeout-install", type=int, default=900) - ap.add_argument("--timeout-test", type=int, default=1800) - - -def run(args): - # Make every print flush immediately so CI streams progress live - # instead of buffering until the script exits. - sys.stdout.reconfigure(line_buffering=True) - - core = config.load_core_package(args.config) - all_packages = config.load_packages(args.config) - packages = all_packages - if args.tiers: - wanted_tiers = {t.strip() for t in args.tiers.split(",") if t.strip()} - packages = [p for p in packages if p.get("tier", "coordinated") in wanted_tiers] - if args.packages: - wanted = {n.strip() for n in args.packages.split(",") if n.strip()} - known = {p["pypi_name"] for p in all_packages} - unknown = wanted - known - if unknown: - sys.exit( - f"Unknown package name(s): {', '.join(sorted(unknown))}. " - f"Valid names are the pypi_name entries in {args.config}." - ) - packages = [p for p in packages if p["pypi_name"] in wanted] - packages = _install_order(packages) - - repo_root = Path.cwd() - results_dir = Path(args.results_dir) - results_dir.mkdir(parents=True, exist_ok=True) - - timeouts = {"install": args.timeout_install, "test": args.timeout_test} - - columns = config.load_columns(args.config) - if args.variant: - columns = [c for c in columns if c["variant"] == args.variant] - if args.python: - columns = [c for c in columns if c["python"] == args.python] - if not columns: - sys.exit("No configured columns match the given --variant/--python filters.") - - fatal_combos = [] - for column in columns: - variant, python_version = column["variant"], column["python"] - result, out_path = run_variant( - variant, python_version, packages, repo_root, results_dir, timeouts, core - ) - print(f"\nDone {variant}/{python_version}: {_counts(result)}") - print(f"Wrote {out_path}") - if result.get("fatal_error"): - fatal_combos.append(f"{variant}/{python_version}") - - if fatal_combos: - sys.exit(f"\n{core['pypi_name']} install failed for: {', '.join(fatal_combos)}") diff --git a/astropy_integration/status.py b/astropy_integration/status.py deleted file mode 100644 index 3c86e0f..0000000 --- a/astropy_integration/status.py +++ /dev/null @@ -1,52 +0,0 @@ -"""Shared status vocabulary for integration-test results. - -Both `astropy_integration.run` (which writes statuses into results JSON) -and `astropy_integration.dashboard` (which renders them into the -dashboard) use these constants and helpers, so the strings are defined -in exactly one place. -""" - -# The recognised core-package variants. Listed once here so both -# scripts (and config validation) agree. -VARIANTS = ("stable", "pre", "dev") - -# install_status values, used in results/.json -INSTALLED = "installed" -SKIPPED = "skipped" # resolver couldn't satisfy alongside the existing venv -INSTALL_FAIL = "install-fail" # install itself crashed (build error, network, etc.) -NO_SPEC = "no-spec" # couldn't build an install spec (no repo_url / no PyPI release) - -# test_status values -PASS = "pass" -FAIL = "fail" -NO_TESTS = "no-tests" -TIMEOUT = "timeout" - - -# Tabular maps used on the per-variant page. -INSTALL_BADGE = { - INSTALLED: {"status": "pass", "label": "installed"}, - SKIPPED: {"status": "skipped", "label": "skipped"}, - INSTALL_FAIL: {"status": "install-fail", "label": "install fail"}, - NO_SPEC: {"status": "missing", "label": "no spec"}, - "": {"status": "missing", "label": "-"}, -} - -TEST_BADGE = { - PASS: {"status": "pass", "label": "PASS"}, - FAIL: {"status": "fail", "label": "FAIL"}, - NO_TESTS: {"status": "no-tests", "label": "no tests"}, - TIMEOUT: {"status": "timeout", "label": "timeout"}, - "": {"status": "missing", "label": "-"}, -} - - -def cell_badge(entry): - """Map a result entry to the {status, label} for its matrix cell. - - Install failures (including no-spec) take precedence over test status. - """ - install = entry.get("install_status", "") - if install != INSTALLED: - return INSTALL_BADGE.get(install, INSTALL_BADGE[""]) - return TEST_BADGE.get(entry.get("test_status", ""), TEST_BADGE[""]) diff --git a/astropy_integration/templates/_base.html b/astropy_integration/templates/_base.html deleted file mode 100644 index 769f3ce..0000000 --- a/astropy_integration/templates/_base.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - -{% block title %}{% endblock %} - - - -{% block nav %}{% endblock %} -{% block body %}{% endblock %} - - diff --git a/astropy_integration/templates/_style.css b/astropy_integration/templates/_style.css deleted file mode 100644 index 47940ec..0000000 --- a/astropy_integration/templates/_style.css +++ /dev/null @@ -1,53 +0,0 @@ -body { font-family: -apple-system, system-ui, sans-serif; margin: 2em; line-height: 1.5; color: #1a1a1a; max-width: 1200px; } -h1, h2 { margin-top: 0; } -a { color: #0366d6; text-decoration: none; } -a:hover { text-decoration: underline; } -table { border-collapse: collapse; } -th, td { border: 1px solid #ddd; padding: 6px 10px; text-align: left; vertical-align: top; } -th { background: #f6f8fa; } -th.python-group { text-align: center; border-bottom: 2px solid #ccc; } -.banner { background: #fff8c5; border: 1px solid #d4a72c; padding: 0.75em 1em; - border-radius: 6px; margin: 1em 0; } -tr.tier-header th { background: #eef2f6; text-align: left; font-weight: 600; - text-transform: lowercase; letter-spacing: 0.5px; color: #444; } -.meta dl { margin: 0.3em 0; display: grid; grid-template-columns: max-content 1fr; gap: 0.2em 1em; color: #444; } -.meta dt { font-weight: 600; } -.pill { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 0.85em; font-weight: 600; min-width: 4em; text-align: center; } -.pill.pass { background: #dcffe4; color: #22863a; } -.pill.fail { background: #ffdce0; color: #cb2431; } -.pill.no-tests { background: #eef2f6; color: #6a737d; } -.pill.skipped { background: #e6e9ee; color: #6a737d; font-style: italic; } -.pill.install-fail { background: #fff1d6; color: #b08000; } -.pill.timeout { background: #ece2ff; color: #5b3fb8; } -.pill.missing { background: #f1f1f1; color: #999; } -a.cell-link { text-decoration: none; } -a.cell-link:hover .pill { filter: brightness(0.94); } -.matrix tr:hover td { background: #fafafa; } -.pkg-name { font-weight: 600; } -pre { background: #1e1e1e; color: #d4d4d4; padding: 1em; border-radius: 6px; - overflow-x: auto; font-size: 0.85em; white-space: pre-wrap; word-wrap: break-word; max-height: 50em; } -details summary { cursor: pointer; padding: 4px 0; font-weight: 600; } -.meta-table td { padding: 4px 10px; } -.meta-table { width: auto; } -nav { margin-bottom: 1.5em; font-size: 0.9em; } -.legend { font-size: 0.85em; color: #6a737d; margin-top: 1em; } -.legend .pill { margin: 0 0.3em; } - -@media (prefers-color-scheme: dark) { - body { background: #0d1117; color: #c9d1d9; } - a { color: #58a6ff; } - th, td { border-color: #30363d; } - th { background: #161b22; } - th.python-group { border-bottom-color: #484f58; } - .banner { background: #2b1d00; border-color: #6e5500; } - tr.tier-header th { background: #161b22; color: #8b949e; } - .meta dl { color: #8b949e; } - .matrix tr:hover td { background: #161b22; } - .pill.pass { background: #0a3a17; color: #3fb950; } - .pill.fail { background: #4a1216; color: #f85149; } - .pill.no-tests { background: #21262d; color: #8b949e; } - .pill.skipped { background: #21262d; color: #8b949e; } - .pill.install-fail{ background: #3d2900; color: #e3b341; } - .pill.timeout { background: #261c4a; color: #a371f7; } - .pill.missing { background: #161b22; color: #6e7681; } -} diff --git a/astropy_integration/templates/index.html b/astropy_integration/templates/index.html deleted file mode 100644 index ad45ec6..0000000 --- a/astropy_integration/templates/index.html +++ /dev/null @@ -1,129 +0,0 @@ -{% extends "_base.html" %} -{% block title %}{{ title }}{% endblock %} -{% block body %} -

{{ title }}

- -{% if pytest_limit %} - -{% endif %} - - - - -{% for v in variants_meta %} - - - - - - - -{% endfor %} - -
PythonVariant{{ core_name }}StartedFinished
{{ v.python }}{{ v.variant }}{% if v.has_data %}{{ v.core_version }}{% if v.extra_index_urls %} (nightly){% endif %}{% else %}-{% endif %}{% if v.has_data %}{{ v.started_at }}{% else %}-{% endif %}{% if v.has_data %}{{ v.finished_at or "(in progress)" }}{% else %}-{% endif %}
- -

Matrix

- - - - - {% for g in column_groups %}{% endfor %} - - - {% for python, variant in columns %}{% endfor %} - - - -{% for tier, group in tier_groups %} - - - -{% for row in group %} - - - {% for cell in row.cells %} - - {% endfor %} - -{% endfor %} -{% endfor %} - -
PackagePython {{ g.python }}
{{ variant }}
{{ tier|capitalize }}
{{ row.name }} - {% if cell.anchor %} - {{ cell.label }} - {% else %} - {{ cell.label }} - {% endif %} - {% if cell.resolved_version %}
{{ cell.resolved_version }}{% endif %} -
- -
Legend: - pass - fail - timeout - no tests - skipped - install fail - missing -
-

skipped: resolver couldn't satisfy this package alongside the rest of the venv. install fail: install step crashed for some other reason (build error, etc.).

- -{% if failures %} -

Failure logs

-

Click any non-passing badge above to jump to its log; the section will auto-expand.

-{% for f in failures %} -
- - {{ f.name }} - ({{ f.variant }} / Python {{ f.python }}) - {{ f.label }} - - {% if f.install_error %} -

Install error

-
{{ f.install_error }}
- {% endif %} - {% if f.test_output %} -

Test output

-
{{ f.test_output }}
- {% endif %} -
-{% endfor %} -{% else %} -

No failures — every package passed in every variant that ran.

-{% endif %} - -{% if variants_meta|selectattr("installed_deps")|list %} -

Installed packages

-

Full uv pip freeze of the shared venv for each variant that ran.

-{% for v in variants_meta %} -{% if v.installed_deps %} -
- - {{ v.variant }} / Python {{ v.python }} - ({{ v.installed_deps|length }} packages) - -
{% for name, ver in v.installed_deps|dictsort %}{{ name }}=={{ ver }}
-{% endfor %}
-
-{% endif %} -{% endfor %} -{% endif %} - - -{% endblock %} diff --git a/conftest.py b/conftest.py index 0c55230..acb4e3e 100644 --- a/conftest.py +++ b/conftest.py @@ -1,25 +1,18 @@ -"""Repo-level pytest plugin, auto-discovered because the runner invokes -every `pytest --pyargs ` with cwd set to the repo root. - -Two jobs: - -1. PR-preview smoke runs: when the env var `PYTEST_LIMIT_N` is set to a - positive integer, pytest collects normally and then truncates the - test list to the first N items. This lets the PR matrix surface a - fast smoke signal per package (typically 10 tests each) without - per-package configuration. - -2. Supply shared test fixtures that a package defines in its own - repo-root conftest.py but does not ship in the installed wheel. - `pytest --pyargs` collects from site-packages, so such fixtures are - otherwise missing and their tests error at setup. Currently: - `tmp_cwd` (astroquery). +"""Repo-root pytest plugin for PR-preview smoke runs. + +When the env var ``PYTEST_LIMIT_N`` is set to a positive integer, pytest +collects normally and then truncates the test list to the first N items. +The integration-dashboard runner sets this on pull requests so each +package surfaces a fast smoke signal (typically 10 tests) without any +per-package configuration. + +This file must live at the root of the repository that invokes the runner +(this repo for its self-test; the consuming repo otherwise), because +``pytest --pyargs`` collects from site-packages and would otherwise never +load it. Downstream consumers copy this file into their repo root. """ import os -from pathlib import Path - -import pytest def pytest_collection_modifyitems(config, items): @@ -32,22 +25,3 @@ def pytest_collection_modifyitems(config, items): return if n > 0 and len(items) > n: del items[n:] - - -@pytest.fixture(scope="function") -def tmp_cwd(tmp_path): - """astroquery shim: run the test in a pristine temp working directory. - - Exists solely for astroquery, which defines this fixture in its - repo-root conftest.py. That file is not part of the installed - package, so the fixture is missing under `pytest --pyargs - astroquery` and the esa/utils, esa/iso and esa/xmm_newton download - tests error out at setup. Remove this if astroquery ever ships the - fixture inside the package. - """ - old_dir = Path.cwd() - os.chdir(tmp_path) - try: - yield tmp_path - finally: - os.chdir(old_dir) diff --git a/packages.yaml b/packages.yaml index 4b682a7..3d78fa0 100644 --- a/packages.yaml +++ b/packages.yaml @@ -1,4 +1,5 @@ -# Configuration for `sunpy-integration run`. +# Configuration for `integration-dashboard run` +# (https://github.com/OpenAstronomy/integration-dashboard). # # `core_package` is the ecosystem's core package. The runner builds a # shared venv, installs the core package first, then installs each @@ -18,16 +19,21 @@ # `dev_index_urls` is unset); each package from git HEAD # # `tier` (on each package) is purely a category label used for -# ordering and the optional `--tiers` CLI filter. Conventions: -# `coordinated` for the official coordinated set, `affiliated` for -# affiliated packages from the frozen pre-APE 22 registry, `pyopensci` -# for affiliated packages reviewed through the pyOpenSci process, -# `other` for anything else worth testing. +# ordering and the optional `--tiers` CLI filter. Tiers are installed +# and displayed in the order they first appear in this file, so keep +# each tier's packages together. This file uses `coordinated`, +# `affiliated` and `provisional`. core_package: pypi_name: sunpy module: sunpy repo_url: https://github.com/sunpy/sunpy.git + # pytest plugins added to every venv alongside pytest itself. + # pytest-remotedata registers the `remote_data` marker that many + # packages use; with the plugin installed but `--remote-data` not + # passed, those tests are skipped instead of running and timing out + # on network calls. + test_deps: [pytest-remotedata] # For the `dev` variant the core package is installed from these # nightly wheel indexes (liberfa hosts pyerfa's dev wheels). Omit # `dev_index_urls` to install the dev version from `git+repo_url`. diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index 17dd450..0000000 --- a/pyproject.toml +++ /dev/null @@ -1,23 +0,0 @@ -[build-system] -requires = ["setuptools>=77"] -build-backend = "setuptools.build_meta" - -[project] -name = "sunpy-integration" -version = "0.1.0" -description = "Run and dashboard the astropy ecosystem integration matrix." -requires-python = ">=3.11" -dependencies = [ - "jinja2", - "packaging", - "pyyaml", -] - -[project.scripts] -sunpy-integration = "astropy_integration.cli:main" - -[tool.setuptools.packages.find] -include = ["astropy_integration*"] - -[tool.setuptools.package-data] -astropy_integration = ["templates/*.html", "templates/*.css"] diff --git a/sunpy_pytest.ini b/sunpy_pytest.ini deleted file mode 100644 index e79ca22..0000000 --- a/sunpy_pytest.ini +++ /dev/null @@ -1,32 +0,0 @@ -# This is a reduced config to run in this specific CI -[pytest] -minversion = 7.0 -testpaths = - sunpy - docs -norecursedirs = - .tox - build - docs/_build - docs/generated - *.egg-info - examples - sunpy/_dev - .history - tools - sunpy/extern - benchmarks -doctest_plus = enabled -doctest_optionflags = NORMALIZE_WHITESPACE FLOAT_CMP ELLIPSIS -addopts = --arraydiff --doctest-rst --doctest-ignore-import-errors -p no:unraisableexception -p no:threadexception -m "not mpl_image_compare" -asdf_schema_tests_enabled = true -asdf_schema_root = sunpy/io/special/asdf/resources/ -markers = - remote_data: marks this test function as needing remote data. - online: marks this test function as needing online connectivity. - mpl_image_compare: marks this test function as using hash-based Matplotlib figure verification. This mark is not meant to be directly applied, but is instead automatically applied when a test function uses the @sunpy.tests.helpers.figure_test decorator. - flaky - array_compare -remote_data_strict = true -filterwarnings = - ignore