diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f8b4d18..6f53b06 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,7 +7,7 @@ on: # manually triggered jobs: - build: + test: runs-on: ubuntu-latest strategy: matrix: @@ -32,3 +32,48 @@ jobs: uv pip install ".[testing]" .venv/bin/pytest tests --cov=pact .venv/bin/pylint --rcfile=.pylintrc pact tests + + docs: + runs-on: ubuntu-latest + steps: + - name: Checkout the repository + uses: actions/checkout@main + - name: Install the default version of uv + id: setup-uv + uses: astral-sh/setup-uv@v3 + - name: Building docs + run: | + uv venv --python 3.11 + uv pip install ".[doc]" + .venv/bin/sphinx-build -a -W -E doc build/sphinx/html + + publish: + if: startsWith(github.ref, 'refs/tags/') + needs: test + runs-on: ubuntu-latest + environment: release + permissions: + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Install hatch + run: pip install hatch + + - name: Build package + run: hatch build + + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + attestations: true + skip-existing: true diff --git a/.gitignore b/.gitignore index e380bff..d9af292 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ dist htmlcov AUTHORS ChangeLog +.venv diff --git a/.readthedocs.yaml b/.readthedocs.yaml new file mode 100644 index 0000000..4a0f38b --- /dev/null +++ b/.readthedocs.yaml @@ -0,0 +1,28 @@ +# .readthedocs.yaml +# Read the Docs configuration file +# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details + +# Required +version: 2 + +# Set the version of Python and other tools you might need +build: + os: ubuntu-22.04 + tools: + python: "3.12" + +# Build documentation in the docs/ directory with Sphinx +sphinx: + configuration: doc/conf.py + +# If using Sphinx, optionally build your docs in additional formats such as PDF +# formats: +# - pdf + +# Optionally declare the Python requirements required to build your docs +python: + install: + - method: pip + path: . + extra_requirements: + - doc diff --git a/Makefile b/Makefile index 77b9f34..02c0578 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ test: env env: uv venv - uv pip install -e ".[testing]" + uv pip install -e ".[testing,doc]" doc: env .venv/bin/sphinx-build -a -W -E doc build/sphinx/html diff --git a/doc/conf.py b/doc/conf.py index b396175..df747e1 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -13,7 +13,7 @@ # serve to show the default. import alabaster -import pkg_resources +import importlib.metadata nitpicky = True @@ -59,7 +59,7 @@ # |version| and |release|, also used in various other places throughout the # built documents. # -version = release = pkg_resources.get_distribution('pact').version +version = release = importlib.metadata.distribution('pact').version # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/tests/test_pact_group.py b/tests/test_pact_group.py index 43074e3..2f5901b 100644 --- a/tests/test_pact_group.py +++ b/tests/test_pact_group.py @@ -11,7 +11,7 @@ def test_group_wait_during(checkpoint, timed_group, num_seconds): assert checkpoint.called_times == num_seconds + 1 -def test_group_wait_then(checkpoint, checkpoint1, checkpoint2, checkpoint3, timed_group, timed_pact): +def test_group_wait_then(*, checkpoint, checkpoint1, checkpoint2, checkpoint3, timed_group, timed_pact): timed_group.lastly(checkpoint1) timed_group.then(checkpoint) timed_pact.then(checkpoint2) @@ -74,7 +74,7 @@ def get_timeout_exception(self, exc_info): group.wait() -def test_group_without_absorb(pred1, pred2, checkpoint, checkpoint1, checkpoint2, checkpoint3): +def test_group_without_absorb(*, pred1, pred2, checkpoint, checkpoint1, checkpoint2, checkpoint3): p1 = Pact('a').until(pred1).lastly(checkpoint).then(checkpoint1) p2 = Pact('b').until(pred2).then(checkpoint2).lastly(checkpoint3) group = p1 + p2 @@ -91,7 +91,7 @@ def test_group_without_absorb(pred1, pred2, checkpoint, checkpoint1, checkpoint2 assert checkpoint3.called -def test_group_with_absorb(pred1, pred2, checkpoint, checkpoint1, checkpoint2, checkpoint3): +def test_group_with_absorb(*, pred1, pred2, checkpoint, checkpoint1, checkpoint2, checkpoint3): # pylint: disable=protected-access p1 = Pact('a').until(pred1).lastly(checkpoint).then(checkpoint1) p2 = Pact('b').until(pred2).then(checkpoint2).lastly(checkpoint3)