Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .flake8

This file was deleted.

29 changes: 17 additions & 12 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,30 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.12]
python-version:
- "3.9"
- "3.14"

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

- name: "Set up Python"
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt -r requirements_test.txt
pip install -e .

- name: Install uv
uses: astral-sh/setup-uv@v7

- name: Install the project
run: uv sync --locked --all-groups

- name: Test with pytest
run: |
pytest --cov webhook_receive --cov-report=xml
uv run pytest --cov webhook_receive --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
with:
file: ./coverage.xml
files: ./coverage.xml
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.12-slim
FROM python:3.14-slim

WORKDIR /app

Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ This is a work in progress and should be used with caution.
```sh
git clone https://github.com/falkben/webhook_receive.git
cd webhook_receive
python3 -m venv venv
. venv/bin/activate
pip install -e .
uv sync --locked
```

## Running
Expand Down Expand Up @@ -97,13 +95,15 @@ It will also bind the current directory to the docker image, so edits you make t

- [ ] support additional webhook events

## To update requirements
## Dependencies

Ensure you have [pip-tools](https://github.com/jazzband/pip-tools): `pip install pip-tools`

Creating the requirements.txt file (this will overwrite): `pip-compile requirements.in`
```sh
uv lock
```

To upgrade: `pip-compile --upgrade`
```sh
uv lock --upgrade
```

## Inspiration

Expand Down
18 changes: 3 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,14 @@ build-backend = "hatchling.build"
name = "webhook_receive"
version = "0.1"
authors = [{ name = "Benjamin Falk" }]
dependencies = [
"fastapi",
"uvicorn[standard]",
"pytest",
"pytest-env",
"requests",
"httpx",
"pytest-asyncio",
"python-dotenv",
]
dependencies = ["fastapi", "uvicorn[standard]", "httpx", "dotenv"]
requires-python = ">=3.9"
description = "FastAPI application to process webhook events"
readme = "README.md"
license = { text = "Apache License (2.0)" }

[project.optional-dependencies]
test = ["pytest", "pytest-cov"]
[dependency-groups]
test = ["pytest", "pytest-cov", "pytest-env", "pytest-asyncio", "python-dotenv"]

[project.urls]
Repository = "https://github.com/falkben/webhook_receive/"
Expand All @@ -33,6 +24,3 @@ env = [
"GITHUB_IPS_ONLY = false",
]
testpaths = ["tests"]

[tool.isort]
profile = "black"
83 changes: 0 additions & 83 deletions requirements.txt

This file was deleted.

88 changes: 0 additions & 88 deletions requirements_test.txt

This file was deleted.

9 changes: 6 additions & 3 deletions tests/test_webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ def remove_testfile():
async def test_github_ips_only():
# using httpx async test client here to allow setting scope (e.g. IP address)
# httpx defaults to 127.0.0.1
async with httpx.AsyncClient(app=app, base_url="http://testserver") as client:
transport = httpx.ASGITransport(app=app)
async with httpx.AsyncClient(
transport=transport, base_url="http://testserver"
) as client:
resp = await client.post(
"/webhook/test_app", headers={"X-GITHUB-EVENT": "ping"}
)
Expand All @@ -44,7 +47,7 @@ def test_webhook_receive(test_output_file):
"/webhook/test_app", json=data, headers={"X-GITHUB-EVENT": "push"}
)
resp_data = resp.json()
assert resp_data == {"message": "Deployment started for [AppNames.test_app]"}
assert resp_data == {"message": "Deployment started for [test_app]"}

# subprocess as background task... lets wait a little bit
time.sleep(0.1)
Expand Down Expand Up @@ -73,5 +76,5 @@ def test_unsupported_event():
)
assert resp.status_code == 200
assert resp.json() == {
"message": "Unable to process action [unsupported_event] for [AppNames.test_app]"
"message": "Unable to process action [unsupported_event] for [test_app]"
}
Loading