-
Notifications
You must be signed in to change notification settings - Fork 0
191 lines (169 loc) · 7.82 KB
/
Copy pathcoverage.yml
File metadata and controls
191 lines (169 loc) · 7.82 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# This workflow generates and deploys code coverage reports
# It runs on a daily schedule (only if there were commits), or manually via workflow_dispatch
name: Code Coverage Report
on:
schedule:
- cron: '0 0 * * *' # Daily at midnight UTC
workflow_dispatch: # Allow manual trigger
# Optionally: push to main for immediate updates
# push:
# branches: [main]
jobs:
coverage:
runs-on: ubuntu-latest
permissions:
contents: write # Required: deploy coverage report to gh-pages
env:
DISPLAY: :0
MAVEN_OPTS: -Djava.awt.headless=true
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Check for recent commits (schedule only)
if: github.event_name == 'schedule'
id: check_commits
run: |
if git log --since="24 hours ago" --oneline | grep -q .; then
echo "has_commits=true" >> $GITHUB_OUTPUT
else
echo "has_commits=false" >> $GITHUB_OUTPUT
echo "No commits in the last 24 hours, skipping coverage build"
fi
- name: Set up JDK 21
if: github.event_name != 'schedule' || steps.check_commits.outputs.has_commits == 'true'
uses: actions/setup-java@v5
with:
java-version: '21'
distribution: 'temurin'
- name: Set up Node.js
if: github.event_name != 'schedule' || steps.check_commits.outputs.has_commits == 'true'
uses: actions/setup-node@v6
with:
node-version: '20'
- name: Install CSS tools for testing
if: github.event_name != 'schedule' || steps.check_commits.outputs.has_commits == 'true'
run: |
npm install -g prettier stylelint stylelint-config-standard
- name: Install Xvfb
if: github.event_name != 'schedule' || steps.check_commits.outputs.has_commits == 'true'
run: |
sudo apt-get update
sudo apt-get install -y xvfb xauth \
libgtk-3-0 libxext6 libxrender1 libxtst6 libxi6 libxrandr2 libxfixes3 \
libasound2t64 libnss3 libgbm1
sudo /usr/bin/Xvfb $DISPLAY -screen 0 1280x1024x24 &
- name: Cache Maven dependencies
if: github.event_name != 'schedule' || steps.check_commits.outputs.has_commits == 'true'
uses: actions/cache@v5
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml', 'sandbox_target/*.target') }}
restore-keys: ${{ runner.os }}-maven-
- name: Set up Maven
if: github.event_name != 'schedule' || steps.check_commits.outputs.has_commits == 'true'
uses: stCarolas/setup-maven@d6af6abeda15e98926a57b5aa970a96bb37f97d1
with:
maven-version: 3.9.9
- name: Build with Coverage
if: github.event_name != 'schedule' || steps.check_commits.outputs.has_commits == 'true'
run: xvfb-run --auto-servernum mvn -e -V -T 1C --batch-mode -Dtycho.localArtifacts=ignore -Pjacoco,product,repo,benchmark,cli-dist,maven-plugin clean verify
- name: Cleanup xvfb
if: github.event_name != 'schedule' || steps.check_commits.outputs.has_commits == 'true'
uses: bcomnes/cleanup-xvfb@v1
- name: Prepare Test Reports for GitHub Pages
if: github.event_name != 'schedule' || steps.check_commits.outputs.has_commits == 'true'
run: |
# Create directory structure for test reports
mkdir -p /tmp/gh-pages/tests
# Create an index.html for the tests directory
cat > /tmp/gh-pages/tests/index.html << 'EOF'
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sandbox Test Reports</title>
<style>
body { font-family: Arial, sans-serif; max-width: 1200px; margin: 0 auto; padding: 20px; }
h1 { color: #333; }
.module { margin: 20px 0; padding: 15px; border: 1px solid #ddd; border-radius: 5px; }
.module h2 { margin-top: 0; color: #0066cc; }
a { color: #0066cc; text-decoration: none; }
a:hover { text-decoration: underline; }
.description { color: #666; margin: 10px 0; }
.update-info { background: #f0f0f0; padding: 10px; border-radius: 5px; margin: 20px 0; }
</style>
</head>
<body>
<h1>Sandbox Test Reports</h1>
<p class="description">
This page contains HTML test reports for all test modules in the Sandbox project.
Each module's report shows test results including passed, failed, and disabled tests.
</p>
<div class="update-info">
<strong>Note:</strong> These reports are updated from the scheduled (daily) coverage build,
which includes all test results alongside code coverage metrics.
For the most recent test-only results (updated on every main commit), see the main build workflow.
</div>
<div class="modules">
EOF
# Copy test reports and add links to index
for module in sandbox_*_test; do
if [ -d "$module/target/site" ] && [ -f "$module/target/site/surefire-report.html" ]; then
echo "Processing test report for $module..."
# Copy the entire site directory to preserve resources
mkdir -p "/tmp/gh-pages/tests/$module"
cp -r "$module/target/site/"* "/tmp/gh-pages/tests/$module/"
# Add module entry to index with HTML escaping for display text
module_escaped=$(echo "$module" | sed 's/&/\&/g; s/</\</g; s/>/\>/g; s/"/\"/g; s/'\''/\'/g')
cat >> /tmp/gh-pages/tests/index.html << EOF
<div class="module">
<h2>${module_escaped}</h2>
<p><a href="${module}/surefire-report.html">View Test Report</a></p>
</div>
EOF
fi
done
# Close HTML
cat >> /tmp/gh-pages/tests/index.html << 'EOF'
</div>
<hr>
<p style="text-align: center; color: #666; margin-top: 30px;">
Generated by <a href="https://github.com/carstenartur/sandbox">Sandbox Project</a> |
<a href="../coverage/">Coverage Reports</a>
</p>
</body>
</html>
EOF
echo "Test reports prepared in /tmp/gh-pages/tests"
- name: Deploy Test Reports to GitHub Pages
if: github.event_name != 'schedule' || steps.check_commits.outputs.has_commits == 'true'
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: /tmp/gh-pages/tests
destination_dir: tests
keep_files: true
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
commit_message: 'Deploy test reports (from scheduled coverage build)'
- name: Deploy Coverage to GitHub Pages
if: github.event_name != 'schedule' || steps.check_commits.outputs.has_commits == 'true'
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./sandbox_coverage/target/site/jacoco-aggregate
destination_dir: coverage
keep_files: true
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
commit_message: 'Deploy JaCoCo coverage report'
- name: Report Deployed URLs
if: github.event_name != 'schedule' || steps.check_commits.outputs.has_commits == 'true'
run: |
echo "### 🔗 Deployed Reports" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "📊 [View Coverage Report](https://carstenartur.github.io/sandbox/coverage/)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "🧪 [View Test Reports](https://carstenartur.github.io/sandbox/tests/)" >> $GITHUB_STEP_SUMMARY