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
70 changes: 67 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,85 @@
name: Tests
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.14"

- name: Install ruff
run: pip install ruff

- name: Ruff check
run: |
set +e
output=$(ruff check . --statistics 2>&1)
exit_code=$?
echo "## Ruff Lint Report" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "$output" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
exit $exit_code

- name: Ruff format check
run: |
set +e
output=$(ruff format --check . 2>&1)
exit_code=$?
echo "## Ruff Format Report" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "$output" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
exit $exit_code

mypy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.14"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
pip install -e ".[fastapi]"

- name: mypy
run: |
set +e
output=$(mypy metricsqlite 2>&1)
exit_code=$?
echo "## mypy Report" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "$output" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
exit $exit_code

test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}

Expand Down
7 changes: 4 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ repos:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 26.3.1

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.12
hooks:
- id: black
- id: ruff-format # Formatter
18 changes: 18 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{ lib, buildPythonPackage, fetchPypi, setuptools, setuptools-scm, fastapi
, pydantic, pymodbus }:

buildPythonPackage {
pname = "metricsqlite";
version = "0.0.0";
format = "pyproject";

src = ./.;

nativeBuildInputs = [ setuptools setuptools-scm ];
propagatedBuildInputs = [ fastapi pydantic ];

meta = with lib; {
description = "MetricSQLite - MetricsQL api with SQLite as backend";
license = licenses.mit;
};
}
34 changes: 34 additions & 0 deletions docs/dev/testing.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,44 @@
To set up a dev environment run;

```bash
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -e .
pip install -e ".[dev]"

pre-commit install
pre-commit autoupdate
```

### pytest

```bash
pytest

# Or run a specific test file:
pytest tests/test_client.py

# Or a specific test:
pytest tests/test_client.py::TestMetricsQLite::test_init_in_memory

# For a code coverage report:
pytest --cov=metricsqlite --cov-report=term-missing
```

### ruff

```bash
ruff check . # Lint
ruff check . --fix # Lint + auto-fix
ruff format . # Format

# pyproject.toml sets `output-format = "concise"`. So show more details run;
ruff check --output-format=full .
```

### mypy

```bash
mypy metricsqlite
```
2 changes: 1 addition & 1 deletion metricsqlite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
from metricsqlite.exceptions import CompactedRangeError
from metricsqlite.lineprotocol import LineProtocolError

__all__ = ["MetricsQLiteClient", "CompactedRangeError", "LineProtocolError", "fastapi"]
__all__ = ["CompactedRangeError", "LineProtocolError", "MetricsQLiteClient", "fastapi"]
Loading