test: make nice pytest reports on github (#2376)

* test: make nice pytest reports on github
utilizing this action: https://github.com/pavelzw/pytest-action/
This commit is contained in:
dni ⚡ 2024-04-05 08:35:51 +02:00 committed by GitHub
parent 820882db28
commit 209e2c5bff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 89 additions and 18 deletions

View file

@ -21,20 +21,18 @@ jobs:
uses: ./.github/workflows/tests.yml
with:
python-version: ${{ matrix.python-version }}
db-url: ${{ matrix.db-url }}
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
migrations:
migration:
needs: [ lint ]
strategy:
matrix:
python-version: ["3.9"]
uses: ./.github/workflows/tests.yml
python-version: ["3.9", "3.10"]
uses: ./.github/workflows/migration.yml
with:
make: test-migration
db-name: migration
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
python-version: ${{ matrix.python-version }}
openapi:
needs: [ lint ]

View file

@ -49,5 +49,5 @@ jobs:
with:
name: jmeter-extension-test-results
path: |
reports/
logs/
lnbits-extensions/reports/
lnbits-extensions/logs/

37
.github/workflows/migration.yml vendored Normal file
View file

@ -0,0 +1,37 @@
name: migration
on:
workflow_call:
inputs:
python-version:
description: "python version"
type: string
default: "3.10"
jobs:
make:
name: migration (${{ inputs.python-version }})
strategy:
matrix:
os-version: ["ubuntu-latest"]
runs-on: ${{ matrix.os-version }}
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: lnbits
POSTGRES_PASSWORD: lnbits
POSTGRES_DB: migration
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare
with:
python-version: ${{ inputs.python-version }}
- run: make test-migration

View file

@ -56,7 +56,8 @@ jobs:
if: ${{ inputs.backend-wallet-class == 'LNbitsWallet' }}
run: docker exec lnbits-lnbits-1 poetry run python tools/create_fake_admin.py
- name: Run Tests
- name: Run pytest
uses: pavelzw/pytest-action@v2
env:
LNBITS_DATABASE_URL: ${{ inputs.db-url }}
LNBITS_BACKEND_WALLET_CLASS: ${{ inputs.backend-wallet-class }}
@ -75,7 +76,16 @@ jobs:
LNBITS_KEY: "d08a3313322a4514af75d488bcc27eee"
ECLAIR_URL: http://127.0.0.1:8082
ECLAIR_PASS: lnbits
run: make test-real-wallet
LNBITS_DATA_FOLDER: "./tests/data"
PYTHONUNBUFFERED: 1
DEBUG: true
with:
verbose: false
job-summary: true
emoji: false
click-to-expand: false
custom-pytest: poetry run pytest
report-title: "regtest (${{ inputs.python-version }}, ${{ inputs.backend-wallet-class }}"
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4

View file

@ -3,9 +3,6 @@ name: tests
on:
workflow_call:
inputs:
make:
default: test
type: string
python-version:
default: "3.9"
type: string
@ -48,15 +45,26 @@ jobs:
with:
python-version: ${{ inputs.python-version }}
- name: Run Tests
- name: Run pytest
uses: pavelzw/pytest-action@v2
env:
LNBITS_DATABASE_URL: ${{ inputs.db-url }}
LNBITS_BACKEND_WALLET_CLASS: FakeWallet
run: make ${{ inputs.make }}
FAKE_WALLET_SECRET: "ToTheMoon1"
LNBITS_DATA_FOLDER: "./tests/data"
PYTHONUNBUFFERED: 1
DEBUG: true
with:
verbose: false
job-summary: true
emoji: false
click-to-expand: false
custom-pytest: poetry run pytest
report-title: "test (${{ inputs.python-version }}, ${{ inputs.db-url }})"
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
verbose: false

View file

@ -37,6 +37,9 @@
asgi-lifespan = prev.asgi-lifespan.overridePythonAttrs (
old: { buildInputs = (old.buildInputs or []) ++ [ prev.setuptools ]; }
);
pytest-md = prev.pytest-md.overridePythonAttrs (
old: { buildInputs = (old.buildInputs or []) ++ [ prev.setuptools ]; }
);
});
};
});

16
poetry.lock generated
View file

@ -1958,6 +1958,20 @@ pytest = ">=4.6"
[package.extras]
testing = ["fields", "hunter", "process-tests", "pytest-xdist", "six", "virtualenv"]
[[package]]
name = "pytest-md"
version = "0.2.0"
description = "Plugin for generating Markdown reports for pytest results"
optional = false
python-versions = ">=3.6"
files = [
{file = "pytest-md-0.2.0.tar.gz", hash = "sha256:3b248d5b360ea5198e05b4f49c7442234812809a63137ec6cdd3643a40cf0112"},
{file = "pytest_md-0.2.0-py3-none-any.whl", hash = "sha256:4c4cd16fea6d1485e87ee254558712c804a96d2aa9674b780e7eb8fb6526e1d1"},
]
[package.dependencies]
pytest = ">=4.2.1"
[[package]]
name = "python-crontab"
version = "3.0.0"
@ -2948,4 +2962,4 @@ liquid = ["wallycore"]
[metadata]
lock-version = "2.0"
python-versions = "^3.10 | ^3.9"
content-hash = "cbe93bb8afbda1cddb4e30721fb15a016b8fb1250d07ee06ff9365b8757c1710"
content-hash = "a58655feabd699c4f4dd8ad67989f09dbc1385e6e62c46364bb3a7df4f254e8c"

View file

@ -72,6 +72,7 @@ types-python-jose = "^3.3.4.8"
openai = "^1.12.0"
json5 = "^0.9.17"
asgi-lifespan = "^2.1.0"
pytest-md = "^0.2.0"
[build-system]
requires = ["poetry-core>=1.0.0"]