Skip to content

Commit 91f94ee

Browse files
committed
ci: add downstream testing
Signed-off-by: Henry Schreiner <[email protected]>
1 parent d293b7c commit 91f94ee

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed

.github/workflows/tests.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,42 @@ jobs:
6969
env_vars: PYTHON
7070
name: ${{ matrix.python }}
7171

72+
downstream:
73+
name: Downstream ${{ matrix.project }}
74+
runs-on: ubuntu-latest
75+
strategy:
76+
fail-fast: false
77+
matrix:
78+
project:
79+
- sphinx-theme-builder
80+
- meson-python
81+
- scikit-build-core
82+
- pdm-backend
83+
84+
steps:
85+
- name: Checkout
86+
uses: actions/checkout@v6
87+
with:
88+
persist-credentials: false
89+
90+
- name: Set up target Python
91+
uses: actions/setup-python@v6
92+
with:
93+
python-version: "3.14"
94+
95+
- name: Install the latest version of uv
96+
uses: astral-sh/setup-uv@v7
97+
98+
- name: Run nox
99+
run: uvx nox -s 'downstream(project="${{ matrix.project }}")'
100+
72101
# https://github.com/marketplace/actions/alls-green#why
73102
required-checks-pass: # This job does nothing and is only used for the branch protection
74103
if: always()
75104

76105
needs:
77106
- pytest
107+
- downstream
78108

79109
runs-on: ubuntu-latest
80110

noxfile.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
# ///
77

88
import argparse
9+
import io
10+
import shutil
11+
import tarfile
12+
import urllib.request
913
from pathlib import Path
1014

1115
import nox
@@ -106,5 +110,57 @@ def docs(session: nox.Session) -> None:
106110
session.run("sphinx-build", "--keep-going", *shared_args)
107111

108112

113+
PROJECTS = {
114+
"sphinx-theme-builder": "https://github.com/pradyunsg/sphinx-theme-builder/archive/refs/tags/0.3.2.tar.gz",
115+
"meson-python": "https://github.com/mesonbuild/meson-python/archive/refs/tags/0.19.0.tar.gz",
116+
"scikit-build-core": "https://github.com/scikit-build/scikit-build-core/archive/41056e7b9aac3721994aa684de3314aa04c17dc9.tar.gz",
117+
"pdm-backend": "https://github.com/pdm-project/pdm-backend/archive/refs/tags/2.4.6.tar.gz",
118+
}
119+
120+
121+
@nox.session(default=False)
122+
@nox.parametrize("project", list(PROJECTS))
123+
def downstream(session: nox.Session, project: str) -> None:
124+
pkg_dir = Path.cwd() / "pyproject_metadata"
125+
env = {"FORCE_COLOR": None}
126+
session.install("-e.")
127+
128+
tmp_dir = Path(session.create_tmp())
129+
session.chdir(tmp_dir)
130+
131+
shutil.rmtree(project, ignore_errors=True)
132+
with urllib.request.urlopen(PROJECTS[project]) as resp: # noqa: S310
133+
data = resp.read()
134+
with tarfile.open(fileobj=io.BytesIO(data), mode="r:gz") as tf:
135+
tf.extractall(project) # noqa: S202
136+
(inner_dir,) = Path(project).iterdir()
137+
session.chdir(inner_dir)
138+
139+
if project == "sphinx-theme-builder":
140+
session.install("-r", "tests/requirements.txt")
141+
session.install("-e.[cli]", "pip")
142+
session.run("pip", "list")
143+
session.run("pytest", "--pspec", "-knot import_name", env=env)
144+
if project == "meson-python":
145+
session.install("-e.", "--group=test", "pip")
146+
session.run("pip", "list")
147+
session.run("pytest", env=env)
148+
if project == "pdm-backend":
149+
session.install(
150+
"-e.", "pytest", "pip", "pytest-gitconfig", "pytest-xdist", "setuptools"
151+
)
152+
session.run("pip", "list")
153+
repl_dir = "src/pdm/backend/_vendor/pyproject_metadata"
154+
shutil.rmtree(repl_dir)
155+
shutil.copytree(pkg_dir, repl_dir)
156+
session.run("pytest", "-knot get_version_from_scm", env=env)
157+
if project == "scikit-build-core":
158+
session.install("-e.", "--group=test")
159+
repl_dir = "src/scikit_build_core/_vendor/pyproject_metadata"
160+
shutil.rmtree(repl_dir)
161+
shutil.copytree(pkg_dir, repl_dir)
162+
session.run("pytest", "-mnot network", env=env)
163+
164+
109165
if __name__ == "__main__":
110166
nox.main()

0 commit comments

Comments
 (0)