-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: migrate to pyproject.toml and hatch #371
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,49 @@ | ||
BUILD_TEST_TASK_TEMPLATE: &BUILD_TEST_TASK_TEMPLATE | ||
TEST_TEMPLATE: &TEST_TEMPLATE | ||
arch_check_script: | ||
- uname -am | ||
test_script: | ||
- python --version | ||
- python -m pip install --upgrade pip | ||
- python -m pip install -r requirements_dev.txt | ||
- python -m flake8 | ||
- python -m pydocstyle pact | ||
- python -m tox -e test | ||
# - make examples | ||
# TODO: Fix lints before enabling | ||
- echo hatch run lint | ||
# TODO: Implement the examples to work in hatch | ||
- echo hatch run example | ||
- hatch run test | ||
|
||
linux_arm64_task: | ||
linux_arm64_task: | ||
env: | ||
PATH: ${HOME}/.local/bin:${PATH} | ||
matrix: | ||
# - IMAGE: python:3.6-slim # This works locally, with cirrus run, but fails in CI | ||
- IMAGE: python:3.7-slim | ||
- IMAGE: python:3.8-slim | ||
- IMAGE: python:3.9-slim | ||
- IMAGE: python:3.10-slim | ||
- IMAGE: "python:3.8-slim" | ||
- IMAGE: "python:3.9-slim" | ||
- IMAGE: "python:3.10-slim" | ||
- IMAGE: "python:3.11-slim" | ||
arm_container: | ||
image: $IMAGE | ||
install_script: | ||
- apt update --yes && apt install --yes gcc make | ||
<< : *BUILD_TEST_TASK_TEMPLATE | ||
|
||
- apt update --yes | ||
- apt install --yes gcc make | ||
- python -m pip install --upgrade pip pipx | ||
- pipx install hatch | ||
<<: *TEST_TEMPLATE | ||
|
||
macosx_arm64_task: | ||
macos_instance: | ||
image: ghcr.io/cirruslabs/macos-ventura-base:latest | ||
env: | ||
PATH: ${HOME}/.pyenv/shims:${PATH} | ||
PATH: ${HOME}/.local/bin:${HOME}/.pyenv/shims:${PATH} | ||
matrix: | ||
- PYTHON: 3.6 | ||
- PYTHON: 3.7 | ||
- PYTHON: 3.8 | ||
- PYTHON: 3.9 | ||
- PYTHON: 3.10 | ||
- PYTHON: "3.8" | ||
- PYTHON: "3.9" | ||
- PYTHON: "3.10" | ||
- PYTHON: "3.11" | ||
install_script: | ||
# Per the pyenv homebrew recommendations. | ||
# https://github.com/pyenv/pyenv/wiki#suggested-build-environment | ||
# - xcode-select --install # Unnecessary on Cirrus | ||
- brew update | ||
# - brew install openssl readline sqlite3 xz zlib | ||
- brew update | ||
- brew install pyenv | ||
- pyenv install ${PYTHON} | ||
- pyenv global ${PYTHON} | ||
- pyenv rehash | ||
## To install rosetta | ||
# - softwareupdate --install-rosetta --agree-to-license | ||
<< : *BUILD_TEST_TASK_TEMPLATE | ||
- python -m pip install --upgrade pip pipx | ||
- pyenv rehash | ||
- pipx install hatch | ||
- pyenv rehash | ||
<<: *TEST_TEMPLATE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
name: build | ||
|
||
on: | ||
push: | ||
tags: | ||
- v* | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.head_ref }} | ||
cancel-in-progress: true | ||
|
||
env: | ||
STABLE_PYTHON_VERSION: "3.11" | ||
CIBW_BUILD_FRONTEND: build | ||
CIBW_TEST_COMMAND: > | ||
python -c | ||
"from pact import EachLike; | ||
assert EachLike(1).generate() == {'json_class': 'Pact::ArrayLike', 'contents': 1, 'min': 1} | ||
" | ||
|
||
jobs: | ||
build-x86_64: | ||
name: Build wheels on ${{ matrix.os }} (x86, 64-bit) | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- os: ubuntu-latest | ||
archs: x86_64 | ||
- os: macos-latest | ||
archs: x86_64 | ||
- os: windows-latest | ||
archs: AMD64 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
# Fetch all tags | ||
fetch-depth: 0 | ||
|
||
- name: Create wheels | ||
uses: pypa/cibuildwheel@v2.15.0 | ||
env: | ||
CIBW_ARCHS: ${{ matrix.archs }} | ||
|
||
- name: Upload wheels | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: wheels | ||
path: ./wheelhouse/*.whl | ||
if-no-files-found: error | ||
|
||
build-x86: | ||
name: Build wheels on ${{ matrix.os }} (x86, 32-bit) | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- os: windows-latest | ||
archs: x86 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
# Fetch all tags | ||
fetch-depth: 0 | ||
|
||
- name: Create wheels | ||
uses: pypa/cibuildwheel@v2.15.0 | ||
env: | ||
CIBW_ARCHS: ${{ matrix.archs }} | ||
|
||
- name: Upload wheels | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: wheels | ||
path: ./wheelhouse/*.whl | ||
if-no-files-found: error | ||
|
||
build-arm64: | ||
name: Build wheels on ${{ matrix.os }} (arm64) | ||
runs-on: ${{ matrix.os }} | ||
# As this requires emulation, it's not worth running on PRs | ||
if: >- | ||
github.event_name == 'push' && | ||
startsWith(github.event.ref, 'refs/tags') | ||
YOU54F marked this conversation as resolved.
Show resolved
Hide resolved
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- os: ubuntu-latest | ||
archs: aarch64 | ||
build: "*manylinux*" | ||
- os: macos-latest | ||
archs: arm64 | ||
build: "*" | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
# Fetch all tags | ||
fetch-depth: 0 | ||
|
||
- name: Set up QEMU | ||
if: matrix.os == 'ubuntu-latest' | ||
uses: docker/setup-qemu-action@v3 | ||
with: | ||
platforms: arm64 | ||
|
||
- name: Create wheels | ||
uses: pypa/cibuildwheel@v2.15.0 | ||
env: | ||
CIBW_ARCHS: ${{ matrix.archs }} | ||
CIBW_BUILD: ${{ matrix.build }} | ||
|
||
- name: Upload wheels | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: wheels | ||
path: ./wheelhouse/*.whl | ||
if-no-files-found: error | ||
|
||
check: | ||
name: Check wheels | ||
needs: | ||
- build-x86_64 | ||
- build-x86 | ||
- build-arm64 | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ env.STABLE_PYTHON_VERSION }} | ||
|
||
- uses: actions/download-artifact@v3 | ||
with: | ||
name: wheels | ||
path: wheelhouse | ||
|
||
- run: | | ||
pipx run twine check --strict wheelhouse/* | ||
|
||
publish: | ||
name: Publish wheels | ||
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') | ||
needs: [check] | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/download-artifact@v3 | ||
with: | ||
name: artifacts | ||
path: wheelhouse | ||
|
||
- name: Push build artifacts to PyPI | ||
uses: pypa/gh-action-pypi-publish@v1.8.10 | ||
with: | ||
skip_existing: true | ||
user: ${{ secrets.PYPI_USERNAME }} | ||
password: ${{ secrets.PYPI_PASSWORD }} | ||
packages-dir: wheelhouse |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: test | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
env: | ||
STABLE_PYTHON_VERSION: "3.11" | ||
|
||
jobs: | ||
run: | ||
name: >- | ||
Python ${{ matrix.python-version }} | ||
on ${{ matrix.os }} | ||
|
||
runs-on: ${{ matrix.os }} | ||
continue-on-error: ${{ matrix.experimental }} | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
python-version: ["3.8", "3.9", "3.10", "3.11"] | ||
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.12-dev" | ||
experimental: true | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install Hatch | ||
run: pip install --upgrade hatch | ||
|
||
- # TODO: Fix lints before enabling this | ||
name: Lint | ||
if: matrix.python-version == env.STABLE_PYTHON_VERSION && runner.os == 'Linux' | ||
run: echo hatch run lint | ||
|
||
- # TODO: Implement the examples to work in hatch | ||
name: Examples | ||
if: matrix.python-version == env.STABLE_PYTHON_VERSION && runner.os == 'Linux' | ||
run: echo hatch run example | ||
|
||
- name: Run tests and track code coverage | ||
run: hatch run test |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we always want to run against the latest version of hatch, or do we want to pin this so it could be picked up via say a dependabot config (or similar) to ensure we can test version updates and ensure consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as a note, my first experience was that I needed to install hatch, which is where I came back to the CI scripts to see how we are installing it :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. I think installing the latest version of hatch should generally not be an issue. Hatch is not an actually dependency of
pact-python
, and instead is just a CLI interface and a build backend. I would be very surprised if regular updates to hatch broke this.Of course, should hatch come out with a completely overhaul in
v2
, then we might need to pin it then, but I'm happy to leave this as future problem.In the same vein, I'm of two minds as to whether we should update system dependencies (
apt
andbrew
) as part of the workflow. Personally, I typically lean towards faster CI/CD builds and therefore use whatever packages are installed in the image, and then trust the CI/CD provider to regularly update these packages.Lastly, would you like me to add a
make
command to install hatch? Or not really worth it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I'm okay with that, the CI will catch any changes, and alert, and we can action accordingly
You get a more repeatable build by not pulling in new updates each version, I've always just updated as a matter of course, going from practises used in Docker files, but also find it incredibly annoying when building things locally that link dynamically, and the dep has been updated with a new named shared lib, causing my built programs to fail, until they are rebuilt. Also why I like statically compiled executables, that will always work, even if they are chonkier.
could do, if we did I would favour it being installed with python, so it saves x platform package manager concerns
if we don't, just have it as a pre-req for development somewhere in the docs.
you could have a make doctor command, which checks if the hatch executable is available and alerts people on how to install it