This commit is contained in:
parent
d40fcfe084
commit
2b1170cac7
@ -36,12 +36,15 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
echo "Downloading initial failed badges..."
|
echo "Downloading initial failed badges..."
|
||||||
|
|
||||||
|
# Create cov_info directory first
|
||||||
|
mkdir -p cov_info
|
||||||
|
|
||||||
# Download failed badges as defaults
|
# Download failed badges as defaults
|
||||||
curl -o coverage.svg "https://img.shields.io/badge/coverage-failed-red.svg"
|
curl -o cov_info/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"
|
curl -o cov_info/coverage-docs.svg "https://img.shields.io/badge/docs-failed-red.svg"
|
||||||
|
|
||||||
echo "Initial failed badges created:"
|
echo "Initial failed badges created:"
|
||||||
ls -la coverage*.svg
|
ls -la cov_info/coverage*.svg
|
||||||
|
|
||||||
- name: Run tests with pytest
|
- name: Run tests with pytest
|
||||||
id: pytest
|
id: pytest
|
||||||
@ -64,13 +67,19 @@ jobs:
|
|||||||
# Exit-zero treats all errors as warnings
|
# Exit-zero treats all errors as warnings
|
||||||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
||||||
|
|
||||||
|
- name: Create coverage info directory
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
mkdir -p cov_info
|
||||||
|
echo "Created cov_info directory for coverage data"
|
||||||
|
|
||||||
- name: Update test coverage badge on success
|
- name: Update test coverage badge on success
|
||||||
if: steps.pytest.outcome == 'success' && always()
|
if: steps.pytest.outcome == 'success' && always()
|
||||||
run: |
|
run: |
|
||||||
echo "Tests passed! Generating successful coverage badge..."
|
echo "Tests passed! Generating successful coverage badge..."
|
||||||
|
|
||||||
if [ -f coverage.json ]; then
|
if [ -f coverage.json ]; then
|
||||||
coverage-badge -o coverage.svg -f
|
coverage-badge -o cov_info/coverage.svg -f
|
||||||
echo "✅ Test coverage badge updated with actual results"
|
echo "✅ Test coverage badge updated with actual results"
|
||||||
else
|
else
|
||||||
echo "⚠️ No coverage.json found, keeping failed badge"
|
echo "⚠️ No coverage.json found, keeping failed badge"
|
||||||
@ -82,8 +91,8 @@ jobs:
|
|||||||
echo "Docs check passed! Generating successful docs badge..."
|
echo "Docs check passed! Generating successful docs badge..."
|
||||||
|
|
||||||
# Remove existing badge first to avoid overwrite error
|
# Remove existing badge first to avoid overwrite error
|
||||||
rm -f coverage-docs.svg
|
rm -f cov_info/coverage-docs.svg
|
||||||
interrogate --generate-badge coverage-docs.svg pyWebLayout/
|
interrogate --generate-badge cov_info/coverage-docs.svg pyWebLayout/
|
||||||
echo "✅ Docs coverage badge updated with actual results"
|
echo "✅ Docs coverage badge updated with actual results"
|
||||||
|
|
||||||
- name: Generate coverage reports
|
- name: Generate coverage reports
|
||||||
@ -98,8 +107,8 @@ jobs:
|
|||||||
with open('coverage.json', 'r') as f:
|
with open('coverage.json', 'r') as f:
|
||||||
coverage_data = json.load(f)
|
coverage_data = json.load(f)
|
||||||
total_coverage = round(coverage_data['totals']['percent_covered'], 1)
|
total_coverage = round(coverage_data['totals']['percent_covered'], 1)
|
||||||
# Create coverage summary file
|
# Create coverage summary file in cov_info directory
|
||||||
with open('coverage-summary.txt', 'w') as f:
|
with open('cov_info/coverage-summary.txt', 'w') as f:
|
||||||
f.write(f'{total_coverage}%')
|
f.write(f'{total_coverage}%')
|
||||||
print(f'Test Coverage: {total_coverage}%')
|
print(f'Test Coverage: {total_coverage}%')
|
||||||
covered_lines = coverage_data['totals']['covered_lines']
|
covered_lines = coverage_data['totals']['covered_lines']
|
||||||
@ -109,6 +118,11 @@ jobs:
|
|||||||
print('No coverage data found')
|
print('No coverage data found')
|
||||||
"
|
"
|
||||||
|
|
||||||
|
# Copy other coverage files to cov_info
|
||||||
|
if [ -f coverage.json ]; then cp coverage.json cov_info/; fi
|
||||||
|
if [ -f coverage.xml ]; then cp coverage.xml cov_info/; fi
|
||||||
|
if [ -d htmlcov ]; then cp -r htmlcov cov_info/; fi
|
||||||
|
|
||||||
- name: Final badge status
|
- name: Final badge status
|
||||||
if: always()
|
if: always()
|
||||||
run: |
|
run: |
|
||||||
@ -116,48 +130,30 @@ jobs:
|
|||||||
echo "Test outcome: ${{ steps.pytest.outcome }}"
|
echo "Test outcome: ${{ steps.pytest.outcome }}"
|
||||||
echo "Docs outcome: ${{ steps.docs.outcome }}"
|
echo "Docs outcome: ${{ steps.docs.outcome }}"
|
||||||
|
|
||||||
if [ -f coverage.svg ]; then
|
if [ -f cov_info/coverage.svg ]; then
|
||||||
echo "✅ Test coverage badge: $(ls -lh coverage.svg)"
|
echo "✅ Test coverage badge: $(ls -lh cov_info/coverage.svg)"
|
||||||
else
|
else
|
||||||
echo "❌ Test coverage badge: MISSING"
|
echo "❌ Test coverage badge: MISSING"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f coverage-docs.svg ]; then
|
if [ -f cov_info/coverage-docs.svg ]; then
|
||||||
echo "✅ Docs coverage badge: $(ls -lh coverage-docs.svg)"
|
echo "✅ Docs coverage badge: $(ls -lh cov_info/coverage-docs.svg)"
|
||||||
else
|
else
|
||||||
echo "❌ Docs coverage badge: MISSING"
|
echo "❌ Docs coverage badge: MISSING"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "All SVG files:"
|
echo "Coverage info directory contents:"
|
||||||
ls -la *.svg 2>/dev/null || echo "No SVG files found"
|
ls -la cov_info/ 2>/dev/null || echo "No cov_info directory 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
|
cov_info/
|
||||||
coverage-docs.svg
|
|
||||||
htmlcov/
|
|
||||||
coverage.json
|
|
||||||
coverage.xml
|
|
||||||
coverage-summary.txt
|
|
||||||
|
|
||||||
- name: Safety check - prevent infinite loops
|
- name: Commit badges to badges branch
|
||||||
if: github.ref == 'refs/heads/master'
|
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: |
|
run: |
|
||||||
git config --local user.email "action@gitea.local"
|
git config --local user.email "action@gitea.local"
|
||||||
git config --local user.name "Gitea Action"
|
git config --local user.name "Gitea Action"
|
||||||
@ -165,15 +161,24 @@ jobs:
|
|||||||
# Set the remote URL to use the token
|
# Set the remote URL to use the token
|
||||||
git remote set-url origin https://${{ secrets.PUSH_TOKEN }}@gitea.tourolle.paris/dtourolle/pyWebLayout.git
|
git remote set-url origin https://${{ secrets.PUSH_TOKEN }}@gitea.tourolle.paris/dtourolle/pyWebLayout.git
|
||||||
|
|
||||||
# Force add the SVG files (ignore .gitignore)
|
# Create or switch to badges branch
|
||||||
git add -f coverage.svg coverage-docs.svg
|
git fetch origin badges:badges 2>/dev/null || git checkout --orphan badges
|
||||||
|
if git show-ref --verify --quiet refs/heads/badges; then
|
||||||
|
git checkout badges
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Remove all files except cov_info
|
||||||
|
git rm -rf . 2>/dev/null || true
|
||||||
|
|
||||||
|
# Add the coverage info directory
|
||||||
|
git add -f cov_info/
|
||||||
|
|
||||||
if git diff --staged --quiet; then
|
if git diff --staged --quiet; then
|
||||||
echo "No badge changes to commit"
|
echo "No badge changes to commit"
|
||||||
else
|
else
|
||||||
echo "Committing updated badges..."
|
echo "Committing updated badges to badges branch..."
|
||||||
git commit -m "Update coverage badges [skip ci]"
|
git commit -m "Update coverage badges [skip ci]"
|
||||||
git push origin HEAD:master
|
git push origin badges
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Test package installation
|
- name: Test package installation
|
||||||
|
|||||||
@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
| 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 |
|
||||||
|  | **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