.gitea/workflows: init test pipeline
This commit is contained in:
81
.gitea/workflows/test.yaml
Normal file
81
.gitea/workflows/test.yaml
Normal file
@@ -0,0 +1,81 @@
|
||||
name: Run tests
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
debug_sql:
|
||||
description: "Print SQL statements executed by SQLAlchemy during tests"
|
||||
type: boolean
|
||||
default: True
|
||||
|
||||
env:
|
||||
DEBUG_SQL: ${{ inputs.debug_sql || true }}
|
||||
|
||||
jobs:
|
||||
run-tests:
|
||||
runs-on: debian-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Install uv
|
||||
uses: astral-sh/setup-uv@v7
|
||||
|
||||
- name: Install dependencies
|
||||
run: uv sync --locked --group test
|
||||
|
||||
- name: Run tests
|
||||
continue-on-error: true
|
||||
run: |
|
||||
set -euo pipefail
|
||||
set -x
|
||||
|
||||
PYTEST_ARGS=(
|
||||
-vv
|
||||
|
||||
--cov=dibbler.lib
|
||||
--cov=dibbler.models
|
||||
--cov=dibbler.queries
|
||||
--cov-report=html
|
||||
--cov-branch
|
||||
|
||||
--self-contained-html
|
||||
--html=./test-report/index.html
|
||||
)
|
||||
|
||||
if [ "$DEBUG_SQL" == "true" ]; then
|
||||
PYTEST_ARGS+=(
|
||||
--debug-sql
|
||||
)
|
||||
fi
|
||||
|
||||
uv run -- pytest "${PYTEST_ARGS[@]}"
|
||||
|
||||
- name: Generate badge
|
||||
run: uv run -- coverage-badge -o htmlcov/badge.svg
|
||||
|
||||
- name: Upload test report
|
||||
uses: https://git.pvv.ntnu.no/Projects/rsync-action@v1
|
||||
with:
|
||||
source: ./test-report/
|
||||
target: ${{ gitea.ref_name }}/test-report/
|
||||
username: gitea-web
|
||||
ssh-key: ${{ secrets.WEB_SYNC_SSH_KEY }}
|
||||
host: pages.pvv.ntnu.no
|
||||
known-hosts: "pages.pvv.ntnu.no ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIH2QjfFB+city1SYqltkVqWACfo1j37k+oQQfj13mtgg"
|
||||
|
||||
- name: Upload coverage report
|
||||
uses: https://git.pvv.ntnu.no/Projects/rsync-action@v1
|
||||
with:
|
||||
source: ./htmlcov/
|
||||
target: ${{ gitea.ref_name }}/coverage/
|
||||
username: gitea-web
|
||||
ssh-key: ${{ secrets.WEB_SYNC_SSH_KEY }}
|
||||
host: pages.pvv.ntnu.no
|
||||
known-hosts: "pages.pvv.ntnu.no ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIH2QjfFB+city1SYqltkVqWACfo1j37k+oQQfj13mtgg"
|
||||
|
||||
- name: Check failure
|
||||
if: failure()
|
||||
run: |
|
||||
echo "Tests failed"
|
||||
exit 1
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -9,3 +9,5 @@ test.db
|
||||
.ruff_cache
|
||||
|
||||
.coverage
|
||||
htmlcov
|
||||
test-report
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
[](https://pages.pvv.ntnu.no/Projects/dibbler/event-sourcing/coverage)
|
||||
[](https://pages.pvv.ntnu.no/Projects/dibbler/event-sourcing/test-report)
|
||||
|
||||
# Dibbler
|
||||
|
||||
EDB-system for PVVVV
|
||||
@@ -41,6 +44,7 @@ Du kan også endre hvilken config-fil som blir brukt direkte i pakken eller i mo
|
||||
Se eksempelet for hvordan skrot er satt opp i `flake.nix` og `nix/skrott.nix`
|
||||
|
||||
### Bygge image for skrot
|
||||
|
||||
Skrot har et image definert i flake.nix:
|
||||
|
||||
1. endre `example-config.ini`
|
||||
|
||||
@@ -19,6 +19,7 @@ mkShell {
|
||||
|
||||
pytest
|
||||
pytest-cov
|
||||
pytest-html
|
||||
]))
|
||||
];
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@ dependencies = [
|
||||
]
|
||||
dynamic = ["version"]
|
||||
|
||||
[project.optional-dependencies]
|
||||
dev = [
|
||||
[dependency-groups]
|
||||
test = [
|
||||
"pytest",
|
||||
"pytest-cov",
|
||||
"coverage-badge>=1.1.2",
|
||||
|
||||
19
uv.lock
generated
19
uv.lock
generated
@@ -256,8 +256,8 @@ dependencies = [
|
||||
{ name = "sqlalchemy" },
|
||||
]
|
||||
|
||||
[package.optional-dependencies]
|
||||
dev = [
|
||||
[package.dev-dependencies]
|
||||
test = [
|
||||
{ name = "coverage-badge" },
|
||||
{ name = "pytest" },
|
||||
{ name = "pytest-cov" },
|
||||
@@ -268,17 +268,20 @@ dev = [
|
||||
[package.metadata]
|
||||
requires-dist = [
|
||||
{ name = "brother-ql" },
|
||||
{ name = "coverage-badge", marker = "extra == 'dev'", specifier = ">=1.1.2" },
|
||||
{ name = "matplotlib" },
|
||||
{ name = "psycopg2-binary", specifier = ">=2.8,<2.10" },
|
||||
{ name = "pytest", marker = "extra == 'dev'" },
|
||||
{ name = "pytest-cov", marker = "extra == 'dev'" },
|
||||
{ name = "pytest-html", marker = "extra == 'dev'", specifier = ">=4.1.1" },
|
||||
{ name = "python-barcode" },
|
||||
{ name = "sqlalchemy", specifier = ">=2.0,<2.1" },
|
||||
{ name = "sqlparse", marker = "extra == 'dev'", specifier = ">=0.5.4" },
|
||||
]
|
||||
provides-extras = ["dev"]
|
||||
|
||||
[package.metadata.requires-dev]
|
||||
test = [
|
||||
{ name = "coverage-badge", specifier = ">=1.1.2" },
|
||||
{ name = "pytest" },
|
||||
{ name = "pytest-cov" },
|
||||
{ name = "pytest-html", specifier = ">=4.1.1" },
|
||||
{ name = "sqlparse", specifier = ">=0.5.4" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fonttools"
|
||||
|
||||
Reference in New Issue
Block a user