Skip to content

Commit 6cce87f

Browse files
authored
Merge pull request #25 from lsst-sqre/tickets/DM-39646
DM-39646: Add FastAPI app integration through dependencies
2 parents fbe6900 + 8e3705c commit 6cce87f

File tree

14 files changed

+271
-21
lines changed

14 files changed

+271
-21
lines changed

.github/workflows/ci.yaml

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Python CI
22

33
"on":
4+
merge_group: {}
45
push:
56
branches-ignore:
67
# These should always correspond to pull requests, so ignore them for
@@ -11,9 +12,9 @@ name: Python CI
1112
- "renovate/**"
1213
- "tickets/**"
1314
- "u/**"
14-
tags:
15-
- "*"
1615
pull_request: {}
16+
release:
17+
types: [published]
1718

1819
jobs:
1920
lint:
@@ -37,8 +38,6 @@ jobs:
3738
strategy:
3839
matrix:
3940
python:
40-
- "3.8"
41-
- "3.9"
4241
- "3.10"
4342
- "3.11"
4443

@@ -81,22 +80,48 @@ jobs:
8180
username: ${{ secrets.LTD_USERNAME }}
8281
password: ${{ secrets.LTD_PASSWORD }}
8382
if: >
84-
github.event_name != 'pull_request'
85-
|| startsWith(github.head_ref, 'tickets/')
83+
github.event_name != 'merge_group'
84+
&& (github.event_name != 'pull_request'
85+
|| startsWith(github.head_ref, 'tickets/'))
86+
87+
test-packaging:
88+
89+
name: Test packaging
90+
runs-on: ubuntu-latest
91+
92+
steps:
93+
- uses: actions/checkout@v3
94+
with:
95+
fetch-depth: 0 # full history for setuptools_scm
96+
97+
- name: Build and publish
98+
uses: lsst-sqre/build-and-publish-to-pypi@v2
99+
with:
100+
python-version: "3.11"
101+
upload: false
86102

87103
pypi:
88104

105+
# This job requires set up:
106+
# 1. Set up a trusted publisher for PyPI
107+
# 2. Set up a "pypi" environment in the repository
108+
# See https://github.com/lsst-sqre/build-and-publish-to-pypi
109+
name: Upload release to PyPI
89110
runs-on: ubuntu-latest
90-
needs: [lint, test, docs]
111+
needs: [lint, test, docs, test-packaging]
112+
environment:
113+
name: pypi
114+
url: https://pypi.org/p/kafkit
115+
permissions:
116+
id-token: write
117+
if: github.event_name == 'release' && github.event.action == 'published'
91118

92119
steps:
93120
- uses: actions/checkout@v3
94121
with:
95122
fetch-depth: 0 # full history for setuptools_scm
96123

97124
- name: Build and publish
98-
uses: lsst-sqre/build-and-publish-to-pypi@v1
125+
uses: lsst-sqre/build-and-publish-to-pypi@v2
99126
with:
100-
pypi-token: ${{ secrets.PYPI_SQRE_ADMIN }}
101127
python-version: "3.11"
102-
upload: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Dependency Update
2+
3+
"on":
4+
schedule:
5+
- cron: "0 12 * * 1"
6+
workflow_dispatch: {}
7+
8+
jobs:
9+
update:
10+
runs-on: ubuntu-latest
11+
timeout-minutes: 10
12+
13+
steps:
14+
- uses: actions/checkout@v3
15+
16+
- name: Run neophile
17+
uses: lsst-sqre/run-neophile@v1
18+
with:
19+
python-version: "3.11"
20+
mode: pr
21+
types: pre-commit
22+
app-id: ${{ secrets.NEOPHILE_APP_ID }}
23+
app-secret: ${{ secrets.NEOPHILE_PRIVATE_KEY }}
24+
25+
- name: Report status
26+
if: always()
27+
uses: ravsamhq/notify-slack-action@v2
28+
with:
29+
status: ${{ job.status }}
30+
notify_when: "failure"
31+
notification_title: "Periodic dependency update for {repo} failed"
32+
env:
33+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_ALERT_WEBHOOK }}

.github/workflows/periodic-ci.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ jobs:
1515
strategy:
1616
matrix:
1717
python:
18-
- "3.8"
19-
- "3.9"
2018
- "3.10"
2119
- "3.11"
2220

@@ -43,17 +41,17 @@ jobs:
4341
tox-envs: "docs,docs-linkcheck"
4442
use-cache: false
4543

46-
pypi:
44+
test-packaging:
4745
runs-on: ubuntu-latest
46+
timeout-minutes: 10
4847

4948
steps:
5049
- uses: actions/checkout@v3
5150
with:
5251
fetch-depth: 0 # full history for setuptools_scm
5352

5453
- name: Build and publish
55-
uses: lsst-sqre/build-and-publish-to-pypi@v1
54+
uses: lsst-sqre/build-and-publish-to-pypi@v2
5655
with:
57-
pypi-token: ""
5856
python-version: "3.11"
5957
upload: false

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.vscode
2+
13
# Byte-compiled / optimized / DLL files
24
__pycache__/
35
*.py[cod]

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ help:
55

66
.PHONY: init
77
init:
8-
pip install -e ".[aiohttp,httpx,pydantic,dev]"
9-
pip install -U tox pre-commit
8+
pip install -e ".[aiohttp,httpx,pydantic,aiokafka,dev]"
9+
pip install -U tox pre-commit scriv
1010
pre-commit install
1111
rm -rf .tox
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
### Backwards-incompatible changes
2+
3+
- Only Python 3.10 or later is supported.
4+
5+
### New features
6+
7+
- Integration into FastAPI apps through dependencies in `kafkit.fastapi.dependencies`:
8+
9+
- `AioKafkaProducerDependency` provides a Kafka producer based on aiokafka's `AIOKafkaProducer` (requires the `aiokafka` extra).
10+
- `PydanticSchemaManager` provides a Pydantic-based schema manager for Avro schemas, `kafkit.schema.manager.PydanticSchemaManager`.
11+
- `RegistryApiDependency` provides an HTTPX-based Schema Registry client, `kafkit.registry.httpx.RegistryApi`.
12+
13+
### Other changes
14+
15+
- Adopt PyPI's trusted publishers mechanism for releases.
16+
- Adopt the new [Neophile](https://github.com/lsst-sqre/neophile) workflow for keeping pre-commit hooks up-to-date.

docs/api.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22
Kafkit API reference
33
####################
44

5+
.. automodapi:: kafkit.fastapi.dependencies.aiokafkaproducer
6+
:no-inheritance-diagram:
7+
:include-all-objects:
8+
9+
.. automodapi:: kafkit.fastapi.dependencies.pydanticschemamanager
10+
:no-inheritance-diagram:
11+
:include-all-objects:
12+
13+
.. automodapi:: kafkit.fastapi.dependencies.registryapi
14+
:no-inheritance-diagram:
15+
:include-all-objects:
16+
517
.. automodapi:: kafkit.registry
618
:no-inheritance-diagram:
719

pyproject.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,22 @@ classifiers = [
1414
"License :: OSI Approved :: MIT License",
1515
"Programming Language :: Python",
1616
"Programming Language :: Python :: 3",
17-
"Programming Language :: Python :: 3.8",
18-
"Programming Language :: Python :: 3.9",
1917
"Programming Language :: Python :: 3.10",
2018
"Programming Language :: Python :: 3.11",
2119
"Intended Audience :: Developers",
2220
"Natural Language :: English",
2321
"Operating System :: POSIX",
2422
"Typing :: Typed",
2523
]
26-
requires-python = ">=3.8"
24+
requires-python = ">=3.10"
2725
dependencies = ["fastavro", "uritemplate"]
2826
dynamic = ["version"]
2927

3028
[project.optional-dependencies]
3129
aiohttp = ["aiohttp"]
3230
httpx = ["httpx"]
3331
pydantic = ["pydantic", "dataclasses-avroschema[pydantic]"]
32+
aiokafka = ["aiokafka"]
3433
dev = [
3534
# Testing
3635
"coverage[toml]",
@@ -82,7 +81,7 @@ exclude_lines = [
8281

8382
[tool.black]
8483
line-length = 79
85-
target-version = ['py38']
84+
target-version = ['py310']
8685
exclude = '''
8786
/(
8887
\.eggs

src/kafkit/fastapi/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Kafkit integration with FastApi applications."""
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""FastAPI dependencies for Kafkit applications."""

0 commit comments

Comments
 (0)