Skip to content

Commit 8b34827

Browse files
committed
refactor: create new 'pytest-taskgraph' module to house test fixtures
These fixtures are useful for any project that wants to test Taskgraph related transforms or scripts. By putting them in a package, we can share them to any other repos that may need them.
1 parent 33803c5 commit 8b34827

28 files changed

+839
-34
lines changed

.github/workflows/pypi-publish.yml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ on:
33
release:
44
types: [published]
55
jobs:
6-
pypi-publish:
6+
pypi-publish-taskcluster-taskgraph:
77
name: upload release to PyPI
8+
if: ${{ ! startswith(github.ref, 'refs/tags/pytest-taskgraph') }}
89
runs-on: ubuntu-latest
910
environment: release
1011
permissions:
@@ -16,9 +17,32 @@ jobs:
1617
with:
1718
python-version: '3.11'
1819
cache: 'pip'
19-
- name: Build package distributions
20+
- name: Build taskcluster-taskgraph package distributions
2021
run: |
2122
pip install build
2223
python -m build
2324
- name: Publish package distributions to PyPI
2425
uses: pypa/gh-action-pypi-publish@release/v1
26+
pypi-publish-pytest-taskgraph:
27+
name: upload release to PyPI
28+
if: startswith(github.ref, 'refs/tags/pytest-taskgraph')
29+
runs-on: ubuntu-latest
30+
environment: release
31+
permissions:
32+
id-token: write
33+
steps:
34+
- name: Checkout sources
35+
uses: actions/checkout@v4
36+
- uses: actions/setup-python@v5
37+
with:
38+
python-version: '3.11'
39+
cache: 'pip'
40+
- name: Build pytest-taskgraph package distributions
41+
working-directory: packages/pytest-taskgraph
42+
run: |
43+
pip install build
44+
python -m build
45+
- name: Publish package distributions to PyPI
46+
uses: pypa/gh-action-pypi-publish@release/v1
47+
with:
48+
packages-dir: packages/pytest-taskgraph/dist

CONTRIBUTING.rst

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ Or if you'd like to update a specific dependency:
150150
151151
uv sync -P <package>
152152
153-
Releasing
154-
---------
153+
Releasing taskcluster-taskgraph
154+
-------------------------------
155155

156156
In order to release a new version of Taskgraph, you will need to:
157157

@@ -161,11 +161,25 @@ In order to release a new version of Taskgraph, you will need to:
161161
4. Create a release in Github pointing to the above commit. Be sure to also
162162
create a new tag matching this version.
163163
5. Wait for the ``pypi-publish`` Github workflow and ``push-image-decision`` task to finish.
164-
6. Verify that expected version has been published to `pypi`_ and pushed to `DockerHub`_.
164+
6. Verify that expected version has been published to `pypi
165+
<https://pypi.org/project/taskcluster-taskgraph>`__ and pushed to `DockerHub`_.
165166

166-
.. _pypi: https://pypi.org/project/taskcluster-taskgraph
167167
.. _DockerHub: https://hub.docker.com/r/mozillareleases/taskgraph/tags
168168

169+
Releasing pytest-taskgraph
170+
--------------------------
171+
172+
There's also a Pytest plugin packaged under ``packages/pytest-taskgraph``. The
173+
release process for this package is:
174+
175+
1. Update ``version`` in ``packages/pytest-taskgraph/pyproject.toml``
176+
2. Commit and land the changes with a commit message like "chore: bump pytest-taskgraph <version>"
177+
3. Create a release in Github pointing to the above commit. Be sure to also
178+
create a new tag of the form ``pytest-taskgraph-v<version>``.
179+
4. Wait for the ``pypi-publish`` Github workflow and ``push-image-decision`` task to finish.
180+
5. Verify that expected version has been published to `pypi <https://pypi.org/project/pytest-taskgraph>`__.
181+
182+
169183
Building the Package
170184
--------------------
171185

packages/pytest-taskgraph/README.md

Whitespace-only changes.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[project]
2+
name = "pytest-taskgraph"
3+
version = "0.1.0"
4+
description = "Add your description here"
5+
readme = "README.md"
6+
authors = [
7+
{ name = "Andrew Halberstadt", email = "[email protected]" }
8+
]
9+
requires-python = ">=3.8"
10+
dependencies = ["pytest", "taskcluster-taskgraph>=12.1.0"]
11+
12+
[project.entry-points.pytest11]
13+
pytest-taskgraph = "pytest_taskgraph"
14+
15+
[build-system]
16+
requires = ["hatchling"]
17+
build-backend = "hatchling.build"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from .fixtures.gen import * # noqa
2+
from .fixtures.vcs import * # noqa

test/fixtures/gen.py renamed to packages/pytest-taskgraph/src/pytest_taskgraph/fixtures/gen.py

File renamed without changes.

test/fixtures/vcs.py renamed to packages/pytest-taskgraph/src/pytest_taskgraph/fixtures/vcs.py

File renamed without changes.

packages/pytest-taskgraph/uv.lock

Lines changed: 654 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ taskgraph = "taskgraph.main:main"
4545
Repository = "https://github.com/taskcluster/taskgraph"
4646
Issues = "https://github.com/taskcluster/taskgraph/issues"
4747

48+
[tool.uv.sources]
49+
pytest-taskgraph = { path = "packages/pytest-taskgraph" }
50+
4851
[tool.uv]
4952
dev-dependencies = [
5053
"coverage",
@@ -53,6 +56,7 @@ dev-dependencies = [
5356
"pyright",
5457
"pytest",
5558
"pytest-mock",
59+
"pytest-taskgraph",
5660
"responses",
5761
"sphinx",
5862
"sphinx-autobuild",
@@ -79,7 +83,7 @@ xfail_strict = true
7983

8084
[tool.coverage.run]
8185
branch = true
82-
source = ["src/taskgraph/", "src/taskgraph/run-task/", "test"]
86+
source = ["src/taskgraph/", "src/taskgraph/run-task/", "packages", "test"]
8387

8488
### Lint and Format
8589
[tool.ruff]
@@ -103,7 +107,7 @@ ignore = [
103107
]
104108

105109
[tool.ruff.lint.isort]
106-
known-first-party = ["taskgraph"]
110+
known-first-party = ["pytest-taskgraph", "taskgraph"]
107111

108112
[tool.pyright]
109113
include = ["src"]

taskcluster/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ index:
1515
task-priority: low
1616

1717
taskgraph:
18+
register: self_taskgraph:register
19+
decision-parameters: 'self_taskgraph.custom_parameters:decision_parameters'
1820
repositories:
1921
ci:
2022
name: Taskgraph

0 commit comments

Comments
 (0)