Delete .gitea/workflow/test.yml

This commit is contained in:
2025-07-21 14:47:47 +02:00
parent c8cd70cb2a
commit a9bb6e4827
-266
View File
@@ -1,266 +0,0 @@
name: Pytest CI Workflow
description: Run pytest with coverage and report upload to Gitea
inputs:
ci-branch:
description: 'Target branch where test reports will be committed'
required: true
module-dir:
description: 'Directory (folder) containing the Python module to test'
required: true
report-dir:
description: 'Directory (folder) where all test and coverage reports will be saved'
required: true
gitea-domain:
description: 'Domain name of your Gitea instance without protocol (e.g., gitea.psi.ch)'
required: true
repo-path:
description: 'Relative path to the root of your repository'
required: true
ci-token:
description: '🔐 CI authentication token (used for pushing to Gitea)'
required: true
runs:
using: "composite"
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Show checked out files
shell: bash
run: |
echo "📂 Files in repo root:"
ls -1
- name: Install Pixi & project dependencies
shell: bash
run: |
echo "🔧 Installing Pixi..."
curl -fsSL https://pixi.sh/install.sh | bash > pixi-download.log 2>&1 || {
echo "❌ Pixi download failed"
cat pixi-download.log
exit 1
}
echo "$HOME/.pixi/bin" >> $GITHUB_PATH
export PATH="$HOME/.pixi/bin:$PATH"
if [ ! -f "pixi.toml" ]; then
echo "❌ Missing pixi.toml at repo root : please add one to use Pixi"
exit 1
fi
echo "📦 Installing dependencies from pixi.toml..."
pixi install > pixi-install.log 2>&1 || {
echo "❌ Pixi project dependencies failed"
cat pixi-install.log
exit 1
}
echo "✅ Pixi installed and environment created"
pixi list
- name: Install Python test/report tools
shell: bash
run: |
echo "🐍 Setting up Python environment..."
python -m venv venv
source venv/bin/activate
pip install -U pip > pip.log 2>&1 || {
echo "❌ pip upgrade failed"
cat pip.log
exit 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
exit 1
}
echo "✅ Python tools installed"
pip list
- name: Run tests and generate reports
shell: bash
run: |
echo "🚀 Running tests and generating reports..."
source venv/bin/activate
mkdir -p ${{ inputs.report-dir }}/{allure,coverage,markdown}
set +e
echo "🧪 Running pytest with coverage and report generation..."
pixi run pytest . \
--continue-on-collection-errors \
--cov=${{ inputs.module-dir }} \
--cov-report=xml:${{ inputs.report-dir }}/coverage/coverage.xml \
--cov-report=html:${{ inputs.report-dir }}/coverage/ \
--json-report \
--json-report-file=${{ inputs.report-dir }}/markdown/pytest-report.json \
--capture=no > ${{ inputs.report-dir }}/markdown/raw-test-output.log 2>&1
exit_code=$?
echo ""
echo "📋 Short test summary:"
awk '/=+ short test summary info =+/,/=+.* in .*s =+/' ${{ inputs.report-dir }}/markdown/raw-test-output.log || true
echo "📦 Pytest exit code: $exit_code"
if [ "$exit_code" -eq 0 ] || [ "$exit_code" -eq 1 ]; then
echo "✅ Pytest completed successfully (code $exit_code)"
else
echo "❌ Pytest failed (code $exit_code)"
fi
set -e
- name: Commit and push reports
shell: bash
run: |
echo "📤 Committing test reports..."
git config user.name "ci-bot"
git config user.email "ci-bot@example.com"
git add ${{ inputs.report-dir }}/
git commit -m "CI: update test report and coverage files" || echo "⚠️ Nothing to commit"
echo "🚀 Pushing to branch '${{ inputs.ci-branch }}'..."
git push https://ci-token:${{ inputs.ci-token }}@${{ inputs.gitea-domain }}/${{ inputs.repo-path }}.git HEAD:${{ inputs.ci-branch }} > push.log 2>&1 || {
echo "❌ Push failed"
cat push.log
exit 1
}
echo "✅ Reports pushed"
- name: Deploy Allure report to gitea-pages
shell: bash
run: |
echo "📚 Cloning gitea-pages branch..."
git clone --branch gitea-pages https://ci-token:${{ inputs.ci-token }}@${{ inputs.gitea-domain }}/${{ inputs.repo-path }}.git gitea-pages
echo "🗑 Cleaning old report files..."
rm -rf gitea-pages/* || true
echo "📂 Copying new allure files..."
cp -r ${{ inputs.report-dir }}/allure/* gitea-pages/
cd gitea-pages
git config user.name "ci-bot"
git config user.email "ci-bot@example.com"
git add .
git commit -m "Update Allure report" || echo "⚠️ Nothing to commit"
echo "🚀 Pushing to gitea-pages..."
git push origin gitea-pages
- name: Get commit info
id: info
shell: bash
run: |
short_sha=$(git rev-parse --short HEAD)
commit_msg=$(git log -1 --pretty=%B)
echo "🔍 Commit SHA: $short_sha"
echo "🔍 Commit message: $commit_msg"
echo "short_sha=$short_sha" >> $GITHUB_OUTPUT
echo "commit_msg=$commit_msg" >> $GITHUB_OUTPUT
- name: Clone Gitea Wiki
shell: bash
env:
CI_TOKEN: ${{ inputs.ci-token }}
run: |
REPO_NAME="${{ github.repository }}"
DOMAIN="${{ inputs.gitea-domain }}"
WIKI_REPO="https://ci-token:${CI_TOKEN}@${DOMAIN}/${REPO_NAME}.wiki.git"
echo "📚 Cloning wiki repo: $WIKI_REPO"
git clone "$WIKI_REPO" wiki > wiki_clone.log 2>&1 || {
echo "❌ Wiki clone failed"
cat wiki_clone.log
exit 1
}
echo "✅ Wiki cloned to ./wiki"
- name: Copy reports into wiki
shell: bash
run: |
SHORT_SHA=$(git rev-parse --short HEAD)
REPO_URL="https://${{ inputs.gitea-domain }}/${{ github.repository }}"
RUN_LINK="${REPO_URL}/actions/runs/${GITHUB_RUN_NUMBER}"
TEST_FILE="run-${GITHUB_RUN_NUMBER}-TEST-commit-${SHORT_SHA}.md"
COVERAGE_FILE="run-${GITHUB_RUN_NUMBER}-COVERAGE-commit-${SHORT_SHA}.md"
echo "## Test Report" > "wiki/${TEST_FILE}"
echo "[View CI Run ${GITHUB_RUN_NUMBER}](${RUN_LINK}) | [Commit ${SHORT_SHA}](${REPO_URL}/commit/${SHORT_SHA})" >> "wiki/${TEST_FILE}"
cat ${{ inputs.report-dir }}/markdown/TEST-REPORT.md >> "wiki/${TEST_FILE}"
echo "## Coverage Report" > "wiki/${COVERAGE_FILE}"
echo "[View CI Run ${GITHUB_RUN_NUMBER}](${RUN_LINK}) | [Commit ${SHORT_SHA}](${REPO_URL}/commit/${SHORT_SHA})" >> "wiki/${COVERAGE_FILE}"
cat ${{ inputs.report-dir }}/markdown/coverage-summary.md >> "wiki/${COVERAGE_FILE}"
HOME_FILE="wiki/Home.md"
TEMP_CONTENT=$(mktemp)
REPORT_LOG="reports.log"
{
echo "# Test Reports History"
echo ""
echo "## Latest Run"
echo "- [run ${GITHUB_RUN_NUMBER} TEST commit ${SHORT_SHA}](${TEST_FILE})"
echo "- [run ${GITHUB_RUN_NUMBER} COVERAGE commit ${SHORT_SHA}](${COVERAGE_FILE})"
echo ""
echo "## Previous Runs"
if [[ -f "${HOME_FILE}" && -s "${HOME_FILE}" ]]; then
sed -n '/## Latest Run/{n;p;n;p}' "${HOME_FILE}"
sed -n '/## Previous Runs/,$p' "${HOME_FILE}" | tail -n +2 | grep -v "^#" || true
fi
} > "${TEMP_CONTENT}" 2> "${REPORT_LOG}" || {
echo "❌ Report preparation failed"
cat "${REPORT_LOG}"
exit 1
}
mv "${TEMP_CONTENT}" "${HOME_FILE}"
- name: Commit and push wiki
shell: bash
env:
CI_TOKEN: ${{ inputs.ci-token }}
run: |
echo "🚀 Pushing wiki changes..."
cd wiki
git config user.name "ci-bot"
git config user.email "ci-bot@example.com"
git add .
if git commit -m "Update wiki with run ${GITHUB_RUN_NUMBER}"; then
REPO_NAME="${{ github.repository }}"
DOMAIN="${{ inputs.gitea-domain }}"
WIKI_REPO="https://ci-token:${CI_TOKEN}@${DOMAIN}/${REPO_NAME}.wiki.git"
git push "$WIKI_REPO" HEAD:main
echo "✅ Wiki updated successfully"
else
echo "⚠️ No changes to commit"
fi
- name: Log wiki report URLs
shell: bash
run: |
REPO_URL="https://${{ inputs.gitea-domain }}/${{ github.repository }}"
SHORT_SHA=$(git rev-parse --short HEAD)
echo "🔗 Wiki Test Report URL:"
echo " ${REPO_URL}/wiki/run-${GITHUB_RUN_NUMBER}-TEST-commit-${SHORT_SHA}.md"
echo "🔗 Wiki Coverage Report URL:"
echo " ${REPO_URL}/wiki/run-${GITHUB_RUN_NUMBER}-COVERAGE-commit-${SHORT_SHA}.md"