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
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,31 @@ jobs:
- name: Lint shell scripts
run: shellcheck --severity=warning scripts/*.sh

unit-tests:
name: Python unit tests + coverage
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install pixi
run: curl -fsSL https://pixi.sh/install.sh | bash && echo "$HOME/.pixi/bin" >> $GITHUB_PATH

- name: Install dependencies
run: pixi install

- name: Run tests with coverage
run: pixi run test-unit

- name: Upload coverage report
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-report
path: coverage.xml
retention-days: 30

atlas-dashboard:
name: Atlas dashboard (Go)
runs-on: ubuntu-latest
Expand Down
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ data/
.DS_Store
*.swp
configs/nginx/htpasswd
__pycache__/
*.pyc
*.pyo
.coverage
htmlcov/
coverage.xml
.pytest_cache/
4 changes: 3 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ dev:
@./scripts/dev-watch.sh

# Run local test suite

# Run local test suite with coverage
test:
python3 -m pytest tests/ -v 2>/dev/null || python3 -m unittest discover -s tests -v
pixi run test-unit

# Tail logs for a specific service (e.g. just logs prometheus)
logs SERVICE:
Expand Down
760 changes: 73 additions & 687 deletions pixi.lock

Large diffs are not rendered by default.

21 changes: 5 additions & 16 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ ruff = ">=0.4,<1"
bandit = ">=1.7,<2"
pyyaml = ">=6.0,<7"
pytest = ">=8.0"
pytest-cov = ">=5.0"
python = ">=3.11,<3.14"

[target.linux-64.dependencies]
Expand All @@ -24,19 +25,7 @@ jq = ">=1.6,<2"
jq = ">=1.6,<2"

[tasks]
start = "just start"
stop = "just stop"
status = "just status"
test = "python -m pytest tests/ -v"

[feature.lint.dependencies]
python = ">=3.11"

[feature.lint.pypi-dependencies]
pip-audit = ">=2.8"

[feature.lint.tasks]
pip-audit = "pip-audit"

[environments]
lint = { features = ["lint"], no-default-feature = true }
start = "just start"
stop = "just stop"
status = "just status"
test-unit = "pytest tests/ -v"
20 changes: 20 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[tool.pytest.ini_options]
addopts = [
"--cov=exporter",
"--cov-report=term-missing",
"--cov-report=html",
"--cov-report=xml",
]

[tool.coverage.run]
source = ["exporter"]
branch = true

[tool.coverage.report]
fail_under = 82
exclude_lines = [
"pragma: no cover",
"if TYPE_CHECKING:",
"class .*\\bProtocol\\):",
"@(abc\\.)?abstractmethod",
]
3 changes: 3 additions & 0 deletions tests/test_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@ def test_loki_datasource_url_uses_proxy(self) -> None:
loki_ds = next(ds for ds in datasources if ds["type"] == "loki")
assert loki_ds["url"] == "http://loki-proxy", (
"Loki datasource must point to loki-proxy, not loki:3100 directly"
)


class TestDockerComposePorts(unittest.TestCase):
def setUp(self) -> None:
self.compose = load_yaml(REPO_ROOT / "docker-compose.yml")
Expand Down
Loading