-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathopenscad-structural-analysis.yml
More file actions
300 lines (256 loc) · 13.2 KB
/
openscad-structural-analysis.yml
File metadata and controls
300 lines (256 loc) · 13.2 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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
name: OpenSCAD Structural Analysis
on:
push:
paths:
- 'LifeTrac-v25/mechanical_design/**/*.scad'
- '.github/workflows/openscad-structural-analysis.yml'
pull_request:
paths:
- 'LifeTrac-v25/mechanical_design/**/*.scad'
workflow_dispatch:
jobs:
structural-analysis:
runs-on: ubuntu-latest
name: Validate Structural Design
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install OpenSCAD
run: |
sudo apt-get update
sudo apt-get install -y openscad xvfb x11-utils
openscad --version
- name: Start Xvfb
run: |
Xvfb :99 -screen 0 1024x768x16 &
XVFB_PID=$!
echo "XVFB_PID=$XVFB_PID" >> $GITHUB_ENV
# Wait for Xvfb to be ready (max 10 seconds)
for i in {1..10}; do
if xdpyinfo -display :99 >/dev/null 2>&1; then
echo "Xvfb is ready on display :99"
break
fi
if [ $i -eq 10 ]; then
echo "Timeout waiting for Xvfb to start"
exit 1
fi
sleep 1
done
echo "DISPLAY=:99" >> $GITHUB_ENV
- name: Validate OpenSCAD syntax
run: |
echo "Validating OpenSCAD files..."
cd LifeTrac-v25/mechanical_design
# Check main design file
openscad -o /dev/null --export-format echo openscad/lifetrac_v25.scad
if [ $? -eq 0 ]; then
echo "✓ Main design file is valid"
else
echo "✗ Main design file has errors"
exit 1
fi
# Check module files
for module in modules/*.scad; do
echo "Checking $module..."
openscad -o /dev/null --export-format echo "$module"
if [ $? -eq 0 ]; then
echo "✓ $module is valid"
else
echo "✗ $module has errors"
exit 1
fi
done
- name: Run structural analysis
run: |
echo "Running structural analysis on main design..."
cd LifeTrac-v25/mechanical_design
# Run OpenSCAD with echo output to capture structural analysis
openscad -o /dev/null --export-format echo openscad/lifetrac_v25.scad 2>&1 | tee structural_analysis.log
echo "Structural analysis complete. Check logs for results."
- name: Generate structural analysis report
run: |
cd LifeTrac-v25/mechanical_design
# Extract key metrics from the log
echo "# Structural Analysis Report" > structural_report.md
echo "" >> structural_report.md
echo "**Generated:** $(date)" >> structural_report.md
echo "**Commit:** ${{ github.sha }}" >> structural_report.md
echo "**Branch:** ${{ github.ref_name }}" >> structural_report.md
echo "" >> structural_report.md
# Extract structural summary if present
if grep -q "COMPLETE STRUCTURAL ANALYSIS SUMMARY" structural_analysis.log; then
echo "## Structural Analysis Results" >> structural_report.md
echo "" >> structural_report.md
echo "\`\`\`" >> structural_report.md
# Extract from summary start to next delimiter or end of relevant section
sed -n '/COMPLETE STRUCTURAL ANALYSIS SUMMARY/,/========================================/{p;/========================================/q}' structural_analysis.log | tail -n +2 >> structural_report.md || \
sed -n '/COMPLETE STRUCTURAL ANALYSIS SUMMARY/,$p' structural_analysis.log | tail -n +2 | head -n 20 >> structural_report.md
echo "\`\`\`" >> structural_report.md
else
echo "No structural analysis summary found in output." >> structural_report.md
fi
cat structural_report.md
- name: Create persistent structural analysis log
run: |
cd LifeTrac-v25/mechanical_design
# Create or update the persistent log file
echo "# Structural Analysis Test Log" > STRUCTURAL_ANALYSIS_LOG.md
echo "" >> STRUCTURAL_ANALYSIS_LOG.md
echo "This file tracks the history of structural analysis test results." >> STRUCTURAL_ANALYSIS_LOG.md
echo "" >> STRUCTURAL_ANALYSIS_LOG.md
echo "---" >> STRUCTURAL_ANALYSIS_LOG.md
echo "" >> STRUCTURAL_ANALYSIS_LOG.md
echo "## Latest Analysis" >> STRUCTURAL_ANALYSIS_LOG.md
echo "" >> STRUCTURAL_ANALYSIS_LOG.md
echo "**Date:** $(date -u '+%Y-%m-%d %H:%M:%S UTC')" >> STRUCTURAL_ANALYSIS_LOG.md
echo "**Commit:** ${{ github.sha }}" >> STRUCTURAL_ANALYSIS_LOG.md
echo "**Branch:** ${{ github.ref_name }}" >> STRUCTURAL_ANALYSIS_LOG.md
echo "**Workflow Run:** ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> STRUCTURAL_ANALYSIS_LOG.md
echo "" >> STRUCTURAL_ANALYSIS_LOG.md
# Extract and format the structural analysis results
if grep -q "COMPLETE STRUCTURAL ANALYSIS SUMMARY" structural_analysis.log; then
echo "### Results Summary" >> STRUCTURAL_ANALYSIS_LOG.md
echo "" >> STRUCTURAL_ANALYSIS_LOG.md
echo "\`\`\`" >> STRUCTURAL_ANALYSIS_LOG.md
sed -n '/COMPLETE STRUCTURAL ANALYSIS SUMMARY/,/========================================/{p;/========================================/q}' structural_analysis.log | tail -n +2 >> STRUCTURAL_ANALYSIS_LOG.md || \
sed -n '/COMPLETE STRUCTURAL ANALYSIS SUMMARY/,$p' structural_analysis.log | tail -n +2 | head -n 20 >> STRUCTURAL_ANALYSIS_LOG.md
echo "\`\`\`" >> STRUCTURAL_ANALYSIS_LOG.md
echo "" >> STRUCTURAL_ANALYSIS_LOG.md
# Extract detailed failure information if any tests failed
if grep -q "FAIL" structural_analysis.log; then
echo "### ⚠️ Failed Components" >> STRUCTURAL_ANALYSIS_LOG.md
echo "" >> STRUCTURAL_ANALYSIS_LOG.md
# Extract rated capacity
CAPACITY=$(grep "RATED LIFT CAPACITY:" structural_analysis.log | head -1 | sed 's/ECHO: "RATED LIFT CAPACITY:", //')
echo "**Current Rated Capacity:** $CAPACITY" >> STRUCTURAL_ANALYSIS_LOG.md
echo "" >> STRUCTURAL_ANALYSIS_LOG.md
# List each failed component with details
echo "#### Detailed Failure Analysis" >> STRUCTURAL_ANALYSIS_LOG.md
echo "" >> STRUCTURAL_ANALYSIS_LOG.md
# Arm Bending
if grep -q "Arm Bending.*FAIL" structural_analysis.log; then
echo "**1. Arm Bending Stress**" >> STRUCTURAL_ANALYSIS_LOG.md
grep -A 5 "=== ARM BENDING STRESS ANALYSIS ===" structural_analysis.log | grep "ECHO:" | sed 's/ECHO: /- /' >> STRUCTURAL_ANALYSIS_LOG.md
echo "" >> STRUCTURAL_ANALYSIS_LOG.md
fi
# Arm Deflection
if grep -q "Arm Deflection.*FAIL" structural_analysis.log; then
echo "**2. Arm Deflection**" >> STRUCTURAL_ANALYSIS_LOG.md
grep -A 5 "=== ARM DEFLECTION ANALYSIS ===" structural_analysis.log | grep "ECHO:" | sed 's/ECHO: /- /' >> STRUCTURAL_ANALYSIS_LOG.md
echo "" >> STRUCTURAL_ANALYSIS_LOG.md
fi
# Cross Beam
if grep -q "Cross Beam.*FAIL" structural_analysis.log; then
echo "**3. Cross Beam Bending**" >> STRUCTURAL_ANALYSIS_LOG.md
grep -A 5 "=== CROSS BEAM STRESS ANALYSIS ===" structural_analysis.log | grep "ECHO:" | sed 's/ECHO: /- /' >> STRUCTURAL_ANALYSIS_LOG.md
echo "" >> STRUCTURAL_ANALYSIS_LOG.md
fi
# Pivot Ring Welds
if grep -q "Pivot Ring.*FAIL" structural_analysis.log; then
echo "**4. Pivot Ring Welds**" >> STRUCTURAL_ANALYSIS_LOG.md
grep -A 5 "=== PIVOT RING WELD ANALYSIS ===" structural_analysis.log | grep "ECHO:" | sed 's/ECHO: /- /' >> STRUCTURAL_ANALYSIS_LOG.md
echo "" >> STRUCTURAL_ANALYSIS_LOG.md
fi
echo "### Recommended Actions" >> STRUCTURAL_ANALYSIS_LOG.md
echo "" >> STRUCTURAL_ANALYSIS_LOG.md
echo "See [STRUCTURAL_ANALYSIS.md](STRUCTURAL_ANALYSIS.md) for design modification recommendations." >> STRUCTURAL_ANALYSIS_LOG.md
echo "" >> STRUCTURAL_ANALYSIS_LOG.md
else
echo "### ✅ All Tests Passed" >> STRUCTURAL_ANALYSIS_LOG.md
echo "" >> STRUCTURAL_ANALYSIS_LOG.md
echo "All structural analysis checks passed successfully." >> STRUCTURAL_ANALYSIS_LOG.md
echo "" >> STRUCTURAL_ANALYSIS_LOG.md
fi
else
echo "### Error" >> STRUCTURAL_ANALYSIS_LOG.md
echo "" >> STRUCTURAL_ANALYSIS_LOG.md
echo "No structural analysis summary found in output. Check the workflow logs for errors." >> STRUCTURAL_ANALYSIS_LOG.md
echo "" >> STRUCTURAL_ANALYSIS_LOG.md
fi
echo "---" >> STRUCTURAL_ANALYSIS_LOG.md
echo "" >> STRUCTURAL_ANALYSIS_LOG.md
echo "_This file is automatically updated by the OpenSCAD Structural Analysis workflow._" >> STRUCTURAL_ANALYSIS_LOG.md
cat STRUCTURAL_ANALYSIS_LOG.md
- name: Commit structural analysis log
run: |
cd LifeTrac-v25/mechanical_design
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
# Add the log file
git add STRUCTURAL_ANALYSIS_LOG.md
# Check if there are changes
if ! git diff --staged --quiet; then
git commit -m "Update structural analysis log [skip ci]"
git push --force-with-lease origin HEAD || {
echo "INFO: git push failed. This is expected on PRs from forks."
echo "The log file is available as a workflow artifact."
}
else
echo "No changes to structural analysis log"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload structural analysis artifacts
uses: actions/upload-artifact@v4
with:
name: structural-analysis
path: |
LifeTrac-v25/mechanical_design/structural_analysis.log
LifeTrac-v25/mechanical_design/structural_report.md
LifeTrac-v25/mechanical_design/STRUCTURAL_ANALYSIS_LOG.md
retention-days: 90
- name: Cleanup Xvfb
if: always()
run: |
if [ -n "$XVFB_PID" ]; then
echo "Stopping Xvfb process (PID: $XVFB_PID)"
# Try graceful shutdown first
kill -TERM $XVFB_PID 2>/dev/null || true
# Wait up to 5 seconds for process to terminate
for i in {1..5}; do
if ! kill -0 $XVFB_PID 2>/dev/null; then
echo "Xvfb stopped gracefully"
break
fi
sleep 1
done
# Force kill if still running
kill -KILL $XVFB_PID 2>/dev/null || true
echo "Xvfb force stopped"
fi
- name: Comment on PR with structural analysis
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
// Read the structural report
let reportContent = 'Structural analysis completed. Check artifacts for detailed results.';
try {
const report = fs.readFileSync('LifeTrac-v25/mechanical_design/structural_report.md', 'utf8');
// Extract just the results section
const match = report.match(/## Structural Analysis Results[\s\S]*$/);
if (match) {
reportContent = match[0];
}
} catch (err) {
console.log('Could not read structural report:', err);
}
const comment = `## OpenSCAD Structural Analysis Results 🔧
✅ Structural analysis completed!
${reportContent}
### Persistent Log
A detailed log with failure descriptions has been committed to:
- \`LifeTrac-v25/mechanical_design/STRUCTURAL_ANALYSIS_LOG.md\`
### Artifacts
Download the detailed analysis from the workflow artifacts:
- \`structural-analysis\` - Complete logs and report
**Workflow Run:** [#${{ github.run_number }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
`;
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: comment
});