Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 7, 2025

The workflow was failing with xvfb-run: error: Xvfb failed to start after rendering multiple OpenSCAD files. Each xvfb-run invocation attempted to spawn a new Xvfb instance, eventually exhausting display resources.

Changes

Xvfb Fix

  • Start persistent Xvfb instance: Launch Xvfb once on display :99 with robust startup verification using xdpyinfo (from x11-utils package)
  • Remove xvfb-run wrappers: Replace all xvfb-run openscad commands with direct openscad invocations using DISPLAY=:99
  • Add cleanup: Terminate Xvfb gracefully (SIGTERM) with SIGKILL fallback, runs always even on failure

Workflow Separation

  • Split workflows: Created two independent workflow files for better organization and parallel execution:
    • openscad-render.yml - Generates visual outputs (PNG renders, animations, CNC files)
    • openscad-structural-analysis.yml - Validates syntax and runs structural analysis tests (stress ratios, lift capacity, design metrics)

Persistent Structural Analysis Logging

  • Automated log file: The structural analysis workflow now creates/updates STRUCTURAL_ANALYSIS_LOG.md in LifeTrac-v25/mechanical_design/
  • Failure tracking: Captures detailed information about failed components including stress ratios, deflections, and capacity metrics
  • Historical record: Log file is committed to the repository with [skip ci] for easy access and tracking of design improvements over time
  • Actionable recommendations: Includes references to fix strategies documented in STRUCTURAL_ANALYSIS.md

Animated GIF Generation

  • Arm movement animation: Generates an animated GIF (lifetrac_v25_animation.gif) showing the loader arms moving through their full range of motion (36 frames)
  • Automatic commit: The GIF is committed to the repository along with other rendered outputs for easy access
  • Visual feedback: Provides an easy way to visualize the mechanical design without running OpenSCAD

Both workflows use the same Xvfb fix and run independently on the same triggers (push, PR, manual dispatch).

Before:

- name: Render preview images
  run: |
    xvfb-run openscad -o output/main.png ...
    xvfb-run openscad -o output/front.png ...
    xvfb-run openscad -o output/top.png ...  # Fails here

After:

- name: Start Xvfb
  run: |
    Xvfb :99 -screen 0 1024x768x16 &
    # Wait for ready, set DISPLAY=:99

- name: Render preview images
  run: |
    openscad -o output/main.png ...
    openscad -o output/front.png ...
    openscad -o output/top.png ...  # Now succeeds

Benefits

  • ✅ Fixes Xvfb startup failures
  • ✅ Faster feedback on structural issues without waiting for renders
  • ✅ Independent execution of validation vs. visualization
  • ✅ Clearer CI results with focused job names
  • ✅ Easier troubleshooting of specific failures
  • ✅ Persistent tracking of structural analysis results for future review and improvement
  • ✅ Animated GIF visualization of arm movement committed to repository
Original prompt

This section details on the original issue you should resolve

<issue_title>github action failure</issue_title>
<issue_description>need to update the yaml

Workflow Installation Step for xvfb Error

In .github/workflows/openscad-render.yml: add/ensure xvfb installation before rendering
YAML

steps:

  • name: Install Xvfb
    run: sudo apt-get install xvfb
  • name: Start Xvfb
    run: Xvfb :99 -screen 0 1024x768x16 &

rest of your render steps...

</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Update GitHub Action to install Xvfb before rendering Fix Xvfb startup failures in OpenSCAD render workflow Dec 7, 2025
Copilot AI requested a review from dorkmo December 7, 2025 06:55
@dorkmo
Copy link
Contributor

dorkmo commented Dec 7, 2025

@copilot lets split out the structural anlysis tests from the other github actions such as the png rendering etc

Copy link
Contributor Author

Copilot AI commented Dec 7, 2025

@copilot lets split out the structural anlysis tests from the other github actions such as the png rendering etc

Done! I've split the workflows into two separate files:

OpenSCAD Render and Export - Handles all PNG rendering, animations, and CNC output files
OpenSCAD Structural Analysis - Validates syntax and runs structural analysis tests (stress ratios, lift capacity, etc.)

Both workflows run independently on the same triggers. The structural analysis captures the ECHO output from your parametric design calculations and generates a separate report artifact.

Commit: c7ff56b

Copilot AI changed the title Fix Xvfb startup failures in OpenSCAD render workflow Fix Xvfb startup failures and split OpenSCAD workflows Dec 7, 2025
@dorkmo
Copy link
Contributor

dorkmo commented Dec 7, 2025

@copilot perhaps we should add a log file in the mechanical design folder with descriptions of the structural analysis failures for future review and improvement.

Copy link
Contributor Author

Copilot AI commented Dec 7, 2025

@copilot perhaps we should add a log file in the mechanical design folder with descriptions of the structural analysis failures for future review and improvement.

Added! The structural analysis workflow now creates STRUCTURAL_ANALYSIS_LOG.md in the mechanical design folder. It includes:

  • Latest test results with timestamp and commit
  • Detailed breakdown of each failed component with metrics
  • Current rated capacity
  • Recommended actions for fixing failures

The log file is automatically committed to the repository for easy tracking and future review.

Commit: 379a04d

Copilot AI changed the title Fix Xvfb startup failures and split OpenSCAD workflows Fix Xvfb startup failures, split OpenSCAD workflows, and add persistent structural analysis logging Dec 7, 2025
Copilot AI requested a review from dorkmo December 7, 2025 07:17
@dorkmo dorkmo marked this pull request as ready for review December 7, 2025 07:17
Copilot AI review requested due to automatic review settings December 7, 2025 07:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes Xvfb startup failures in GitHub Actions workflows by starting a persistent Xvfb instance instead of spawning multiple instances via xvfb-run. It also splits the monolithic workflow into two separate workflows for better organization and parallel execution.

Key Changes

  • Xvfb Fix: Replaced xvfb-run wrappers with a single persistent Xvfb instance on display :99, using xdpyinfo for startup verification and proper graceful cleanup
  • Workflow Separation: Split validation and rendering into two independent workflows (openscad-render.yml for visual outputs, openscad-structural-analysis.yml for validation)
  • Persistent Logging: Added automated STRUCTURAL_ANALYSIS_LOG.md generation and commit with detailed failure tracking and historical records

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 5 comments.

File Description
.github/workflows/openscad-render.yml Updated to use persistent Xvfb instance, removed validation steps (moved to structural analysis workflow), added cleanup step and cross-reference to structural analysis workflow
.github/workflows/openscad-structural-analysis.yml New workflow for syntax validation and structural analysis with persistent Xvfb, generates and commits detailed analysis logs with failure tracking
LifeTrac-v25/mechanical_design/STRUCTURAL_ANALYSIS_LOG.md New automatically-generated log file tracking structural analysis test results with timestamps, commit info, and failure details
LifeTrac-v25/mechanical_design/assembly.png Binary PNG file generated by the render workflow (visual output artifact)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +103 to +104
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
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sed command uses a fallback with || operator, but the logic is slightly confusing. The first sed command exits with code 0 if it finds the pattern, even if the closing delimiter ======================================== isn't found. The fallback will only execute if the first command exits non-zero (which is rare for sed).

Consider checking if the output is empty or adding explicit error handling to ensure the fallback works as intended.

Suggested change
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
summary=$(sed -n '/COMPLETE STRUCTURAL ANALYSIS SUMMARY/,/========================================/{p;/========================================/q}' structural_analysis.log | tail -n +2)
if [ -z "$summary" ]; then
summary=$(sed -n '/COMPLETE STRUCTURAL ANALYSIS SUMMARY/,$p' structural_analysis.log | tail -n +2 | head -n 20)
fi
echo "$summary" >> structural_report.md

Copilot uses AI. Check for mistakes.
Comment on lines +206 to +224
- 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
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow performs git operations (commit and push) but doesn't explicitly declare the required permissions. While GITHUB_TOKEN is provided, newer GitHub Actions security practices require explicit permission declarations.

Consider adding a permissions: block at the job or workflow level with contents: write to make the required permissions explicit and follow security best practices.

Copilot uses AI. Check for mistakes.
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
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The openscad command's exit code is not checked after running the structural analysis. If OpenSCAD fails, the pipeline will continue and subsequent steps may produce misleading results (e.g., "No structural analysis summary found" error instead of indicating the actual OpenSCAD failure).

Consider adding error checking similar to the validation step above, or use set -e and set -o pipefail at the beginning of the script to ensure the step fails on command errors.

Suggested change
openscad -o /dev/null --export-format echo openscad/lifetrac_v25.scad 2>&1 | tee structural_analysis.log
openscad -o /dev/null --export-format echo openscad/lifetrac_v25.scad 2>&1 | tee structural_analysis.log
OPENSCAD_EXIT=${PIPESTATUS[0]}
if [ $OPENSCAD_EXIT -ne 0 ]; then
echo "✗ OpenSCAD structural analysis failed (exit code $OPENSCAD_EXIT)"
exit $OPENSCAD_EXIT
fi

Copilot uses AI. Check for mistakes.
# 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 || {
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using --force-with-lease may cause issues when committing back to the same branch that triggered the workflow. On push events, the workflow checks out the exact commit SHA, not the branch HEAD. If another commit is pushed before the workflow completes, --force-with-lease will fail.

Consider using a regular git push instead, or add logic to handle concurrent pushes more gracefully. The fallback error handler is good for fork PRs, but may also silently mask legitimate push failures on the main repository.

Suggested change
git push --force-with-lease origin HEAD || {
git push origin HEAD || {

Copilot uses AI. Check for mistakes.
echo "" >> STRUCTURAL_ANALYSIS_LOG.md

# Extract rated capacity
CAPACITY=$(grep "RATED LIFT CAPACITY:" structural_analysis.log | head -1 | sed 's/ECHO: "RATED LIFT CAPACITY:", //')
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sed command to extract the CAPACITY may fail silently if the pattern doesn't match exactly. The variable $CAPACITY could be empty or contain unexpected content if the log format varies.

Consider adding validation to check if $CAPACITY is non-empty before using it, or provide a default value like "Unknown" to avoid rendering an incomplete markdown line.

Suggested change
CAPACITY=$(grep "RATED LIFT CAPACITY:" structural_analysis.log | head -1 | sed 's/ECHO: "RATED LIFT CAPACITY:", //')
CAPACITY=$(grep "RATED LIFT CAPACITY:" structural_analysis.log | head -1 | sed 's/ECHO: "RATED LIFT CAPACITY:", //')
if [ -z "$CAPACITY" ]; then
CAPACITY="Unknown"
fi

Copilot uses AI. Check for mistakes.
@dorkmo
Copy link
Contributor

dorkmo commented Dec 7, 2025

@copilot would it be possible to generate an animated gif of the arms moving in the openscad animation?

Copy link
Contributor Author

Copilot AI commented Dec 7, 2025

@copilot would it be possible to generate an animated gif of the arms moving in the openscad animation?

Yes! The workflow already generates 36 animation frames and now creates an animated GIF (lifetrac_v25_animation.gif) showing the arms moving through their full range of motion. The GIF is automatically committed to the repository along with the other rendered outputs for easy access.

The animation uses the parametric $t variable to animate the arm movement from ground position to fully raised.

Commit: eda6ae4

Copilot AI changed the title Fix Xvfb startup failures, split OpenSCAD workflows, and add persistent structural analysis logging Fix Xvfb startup failures, split OpenSCAD workflows, add persistent logging and animated GIF generation Dec 7, 2025
@dorkmo dorkmo merged commit 6af488f into main Dec 7, 2025
1 check failed
@dorkmo dorkmo deleted the copilot/update-xvfb-installation branch December 7, 2025 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

github action failure

2 participants