This commit is contained in:
parent
a4accf4070
commit
099a1c9d5f
@ -3,6 +3,9 @@ name: Python CI
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ main, master, develop ]
|
branches: [ main, master, develop ]
|
||||||
|
paths-ignore:
|
||||||
|
- 'coverage*.svg'
|
||||||
|
- 'README.md'
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ main, master, develop ]
|
branches: [ main, master, develop ]
|
||||||
|
|
||||||
@ -29,12 +32,16 @@ jobs:
|
|||||||
# Install common test packages
|
# Install common test packages
|
||||||
pip install pytest pytest-cov flake8 coverage-badge interrogate
|
pip install pytest pytest-cov flake8 coverage-badge interrogate
|
||||||
|
|
||||||
- name: Lint with flake8
|
- name: Download initial failed badges
|
||||||
run: |
|
run: |
|
||||||
# Stop the build if there are Python syntax errors or undefined names
|
echo "Downloading initial failed badges..."
|
||||||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
|
||||||
# Exit-zero treats all errors as warnings
|
# Download failed badges as defaults
|
||||||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
curl -o coverage.svg "https://img.shields.io/badge/coverage-failed-red.svg"
|
||||||
|
curl -o coverage-docs.svg "https://img.shields.io/badge/docs-failed-red.svg"
|
||||||
|
|
||||||
|
echo "Initial failed badges created:"
|
||||||
|
ls -la coverage*.svg
|
||||||
|
|
||||||
- name: Run tests with pytest
|
- name: Run tests with pytest
|
||||||
id: pytest
|
id: pytest
|
||||||
@ -50,40 +57,32 @@ jobs:
|
|||||||
# Generate documentation coverage report
|
# Generate documentation coverage report
|
||||||
interrogate -v --ignore-init-method --ignore-init-module --ignore-magic --ignore-private --ignore-property-decorators --ignore-semiprivate --fail-under=80 pyWebLayout/
|
interrogate -v --ignore-init-method --ignore-init-module --ignore-magic --ignore-private --ignore-property-decorators --ignore-semiprivate --fail-under=80 pyWebLayout/
|
||||||
|
|
||||||
- name: Generate coverage badges
|
- name: Lint with flake8
|
||||||
run: |
|
run: |
|
||||||
COMMIT_HASH=$(git rev-parse --short HEAD)
|
# Stop the build if there are Python syntax errors or undefined names
|
||||||
echo "Generating badges for commit: ${COMMIT_HASH}"
|
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
||||||
|
# Exit-zero treats all errors as warnings
|
||||||
|
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
||||||
|
|
||||||
# Generate test coverage badge or error badge
|
- name: Update test coverage badge on success
|
||||||
if [ "${{ steps.pytest.outcome }}" == "success" ] && [ -f coverage.json ]; then
|
if: steps.pytest.outcome == 'success' && always()
|
||||||
echo "Generating successful test coverage badge..."
|
run: |
|
||||||
coverage-badge -o coverage-${COMMIT_HASH}.svg
|
echo "Tests passed! Generating successful coverage badge..."
|
||||||
echo "Test coverage badge created: coverage-${COMMIT_HASH}.svg"
|
|
||||||
|
if [ -f coverage.json ]; then
|
||||||
|
coverage-badge -o coverage.svg
|
||||||
|
echo "✅ Test coverage badge updated with actual results"
|
||||||
else
|
else
|
||||||
echo "Generating error badge for test coverage (pytest outcome: ${{ steps.pytest.outcome }})"
|
echo "⚠️ No coverage.json found, keeping failed badge"
|
||||||
curl -o coverage-${COMMIT_HASH}.svg "https://img.shields.io/badge/coverage-error-red.svg"
|
|
||||||
echo "Error test coverage badge created: coverage-${COMMIT_HASH}.svg"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Generate docs coverage badge or error badge
|
- name: Update docs coverage badge on success
|
||||||
if [ "${{ steps.docs.outcome }}" == "success" ]; then
|
if: steps.docs.outcome == 'success' && always()
|
||||||
echo "Generating successful docs coverage badge..."
|
run: |
|
||||||
interrogate --generate-badge coverage-docs-${COMMIT_HASH}.svg pyWebLayout/
|
echo "Docs check passed! Generating successful docs badge..."
|
||||||
echo "Docs coverage badge created: coverage-docs-${COMMIT_HASH}.svg"
|
|
||||||
else
|
|
||||||
echo "Generating error badge for docs coverage (docs outcome: ${{ steps.docs.outcome }})"
|
|
||||||
curl -o coverage-docs-${COMMIT_HASH}.svg "https://img.shields.io/badge/docs-error-red.svg"
|
|
||||||
echo "Error docs coverage badge created: coverage-docs-${COMMIT_HASH}.svg"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# List all SVG files created
|
interrogate --generate-badge coverage-docs.svg pyWebLayout/
|
||||||
echo "SVG files in directory:"
|
echo "✅ Docs coverage badge updated with actual results"
|
||||||
ls -la *.svg || echo "No SVG files found"
|
|
||||||
echo "Current working directory:"
|
|
||||||
pwd
|
|
||||||
echo "All files in current directory:"
|
|
||||||
ls -la
|
|
||||||
|
|
||||||
- name: Generate coverage reports
|
- name: Generate coverage reports
|
||||||
if: steps.pytest.outcome == 'success'
|
if: steps.pytest.outcome == 'success'
|
||||||
@ -105,28 +104,70 @@ jobs:
|
|||||||
print('No coverage data found')
|
print('No coverage data found')
|
||||||
"
|
"
|
||||||
|
|
||||||
- name: Debug artifacts before upload
|
- name: Final badge status
|
||||||
|
if: always()
|
||||||
run: |
|
run: |
|
||||||
echo "Files matching coverage patterns:"
|
echo "=== FINAL BADGE STATUS ==="
|
||||||
ls -la coverage-*.svg || echo "No coverage-*.svg files found"
|
echo "Test outcome: ${{ steps.pytest.outcome }}"
|
||||||
ls -la coverage-docs-*.svg || echo "No coverage-docs-*.svg files found"
|
echo "Docs outcome: ${{ steps.docs.outcome }}"
|
||||||
ls -la coverage.json || echo "No coverage.json found"
|
|
||||||
ls -la coverage-summary.txt || echo "No coverage-summary.txt found"
|
if [ -f coverage.svg ]; then
|
||||||
ls -la htmlcov/ || echo "No htmlcov directory found"
|
echo "✅ Test coverage badge: $(ls -lh coverage.svg)"
|
||||||
echo "All files in current directory:"
|
else
|
||||||
ls -la
|
echo "❌ Test coverage badge: MISSING"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f coverage-docs.svg ]; then
|
||||||
|
echo "✅ Docs coverage badge: $(ls -lh coverage-docs.svg)"
|
||||||
|
else
|
||||||
|
echo "❌ Docs coverage badge: MISSING"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "All SVG files:"
|
||||||
|
ls -la *.svg 2>/dev/null || echo "No SVG files found"
|
||||||
|
|
||||||
- name: Upload coverage artifacts
|
- name: Upload coverage artifacts
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: coverage-reports
|
name: coverage-reports
|
||||||
path: |
|
path: |
|
||||||
coverage-*.svg
|
coverage.svg
|
||||||
coverage-docs-*.svg
|
coverage-docs.svg
|
||||||
htmlcov/
|
htmlcov/
|
||||||
coverage.json
|
coverage.json
|
||||||
coverage-summary.txt
|
coverage-summary.txt
|
||||||
|
|
||||||
|
- name: Safety check - prevent infinite loops
|
||||||
|
if: github.ref == 'refs/heads/master'
|
||||||
|
run: |
|
||||||
|
# Check if this is a CI-generated commit
|
||||||
|
LAST_COMMIT_MSG=$(git log -1 --pretty=%B)
|
||||||
|
if [[ "$LAST_COMMIT_MSG" == *"[skip ci]"* ]] || [[ "$LAST_COMMIT_MSG" == *"Update coverage badges"* ]]; then
|
||||||
|
echo "Last commit was CI-generated, skipping badge update to prevent loops"
|
||||||
|
echo "SKIP_BADGE_COMMIT=true" >> $GITHUB_ENV
|
||||||
|
else
|
||||||
|
echo "Safe to update badges"
|
||||||
|
echo "SKIP_BADGE_COMMIT=false" >> $GITHUB_ENV
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Commit badges to repository
|
||||||
|
if: github.ref == 'refs/heads/master' && env.SKIP_BADGE_COMMIT != 'true'
|
||||||
|
run: |
|
||||||
|
git config --local user.email "action@gitea.local"
|
||||||
|
git config --local user.name "Gitea Action"
|
||||||
|
|
||||||
|
# Force add the SVG files (ignore .gitignore)
|
||||||
|
git add -f coverage.svg coverage-docs.svg
|
||||||
|
|
||||||
|
if git diff --staged --quiet; then
|
||||||
|
echo "No badge changes to commit"
|
||||||
|
else
|
||||||
|
echo "Committing updated badges..."
|
||||||
|
git commit -m "Update coverage badges [skip ci]"
|
||||||
|
# Use personal access token for push
|
||||||
|
git push https://${{ secrets.PUSH_TOKEN }}@gitea.tourolle.paris/dtourolle/pyWebLayout.git HEAD:master
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Test package installation
|
- name: Test package installation
|
||||||
run: |
|
run: |
|
||||||
# Test that the package can be imported
|
# Test that the package can be imported
|
||||||
|
|||||||
@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
## Project Status
|
## Project Status
|
||||||
|
|
||||||
|
|
||||||
| Badge | Description |
|
| Badge | Description |
|
||||||
|-------|-------------|
|
|-------|-------------|
|
||||||
|  | **Test Coverage** - Percentage of code covered by unit tests |
|
|  | **Test Coverage** - Percentage of code covered by unit tests |
|
||||||
|  | **Documentation Coverage** - Percentage of code with docstrings |
|
|  | **Documentation Coverage** - Percentage of code with docstrings |
|
||||||
|  | **Build Status** - Current CI/CD pipeline status |
|
|
||||||
|  | **License** - Project licensing information |
|
|  | **License** - Project licensing information |
|
||||||
A Python library for HTML-like layout and rendering.
|
A Python library for HTML-like layout and rendering.
|
||||||
> 📋 **Note**: Badges show results from the commit referenced in the URLs. Red "error" badges indicate build failures for that specific step.
|
> 📋 **Note**: Badges show results from the commit referenced in the URLs. Red "error" badges indicate build failures for that specific step.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user