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
43 changes: 39 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ on:
push:
branches:
- main
pull_request:
branches:
- "**"

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
build:
lint-and-test:
env:
UV_CACHE_DIR: /tmp/.uv-cache
runs-on: ubuntu-24.04
Expand All @@ -23,29 +26,61 @@ jobs:
with:
python-version-file: ".python-version"
- name: Set up uv
uses: astral-sh/setup-uv@v7
uses: astral-sh/setup-uv@v8.1.0
with:
enable-cache: true
version-file: "pyproject.toml"
- name: Install dependencies
run: uv sync --all-extras --dev --frozen
- name: Run ruff lint
run: uv run ruff check src tests
- name: Run ruff format check
run: uv run ruff format --check src tests
- name: Run mypy
run: uv run mypy
- name: Run bandit
run: uv run bandit -r src
- name: Test with pytest
run: uv run pytest tests --cov=src
- name: Minimize uv cache
run: uv cache prune --ci

build:
needs: lint-and-test
env:
UV_CACHE_DIR: /tmp/.uv-cache
runs-on: ubuntu-24.04
steps:
- name: Checkout source code
uses: actions/checkout@v6
- name: Set up python
id: setup-python
uses: actions/setup-python@v6
with:
python-version-file: ".python-version"
- name: Set up uv
uses: astral-sh/setup-uv@v8.1.0
with:
enable-cache: true
version-file: "pyproject.toml"
- name: Install dependencies
run: uv sync --all-extras --dev --frozen
- name: Build a wheel
run: uv build
- name: Minimize uv cache
run: uv cache prune --ci

build-image:
needs: lint-and-test
runs-on: ubuntu-24.04

steps:
- name: Checkout source code
uses: actions/checkout@v6
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@v4
- name: Build docker image
uses: docker/build-push-action@v6
uses: docker/build-push-action@v7
with:
context: .
push: false
51 changes: 0 additions & 51 deletions .github/workflows/pr.yml

This file was deleted.

15 changes: 8 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repos:

# ruff - linting + formatting
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.1
rev: v0.15.12
hooks:
- id: ruff
name: ruff
Expand All @@ -25,14 +25,14 @@ repos:

# mypy - lint-like type checking
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.19.1
rev: v1.20.2
hooks:
- id: mypy
name: mypy

# bandit - find common security issues
- repo: https://github.com/pycqa/bandit
rev: 1.9.3
rev: 1.9.4
hooks:
- id: bandit
name: bandit
Expand All @@ -50,9 +50,10 @@ repos:
types: [python]
pass_filenames: false

# prettier - formatting JS, CSS, JSON, Markdown, ...
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
# oxfmt - formatting YAML, JSON, Markdown, ...
- repo: https://github.com/oxc-project/mirrors-oxfmt
rev: v0.47.0
hooks:
- id: prettier
- id: oxfmt
types_or: [yaml, markdown, json]
exclude: ^uv.lock
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.14.3
3.14.4
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.14.3-slim-trixie AS python-base
FROM python:3.14.4-slim-trixie AS python-base

ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
Expand All @@ -9,7 +9,7 @@ ENV PATH="$VIRTUAL_ENV/bin:$PATH"

FROM python-base AS builder-base

COPY --from=ghcr.io/astral-sh/uv:0.10.3 /uv /uvx /bin/
COPY --from=ghcr.io/astral-sh/uv:0.11.8 /uv /uvx /bin/

WORKDIR $WORKDIR_PATH

Expand Down
55 changes: 52 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@
- [Installation](#installation)
- [What's in the box ?](#whats-in-the-box-)
- [Testing](#testing)
- [Validation](#validation)
- [Docker](#docker)

---

## Prerequisites

- [Python](https://www.python.org/downloads/) **>=3.14.0 <3.15.0** (_tested with 3.14.3_)
- [Python](https://www.python.org/downloads/) **>=3.14.0 <3.15.0** (_tested with 3.14.4_)
- [pre-commit](https://pre-commit.com/#install) **>=3.2.0 <5.0.0** (_tested with 4.5.1_)
- [uv](https://docs.astral.sh/uv/getting-started/installation/) **>=0.9.30** (_tested with 0.10.3_)
- [uv](https://docs.astral.sh/uv/getting-started/installation/) **>=0.11.5** (_tested with 0.11.8_)
- [docker](https://docs.docker.com/get-docker/) (_optional_)

---
Expand Down Expand Up @@ -159,7 +160,7 @@ collected 1 item

tests/test_python_boilerplate.py::test_hello_world PASSED

---------- coverage: platform linux, python 3.14.3-final-0 -----------
---------- coverage: platform linux, python 3.14.4-final-0 -----------
Name Stmts Miss Cover
--------------------------------------------------------
src/python_boilerplate/__init__.py 1 0 100%
Expand All @@ -172,6 +173,54 @@ TOTAL 7 2 71%

---

## Validation

### Lint & format

To run ruff lint check:

```bash
uv run ruff check src tests
```

To run ruff format check:

```bash
uv run ruff format --check src tests
```

To apply ruff formatting:

```bash
uv run ruff format src tests
```

### Type check

To run mypy:

```bash
uv run mypy
```

### Security

To run bandit:

```bash
uv run bandit -r src
```

### Pre-commit

To run all pre-commit hooks against all files:

```bash
pre-commit run --all-files
```

---

## Docker

### Build
Expand Down
14 changes: 7 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ homepage = "https://github.com/smarlhens/python-boilerplate#readme"
repository = "https://github.com/smarlhens/python-boilerplate"

[build-system]
requires = ["uv_build>=0.9.30,<0.11.0"]
requires = ["uv_build>=0.11.5,<0.12.0"]
build-backend = "uv_build"

[dependency-groups]
dev = [
"pytest>=9.0.2",
"pytest-cov>=7.0.0",
"mypy>=1.19.1",
"bandit>=1.9.3",
"ruff>=0.15.1",
"pytest>=9.0.3",
"pytest-cov>=7.1.0",
"mypy>=1.20.2",
"bandit>=1.9.4",
"ruff>=0.15.12",
]

[tool.uv]
required-version = ">=0.9.30"
required-version = ">=0.11.5"

[tool.pytest.ini_options]
addopts = "-vvv"
Expand Down
Loading
Loading