Update .gitea/workflows/test.yml
This commit is contained in:
+56
-63
@@ -1,10 +1,10 @@
|
||||
name: Run Pytest with Allure and Coverage Reports
|
||||
name: Run Pytest with HTML and XML Test Reports
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [utils_testing]
|
||||
branches: [testing_json]
|
||||
pull_request:
|
||||
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -18,7 +18,7 @@ jobs:
|
||||
- name: Show checked out files
|
||||
run: |
|
||||
echo "📂 Files in repo root:"
|
||||
ls -1 | head -n 20
|
||||
ls -1
|
||||
|
||||
- name: Install Pixi & project dependencies
|
||||
run: |
|
||||
@@ -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 rich > pip.log 2>&1 || {
|
||||
echo "❌ Python testing tools install failed"
|
||||
cat pip.log | grep -i 'error\|fatal'
|
||||
exit 1
|
||||
@@ -62,30 +62,9 @@ jobs:
|
||||
echo "✅ Python tools installed"
|
||||
pip list
|
||||
|
||||
- name: Install Java
|
||||
- name: 🧪 Extract Pytest Parameters
|
||||
run: |
|
||||
echo "☕ Installing Java..."
|
||||
sudo apt update > java.log 2>&1 && sudo apt install -y openjdk-11-jdk >> java.log 2>&1 || {
|
||||
echo "❌ Java installation failed"
|
||||
cat java.log | grep -i 'error\|fatal'
|
||||
exit 1
|
||||
}
|
||||
echo "✅ Java installed"
|
||||
java -version
|
||||
|
||||
- name: Install Allure CLI
|
||||
run: |
|
||||
echo "📊 Installing Allure..."
|
||||
curl -sL https://github.com/allure-framework/allure2/releases/download/2.27.0/allure-2.27.0.tgz | tar -xz > allure.log 2>&1 || {
|
||||
echo "❌ Allure download failed"
|
||||
cat allure.log | grep -i 'error\|fatal'
|
||||
exit 1
|
||||
}
|
||||
|
||||
sudo mv allure-2.27.0 /opt/allure
|
||||
sudo ln -s /opt/allure/bin/allure /usr/local/bin/allure
|
||||
echo "✅ Allure installed"
|
||||
allure --version
|
||||
python log_all_test_params.py
|
||||
|
||||
- name: Run tests and generate reports
|
||||
run: |
|
||||
@@ -93,64 +72,78 @@ jobs:
|
||||
source venv/bin/activate
|
||||
mkdir -p ci-reports/{allure,coverage,markdown}
|
||||
|
||||
set +e
|
||||
|
||||
echo "🧪 Running pytest with coverage and report generation..."
|
||||
pixi run pytest . \
|
||||
--cov=slic \
|
||||
--continue-on-collection-errors \
|
||||
--cov=functions \
|
||||
--cov-report=xml:ci-reports/coverage/coverage.xml \
|
||||
--cov-report=html:ci-reports/coverage/ \
|
||||
--alluredir=allure-results \
|
||||
--json-report \
|
||||
--json-report-file=ci-reports/markdown/pytest-report.json \
|
||||
--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 ""
|
||||
echo "⚠️ Some tests failed"
|
||||
tail -n 20 ci-reports/markdown/raw-test-output.log | grep -i 'error\|fail' || true
|
||||
}
|
||||
--capture=no > ci-reports/markdown/raw-test-output.log 2>&1
|
||||
|
||||
echo ""
|
||||
echo "📊 Generating Allure report..."
|
||||
allure generate allure-results -o ci-reports/allure --clean > /dev/null 2>&1 && {
|
||||
echo "✅ Allure report generated"
|
||||
} || {
|
||||
echo "⚠️ Allure generation failed"
|
||||
}
|
||||
exit_code=$?
|
||||
|
||||
set -e
|
||||
|
||||
echo "📦 Pytest exit code: $exit_code"
|
||||
|
||||
echo ""
|
||||
echo "📈 Generating coverage summary..."
|
||||
coverage report --format=markdown > ci-reports/markdown/coverage-summary.md && {
|
||||
coverage report --format=markdown > ci-reports/markdown/coverage-summary.md 2> ci-reports/markdown/coverage-error.log && {
|
||||
echo "✅ Coverage summary generated"
|
||||
} || {
|
||||
echo "⚠️ Coverage generation failed"
|
||||
echo "⚠️ Coverage summary generation failed"
|
||||
echo "🪵 Extracting coverage error:"
|
||||
cat ci-reports/markdown/coverage-error.log | grep -i 'error\|fatal' || echo "No matching error lines"
|
||||
}
|
||||
|
||||
{
|
||||
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 \
|
||||
--allure-dir ci-reports/allure/data/test-cases
|
||||
echo "✅ Tests markdown generated"
|
||||
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 \
|
||||
--exit-code $exit_code > ci-reports/markdown/md-report.log 2>&1 && {
|
||||
echo "✅ Tests markdown generated"
|
||||
} || {
|
||||
echo "⚠️ Tests markdown generation failed"
|
||||
echo "⚠️ Tests markdown generation failed"
|
||||
echo "🪵 Extracting markdown generation error:"
|
||||
cat ci-reports/markdown/md-report.log | grep -i 'error\|fatal\|traceback' || echo "No matching error lines"
|
||||
}
|
||||
|
||||
echo ""
|
||||
echo "🌳 Generating JSON tree view..."
|
||||
python json_to_tree.py ci-reports/markdown/pytest-report.json > ci-reports/markdown/json-tree-gen.log 2>&1 && {
|
||||
echo "✅ JSON tree view generated"
|
||||
} || {
|
||||
echo "❌ JSON tree generation failed"
|
||||
cat ci-reports/markdown/json-tree-gen.log | grep -i 'error\|fatal\|traceback' || echo "No matching error lines"
|
||||
}
|
||||
|
||||
echo "🧹 Cleaning up ci-reports/markdown..."
|
||||
find ci-reports/markdown -type f ! \( \
|
||||
-name 'coverage-summary.md' -o \
|
||||
-name 'json-tree-view.txt' -o \
|
||||
-name 'pytest-report.json' -o \
|
||||
-name 'TEST-REPORT.md' \
|
||||
\) -delete
|
||||
|
||||
echo "✅ Kept only coverage-summary.md, json-tree-view.txt, pytest-report.json, TEST-REPORT.md"
|
||||
|
||||
- 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/
|
||||
git commit -m "CI: update test and coverage reports" || echo "⚠️ Nothing to commit"
|
||||
git commit -m "CI: update test report and coverage files" || echo "⚠️ Nothing to commit"
|
||||
|
||||
echo "🚀 Pushing to branch 'utils_testing' on slic.git..."
|
||||
git push https://ci-token:${{ secrets.CI_TOKEN }}@gitea.psi.ch/tligui_y/slic.git HEAD:utils_testing > push_main.log 2>&1 || {
|
||||
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 || {
|
||||
echo "❌ Push to main repo failed"
|
||||
cat push_main.log | grep -i 'error\|fatal\|refused'
|
||||
exit 1
|
||||
|
||||
Reference in New Issue
Block a user