From 4236be3762de8332c5ce39b96f9a56446cde9a42 Mon Sep 17 00:00:00 2001 From: JP-Ellis Date: Wed, 21 Aug 2024 16:24:42 +1000 Subject: [PATCH] chore: add extra checks Add a few extra checks: - Typos - All `pre-commit` checks Also refactor the test CI workflow Signed-off-by: JP-Ellis --- .github/workflows/build.yml | 20 +++- .github/workflows/test.yml | 108 +++++++++++++++--- .pre-commit-config.yaml | 40 ++++--- CHANGELOG.md | 40 +++---- CONTRIBUTING.md | 2 +- biome.json | 16 +++ committed.toml | 17 +++ ...2 integrating rust ffi with pact python.md | 2 +- docs/provider.md | 2 +- docs/scripts/python.py | 2 +- pyproject.toml | 9 ++ src/pact/matchers.py | 2 +- src/pact/message_consumer.py | 4 +- src/pact/message_provider.py | 2 +- src/pact/v3/ffi.py | 6 +- src/pact/v3/interaction/_http_interaction.py | 2 +- tests/test_verifier.py | 2 +- .../test_v3_message_consumer.py | 2 +- .../util/interaction_definition.py | 2 +- 19 files changed, 207 insertions(+), 73 deletions(-) create mode 100644 biome.json create mode 100644 committed.toml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6c064fb9c..e33ad9145 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,6 +21,24 @@ env: CIBW_BUILD_FRONTEND: build jobs: + complete: + name: Build completion check + if: always() + + permissions: + contents: none + + runs-on: ubuntu-latest + needs: + - build-sdist + - build-x86_64 + - build-arm64 + + steps: + - name: Failed + run: exit 1 + if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') + build-sdist: name: Build source distribution @@ -123,7 +141,7 @@ jobs: # As this requires emulation, it's not worth running on PRs or master if: >- github.event_name == 'push' && - startsWith(github.event.ref, 'refs/tags') + startsWith(github.event.ref, 'refs/tags/v*') runs-on: ${{ matrix.os }} strategy: fail-fast: false diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fd7528046..05f260225 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,9 +19,33 @@ env: FORCE_COLOR: "1" jobs: - test-container: + complete: + name: Test completion check + if: always() + + permissions: + contents: none + + runs-on: ubuntu-latest + needs: + - test-linux + - test-other + - example + - format + - lint + - typecheck + - spelling + - pre-commit + + steps: + - name: Failed + run: exit 1 + if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped') + + test-linux: name: >- - Tests py${{ matrix.python-version }} on ${{ matrix.os }} + Test Python ${{ matrix.python-version }} + on ${{ startsWith(matrix.os, 'macos-') && 'macOS' || startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }} runs-on: ${{ matrix.os }} continue-on-error: ${{ matrix.experimental }} @@ -93,9 +117,10 @@ jobs: with: token: ${{ secrets.CODECOV_TOKEN }} - test-no-container: + test-other: name: >- - Tests py${{ matrix.python-version }} on ${{ matrix.os }} + Test Python ${{ matrix.python-version }} + on ${{ startsWith(matrix.os, 'macos-') && 'macOS' || startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }} runs-on: ${{ matrix.os }} @@ -139,17 +164,6 @@ jobs: - name: Run tests run: hatch run test - test-conlusion: - name: Test matrix complete - - runs-on: ubuntu-latest - needs: - - test-container - - test-no-container - - steps: - - run: echo "Test matrix completed successfully." - example: name: Example @@ -197,6 +211,26 @@ jobs: run: > hatch run example --broker-url=http://pactbroker:pactbroker@localhost:9292 + format: + name: Format + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 + + - name: Set up Python + uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5 + with: + python-version: ${{ env.STABLE_PYTHON_VERSION }} + cache: pip + + - name: Install Hatch + run: pip install --upgrade hatch + + - name: Format + run: hatch run format + lint: name: Lint @@ -214,11 +248,47 @@ jobs: - name: Install Hatch run: pip install --upgrade hatch - - name: Lint + - name: Format run: hatch run lint - - name: Typecheck - run: hatch run typecheck + typecheck: + name: Typecheck + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 + + - name: Set up Python + uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5 + with: + python-version: ${{ env.STABLE_PYTHON_VERSION }} + cache: pip + + - name: Install Hatch + run: pip install --upgrade hatch - name: Format - run: hatch run format + run: hatch run typecheck + + spelling: + name: Spell check + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Spell Check Repo + uses: crate-ci/typos@master + + pre-commit: + name: Pre-commit + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Run pre-commit + uses: pre-commit/action@v3.0.1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 09a7df3f7..ce06edea5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -35,11 +35,11 @@ repos: # allows for comments within JSON files. - id: check-json5 - - repo: https://github.com/pre-commit/mirrors-prettier - rev: v3.1.0 + - repo: https://github.com/biomejs/pre-commit + rev: "v0.4.0" # Use the sha / tag you want to point at hooks: - - id: prettier - stages: [pre-push] + - id: biome-check + additional_dependencies: ["@biomejs/biome@1.8.2"] - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.6.1 @@ -52,11 +52,25 @@ repos: - id: ruff-format exclude: ^(pact|tests)/(?!v3/).*\.py$ - - repo: https://github.com/commitizen-tools/commitizen - rev: v3.29.0 + - repo: https://github.com/crate-ci/committed + rev: v1.0.20 + hooks: + - id: committed + + - repo: https://github.com/igorshubovych/markdownlint-cli + rev: v0.41.0 hooks: - - id: commitizen - stages: [commit-msg] + - id: markdownlint + exclude: | + (?x)^( + .github/PULL_REQUEST_TEMPLATE\.md + | CHANGELOG.md + ) + + - repo: https://github.com/crate-ci/typos + rev: v1.23.6 + hooks: + - id: typos - repo: local hooks: @@ -69,13 +83,3 @@ repos: types: [python] exclude: ^(src/pact|tests)/(?!v3/).*\.py$ stages: [pre-push] - - - repo: https://github.com/igorshubovych/markdownlint-cli - rev: v0.41.0 - hooks: - - id: markdownlint - exclude: | - (?x)^( - .github/PULL_REQUEST_TEMPLATE\.md - | CHANGELOG.md - ) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02166afb4..27152f718 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -293,7 +293,7 @@ Identical to 2.1.0, but with a fix to the publication process to PyPI. - e097153 - docs: update readme (William Infante, Mon Jan 25 17:18:35 2021 +1100) - fc0d91c - feat: address PR comments (William Infante, Mon Jan 25 10:30:33 2021 +1100) - 5448d8c - test: remove mock and check generated json file (William Infante, Wed Jan 20 21:07:39 2021 +1100) -- abd3574 - fix: few more tests to improve coverage (Tuan Pham, Wed Jan 20 09:23:13 2021 +1100) +- abd3574 - fix: few more tests to improve coverage (Tuan Pham, Wed Jan 20 09:23:13 2021 +1100) - 0ef971f - fix: improve test coverage (Tuan Pham, Tue Jan 19 15:11:11 2021 +1100) - e543f04 - chore: add missing import (William Infante, Tue Jan 19 13:58:17 2021 +1100) - bc7ff78 - chore: pydocstyle (Tuan Pham, Tue Jan 19 10:40:12 2021 +1100) @@ -301,9 +301,9 @@ Identical to 2.1.0, but with a fix to the publication process to PyPI. - 19827d0 - chore: remove test param for provider (Tuan Pham, Mon Jan 18 16:06:42 2021 +1100) - 912b477 - chore: flake8 revert (Tuan Pham, Mon Jan 18 16:04:00 2021 +1100) - 4a730ae - fix: revert changes to quotes (Tuan Pham, Mon Jan 18 15:57:14 2021 +1100) -- cfe35cc - feat: update message hander to be independent of pact (William Infante, Mon Jan 18 13:12:17 2021 +1100) +- cfe35cc - feat: update message handler to be independent of pact (William Infante, Mon Jan 18 13:12:17 2021 +1100) - 12b4a50 - fix: flake8 warning (Tuan Pham, Mon Jan 18 12:50:50 2021 +1100) -- 7afe693 - test: update message handler condition based on content (William Infante, Mon Jan 18 12:37:50 2021 +1100) +- 7afe693 - test: update message handler condition based on content (William Infante, Mon Jan 18 12:37:50 2021 +1100) - 79106bb - feat: move publish function to broker class (Tuan Pham, Mon Jan 18 11:30:35 2021 +1100) - a04b954 - docs: add readme for message consumer (William Infante, Mon Jan 18 09:48:01 2021 +1100) - 8672e2f - feat: update handler to handle error exceptions (William Infante, Fri Jan 15 16:24:38 2021 +1100) @@ -322,7 +322,7 @@ Identical to 2.1.0, but with a fix to the publication process to PyPI. - 8546a26 - fix: linting (Tuan Pham, Thu Jan 14 10:38:52 2021 +1100) - 65b69d7 - fix: remove publish fn for now (Tuan Pham, Thu Jan 14 10:38:10 2021 +1100) - e31dd45 - feat: add constants test (William Infante, Wed Jan 13 17:28:45 2021 +1100) -- 955dbe1 - feat: update MessageConsumer and tests (William Infante, Wed Jan 13 16:38:30 2021 +1100) +- 955dbe1 - feat: update MessageConsumer and tests (William Infante, Wed Jan 13 16:38:30 2021 +1100) - af5c9fb - feat: create basic tests for single pact message (William Infante, Wed Jan 13 15:52:07 2021 +1100) - fea27c8 - feat: single message flow (William Infante, Wed Jan 13 15:03:41 2021 +1100) - 9047855 - feat: add MessageConsumer (William Infante, Wed Jan 13 12:45:19 2021 +1100) @@ -378,7 +378,7 @@ Identical to 2.1.0, but with a fix to the publication process to PyPI. - e097153 - docs: update readme (William Infante, Mon Jan 25 17:18:35 2021 +1100) - fc0d91c - feat: address PR comments (William Infante, Mon Jan 25 10:30:33 2021 +1100) - 5448d8c - test: remove mock and check generated json file (William Infante, Wed Jan 20 21:07:39 2021 +1100) -- abd3574 - fix: few more tests to improve coverage (Tuan Pham, Wed Jan 20 09:23:13 2021 +1100) +- abd3574 - fix: few more tests to improve coverage (Tuan Pham, Wed Jan 20 09:23:13 2021 +1100) - 0ef971f - fix: improve test coverage (Tuan Pham, Tue Jan 19 15:11:11 2021 +1100) - e543f04 - chore: add missing import (William Infante, Tue Jan 19 13:58:17 2021 +1100) - bc7ff78 - chore: pydocstyle (Tuan Pham, Tue Jan 19 10:40:12 2021 +1100) @@ -386,9 +386,9 @@ Identical to 2.1.0, but with a fix to the publication process to PyPI. - 19827d0 - chore: remove test param for provider (Tuan Pham, Mon Jan 18 16:06:42 2021 +1100) - 912b477 - chore: flake8 revert (Tuan Pham, Mon Jan 18 16:04:00 2021 +1100) - 4a730ae - fix: revert changes to quotes (Tuan Pham, Mon Jan 18 15:57:14 2021 +1100) -- cfe35cc - feat: update message hander to be independent of pact (William Infante, Mon Jan 18 13:12:17 2021 +1100) +- cfe35cc - feat: update message handler to be independent of pact (William Infante, Mon Jan 18 13:12:17 2021 +1100) - 12b4a50 - fix: flake8 warning (Tuan Pham, Mon Jan 18 12:50:50 2021 +1100) -- 7afe693 - test: update message handler condition based on content (William Infante, Mon Jan 18 12:37:50 2021 +1100) +- 7afe693 - test: update message handler condition based on content (William Infante, Mon Jan 18 12:37:50 2021 +1100) - 79106bb - feat: move publish function to broker class (Tuan Pham, Mon Jan 18 11:30:35 2021 +1100) - a04b954 - docs: add readme for message consumer (William Infante, Mon Jan 18 09:48:01 2021 +1100) - 8672e2f - feat: update handler to handle error exceptions (William Infante, Fri Jan 15 16:24:38 2021 +1100) @@ -407,7 +407,7 @@ Identical to 2.1.0, but with a fix to the publication process to PyPI. - 8546a26 - fix: linting (Tuan Pham, Thu Jan 14 10:38:52 2021 +1100) - 65b69d7 - fix: remove publish fn for now (Tuan Pham, Thu Jan 14 10:38:10 2021 +1100) - e31dd45 - feat: add constants test (William Infante, Wed Jan 13 17:28:45 2021 +1100) -- 955dbe1 - feat: update MessageConsumer and tests (William Infante, Wed Jan 13 16:38:30 2021 +1100) +- 955dbe1 - feat: update MessageConsumer and tests (William Infante, Wed Jan 13 16:38:30 2021 +1100) - af5c9fb - feat: create basic tests for single pact message (William Infante, Wed Jan 13 15:52:07 2021 +1100) - fea27c8 - feat: single message flow (William Infante, Wed Jan 13 15:03:41 2021 +1100) - 9047855 - feat: add MessageConsumer (William Infante, Wed Jan 13 12:45:19 2021 +1100) @@ -422,7 +422,7 @@ Identical to 2.1.0, but with a fix to the publication process to PyPI. ## 1.2.11 -- ba10318 - Merge pull request #192 from pact-foundation/fix/deploy_wheel_fix (Elliott Murray, Tue Dec 29 20:05:52 2020 +0000) +- ba10318 - Merge pull request #192 from pact-foundation/fix/deploy_wheel_fix (Elliott Murray, Tue Dec 29 20:05:52 2020 +0000) - 289e784 - fix: not creating wheel (Elliott Murray, Tue Dec 29 20:00:19 2020 +0000) - d217e67 - chore: Releasing version 1.2.10 (Elliott Murray, Sat Dec 19 12:41:02 2020 +0000) - 9438449 - Merge pull request #191 from pact-foundation/build-and-test-with-github-actions (Elliott Murray, Sat Dec 19 12:38:23 2020 +0000) @@ -438,7 +438,7 @@ Identical to 2.1.0, but with a fix to the publication process to PyPI. - 48a2a21 - Merge pull request #186 from jstoebel/patch-2 (Elliott Murray, Sat Nov 21 10:39:48 2020 +0000) - 74f9a4f - docs: fix small typo in `with_request` doc string (Jacob Stoebel, Wed Nov 18 14:51:03 2020 -0500) - 4e4ed26 - chore: added run test to travis (Elliott Murray, Sun Nov 1 11:49:38 2020 +0000) -- 37e2f3a - chore: wqshell script to run flask in exmaples (Elliott Murray, Sun Nov 1 11:41:59 2020 +0000) +- 37e2f3a - chore: wqshell script to run flask in examples (Elliott Murray, Sun Nov 1 11:41:59 2020 +0000) - b5d9d7b - chore(upgrade): upgrade python version to 3.8 (Elliott Murray, Sun Nov 1 11:12:10 2020 +0000) ## 1.2.10 @@ -456,7 +456,7 @@ Identical to 2.1.0, but with a fix to the publication process to PyPI. - 48a2a21 - Merge pull request #186 from jstoebel/patch-2 (Elliott Murray, Sat Nov 21 10:39:48 2020 +0000) - 74f9a4f - docs: fix small typo in `with_request` doc string (Jacob Stoebel, Wed Nov 18 14:51:03 2020 -0500) - 4e4ed26 - chore: added run test to travis (Elliott Murray, Sun Nov 1 11:49:38 2020 +0000) -- 37e2f3a - chore: wqshell script to run flask in exmaples (Elliott Murray, Sun Nov 1 11:41:59 2020 +0000) +- 37e2f3a - chore: wqshell script to run flask in examples (Elliott Murray, Sun Nov 1 11:41:59 2020 +0000) - b5d9d7b - chore(upgrade): upgrade python version to 3.8 (Elliott Murray, Sun Nov 1 11:12:10 2020 +0000) ## 1.2.9 @@ -482,9 +482,9 @@ Identical to 2.1.0, but with a fix to the publication process to PyPI. ## 1.2.7 - 90b71d2 - Merge pull request #178 from pact-foundation/fix/custom_header_typo (Elliott Murray, Fri Oct 9 12:47:37 2020 +0100) -- b07ef69 - fix(verifier): headers not propogated properly (Elliott Murray, Fri Oct 9 12:24:25 2020 +0100) +- b07ef69 - fix(verifier): headers not propagated properly (Elliott Murray, Fri Oct 9 12:24:25 2020 +0100) - 0e9b71c - Merge pull request #177 from pact-foundation/docs/remove_handcrafted_broker (Elliott Murray, Fri Oct 9 12:01:24 2020 +0100) -- 2db7008 - docs(examples): removed manaul publish to broker (Elliott Murray, Fri Oct 9 11:54:30 2020 +0100) +- 2db7008 - docs(examples): removed manual publish to broker (Elliott Murray, Fri Oct 9 11:54:30 2020 +0100) ## 1.2.6 @@ -514,7 +514,7 @@ Identical to 2.1.0, but with a fix to the publication process to PyPI. - 8188d88 - chore: fix release script (Elliott Murray, Wed Aug 26 12:46:10 2020 +0100) - e0e5106 - Merge pull request #169 from pact-foundation/chore/update_pr_scripts (Elliott Murray, Wed Aug 26 10:24:47 2020 +0100) -- 81fd653 - chore: release script updates version automaitcally now (Elliott Murray, Wed Aug 26 10:16:14 2020 +0100) +- 81fd653 - chore: release script updates version automatically now (Elliott Murray, Wed Aug 26 10:16:14 2020 +0100) - 773d3f9 - chore: script now uses gh over hub (Elliott Murray, Wed Aug 26 10:03:06 2020 +0100) - 468e4ad - Merge pull request #168 from pact-foundation/chore/upgrade-to-pact-ruby-standalone-1-88-3 (Elliott Murray, Wed Aug 26 09:49:33 2020 +0100) - ce944fe - feat: update standalone to 1.88.3 (Elliott Murray, Wed Aug 26 09:08:27 2020 +0100) @@ -607,7 +607,7 @@ Identical to 2.1.0, but with a fix to the publication process to PyPI. - 48ad173 - Merge pull request #135 from m-aciek/master (Elliott Murray, Sat May 9 17:21:52 2020 +0100) - 6948482 - Merge pull request #136 from pact-foundation/chore/upgrade-to-pact-ruby-standalone-1-84-0 (Elliott Murray, Sat May 9 15:13:07 2020 +0100) - 14603ac - feat: update standalone to 1.84.0 (Beth Skurrie, Sat May 2 09:43:30 2020 +1000) -- 410caf1 - chore: add script to create a PR to update the pact-ruby-standalone version (Beth Skurrie, Sat May 2 09:42:55 2020 +1000) +- 410caf1 - chore: add script to create a PR to update the pact-ruby-standalone version (Beth Skurrie, Sat May 2 09:42:55 2020 +1000) - b5af1fc - Fix missing normalization of consumer name while publishing pact (Maciej Olko, Thu Apr 30 08:50:17 2020 +0200) - 5785782 - Move tests to standard tests dir (Peter Yasi, Fri Apr 17 14:03:04 2020 -0400) - 88ea23d - docs: update RELEASING.md (Beth Skurrie, Tue Feb 18 10:46:11 2020 +1100) @@ -624,11 +624,11 @@ Identical to 2.1.0, but with a fix to the publication process to PyPI. ## 0.20.0 - 978d9f3 - fix typo (Jingjing Duan, Wed May 24 15:48:43 2017 -0700) -- 4ede7d5 - Merge pull request #117 from dlmiddlecote/feature/expose-more-options (Matt Fellows, Fri Jan 17 10:00:56 2020 +1100) +- 4ede7d5 - Merge pull request #117 from dlmiddlecote/feature/expose-more-options (Matt Fellows, Fri Jan 17 10:00:56 2020 +1100) - 73ae8d2 - Update docs (Daniel Middlecote, Tue Jan 14 22:11:40 2020 +0000) - 2bffe5e - Simple test case (Daniel Middlecote, Tue Jan 14 22:11:25 2020 +0000) -- 3ba51b5 - Add --broker-token support (Daniel Middlecote, Tue Jan 14 22:04:39 2020 +0000) -- d3a8ba6 - Update pact-ruby-standalone (Daniel Middlecote, Tue Jan 14 21:45:01 2020 +0000) +- 3ba51b5 - Add --broker-token support (Daniel Middlecote, Tue Jan 14 22:04:39 2020 +0000) +- d3a8ba6 - Update pact-ruby-standalone (Daniel Middlecote, Tue Jan 14 21:45:01 2020 +0000) - 0cbb9d4 - Merge pull request #115 from ejrb/patch-1 (Matthew Balvanz, Sat Dec 14 20:49:56 2019 -0600) - 0c85502 - match platforms like 'macOS-\*' to osx suffix (ejrb, Mon Dec 9 11:13:19 2019 +0000) - 9a0eaa7 - Merge pull request #109 from pact-foundation/dependabot/pip/flask-1.0 (Matthew Balvanz, Mon Sep 30 21:35:20 2019 -0500) @@ -700,7 +700,7 @@ Identical to 2.1.0, but with a fix to the publication process to PyPI. - 149dfc7 - Merge pull request #67 from jawu/enable-possibility-to-use-mathers-in-path (Matthew Balvanz, Sun Dec 17 10:32:34 2017 -0600) - fb97d2f - fixed doc string of Request (Janneck Wullschleger, Sat Dec 16 20:44:11 2017 +0100) -- c2c24cc - adjusted doc string of Request calss to allow str and Matcher as path parameter (Janneck Wullschleger, Sat Dec 16 20:40:35 2017 +0100) +- c2c24cc - adjusted doc string of Request class to allow str and Matcher as path parameter (Janneck Wullschleger, Sat Dec 16 20:40:35 2017 +0100) - 697a6a2 - fixed port parameter in e2e test for python 2.7 (Janneck Wullschleger, Thu Dec 14 15:08:05 2017 +0100) - ca2eb92 - added from_term call in Request constructor to process path property for json transport (Janneck Wullschleger, Thu Dec 14 14:45:11 2017 +0100) @@ -826,5 +826,5 @@ Identical to 2.1.0, but with a fix to the publication process to PyPI. - 189c647 - Merge pull request #3 from pact-foundation/travis-ci (Jose Salvatierra, Fri Apr 7 21:40:02 2017 +0100) - 559efb8 - Add Travis CI build (Matthew Balvanz, Fri Apr 7 11:12:01 2017 -0500) - 8f074a0 - Merge pull request #1 from pact-foundation/initial-framework (Matthew Balvanz, Fri Apr 7 09:55:34 2017 -0500) -- f5caf9c - Initial pact-python implementation (Matthew Balvanz, Mon Apr 3 09:16:59 2017 -0500) +- f5caf9c - Initial pact-python implementation (Matthew Balvanz, Mon Apr 3 09:16:59 2017 -0500) - bfb8380 - Initial pact-python implementation (Matthew Balvanz, Thu Mar 30 20:41:05 2017 -0500) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index db794c92f..2123f55f5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -99,7 +99,7 @@ You can also try using the new [github.dev](https://github.dev/pact-foundation/p pipx install hatch ``` -3. After cloning the repository, run `hatch shell` in the root of the repository. This will install all dependencies in a Python virtual environment and then ensure that the virtual environment is activated. You will also need to run `git submodule init` if you want to run tests, as Pact Python makes use of the Pact Compability Suite. +3. After cloning the repository, run `hatch shell` in the root of the repository. This will install all dependencies in a Python virtual environment and then ensure that the virtual environment is activated. You will also need to run `git submodule init` if you want to run tests, as Pact Python makes use of the Pact Compatibility Suite. 4. Patch the compatibility suite by running `cd tests/v3/compatibility_suite && patch -p1 -d definition < definition-update.diff && cd -` in the root of the repository. diff --git a/biome.json b/biome.json new file mode 100644 index 000000000..76cd05459 --- /dev/null +++ b/biome.json @@ -0,0 +1,16 @@ +{ + "$schema": "https://biomejs.dev/schemas/1.8.2/schema.json", + "organizeImports": { + "enabled": true + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true + } + }, + "formatter": { + "indentWidth": 2, + "indentStyle": "space" + } +} diff --git a/committed.toml b/committed.toml new file mode 100644 index 000000000..0899f2f51 --- /dev/null +++ b/committed.toml @@ -0,0 +1,17 @@ +## Configuration for committed +## +## See +style = "conventional" +allowed_types = [ + "fix", + "feat", + "chore", + "docs", + "style", + "refactor", + "perf", + "test", + "release", +] +merge_commit = false +subject_capitalized = false diff --git a/docs/blog/posts/2024/05-02 integrating rust ffi with pact python.md b/docs/blog/posts/2024/05-02 integrating rust ffi with pact python.md index 648361548..54515dad3 100644 --- a/docs/blog/posts/2024/05-02 integrating rust ffi with pact python.md +++ b/docs/blog/posts/2024/05-02 integrating rust ffi with pact python.md @@ -83,7 +83,7 @@ if isinstance(version, bytes): # (3) 2. Convert the pointer to a Python string, or bytes if necessary, using the `ffi.string` method. 3. Decode the bytes to a string if needed. -While the process is reasonably straightforward, it does require some boilerplate code to handle the type conversions. To simplify this, we've wrapped each function from the Rust core library in a simple Python function that performs these conversion autoamtically. You can find these wrapper functions in the [`ffi` module](https://github.com/pact-foundation/pact-python/blob/d6869797b52429252b5d0da4d0fc0079f9d3671c/src/pact/v3/ffi.py). For example, the `version` function is implemented as follows: +While the process is reasonably straightforward, it does require some boilerplate code to handle the type conversions. To simplify this, we've wrapped each function from the Rust core library in a simple Python function that performs these conversion automatically. You can find these wrapper functions in the [`ffi` module](https://github.com/pact-foundation/pact-python/blob/d6869797b52429252b5d0da4d0fc0079f9d3671c/src/pact/v3/ffi.py). For example, the `version` function is implemented as follows: ```python def version() -> str: diff --git a/docs/provider.md b/docs/provider.md index f4dded900..363d0b721 100644 --- a/docs/provider.md +++ b/docs/provider.md @@ -1,6 +1,6 @@ # Provider Testing -Pact is a consumer-driven contract testng tool. This means that the consumer specifies the expected interactions with the provider, and these interactions are used to create a contract. This contract is then used to verify that the provider behaves as expected. +Pact is a consumer-driven contract testing tool. This means that the consumer specifies the expected interactions with the provider, and these interactions are used to create a contract. This contract is then used to verify that the provider behaves as expected. The provider verification process works by replaying the interactions from the consumer against the provider and checking that the responses match what was expected. This is done by using the Pact files created by the consumer tests, either by reading them from a local filesystem, or by fetching them from a Pact Broker. diff --git a/docs/scripts/python.py b/docs/scripts/python.py index 21e024fee..f5335c00f 100644 --- a/docs/scripts/python.py +++ b/docs/scripts/python.py @@ -155,7 +155,7 @@ def process_python( List of tuples containing the source and destination Python identifiers to map. Note that the list is processed in order, with later mappings applied after earlier mappings. This is applied - idependently of the `destination_mapping` argument. + independently of the `destination_mapping` argument. ignore_private: Whether to ignore private modules (those starting with an underscore diff --git a/pyproject.toml b/pyproject.toml index ece85cd42..c3580a91c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -344,3 +344,12 @@ before-build = [ 'IF EXIST src\pact\v3\data\ RMDIR /S /Q src\pact\v3\data', 'IF EXIST src\pact\v3\lib\ RMDIR /S /Q src\pact\v3\lib', ] + +################################################################################ +## Typos +################################################################################ + +[tool.typos.default] +extend-ignore-re = [ + "(?Rm)^.*(#|//|