Skip to content

Commit 78810ee

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 78810ee

21 files changed

+738
-27
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

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 = "ahal@mozilla.com" }
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/docker/decision/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ LABEL maintainer="Release Engineering <release+taskgraph@mozilla.com>"
44
ENV UV_PROJECT_ENVIRONMENT=/setup/taskgraph
55

66
# %include src
7+
# %include packages
78
# %include .hatch_build.py
89
# %include README.rst
910
# %include pyproject.toml

test/conftest.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
import pytest
55
from responses import RequestsMock
66

7-
from .fixtures.gen import * # noqa
8-
from .fixtures.vcs import * # noqa
9-
107
here = Path(__file__).parent
118

9+
pytest_plugins = ("pytest-taskgraph",)
10+
1211
# Disable as much system/user level configuration as we can to avoid
1312
# interference with tests.
1413
# This ignores ~/.hgrc

0 commit comments

Comments
 (0)