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
22 changes: 22 additions & 0 deletions .github/workflows/container-build-push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: "Container Build and Push"

on:
push:
branches:
- main
tags:
- v*
pull_request:

permissions:
contents: read
packages: write
# Used by actions/attest-build-provenance
id-token: write
attestations: write

jobs:
build-push:
uses: darbiadev/.github/.github/workflows/container-build-push.yaml@41518576ed6c499ed3e68d5cbceaeaa50abd471a # v14.1.0
with:
file-name: Dockerfile
20 changes: 0 additions & 20 deletions .github/workflows/docker-build-push.yaml

This file was deleted.

56 changes: 39 additions & 17 deletions .github/workflows/python-ci.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Python CI"
name: Python CI

on:
push:
Expand All @@ -7,24 +7,46 @@ on:
pull_request:

jobs:
pre-commit:
uses: darbiadev/.github/.github/workflows/generic-precommit.yaml@29197a38ef3741064f47b623ede0c1ad22402c57 # v13.0.3
lint-test:
runs-on: ubuntu-latest

lint:
needs: pre-commit
uses: darbiadev/.github/.github/workflows/python-lint.yaml@29197a38ef3741064f47b623ede0c1ad22402c57 # v13.0.3
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

test:
needs: lint
strategy:
matrix:
os: [ ubuntu-latest ]
python-version: [ "3.11" ]
- name: Setup Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: 3.12
allow-prereleases: true
cache: pip
cache-dependency-path: uv.lock

uses: darbiadev/.github/.github/workflows/python-test.yaml@29197a38ef3741064f47b623ede0c1ad22402c57 # v13.0.3
with:
os: ${{ matrix.os }}
python-version: ${{ matrix.python-version }}
- name: Set up uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh

- name: Sync dependencies
run: uv sync --group dev --group tests

- name: Run pre-commit
run: uv run pre-commit run --all-files

- name: Check formatting
run: uv run ruff format --check .

- name: Run Ruff checks
run: uv run ruff check --output-format=github .

- name: Run mypy
run: uv run mypy --strict src/

- name: Run tests
run: uv run python -m coverage run -m pytest -v

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@d168679d447a7d9f9917d4b26caf2cfbf080cfb4 # v5.0.6
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

docs:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
Expand All @@ -33,4 +55,4 @@ jobs:
pages: write
id-token: write

uses: darbiadev/.github/.github/workflows/github-pages-python-sphinx.yaml@29197a38ef3741064f47b623ede0c1ad22402c57 # v13.0.3
uses: darbiadev/.github/.github/workflows/github-pages-python-sphinx.yaml@41518576ed6c499ed3e68d5cbceaeaa50abd471a # v14.1.0
22 changes: 21 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v5.0.0
hooks:
- id: check-case-conflict
- id: check-merge-conflict
Expand All @@ -12,3 +12,23 @@ repos:
- id: mixed-line-ending
args: [ --fix=lf ]
- id: end-of-file-fixer
exclude: .devcontainer/devcontainer-lock.json

- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.5.4
hooks:
- id: uv-lock
- id: uv-export
args:
- --frozen
- --no-emit-project
- --output-file=requirements.txt
files: pyproject.toml|uv.lock
- id: uv-export
args:
- --frozen
- --no-emit-project
- --all-extras
- --all-groups
- --output-file=requirements-dependabot.txt
files: pyproject.toml|uv.lock
10 changes: 4 additions & 6 deletions Containerfile → Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,17 @@ FROM python:3.12-slim@sha256:43a49c9cc2e614468e3d1a903aabe17a97a4c788c76cf5337b5
ARG git_sha="development"
ENV GIT_SHA=$git_sha

WORKDIR /home/api

COPY requirements/requirements.txt .
COPY requirements.txt requirements.txt
RUN python -m pip install --requirement requirements.txt

COPY pyproject.toml pyproject.toml
COPY pyproject.toml README.md ./
COPY src/ src/
RUN python -m pip install .
RUN PYTHONDONTWRITEBYTECODE=1 pip install --no-cache-dir .

RUN adduser --disabled-password api
USER api

# HTTP
EXPOSE 8080

CMD ["uvicorn", "api.server:app", "--host", "0.0.0.0", "--port", "8080"]
ENTRYPOINT ["gunicorn", "--bind", "0.0.0.0:8080", "--workers", "4", "--worker-class", "uvicorn.workers.UvicornWorker", "api.server:app"]
6 changes: 3 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ def linkcode_resolve(domain: str, info: dict) -> str:
if not info["module"]:
return None

import importlib # noqa: PLC0415
import inspect # noqa: PLC0415
import types # noqa: PLC0415
import importlib
import inspect
import types

mod = importlib.import_module(info["module"])

Expand Down
126 changes: 0 additions & 126 deletions make.ps1

This file was deleted.

52 changes: 52 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"""Noxfile."""

import shutil
from pathlib import Path

import nox

nox.options.default_venv_backend = "none"
nox.options.sessions = ["lints"]


CLEANABLE_TARGETS = [
"./dist",
"./build",
"./.nox",
"./.coverage",
"./.coverage.*",
"./coverage.json",
"./**/.mypy_cache",
"./**/.pytest_cache",
"./**/__pycache__",
"./**/*.pyc",
"./**/*.pyo",
]


@nox.session
def tests(session: nox.Session) -> None:
"""Run tests."""
session.run("pytest")


@nox.session
def lints(session: nox.Session) -> None:
"""Run lints."""
session.run("pre-commit", "run", "--all-files")
session.run("ruff", "format", ".")
session.run("ruff", "check", "--fix", ".")
session.run("mypy", "--strict", "src/")


@nox.session
def clean(_: nox.Session) -> None:
"""Clean cache, .pyc, .pyo, and test/build artifact files from project."""
count = 0
for searchpath in CLEANABLE_TARGETS:
for filepath in Path().glob(searchpath):
if filepath.is_dir():
shutil.rmtree(filepath)
else:
filepath.unlink()
count += 1
Loading
Loading