Skip to content

Commit

Permalink
build: drop python3.8, introduce 3.13. Update workflows to use hatch
Browse files Browse the repository at this point in the history
  • Loading branch information
KarolJagodzinski committed Feb 18, 2025
1 parent 3eeb06a commit 6483bba
Show file tree
Hide file tree
Showing 16 changed files with 326 additions and 178 deletions.
1 change: 1 addition & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3eeb06a168afc7ae37702db089c3faa2539ab652 # style: update codebase for Python 3.8 deprecation and Hatch configurationq
20 changes: 11 additions & 9 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,27 @@ jobs:
fail-fast: false
max-parallel: 1
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v3
- name: Checkout source code
uses: actions/checkout@v4
with:
ref: main

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install wheel
pip install -e .[asgi-file-uploads,tracing,telemetry,test,dev]

- name: Install Hatch
uses: pypa/hatch@257e27e51a6a5616ed08a39a408a21c35c9931bc

- name: Benchmark
run: |
pytest benchmark --benchmark-storage=file://benchmark/results --benchmark-autosave
hatch test benchmark --benchmark-storage=file://benchmark/results --benchmark-autosave
cd benchmark && python rotate_results.py "${{ matrix.python-version }}"
- name: Commit
run: |
git config user.name "pytest-benchmark"
Expand Down
70 changes: 70 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Build

on:
workflow_call:
workflow_dispatch:

env:
PYTHONUNBUFFERED: "1"
FORCE_COLOR: "1"

jobs:
test:
uses: ./.github/workflows/test.yml
permissions:
contents: read
build:
name: Build distribution 📦
runs-on: ubuntu-latest
needs:
- test
steps:
- name: Checkout source code
uses: actions/checkout@v4

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version-file: pyproject.toml

- name: Install Hatch
uses: pypa/hatch@257e27e51a6a5616ed08a39a408a21c35c9931bc

- name: Set package version from tag
run: hatch version $(git describe --tags --always)

- name: Build package
run: hatch build

- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

sign-release:
name: >-
Sign the Python 🐍 distribution 📦 with Sigstore
needs:
- build
runs-on: ubuntu-latest
permissions:
id-token: write # IMPORTANT: mandatory for sigstore
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Sign the dists with Sigstore
uses: sigstore/[email protected]
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Store the signature files
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
overwrite: true
42 changes: 42 additions & 0 deletions .github/workflows/prepare_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Prepare release

on:
push:
tags:
- '*'
workflow_call:
workflow_dispatch:

env:
PYTHONUNBUFFERED: "1"
FORCE_COLOR: "1"

jobs:
build:
uses: ./.github/workflows/build.yml
permissions:
contents: read
id-token: write # IMPORTANT: mandatory for sigstore in build.yml

create-release:
needs:
- build
runs-on: ubuntu-latest
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Release
id: create-draft-release
uses: softprops/action-gh-release@v2
with:
files: |
./dist/*
draft: true
- name: Summary
run: |
echo "# Release summary" >> $GITHUB_STEP_SUMMARY
echo "Url: ${{ steps.create-draft-release.outputs.url }}" >> $GITHUB_STEP_SUMMARY
echo "You can now publish the release on GitHub" >> $GITHUB_STEP_SUMMARY
60 changes: 33 additions & 27 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,42 @@
name: Publish on PyPI
name: Publish

on:
release:
types:
- published
workflow_call:
workflow_dispatch:

env:
PYTHONUNBUFFERED: "1"
FORCE_COLOR: "1"

jobs:
build-n-publish:
name: Build and publish to PyPI
publish-to-pypi:
name: >-
Publish Python 🐍 distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/ariadne
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
contents: read

steps:
- uses: actions/checkout@master
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
- name: Publish distribution to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Download all the dists from the release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release download
'${{ github.ref_name }}'
-p '*.whl'
-p '*.tar.gz'
--dir dist/
--repo '${{ github.repository }}'
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
86 changes: 48 additions & 38 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,58 +7,68 @@ on:
pull_request:
schedule:
- cron: "0 7 * * 1,3"
workflow_call:
workflow_dispatch:

concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
PYTHONUNBUFFERED: "1"
FORCE_COLOR: "1"

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Hatch
uses: pypa/hatch@install
- name: Pytest
run: hatch test -c -py ${{ matrix.python-version }}
- uses: codecov/codecov-action@v3
- name: Pylint
run: hatch run pylint --py-version=3.8 ariadne tests
- name: mypy
run: hatch run mypy ariadne tests_mypy --ignore-missing-imports --check-untyped-defs
- name: black
run: hatch run black -t py38 --check .
- name: Benchmark
run: |
hatch run pytest benchmark --benchmark-storage=file://benchmark/results --benchmark-compare
- name: Checkout source code
uses: actions/checkout@v4

integration:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install Hatch
uses: pypa/hatch@257e27e51a6a5616ed08a39a408a21c35c9931bc

- name: Run static analysis
run: hatch fmt --check

- name: Run type checking
run: hatch run types:check

- name: Run tests
run: hatch test -c -py ${{ matrix.python-version }}

- name: Benchmark
run: hatch test benchmark --benchmark-storage=file://benchmark/results --benchmark-compare

integration:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
library: ["fastapi", "starlette", "flask"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
env: ["test-integration-fastapi", "test-integration-starlette", "test-integration-flask"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install wheel
pip install -r tests_integrations/${{ matrix.library }}/requirements.txt
pip install -e .[asgi-file-uploads,tracing,telemetry,test,dev]
- name: Pytest
run: |
pytest tests_integrations/${{ matrix.library }}
- name: Checkout source code
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install Hatch
uses: pypa/hatch@257e27e51a6a5616ed08a39a408a21c35c9931bc

- name: Run integration tests for ${{ matrix.env }}
run: hatch run ${{ matrix.env }}:test
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 3-Clause License

Copyright (c) 2023, Mirumee Labs
Copyright (c) 2025, Mirumee Labs
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
1 change: 1 addition & 0 deletions ariadne/__about__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.0.1.dev0" # This is overwritten by Hatch in CI/CD, don't change it.
3 changes: 2 additions & 1 deletion ariadne/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
)
from .graphql import graphql, graphql_sync, subscribe
from .inputs import InputType
from .interfaces import InterfaceType, type_implements_interface
from .interfaces import InterfaceType
from .load_schema import load_schema_from_path
from .objects import MutationType, ObjectType, QueryType
from .resolvers import (
Expand All @@ -35,6 +35,7 @@
convert_camel_case_to_snake,
convert_kwargs_to_snake_case,
gql,
type_implements_interface,
unwrap_graphql_error,
)

Expand Down
Loading

0 comments on commit 6483bba

Please sign in to comment.