Update .gitea/workflows/test.yml
Run Pytest with Allure and Coverage Reports / tests (push) Successful in 53s
Run Pytest with Allure and Coverage Reports / tests (push) Successful in 53s
This commit is contained in:
@@ -41,51 +41,22 @@ jobs:
|
||||
pip install coverage pytest-html pytest-cov
|
||||
echo "VIRTUAL_ENV=$HOME/venv" >> $GITHUB_ENV
|
||||
|
||||
- name: Run tests with coverage and generate reports
|
||||
- name: Run tests with coverage and generate reports
|
||||
run: |
|
||||
export PATH="$HOME/.pixi/bin:$PATH"
|
||||
source "$VIRTUAL_ENV/bin/activate"
|
||||
|
||||
mkdir -p ci-reports/{allure,coverage,markdown}
|
||||
|
||||
|
||||
pixi run pytest --cov=slic \
|
||||
--cov-report=xml:ci-reports/coverage/coverage.xml \
|
||||
--cov-report=html:ci-reports/coverage/ \
|
||||
--alluredir=allure-results || true
|
||||
|
||||
allure generate allure-results -o ci-reports/allure --clean || true
|
||||
|
||||
# Coverage summary
|
||||
allure generate allure-results -o ci-reports/allure --clean || true
|
||||
coverage report --format=markdown > ci-reports/markdown/coverage-summary.md
|
||||
|
||||
# Test summary table by file
|
||||
python -c "
|
||||
import glob, json
|
||||
from collections import defaultdict
|
||||
|
||||
statuses = ['passed', 'failed', 'broken', 'skipped', 'unknown']
|
||||
results = defaultdict(lambda: defaultdict(int))
|
||||
|
||||
for f in glob.glob('allure-results/*-result.json'):
|
||||
with open(f) as j:
|
||||
data = json.load(j)
|
||||
status = data.get('status', 'unknown').lower()
|
||||
fname = data.get('fullName', 'unknown')
|
||||
test_file = next((part for part in fname.split('.') if part.startswith('test_')), 'unknown')
|
||||
results[test_file][status] += 1
|
||||
|
||||
# Create markdown table
|
||||
with open('ci-reports/markdown/test-summary.md', 'w') as out:
|
||||
out.write('# Test Summary by File\\n\\n')
|
||||
out.write('| File | Passed | Failed | Broken | Skipped | Unknown |\\n')
|
||||
out.write('|------|--------|--------|--------|---------|---------|\\n')
|
||||
for file in sorted(results):
|
||||
counts = results[file]
|
||||
row = [file]
|
||||
for s in statuses:
|
||||
row.append(str(counts.get(s, 0)))
|
||||
out.write('| ' + ' | '.join(row) + ' |\\n')
|
||||
"
|
||||
python generate_test_summary.py
|
||||
|
||||
- name: Commit and push reports
|
||||
run: |
|
||||
|
||||
Reference in New Issue
Block a user