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
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ DATA_PATH=src/spanselector/data/sample.csv
HOST=127.0.0.1
PORT=8080
# RELOAD=false
# SHOW=true

# Optional: Logging level (DEBUG, INFO, WARNING, ERROR)
# LOG_LEVEL=INFO
43 changes: 34 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,16 @@ permissions:
contents: read

jobs:
quality:
name: Python ${{ matrix.python-version }}
static-analysis:
name: Static analysis (Ruff + mypy)
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12", "3.13", "3.14"]

steps:
- uses: actions/checkout@v7
- name: Install uv
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
with:
python-version: ${{ matrix.python-version }}
python-version: "3.13"
enable-cache: true
- name: Install dependencies
run: uv sync --locked --extra dev
Expand All @@ -32,14 +28,43 @@ jobs:
run: uv run ruff format --check .
- name: Type check
run: uv run mypy src/spanselector

tests:
name: Tests / Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12", "3.13", "3.14"]

steps:
- uses: actions/checkout@v7
- name: Install uv
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
with:
python-version: ${{ matrix.python-version }}
enable-cache: true
- name: Install dependencies
run: uv sync --locked --extra dev
- name: Test
run: uv run pytest

package:
name: Package / Build distributions
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v7
- name: Install uv
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
with:
python-version: "3.13"
enable-cache: true
- name: Build package
if: matrix.python-version == '3.13'
run: uv build

browser-tests:
name: Selection in ${{ matrix.browser }}
name: E2E / Selection / ${{ matrix.browser }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand Down
62 changes: 62 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
minimum_pre_commit_version: "4.0.0"
default_install_hook_types: [pre-commit]

# These local hooks intentionally mirror .github/workflows/ci.yml. They run
# against the whole repository so documentation-only commits cannot bypass CI.
repos:
- repo: local
hooks:
- id: ruff-lint
name: CI / Ruff lint
entry: uv run --locked --extra dev ruff check .
language: system
pass_filenames: false
always_run: true

- id: ruff-format
name: CI / Ruff format
entry: uv run --locked --extra dev ruff format --check .
language: system
pass_filenames: false
always_run: true

- id: mypy
name: CI / mypy
entry: uv run --locked --extra dev mypy --no-incremental src/spanselector
language: system
pass_filenames: false
always_run: true

- id: pytest
name: CI / pytest
entry: uv run --locked --extra dev pytest
language: system
pass_filenames: false
always_run: true

- id: build
name: CI / package build
entry: uv build
language: system
pass_filenames: false
always_run: true

- id: e2e-chromium
name: CI / Playwright Chromium
entry: >-
uv run --locked --extra dev --extra e2e pytest tests/e2e --run-e2e
--browser chromium --no-cov --tracing retain-on-failure
--screenshot only-on-failure
language: system
pass_filenames: false
always_run: true

- id: e2e-firefox
name: CI / Playwright Firefox
entry: >-
uv run --locked --extra dev --extra e2e pytest tests/e2e --run-e2e
--browser firefox --no-cov --tracing retain-on-failure
--screenshot only-on-failure
language: system
pass_filenames: false
always_run: true
13 changes: 12 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,23 @@ strengthen the local span-annotation loop before expanding its product surface.
## Set up

```bash
uv sync --extra dev
uv sync --extra dev --extra e2e
uv run playwright install chromium firefox
uv run pre-commit install
uv run spanselector
```

## Before opening a pull request

Every commit runs the same lint, format, type, test, build, and browser checks as CI. To run the
complete gate without creating a commit:

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

The individual commands are:

```bash
uv run ruff format --check .
uv run ruff check .
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Issues = "https://github.com/wiperpaul/span-annotator/issues"

[project.optional-dependencies]
dev = [
"pre-commit>=4.0",
"pytest>=7.4",
"pytest-cov>=4.1",
"ruff>=0.2.0",
Expand Down Expand Up @@ -78,4 +79,4 @@ ignore_missing_imports = true
where = ["src"]

[tool.setuptools.package-data]
spanselector = ["data/*.csv", "schemas/*.yaml"]
spanselector = ["assets/*.css", "data/*.csv", "schemas/*.yaml"]
Loading