From f3afb978954ff8204c2832b13925a1783ac458b1 Mon Sep 17 00:00:00 2001 From: JP-Ellis Date: Fri, 8 Nov 2024 15:08:03 +1100 Subject: [PATCH] chore: add debug Signed-off-by: JP-Ellis --- .github/workflows/build.yml | 295 ------------------------------------ .github/workflows/test.yml | 278 ++++++++++++++++----------------- src/pact/message_pact.py | 11 +- 3 files changed, 148 insertions(+), 436 deletions(-) delete mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 9ca0d56996..0000000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,295 +0,0 @@ -name: build - -on: - push: - tags: - - v* - branches: - - master - pull_request: - branches: - - master - -concurrency: - group: ${{ github.workflow }}-${{ github.ref || github.run_id }} - cancel-in-progress: true - -env: - STABLE_PYTHON_VERSION: "3.13" - HATCH_VERBOSE: "1" - FORCE_COLOR: "1" - 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 - - runs-on: ubuntu-20.04 - - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - with: - # Fetch all tags - fetch-depth: 0 - - - name: Set up Python - uses: astral-sh/setup-uv@2e657c127d5b1635d5a8e3fa40e0ac50a5bf6992 # v3.2.2 - with: - enable-cache: true - cache-dependency-glob: | - **/pyproject.toml - **/uv.lock - - - name: Install Python - run: uv python install ${{ env.STABLE_PYTHON_VERSION }} - - - name: Install hatch - run: uv tool install hatch - - - name: Create source distribution - run: | - hatch build --target sdist - - - name: Upload sdist - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4 - with: - name: wheels-sdist - path: ./dist/*.tar.* - if-no-files-found: error - compression-level: 0 - - build-x86_64: - name: Build wheels on ${{ matrix.os }} (x86, 64-bit) - - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - include: - - os: ubuntu-20.04 - archs: x86_64 - - os: macos-12 - archs: x86_64 - - os: windows-2019 - archs: AMD64 - - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - with: - # Fetch all tags - fetch-depth: 0 - - - name: Cache pip packages - uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4 - with: - path: ~/.cache/pip - key: ${{ github.workflow }}-pip-${{ runner.os }}-${{ hashFiles('**/pyproject.toml') }} - restore-keys: | - ${{ github.workflow }}-pip-${{ runner.os }} - ${{ github.workflow }}-pip - ${{ github.workflow }} - - - name: Filter targets - id: cibw-filter - shell: bash - # Building all wheels on PRs is too slow, so we filter them to target - # the latest stable version of Python. - run: | - if [[ "${{ github.event_name}}" == "pull_request" ]] ; then - echo "build=cp${STABLE_PYTHON_VERSION/./}-*" >> "$GITHUB_OUTPUT" - else - echo "build=*" >> "$GITHUB_OUTPUT" - fi - - - name: Set macOS deployment target - if: startsWith(matrix.os, 'macos-') - run: | - echo "MACOSX_DEPLOYMENT_TARGET=10.12" >> "$GITHUB_ENV" - - - name: Create wheels - uses: pypa/cibuildwheel@7940a4c0e76eb2030e473a5f864f291f63ee879b # v2.21.3 - env: - CIBW_ARCHS: ${{ matrix.archs }} - CIBW_BUILD: ${{ steps.cibw-filter.outputs.build }} - - - name: Upload wheels - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4 - with: - name: wheels-${{ matrix.os }}-${{ matrix.archs }} - path: ./wheelhouse/*.whl - if-no-files-found: error - compression-level: 0 - - build-arm64: - name: Build wheels on ${{ matrix.os }} (arm64) - - # As this requires emulation, it's not worth running on PRs or master - if: >- - github.event_name == 'push' && - startsWith(github.event.ref, 'refs/tags/v') - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - include: - - os: ubuntu-20.04 - archs: aarch64 - build: manylinux - - os: ubuntu-20.04 - archs: aarch64 - build: musllinux - - os: macos-14 - archs: arm64 - build: "" - # TODO: Re-enable once the issues with Windows ARM64 are resolved.exclude: - # See: pypa/cibuildwheel#1942 - # - os: windows-2019 - # archs: ARM64 - # build: "" - - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - with: - # Fetch all tags - fetch-depth: 0 - - - name: Cache pip packages - uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4 - with: - path: ~/.cache/pip - key: ${{ github.workflow }}-pip-${{ runner.os }}-${{ hashFiles('**/pyproject.toml') }} - restore-keys: | - ${{ github.workflow }}-pip-${{ runner.os }} - ${{ github.workflow }}-pip - ${{ github.workflow }} - - - name: Set up QEMU - if: startsWith(matrix.os, 'ubuntu-') - uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3 - with: - platforms: arm64 - - - name: Create wheels - uses: pypa/cibuildwheel@7940a4c0e76eb2030e473a5f864f291f63ee879b # v2.21.3 - env: - CIBW_ARCHS: ${{ matrix.archs }} - CIBW_BUILD: ${{ matrix.build == '' && '*' || format('*{0}*', matrix.build) }} - - - name: Upload wheels - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4 - with: - name: wheels-${{ matrix.os }}-${{ matrix.archs }}-${{ matrix.build }} - path: ./wheelhouse/*.whl - if-no-files-found: error - compression-level: 0 - - publish: - name: Publish wheels and sdist - - if: >- - github.event_name == 'push' && - startsWith(github.event.ref, 'refs/tags/v') - runs-on: ubuntu-20.04 - environment: - name: pypi - url: https://pypi.org/p/pact-python - - needs: - - build-sdist - - build-x86_64 - - build-arm64 - - permissions: - # Required for trusted publishing - id-token: write - # Required for release creation - contents: write - - steps: - - name: Checkout code - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - with: - # Fetch all tags - fetch-depth: 0 - - - name: Download wheels and sdist - uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4 - with: - path: wheels - merge-multiple: true - - - name: Set up uv - uses: astral-sh/setup-uv@2e657c127d5b1635d5a8e3fa40e0ac50a5bf6992 # v3.2.2 - with: - enable-cache: true - cache-dependency-glob: | - **/pyproject.toml - **/uv.lock - - - name: Install Python - run: uv python install ${{ env.STABLE_PYTHON_VERSION }} - - - name: Install commitizen - run: uv tool install commitizen - - - name: Update changelog - id: changelog - run: | - pip install --upgrade commitizen - - cz changelog \ - --incremental \ - --template .github/CHANGELOG.md.j2 \ - --dry-run \ - | tail -n+2 \ - > ${{ runner.temp }}/changelog - echo -e "\n\n## Pull Requests\n\n" >> ${{ runner.temp }}/changelog - - cz changelog \ - --incremental \ - --template .github/CHANGELOG.md.j2 - - - name: Generate release - id: release - uses: softprops/action-gh-release@e7a8f85e1c67a31e6ed99a94b41bd0b71bbee6b8 # v2.0.9 - with: - files: wheels/* - body_path: ${{ runner.temp }}/changelog - draft: false - prerelease: false - generate_release_notes: true - - - name: Push build artifacts to PyPI - uses: pypa/gh-action-pypi-publish@15c56dba361d8335944d31a2ecd17d700fc7bcbc # v1.12.2 - with: - skip-existing: true - packages-dir: wheels - - - name: Create PR for changelog update - uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7 - with: - token: ${{ secrets.GH_TOKEN }} - commit-message: "chore: update changelog ${{ github.ref_name }}" - title: "chore: update changelog" - body: | - This PR updates the changelog for ${{ github.ref_name }}. - branch: chore/update-changelog - base: master diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 27002e6d6f..bd81d981fe 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,9 +28,9 @@ jobs: runs-on: ubuntu-latest needs: - - test-linux + # - test-linux - test-other - - example + # - example - format - lint - typecheck @@ -42,85 +42,85 @@ jobs: run: exit 1 if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped') - test-linux: - name: >- - 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 }} - - services: - broker: - image: pactfoundation/pact-broker:latest@sha256:05e813c53cbc4d5fadb34a608baaf17348a50c669dc1e3e94dad55e364609912 - ports: - - "9292:9292" - env: - # Basic auth credentials for the Broker - PACT_BROKER_ALLOW_PUBLIC_READ: "true" - PACT_BROKER_BASIC_AUTH_USERNAME: pactbroker - PACT_BROKER_BASIC_AUTH_PASSWORD: pactbroker - # Database - PACT_BROKER_DATABASE_URL: sqlite:////tmp/pact_broker.sqlite - - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest] - python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] - experimental: [false] - include: - - # Run tests against the next Python version, but no need for the full list of OSes. - os: ubuntu-latest - python-version: "3.14" - experimental: true - - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - with: - submodules: true - - - name: Apply temporary definitions update - shell: bash - run: | - cd tests/v3/compatibility_suite - patch -p1 -d definition < definition-update.diff - - - name: Set up uv - uses: astral-sh/setup-uv@2e657c127d5b1635d5a8e3fa40e0ac50a5bf6992 # v3.2.2 - with: - enable-cache: true - cache-dependency-glob: | - **/pyproject.toml - **/uv.lock - - - name: Install Python - run: uv python install ${{ matrix.python-version }} - - - name: Install Hatch - run: uv tool install hatch - - - name: Ensure broker is live - run: | - i=0 - until curl -sSf http://localhost:9292/diagnostic/status/heartbeat; do - i=$((i+1)) - if [ $i -gt 120 ]; then - echo "Broker failed to start" - exit 1 - fi - sleep 1 - done - - - name: Run tests - run: hatch run test --broker-url=http://pactbroker:pactbroker@localhost:9292 --container - - - name: Upload coverage - if: matrix.python-version == env.STABLE_PYTHON_VERSION && matrix.os == 'ubuntu-latest' - uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4 - with: - token: ${{ secrets.CODECOV_TOKEN }} - flags: tests + # test-linux: + # name: >- + # 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 }} + + # services: + # broker: + # image: pactfoundation/pact-broker:latest@sha256:05e813c53cbc4d5fadb34a608baaf17348a50c669dc1e3e94dad55e364609912 + # ports: + # - "9292:9292" + # env: + # # Basic auth credentials for the Broker + # PACT_BROKER_ALLOW_PUBLIC_READ: "true" + # PACT_BROKER_BASIC_AUTH_USERNAME: pactbroker + # PACT_BROKER_BASIC_AUTH_PASSWORD: pactbroker + # # Database + # PACT_BROKER_DATABASE_URL: sqlite:////tmp/pact_broker.sqlite + + # strategy: + # fail-fast: false + # matrix: + # os: [ubuntu-latest] + # python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] + # experimental: [false] + # include: + # - # Run tests against the next Python version, but no need for the full list of OSes. + # os: ubuntu-latest + # python-version: "3.14" + # experimental: true + + # steps: + # - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + # with: + # submodules: true + + # - name: Apply temporary definitions update + # shell: bash + # run: | + # cd tests/v3/compatibility_suite + # patch -p1 -d definition < definition-update.diff + + # - name: Set up uv + # uses: astral-sh/setup-uv@2e657c127d5b1635d5a8e3fa40e0ac50a5bf6992 # v3.2.2 + # with: + # enable-cache: true + # cache-dependency-glob: | + # **/pyproject.toml + # **/uv.lock + + # - name: Install Python + # run: uv python install ${{ matrix.python-version }} + + # - name: Install Hatch + # run: uv tool install hatch + + # - name: Ensure broker is live + # run: | + # i=0 + # until curl -sSf http://localhost:9292/diagnostic/status/heartbeat; do + # i=$((i+1)) + # if [ $i -gt 120 ]; then + # echo "Broker failed to start" + # exit 1 + # fi + # sleep 1 + # done + + # - name: Run tests + # run: hatch run test --broker-url=http://pactbroker:pactbroker@localhost:9292 --container + + # - name: Upload coverage + # if: matrix.python-version == env.STABLE_PYTHON_VERSION && matrix.os == 'ubuntu-latest' + # uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4 + # with: + # token: ${{ secrets.CODECOV_TOKEN }} + # flags: tests test-other: name: >- @@ -132,7 +132,7 @@ jobs: strategy: fail-fast: false matrix: - os: [windows-latest, macos-latest] + os: [windows-latest] python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] # Python 3.9 aren't supported on macos-latest (ARM) exclude: @@ -170,63 +170,63 @@ jobs: - name: Run tests run: hatch run test - example: - name: Example - - runs-on: ubuntu-latest - if: github.event_name == 'push' || ! github.event.pull_request.draft - - services: - broker: - image: pactfoundation/pact-broker:latest@sha256:05e813c53cbc4d5fadb34a608baaf17348a50c669dc1e3e94dad55e364609912 - ports: - - "9292:9292" - env: - # Basic auth credentials for the Broker - PACT_BROKER_ALLOW_PUBLIC_READ: "true" - PACT_BROKER_BASIC_AUTH_USERNAME: pactbroker - PACT_BROKER_BASIC_AUTH_PASSWORD: pactbroker - # Database - PACT_BROKER_DATABASE_URL: sqlite:////tmp/pact_broker.sqlite - - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - - - name: Set up uv - uses: astral-sh/setup-uv@2e657c127d5b1635d5a8e3fa40e0ac50a5bf6992 # v3.2.2 - with: - enable-cache: true - cache-dependency-glob: | - **/pyproject.toml - **/uv.lock - - - name: Install Python - run: uv python install ${{ env.STABLE_PYTHON_VERSION }} - - - name: Install Hatch - run: uv tool install hatch - - - name: Ensure broker is live - run: | - i=0 - until curl -sSf http://localhost:9292/diagnostic/status/heartbeat; do - i=$((i+1)) - if [ $i -gt 120 ]; then - echo "Broker failed to start" - exit 1 - fi - sleep 1 - done - - - name: Examples - run: > - hatch run example --broker-url=http://pactbroker:pactbroker@localhost:9292 - - - name: Upload coverage - uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4 - with: - token: ${{ secrets.CODECOV_TOKEN }} - flags: examples + # example: + # name: Example + + # runs-on: ubuntu-latest + # if: github.event_name == 'push' || ! github.event.pull_request.draft + + # services: + # broker: + # image: pactfoundation/pact-broker:latest@sha256:05e813c53cbc4d5fadb34a608baaf17348a50c669dc1e3e94dad55e364609912 + # ports: + # - "9292:9292" + # env: + # # Basic auth credentials for the Broker + # PACT_BROKER_ALLOW_PUBLIC_READ: "true" + # PACT_BROKER_BASIC_AUTH_USERNAME: pactbroker + # PACT_BROKER_BASIC_AUTH_PASSWORD: pactbroker + # # Database + # PACT_BROKER_DATABASE_URL: sqlite:////tmp/pact_broker.sqlite + + # steps: + # - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + + # - name: Set up uv + # uses: astral-sh/setup-uv@2e657c127d5b1635d5a8e3fa40e0ac50a5bf6992 # v3.2.2 + # with: + # enable-cache: true + # cache-dependency-glob: | + # **/pyproject.toml + # **/uv.lock + + # - name: Install Python + # run: uv python install ${{ env.STABLE_PYTHON_VERSION }} + + # - name: Install Hatch + # run: uv tool install hatch + + # - name: Ensure broker is live + # run: | + # i=0 + # until curl -sSf http://localhost:9292/diagnostic/status/heartbeat; do + # i=$((i+1)) + # if [ $i -gt 120 ]; then + # echo "Broker failed to start" + # exit 1 + # fi + # sleep 1 + # done + + # - name: Examples + # run: > + # hatch run example --broker-url=http://pactbroker:pactbroker@localhost:9292 + + # - name: Upload coverage + # uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4 + # with: + # token: ${{ secrets.CODECOV_TOKEN }} + # flags: examples format: name: Format diff --git a/src/pact/message_pact.py b/src/pact/message_pact.py index 958c504775..aa7fefc53d 100644 --- a/src/pact/message_pact.py +++ b/src/pact/message_pact.py @@ -178,6 +178,7 @@ def write_to_pact_file(self): :rtype: int """ pact_dir = Path(self.pact_dir).resolve() + print("Writing to pact dir: ", pact_dir) command = [ MESSAGE_PATH, "update", @@ -192,9 +193,14 @@ def write_to_pact_file(self): pact_dir.mkdir(parents=True) elif not pact_dir.is_dir(): raise NotADirectoryError(f"{pact_dir} is not a directory") + print("Running command: ", command) self._message_process = Popen(command) self._message_process.wait() + print("Pact file written") + for file in pact_dir.glob("*.json"): + print(file) + def _insert_message_if_complete(self): """ Insert a new message if current message is complete. @@ -218,9 +224,10 @@ def __exit__(self, exc_type, exc_val, exc_tb): Calls pact-message to write out the contracts to disk. """ - if (exc_type, exc_val, exc_tb) != (None, None, None): + print("Exiting context manager") + if exc_type is not None or exc_val is not None or exc_tb is not None: return - + print("No exceptions, writing to pact file") self.write_to_pact_file() if self.publish_to_broker: