Update .gitea/workflows/test.yml
Run Pytest with HTML and XML Test Reports / tests (push) Successful in 22s

This commit is contained in:
2025-07-15 14:23:10 +02:00
parent f145ca6b5a
commit b080250370
+21 -32
View File
@@ -1,4 +1,4 @@
name: Run Pytest with Allure and Coverage Reports
name: Run Pytest with HTML and XML Test Reports
on:
push:
@@ -53,7 +53,7 @@ jobs:
exit 1
}
pip install pytest pytest-cov coverage pytest-md-report > pip.log 2>&1 || {
pip install pytest pytest-cov pytest-html pytest-md-report > pip.log 2>&1 || {
echo "❌ Python testing tools install failed"
cat pip.log | grep -i 'error\|fatal'
exit 1
@@ -66,58 +66,47 @@ jobs:
run: |
echo "🚀 Running tests and generating reports..."
source venv/bin/activate
mkdir -p ci-reports/{coverage,markdown}
mkdir -p ci-reports/{markdown,html,xml}
echo "🧪 Running pytest with coverage and report generation..."
echo "🧪 Running pytest with HTML, XML, and JSON report generation..."
pixi run pytest . \
--continue-on-collection-errors \
--cov=functions \
--cov-report=xml:ci-reports/coverage/coverage.xml \
--cov-report=html:ci-reports/coverage/ \
--json-report \
--json-report-file=ci-reports/markdown/pytest-report.json \
--html=ci-reports/html/pytest-report.html \
--junitxml=ci-reports/xml/pytest-report.xml \
--capture=no > ci-reports/markdown/raw-test-output.log 2>&1 && {
echo "✅ Pytest completed"
echo ""
echo "📄 Markdown: ci-reports/markdown/test-report.md"
echo ""
echo "📦 JSON: ci-reports/markdown/pytest.json"
echo "📄 HTML: ci-reports/html/pytest-report.html"
echo "📄 XML: ci-reports/xml/pytest-report.xml"
echo "📦 JSON: ci-reports/markdown/pytest-report.json"
} || {
echo ""
echo "⚠️ Some tests failed"
awk '/=+ short test summary info =+/,/=+.* in .*s =+/' ci-reports/markdown/raw-test-output.log || true
#cat ci-reports/markdown/raw-test-output.log
}
echo ""
echo "📈 Generating coverage summary..."
coverage report --format=markdown > ci-reports/markdown/coverage-summary.md && {
echo "✅ Coverage summary generated"
echo "📊 Generating tests markdown summary..."
python json_to_md.py \
--input ci-reports/markdown/pytest-report.json \
--output ci-reports/markdown/TEST-REPORT.md \
--log ci-reports/markdown/raw-test-output.log \
--json ci-reports/markdown/pytest-report.json && {
echo "✅ Tests markdown generated"
} || {
echo "⚠️ Coverage generation failed"
}
{
echo ""
echo "📊 Generating tests markdown summary..."
python json_to_md.py \
--input ci-reports/markdown/pytest-report.json \
--output ci-reports/markdown/TEST-REPORT.md \
--log ci-reports/markdown/raw-test-output.log \
--json ci-reports/markdown/pytest-report.json
echo "✅ Tests markdown generated"
} || {
echo "⚠️ Tests markdown generation failed"
echo "⚠️ Tests markdown generation failed"
}
- name: Commit and push reports
run: |
echo "📤 Committing test & coverage reports to slic.git..."
echo "📤 Committing all test reports to slic.git..."
git config user.name "ci-bot"
git config user.email "ci-bot@example.com"
git add ci-reports/markdown/TEST-REPORT.md ci-reports/markdown/pytest-report.json ci-reports/markdown/coverage-summary.md
git commit -m "CI: update test and coverage reports" || echo "⚠️ Nothing to commit"
git add ci-reports/
git commit -m "CI: update all test reports (HTML, XML, JSON, MD)" || echo "⚠️ Nothing to commit"
echo "🚀 Pushing to branch 'testing_json' on slic.git..."
git push https://ci-token:${{ secrets.CI_TOKEN }}@gitea.psi.ch/tligui_y/slic.git HEAD:testing_json > push_main.log 2>&1 || {
@@ -127,4 +116,4 @@ jobs:
}
echo "✅ Reports pushed to https://gitea.psi.ch/tligui_y/slic/ci-reports/"
env:
CI_TOKEN: ${{ secrets.CI_TOKEN }}
CI_TOKEN: ${{ secrets.CI_TOKEN }}