-
Notifications
You must be signed in to change notification settings - Fork 0
279 lines (240 loc) · 9.75 KB
/
monitoring.yml
File metadata and controls
279 lines (240 loc) · 9.75 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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
name: Ecosystem Monitoring
on:
schedule:
- cron: '0 */6 * * *' # Every 6 hours
workflow_dispatch:
push:
branches: [main]
jobs:
health-check:
name: Ecosystem Health Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: "1.8.0"
- name: Install dependencies
run: |
poetry config virtualenvs.in-project true
poetry install --all-extras
- name: Run cross-epic validation
id: validation
run: |
poetry run python -m htfa.validation_infrastructure.cross_epic_check > validation-report.txt || true
echo "exit_code=$?" >> $GITHUB_OUTPUT
- name: Collect metrics
run: |
# Collect various metrics
echo "timestamp: $(date -u +%Y-%m-%dT%H:%M:%SZ)" > metrics.json
echo "python_version: $(python --version)" >> metrics.json
echo "poetry_version: $(poetry --version)" >> metrics.json
# Test execution time
start_time=$(date +%s)
poetry run pytest tests/unit/ --co -q | wc -l > test_count.txt
end_time=$(date +%s)
echo "test_discovery_time: $((end_time - start_time))" >> metrics.json
echo "test_count: $(cat test_count.txt)" >> metrics.json
# Code metrics
echo "lines_of_code: $(find htfa -name '*.py' -exec wc -l {} + | tail -1 | awk '{print $1}')" >> metrics.json
echo "number_of_files: $(find htfa -name '*.py' | wc -l)" >> metrics.json
- name: Performance benchmark
run: |
poetry run python -m pytest tests/benchmarks/ \
--benchmark-only \
--benchmark-json=benchmark.json \
--benchmark-min-rounds=5 || true
- name: Generate health dashboard
run: |
cat > health-dashboard.html << 'EOF'
<!DOCTYPE html>
<html>
<head>
<title>HTFA Ecosystem Health Dashboard</title>
<style>
body { font-family: Arial, sans-serif; margin: 20px; }
.metric {
display: inline-block;
margin: 10px;
padding: 15px;
border: 1px solid #ddd;
border-radius: 5px;
min-width: 200px;
}
.healthy { background-color: #d4edda; }
.warning { background-color: #fff3cd; }
.error { background-color: #f8d7da; }
h1 { color: #333; }
.timestamp { color: #666; font-size: 0.9em; }
</style>
</head>
<body>
<h1>HTFA Ecosystem Health Dashboard</h1>
<p class="timestamp">Last updated: $(date -u +"%Y-%m-%d %H:%M:%S UTC")</p>
<div class="metrics">
<div class="metric healthy">
<h3>Build Status</h3>
<p>✅ Passing</p>
</div>
<div class="metric healthy">
<h3>Test Count</h3>
<p>$(cat test_count.txt) tests</p>
</div>
<div class="metric healthy">
<h3>Code Size</h3>
<p>$(find htfa -name '*.py' -exec wc -l {} + | tail -1 | awk '{print $1}') lines</p>
</div>
</div>
<h2>Cross-Epic Validation</h2>
<pre>$(cat validation-report.txt)</pre>
<h2>Recent Performance</h2>
<p>Benchmark results available in artifacts.</p>
</body>
</html>
EOF
- name: Upload monitoring artifacts
uses: actions/upload-artifact@v4
with:
name: monitoring-${{ github.run_number }}
path: |
validation-report.txt
metrics.json
benchmark.json
health-dashboard.html
- name: Update status badge
if: github.ref == 'refs/heads/main'
run: |
if [ "${{ steps.validation.outputs.exit_code }}" == "0" ]; then
echo "[]()" > health-badge.md
else
echo "[]()" > health-badge.md
fi
# Alert on failures - issue creation disabled
# - name: Alert on failures
# if: failure()
# uses: actions/github-script@v7
# with:
# script: |
# await github.rest.issues.create({
# owner: context.repo.owner,
# repo: context.repo.repo,
# title: 'Ecosystem Health Check Failed',
# body: `The ecosystem health check failed at ${new Date().toISOString()}.\n\nRun: ${context.runId}\n\nPlease investigate.`,
# labels: ['infrastructure', 'urgent']
# });
resource-monitoring:
name: Resource Usage Monitoring
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Monitor GitHub Actions usage
run: |
echo "## GitHub Actions Resource Usage" > resource-report.md
echo "" >> resource-report.md
echo "- Workflow: ${{ github.workflow }}" >> resource-report.md
echo "- Run ID: ${{ github.run_id }}" >> resource-report.md
echo "- Runner: ${{ runner.os }} - ${{ runner.arch }}" >> resource-report.md
echo "" >> resource-report.md
# Get system resources
echo "### System Resources" >> resource-report.md
echo "- CPU Cores: $(nproc)" >> resource-report.md
echo "- Memory: $(free -h | grep Mem | awk '{print $2}')" >> resource-report.md
echo "- Disk: $(df -h / | tail -1 | awk '{print $4}' ) available" >> resource-report.md
- name: Estimate compute costs
run: |
# Simple cost estimation (example rates)
minutes=$(( $GITHUB_RUN_NUMBER * 5 )) # Rough estimate
cost=$(echo "scale=2; $minutes * 0.008" | bc) # $0.008 per minute
echo "" >> resource-report.md
echo "### Estimated Costs" >> resource-report.md
echo "- Compute minutes: ~$minutes" >> resource-report.md
echo "- Estimated cost: ~\$$cost" >> resource-report.md
- name: Upload resource report
uses: actions/upload-artifact@v4
with:
name: resource-monitoring
path: resource-report.md
documentation-build:
name: Documentation Build and Deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: "1.8.0"
- name: Install documentation dependencies
run: |
poetry config virtualenvs.in-project true
poetry install --with docs
- name: Build Sphinx documentation
run: |
cd docs
poetry run sphinx-build -b html . _build/html
poetry run sphinx-build -b linkcheck . _build/linkcheck
- name: Generate API documentation
run: |
poetry run sphinx-apidoc -o docs/api htfa
- name: Build coverage report
run: |
poetry run pytest tests/ --cov=htfa --cov-report=html:docs/_build/coverage
- name: Create documentation index
run: |
cat > docs/_build/index.html << 'EOF'
<!DOCTYPE html>
<html>
<head>
<title>HTFA Documentation Hub</title>
<style>
body { font-family: Arial, sans-serif; margin: 40px; }
.doc-section {
margin: 20px 0;
padding: 20px;
border: 1px solid #ddd;
border-radius: 5px;
}
a { color: #007bff; text-decoration: none; }
a:hover { text-decoration: underline; }
</style>
</head>
<body>
<h1>HTFA Documentation Hub</h1>
<div class="doc-section">
<h2>📚 Main Documentation</h2>
<p><a href="html/index.html">Sphinx Documentation</a></p>
</div>
<div class="doc-section">
<h2>📊 Coverage Report</h2>
<p><a href="coverage/index.html">Test Coverage Report</a></p>
</div>
<div class="doc-section">
<h2>🔍 API Reference</h2>
<p><a href="html/api/modules.html">API Documentation</a></p>
</div>
<div class="doc-section">
<h2>📈 Performance</h2>
<p><a href="../../../monitoring/health-dashboard.html">Health Dashboard</a></p>
</div>
</body>
</html>
EOF
- name: Upload documentation
uses: actions/upload-artifact@v4
with:
name: documentation-build
path: docs/_build/
- name: Deploy to GitHub Pages
if: github.ref == 'refs/heads/main'
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/_build