-
-
Notifications
You must be signed in to change notification settings - Fork 263
90 lines (72 loc) · 2.65 KB
/
coverage-to-pages.yml
File metadata and controls
90 lines (72 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
name: Code Coverage → GitHub Pages
on:
push:
branches: [main]
# Optional: Manuelles Triggern über die GitHub UI
workflow_dispatch:
# Sicherstellen, dass immer nur ein Deployment gleichzeitig läuft
concurrency:
group: pages
cancel-in-progress: true
permissions:
contents: read
pages: write
id-token: write
jobs:
coverage:
name: Generate Coverage & Deploy
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.5'
extensions: mbstring, xml, dom
coverage: pcov
- name: Validate composer.json
run: composer validate --strict
- name: Cache Composer packages
uses: actions/cache@v5
with:
path: vendor
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --no-interaction --prefer-dist
- name: Run tests with coverage
run: |
php -dxdebug.mode=coverage phpmyfaq/src/libs/bin/phpunit \
--coverage-html build/coverage \
--coverage-clover build/coverage/clover.xml
# Optional: Coverage-Zusammenfassung in der GitHub Actions Summary anzeigen
- name: Coverage Summary
if: always()
run: |
if [ -f build/coverage/clover.xml ]; then
echo "## Code Coverage Report" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
# Gesamtabdeckung aus clover.xml extrahieren
COVERED=$(grep -oP 'coveredstatements="\K[0-9]+' build/coverage/clover.xml | tail -1)
TOTAL=$(grep -oP 'statements="\K[0-9]+' build/coverage/clover.xml | tail -1)
if [ -n "$COVERED" ] && [ -n "$TOTAL" ] && [ "$TOTAL" -gt 0 ]; then
PERCENT=$(awk "BEGIN { printf \"%.1f\", ($COVERED/$TOTAL)*100 }")
echo "**Gesamtabdeckung: ${PERCENT}%** (${COVERED}/${TOTAL} Statements)" >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "📊 [Vollständiger Report](${{ steps.deployment.outputs.page_url }})" >> $GITHUB_STEP_SUMMARY
fi
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v4
with:
path: build/coverage
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4