feat: MCP Bridge Workbench, just command cleanup, testing, etc. (#24)
* fix: lots of fixes and name refactoring * feat: Add workbench preferences * fix: MCP bridge status widget and just command fixes * fix(tests): Use the correct mesa-glx package * fix(ci): Add fontconfig to GUI test dependencies FreeCAD GUI was failing to start with: "Fontconfig error: Cannot load default config file: No such file" Added fontconfig and fonts-dejavu-core packages to the GUI test job dependencies to resolve the font configuration issue. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * refactor(addon): Extract path utilities into shared module Create path_utils.py module that consolidates duplicated path-finding logic from commands.py and InitGui.py: - get_addon_path(): Find addon directory with caching and fallbacks - get_icon_path(): Get full path to an icon file - get_icons_dir(): Get path to icons directory - get_workbench_icon(): Get path to workbench main icon This removes ~100 lines of duplicated code while preserving the same behavior including _addon_path_cache and all fallback methods. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(addon): Prevent stale plugin state on startup failure The StartMCPBridgeCommand.Activated method could leave _mcp_plugin in a partially initialized state if FreecadMCPPlugin.start() failed after the plugin was instantiated. Changes: - Create plugin in a local variable first - Only assign to _mcp_plugin after start() succeeds - Explicitly clear _mcp_plugin and _running_config in exception handlers to ensure clean state for subsequent retry attempts Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: Lot of broad improvements * fix(ci): Use blocking headless_server.py for GUI tests The GUI test was using startup_bridge.py which is non-blocking (designed for interactive use). For CI, even in GUI mode, we need the blocking headless_server.py that calls run_forever() to keep FreeCAD running. GUI features are still available since we use the 'freecad' executable instead of 'freecadcmd'. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * refactor(addon): Rename headless_server.py to blocking_bridge.py The old name was misleading because: - It works with both GUI (freecad) and headless (freecadcmd) modes - The key characteristic is that it BLOCKS with run_forever() New naming convention clarifies the difference: - blocking_bridge.py: Starts bridge and blocks (for CI, servers) - startup_bridge.py: Starts bridge and returns (for interactive GUI) Updated all references across: - GitHub workflow (macro-test.yaml) - Just commands (freecad.just) - Unit tests (test_addon_structure.py) - Documentation (5 files) - CLAUDE.md Also improved the script to detect GUI mode dynamically using FreeCAD.GuiUp and display the appropriate status message. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(just): Remove erroneous rm of startup_bridge.py on error The startup script is now a permanent source file in the repository, not a generated temporary file. The rm -f would have deleted source code if FreeCAD wasn't found. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: General improvements * fix: Lots of general fixes and only stable to PyPi * fix: small cleanup * fix: Small fixes and hopefully fixes the GUI tests * fix: Add proper library paths for FreeCAD GUI in CI - Create wrapper scripts instead of symlinks for AppImage binaries - Set LD_LIBRARY_PATH, QT_PLUGIN_PATH for GUI mode - Add diagnostic output to identify startup failures * fix: Use apprun for GUI tests in CI * fix: Improving Xvfb tests * fix: GUI tests worlk * chore: remove invalid --no-splash comments * fix: ARM64 architecture support and other fixes * fix: cleanup * test: just commands test suite * test: improve just command tests * fix: more general improvements * fix: more cleanup * fix: more updates * fix: small tweaks --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.5
parent
bcc3048876
commit
8c338f6da7
@@ -0,0 +1,215 @@
|
||||
name: Setup FreeCAD
|
||||
description: Downloads and sets up FreeCAD AppImage for CI testing (supports x86_64 and ARM64 runners)
|
||||
|
||||
inputs:
|
||||
freecad-tag:
|
||||
description: "Specific FreeCAD release tag to install (e.g., '1.0.2'). If empty, uses latest stable release."
|
||||
required: false
|
||||
default: ""
|
||||
|
||||
outputs:
|
||||
freecad-tag:
|
||||
description: The FreeCAD release tag that was installed
|
||||
value: ${{ steps.freecad-release.outputs.tag }}
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Get latest FreeCAD release info
|
||||
id: freecad-release
|
||||
shell: bash
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
INPUT_FREECAD_TAG: ${{ inputs.freecad-tag }}
|
||||
run: |
|
||||
# Detect runner architecture
|
||||
RUNNER_ARCH=$(uname -m)
|
||||
case "$RUNNER_ARCH" in
|
||||
x86_64)
|
||||
ARCH_SUFFIX="x86_64"
|
||||
;;
|
||||
aarch64|arm64)
|
||||
ARCH_SUFFIX="aarch64"
|
||||
;;
|
||||
*)
|
||||
echo "ERROR: Unsupported architecture: $RUNNER_ARCH"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
echo "Detected architecture: $RUNNER_ARCH -> $ARCH_SUFFIX"
|
||||
echo "arch=$ARCH_SUFFIX" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# Get FreeCAD release info from GitHub API
|
||||
# Use GitHub token to avoid rate limiting
|
||||
if [ -n "$INPUT_FREECAD_TAG" ]; then
|
||||
echo "Using specified FreeCAD tag: $INPUT_FREECAD_TAG"
|
||||
RELEASE_INFO=$(curl -s -H "Authorization: Bearer $GH_TOKEN" \
|
||||
"https://api.github.com/repos/FreeCAD/FreeCAD/releases/tags/$INPUT_FREECAD_TAG")
|
||||
else
|
||||
echo "Fetching latest FreeCAD release..."
|
||||
RELEASE_INFO=$(curl -s -H "Authorization: Bearer $GH_TOKEN" \
|
||||
https://api.github.com/repos/FreeCAD/FreeCAD/releases/latest)
|
||||
fi
|
||||
|
||||
# Validate response has required fields
|
||||
TAG_NAME=$(echo "$RELEASE_INFO" | jq -r '.tag_name')
|
||||
if [ -z "$TAG_NAME" ] || [ "$TAG_NAME" = "null" ]; then
|
||||
echo "ERROR: Could not get tag_name from release info"
|
||||
echo "Response: $RELEASE_INFO"
|
||||
exit 1
|
||||
fi
|
||||
echo "FreeCAD release: $TAG_NAME"
|
||||
echo "tag=$TAG_NAME" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# Find the Linux AppImage asset URL for the detected architecture
|
||||
# Priority: conda build with py311 > any conda build > any AppImage
|
||||
# The conda builds are the officially recommended AppImages
|
||||
APPIMAGE_URL=""
|
||||
APPIMAGE_NAME=""
|
||||
|
||||
# First try: conda build with py311 (most specific, preferred)
|
||||
APPIMAGE_URL=$(echo "$RELEASE_INFO" | jq -r ".assets[] | select(.name | test(\"conda-Linux-${ARCH_SUFFIX}-py311\\\\.AppImage$\")) | .browser_download_url" | head -1)
|
||||
APPIMAGE_NAME=$(echo "$RELEASE_INFO" | jq -r ".assets[] | select(.name | test(\"conda-Linux-${ARCH_SUFFIX}-py311\\\\.AppImage$\")) | .name" | head -1)
|
||||
|
||||
# Second try: any conda build for the architecture
|
||||
if [ -z "$APPIMAGE_URL" ] || [ "$APPIMAGE_URL" = "null" ]; then
|
||||
echo "Note: py311 conda build not found, trying any conda build..."
|
||||
APPIMAGE_URL=$(echo "$RELEASE_INFO" | jq -r ".assets[] | select(.name | test(\"conda-Linux-${ARCH_SUFFIX}.*\\\\.AppImage$\")) | .browser_download_url" | head -1)
|
||||
APPIMAGE_NAME=$(echo "$RELEASE_INFO" | jq -r ".assets[] | select(.name | test(\"conda-Linux-${ARCH_SUFFIX}.*\\\\.AppImage$\")) | .name" | head -1)
|
||||
fi
|
||||
|
||||
# Third try: any AppImage for the architecture (fallback)
|
||||
if [ -z "$APPIMAGE_URL" ] || [ "$APPIMAGE_URL" = "null" ]; then
|
||||
echo "Note: conda build not found, trying any ${ARCH_SUFFIX} AppImage..."
|
||||
APPIMAGE_URL=$(echo "$RELEASE_INFO" | jq -r ".assets[] | select(.name | test(\"Linux-${ARCH_SUFFIX}.*\\\\.AppImage$\")) | .browser_download_url" | head -1)
|
||||
APPIMAGE_NAME=$(echo "$RELEASE_INFO" | jq -r ".assets[] | select(.name | test(\"Linux-${ARCH_SUFFIX}.*\\\\.AppImage$\")) | .name" | head -1)
|
||||
fi
|
||||
|
||||
if [ -z "$APPIMAGE_URL" ] || [ "$APPIMAGE_URL" = "null" ]; then
|
||||
echo "ERROR: Could not find Linux ${ARCH_SUFFIX} AppImage in release assets"
|
||||
echo "Available assets:"
|
||||
echo "$RELEASE_INFO" | jq -r '.assets[].name'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "AppImage URL: $APPIMAGE_URL"
|
||||
echo "AppImage name: $APPIMAGE_NAME"
|
||||
echo "url=$APPIMAGE_URL" >> "$GITHUB_OUTPUT"
|
||||
echo "name=$APPIMAGE_NAME" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Cache FreeCAD AppImage
|
||||
id: cache-freecad
|
||||
uses: actions/cache@v5
|
||||
with:
|
||||
path: ~/freecad-appimage
|
||||
key: ${{ runner.os }}-${{ steps.freecad-release.outputs.arch }}-freecad-appimage-${{ steps.freecad-release.outputs.tag }}
|
||||
|
||||
- name: Download FreeCAD AppImage
|
||||
if: steps.cache-freecad.outputs.cache-hit != 'true'
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p ~/freecad-appimage
|
||||
echo "Downloading FreeCAD ${{ steps.freecad-release.outputs.tag }}..."
|
||||
# Use retry, timeout, and fail-fast flags for reliable downloads
|
||||
curl -L --retry 3 --retry-delay 5 --connect-timeout 30 --max-time 600 \
|
||||
-f -o ~/freecad-appimage/FreeCAD.AppImage \
|
||||
"${{ steps.freecad-release.outputs.url }}"
|
||||
chmod +x ~/freecad-appimage/FreeCAD.AppImage
|
||||
|
||||
- name: Setup FreeCAD AppImage
|
||||
shell: bash
|
||||
run: |
|
||||
# Make AppImage executable (in case restored from cache)
|
||||
chmod +x ~/freecad-appimage/FreeCAD.AppImage
|
||||
|
||||
# Extract AppImage for headless use (AppImages need FUSE which isn't available in CI)
|
||||
# Skip extraction if already extracted (from cache)
|
||||
cd ~/freecad-appimage
|
||||
if [ ! -d "squashfs-root" ]; then
|
||||
echo "Extracting AppImage..."
|
||||
if ! ./FreeCAD.AppImage --appimage-extract > /dev/null 2>&1; then
|
||||
echo "ERROR: AppImage extraction failed"
|
||||
exit 1
|
||||
fi
|
||||
# Verify extraction produced expected structure
|
||||
if [ ! -d "squashfs-root/usr/bin" ]; then
|
||||
echo "ERROR: Extracted AppImage missing expected structure"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "Using cached extracted AppImage"
|
||||
fi
|
||||
|
||||
# Create wrapper scripts that use AppRun to properly set up the environment
|
||||
# The conda-based FreeCAD AppImage has complex environment requirements
|
||||
# Using AppRun ensures all paths and variables are correctly configured
|
||||
APPIMAGE_DIR="$HOME/freecad-appimage/squashfs-root"
|
||||
|
||||
# Check if AppRun exists and show its structure
|
||||
echo "Checking AppImage structure..."
|
||||
ls -la "$APPIMAGE_DIR/" | head -20
|
||||
if [ -f "$APPIMAGE_DIR/AppRun" ]; then
|
||||
echo "AppRun found, will use it for wrappers"
|
||||
else
|
||||
echo "WARNING: AppRun not found, falling back to direct execution"
|
||||
fi
|
||||
|
||||
# Create freecadcmd wrapper - use AppRun with freecadcmd as argument
|
||||
{
|
||||
echo '#!/bin/bash'
|
||||
echo "export APPDIR=\"$APPIMAGE_DIR\""
|
||||
echo "export APPIMAGE_EXTRACT_AND_RUN=1"
|
||||
echo "# Use AppRun if available, otherwise direct execution"
|
||||
echo "if [ -f \"\$APPDIR/AppRun\" ]; then"
|
||||
echo " exec \"\$APPDIR/AppRun\" freecadcmd \"\$@\""
|
||||
echo "else"
|
||||
echo " export LD_LIBRARY_PATH=\"\$APPDIR/usr/lib:\$LD_LIBRARY_PATH\""
|
||||
echo " exec \"\$APPDIR/usr/bin/freecadcmd\" \"\$@\""
|
||||
echo "fi"
|
||||
} | sudo tee /usr/local/bin/freecadcmd > /dev/null
|
||||
sudo chmod +x /usr/local/bin/freecadcmd
|
||||
|
||||
# Create freecad (GUI) wrapper - use AppRun with freecad as argument
|
||||
{
|
||||
echo '#!/bin/bash'
|
||||
echo "export APPDIR=\"$APPIMAGE_DIR\""
|
||||
echo "export APPIMAGE_EXTRACT_AND_RUN=1"
|
||||
echo "# Use AppRun if available, otherwise direct execution"
|
||||
echo "if [ -f \"\$APPDIR/AppRun\" ]; then"
|
||||
echo " exec \"\$APPDIR/AppRun\" freecad \"\$@\""
|
||||
echo "else"
|
||||
echo " export LD_LIBRARY_PATH=\"\$APPDIR/usr/lib:\$LD_LIBRARY_PATH\""
|
||||
echo " exec \"\$APPDIR/usr/bin/freecad\" \"\$@\""
|
||||
echo "fi"
|
||||
} | sudo tee /usr/local/bin/freecad > /dev/null
|
||||
sudo chmod +x /usr/local/bin/freecad
|
||||
|
||||
echo "Created wrapper scripts for freecad and freecadcmd"
|
||||
|
||||
- name: Verify FreeCAD installation
|
||||
shell: bash
|
||||
run: |
|
||||
echo "Checking FreeCAD installation..."
|
||||
# Only verify with freecadcmd (headless) - freecad --version displays a GUI dialog
|
||||
# and would hang without a window manager (Xvfb + openbox)
|
||||
if freecadcmd --version; then
|
||||
echo "FreeCAD version check passed"
|
||||
else
|
||||
echo "ERROR: freecadcmd --version failed"
|
||||
echo ""
|
||||
echo "=== Diagnostic Information ==="
|
||||
echo "--- which freecadcmd ---"
|
||||
which freecadcmd || echo "freecadcmd not found in PATH"
|
||||
echo "--- which freecad ---"
|
||||
which freecad || echo "freecad not found in PATH"
|
||||
echo "--- FreeCAD AppImage bin directory ---"
|
||||
ls -la ~/freecad-appimage/squashfs-root/usr/bin/ | head -20 || echo "Directory not found"
|
||||
echo "--- PATH ---"
|
||||
echo "$PATH"
|
||||
echo "=== End Diagnostic Information ==="
|
||||
exit 1
|
||||
fi
|
||||
which freecadcmd
|
||||
which freecad
|
||||
# Show Python version bundled with FreeCAD
|
||||
freecadcmd -c "import sys; print(f'FreeCAD Python: {sys.version}')" || true
|
||||
@@ -10,6 +10,7 @@ on:
|
||||
- "addon/FreecadRobustMCP/**/*.py"
|
||||
- "tests/integration/**/*.py"
|
||||
- ".github/workflows/macro-test.yaml"
|
||||
- ".github/actions/setup-freecad/**"
|
||||
pull_request:
|
||||
branches: [main, master]
|
||||
paths:
|
||||
@@ -19,6 +20,7 @@ on:
|
||||
- "addon/FreecadRobustMCP/**/*.py"
|
||||
- "tests/integration/**/*.py"
|
||||
- ".github/workflows/macro-test.yaml"
|
||||
- ".github/actions/setup-freecad/**"
|
||||
workflow_dispatch:
|
||||
workflow_call:
|
||||
|
||||
@@ -31,6 +33,7 @@ jobs:
|
||||
test-integration:
|
||||
name: Integration Tests with FreeCAD
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
@@ -39,64 +42,8 @@ jobs:
|
||||
- name: Install mise
|
||||
uses: jdx/mise-action@v3
|
||||
|
||||
- name: Get latest FreeCAD release info
|
||||
id: freecad-release
|
||||
run: |
|
||||
# Get the latest stable release tag from GitHub API
|
||||
RELEASE_INFO=$(curl -s https://api.github.com/repos/FreeCAD/FreeCAD/releases/latest)
|
||||
TAG_NAME=$(echo "$RELEASE_INFO" | jq -r '.tag_name')
|
||||
echo "Latest FreeCAD release: $TAG_NAME"
|
||||
echo "tag=$TAG_NAME" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# Find the Linux AppImage asset URL
|
||||
APPIMAGE_URL=$(echo "$RELEASE_INFO" | jq -r '.assets[] | select(.name | test("Linux-x86_64.*\\.AppImage$")) | .browser_download_url' | head -1)
|
||||
APPIMAGE_NAME=$(echo "$RELEASE_INFO" | jq -r '.assets[] | select(.name | test("Linux-x86_64.*\\.AppImage$")) | .name' | head -1)
|
||||
|
||||
if [ -z "$APPIMAGE_URL" ] || [ "$APPIMAGE_URL" = "null" ]; then
|
||||
echo "ERROR: Could not find Linux AppImage in release assets"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "AppImage URL: $APPIMAGE_URL"
|
||||
echo "AppImage name: $APPIMAGE_NAME"
|
||||
echo "url=$APPIMAGE_URL" >> "$GITHUB_OUTPUT"
|
||||
echo "name=$APPIMAGE_NAME" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Cache FreeCAD AppImage
|
||||
id: cache-freecad
|
||||
uses: actions/cache@v5
|
||||
with:
|
||||
path: ~/freecad-appimage
|
||||
key: freecad-appimage-${{ steps.freecad-release.outputs.tag }}
|
||||
|
||||
- name: Download FreeCAD AppImage
|
||||
if: steps.cache-freecad.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
mkdir -p ~/freecad-appimage
|
||||
echo "Downloading FreeCAD ${{ steps.freecad-release.outputs.tag }}..."
|
||||
curl -L -o ~/freecad-appimage/FreeCAD.AppImage "${{ steps.freecad-release.outputs.url }}"
|
||||
chmod +x ~/freecad-appimage/FreeCAD.AppImage
|
||||
|
||||
- name: Setup FreeCAD AppImage
|
||||
run: |
|
||||
# Make AppImage executable (in case restored from cache)
|
||||
chmod +x ~/freecad-appimage/FreeCAD.AppImage
|
||||
|
||||
# Extract AppImage for headless use (AppImages need FUSE which isn't available in CI)
|
||||
cd ~/freecad-appimage
|
||||
./FreeCAD.AppImage --appimage-extract > /dev/null 2>&1
|
||||
|
||||
# Create symlinks for easy access
|
||||
sudo ln -sf ~/freecad-appimage/squashfs-root/usr/bin/freecadcmd /usr/local/bin/freecadcmd
|
||||
sudo ln -sf ~/freecad-appimage/squashfs-root/usr/bin/freecad /usr/local/bin/freecad
|
||||
|
||||
- name: Verify FreeCAD installation
|
||||
run: |
|
||||
echo "Checking FreeCAD installation..."
|
||||
freecadcmd --version || freecad --version || echo "Version check failed"
|
||||
which freecadcmd
|
||||
# Show Python version bundled with FreeCAD
|
||||
freecadcmd -c "import sys; print(f'FreeCAD Python: {sys.version}')" || true
|
||||
- name: Setup FreeCAD
|
||||
uses: ./.github/actions/setup-freecad
|
||||
|
||||
- name: Cache uv dependencies
|
||||
uses: astral-sh/setup-uv@v7
|
||||
@@ -124,8 +71,9 @@ jobs:
|
||||
echo "Using FreeCAD: freecadcmd"
|
||||
|
||||
# Start FreeCAD headless with MCP bridge in background
|
||||
# Uses the workbench addon's headless server script
|
||||
freecadcmd addon/FreecadRobustMCP/freecad_mcp_bridge/headless_server.py > /tmp/freecad_bridge.log 2>&1 &
|
||||
# Uses the workbench addon's blocking bridge script
|
||||
# Use setsid to create a new process group for reliable cleanup
|
||||
setsid freecadcmd addon/FreecadRobustMCP/freecad_mcp_bridge/blocking_bridge.py > /tmp/freecad_bridge.log 2>&1 &
|
||||
FREECAD_PID=$!
|
||||
echo "FREECAD_PID=$FREECAD_PID" >> "$GITHUB_ENV"
|
||||
|
||||
@@ -181,11 +129,251 @@ jobs:
|
||||
run: |
|
||||
uv run pytest tests/integration/test_headless_mode.py -v --tb=short
|
||||
|
||||
- name: Upload FreeCAD logs on failure
|
||||
if: failure() || cancelled()
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: freecad-headless-logs
|
||||
path: /tmp/freecad_bridge.log
|
||||
retention-days: 7
|
||||
if-no-files-found: ignore
|
||||
|
||||
- name: Stop FreeCAD
|
||||
if: always()
|
||||
run: |
|
||||
if [ -n "$FREECAD_PID" ]; then
|
||||
kill "$FREECAD_PID" 2>/dev/null || true
|
||||
# Kill process group (handles child processes spawned by FreeCAD/AppImage)
|
||||
kill -- "-$FREECAD_PID" 2>/dev/null || kill "$FREECAD_PID" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
test-gui:
|
||||
name: GUI Tests with FreeCAD + Xvfb
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
# FreeCAD GUI requires a window manager to generate expose/configure events.
|
||||
# Without a WM, the GUI binary hangs during Qt initialization.
|
||||
# Solution: Xvfb + openbox window manager + xdotool for synthetic events.
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Install mise
|
||||
uses: jdx/mise-action@v3
|
||||
|
||||
# Note: apt cache removed - caching /var/cache/apt/archives causes permission
|
||||
# issues and is largely negated by the immediate sudo apt-get update
|
||||
|
||||
- name: Install Xvfb, openbox, and X11 dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y \
|
||||
xvfb \
|
||||
openbox \
|
||||
xdotool \
|
||||
libxkbcommon-x11-0 \
|
||||
libxcb-icccm4 \
|
||||
libxcb-image0 \
|
||||
libxcb-keysyms1 \
|
||||
libxcb-randr0 \
|
||||
libxcb-render-util0 \
|
||||
libxcb-xinerama0 \
|
||||
libxcb-xfixes0 \
|
||||
libxcb-shape0 \
|
||||
libxcb-cursor0 \
|
||||
x11-utils \
|
||||
libegl1 \
|
||||
libgl1-mesa-dri \
|
||||
libgl1 \
|
||||
mesa-utils \
|
||||
fontconfig \
|
||||
fonts-dejavu-core
|
||||
# Rebuild font cache (required after installing fonts, especially from cache)
|
||||
sudo fc-cache -f -v
|
||||
|
||||
- name: Setup FreeCAD
|
||||
uses: ./.github/actions/setup-freecad
|
||||
|
||||
- name: Start Xvfb and openbox
|
||||
run: |
|
||||
echo "Starting Xvfb virtual display..."
|
||||
# Use -nolisten tcp to prevent TCP listeners for security
|
||||
Xvfb :99 -screen 0 1920x1080x24 -nolisten tcp &
|
||||
XVFB_PID=$!
|
||||
echo "XVFB_PID=$XVFB_PID" >> "$GITHUB_ENV"
|
||||
echo "DISPLAY=:99" >> "$GITHUB_ENV"
|
||||
sleep 2
|
||||
# Verify Xvfb is running
|
||||
if ! ps -p $XVFB_PID > /dev/null; then
|
||||
echo "ERROR: Xvfb failed to start"
|
||||
exit 1
|
||||
fi
|
||||
echo "Xvfb started on display :99 (PID: $XVFB_PID)"
|
||||
|
||||
# Start openbox window manager (required for FreeCAD GUI)
|
||||
# FreeCAD needs a WM to generate expose/configure events
|
||||
echo "Starting openbox window manager..."
|
||||
DISPLAY=:99 openbox &
|
||||
OPENBOX_PID=$!
|
||||
echo "OPENBOX_PID=$OPENBOX_PID" >> "$GITHUB_ENV"
|
||||
sleep 1
|
||||
if ! ps -p $OPENBOX_PID > /dev/null; then
|
||||
echo "WARNING: openbox may have failed to start"
|
||||
else
|
||||
echo "openbox started (PID: $OPENBOX_PID)"
|
||||
fi
|
||||
|
||||
- name: Verify X11 display
|
||||
env:
|
||||
DISPLAY: ":99"
|
||||
run: |
|
||||
echo "Checking X11 display..."
|
||||
xdpyinfo | head -10 || echo "xdpyinfo not available"
|
||||
|
||||
- name: Cache uv dependencies
|
||||
uses: astral-sh/setup-uv@v7
|
||||
with:
|
||||
enable-cache: true
|
||||
cache-dependency-glob: "**/uv.lock"
|
||||
|
||||
- name: Install dependencies
|
||||
run: uv sync --all-extras
|
||||
|
||||
- name: Verify fontconfig setup
|
||||
run: |
|
||||
echo "Checking fontconfig configuration..."
|
||||
# Verify the system fontconfig config exists
|
||||
if [ -f /etc/fonts/fonts.conf ]; then
|
||||
echo "System fontconfig found at /etc/fonts/fonts.conf"
|
||||
else
|
||||
echo "ERROR: /etc/fonts/fonts.conf not found!"
|
||||
ls -la /etc/fonts/ || echo "/etc/fonts/ directory doesn't exist"
|
||||
fi
|
||||
# Test fontconfig is working
|
||||
echo "Testing fc-list..."
|
||||
fc-list | head -5 || echo "fc-list failed"
|
||||
echo "Fontconfig setup verified."
|
||||
|
||||
- name: Start FreeCAD GUI with MCP bridge
|
||||
env:
|
||||
DISPLAY: ":99"
|
||||
QT_QPA_PLATFORM: xcb
|
||||
# Use software rendering for OpenGL (more reliable in CI)
|
||||
LIBGL_ALWAYS_SOFTWARE: "1"
|
||||
# Explicit fontconfig paths for AppImage compatibility
|
||||
# The AppImage's bundled fontconfig may not find system config automatically
|
||||
FONTCONFIG_FILE: /etc/fonts/fonts.conf
|
||||
FONTCONFIG_PATH: /etc/fonts
|
||||
# Set XDG_RUNTIME_DIR to avoid Qt warning
|
||||
XDG_RUNTIME_DIR: /tmp/runtime-root
|
||||
run: |
|
||||
# Create XDG_RUNTIME_DIR
|
||||
mkdir -p "$XDG_RUNTIME_DIR"
|
||||
chmod 700 "$XDG_RUNTIME_DIR"
|
||||
|
||||
echo "Starting FreeCAD GUI with MCP bridge under Xvfb + openbox..."
|
||||
echo "DISPLAY=$DISPLAY"
|
||||
echo "QT_QPA_PLATFORM=$QT_QPA_PLATFORM"
|
||||
echo "LIBGL_ALWAYS_SOFTWARE=$LIBGL_ALWAYS_SOFTWARE"
|
||||
echo "XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR"
|
||||
|
||||
# Verify freecadcmd works (headless mode)
|
||||
echo "=== Testing freecadcmd (headless) ==="
|
||||
freecadcmd --version || echo "freecadcmd failed"
|
||||
|
||||
# Export fontconfig vars so they're available to backgrounded process
|
||||
export FONTCONFIG_FILE FONTCONFIG_PATH
|
||||
|
||||
# Start FreeCAD GUI (not headless) with MCP bridge
|
||||
# Uses blocking_bridge.py which blocks with run_forever() to keep process alive
|
||||
# GUI features are available since we're using 'freecad' not 'freecadcmd'
|
||||
# Use setsid to create a new process group for reliable cleanup
|
||||
setsid freecad addon/FreecadRobustMCP/freecad_mcp_bridge/blocking_bridge.py > /tmp/freecad_gui.log 2>&1 &
|
||||
FREECAD_PID=$!
|
||||
echo "FREECAD_PID=$FREECAD_PID" >> "$GITHUB_ENV"
|
||||
|
||||
echo "Waiting for MCP bridge to start..."
|
||||
# Send xdotool events to help FreeCAD GUI initialize
|
||||
# FreeCAD needs mouse/keyboard events to process its event queue
|
||||
for i in {1..90}; do
|
||||
# Send synthetic events to help FreeCAD initialize
|
||||
xdotool mousemove $((400 + i*3)) $((300 + i*3)) click 1 key Escape 2>/dev/null || true
|
||||
|
||||
# Check if process is still running
|
||||
if ! ps -p "$FREECAD_PID" > /dev/null 2>&1; then
|
||||
echo "ERROR: FreeCAD process died (PID $FREECAD_PID)"
|
||||
echo "=== FreeCAD GUI log ==="
|
||||
cat /tmp/freecad_gui.log || echo "Log file is empty or missing"
|
||||
exit 1
|
||||
fi
|
||||
if curl -s --max-time 2 -X POST \
|
||||
-H "Content-Type: text/xml" \
|
||||
-d '<?xml version="1.0"?><methodCall><methodName>system.listMethods</methodName></methodCall>' \
|
||||
http://localhost:9875 > /dev/null 2>&1; then
|
||||
echo "MCP bridge is ready (took ${i}s)"
|
||||
break
|
||||
fi
|
||||
if [ "$i" -eq 90 ]; then
|
||||
echo "ERROR: MCP bridge did not start within 90s"
|
||||
echo "=== FreeCAD GUI log ==="
|
||||
cat /tmp/freecad_gui.log || echo "Log file is empty or missing"
|
||||
echo "=== Process status ==="
|
||||
pgrep -a freecad || echo "No freecad processes found"
|
||||
kill -- "-$FREECAD_PID" 2>/dev/null || kill "$FREECAD_PID" 2>/dev/null || true
|
||||
exit 1
|
||||
fi
|
||||
# Show progress every 10 seconds
|
||||
if [ $((i % 10)) -eq 0 ]; then
|
||||
echo "Still waiting... (${i}s)"
|
||||
# Show last few lines of log
|
||||
tail -5 /tmp/freecad_gui.log 2>/dev/null || true
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
# Verify GUI is available
|
||||
sleep 2
|
||||
BRIDGE_INSTANCE_ID=$(grep -o 'FREECAD_MCP_BRIDGE_INSTANCE_ID=[^ ]*' /tmp/freecad_gui.log | cut -d= -f2 | head -1)
|
||||
echo "Bridge Instance ID: $BRIDGE_INSTANCE_ID"
|
||||
|
||||
# Check if GUI is up
|
||||
if grep -q "GuiUp.*True\|GUI.*available" /tmp/freecad_gui.log 2>/dev/null; then
|
||||
echo "FreeCAD GUI is available"
|
||||
else
|
||||
echo "Note: Could not confirm GUI status from log (may still work)"
|
||||
fi
|
||||
|
||||
- name: Run GUI mode integration tests
|
||||
env:
|
||||
FREECAD_MODE: xmlrpc
|
||||
DISPLAY: ":99"
|
||||
# Tests for GUI-only features (screenshots, visibility, colors, camera, etc.)
|
||||
# GUI tests under Xvfb can be flaky; don't fail the workflow during stabilization
|
||||
continue-on-error: true
|
||||
run: |
|
||||
uv run pytest tests/integration/test_gui_mode.py -v --tb=short
|
||||
|
||||
- name: Upload FreeCAD logs on failure
|
||||
if: failure() || cancelled()
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: freecad-gui-logs
|
||||
path: /tmp/freecad_gui.log
|
||||
retention-days: 7
|
||||
if-no-files-found: ignore
|
||||
|
||||
- name: Stop FreeCAD, openbox, and Xvfb
|
||||
if: always()
|
||||
run: |
|
||||
if [ -n "$FREECAD_PID" ]; then
|
||||
# Kill process group (handles child processes spawned by FreeCAD/AppImage)
|
||||
kill -- "-$FREECAD_PID" 2>/dev/null || kill "$FREECAD_PID" 2>/dev/null || true
|
||||
fi
|
||||
if [ -n "$OPENBOX_PID" ]; then
|
||||
kill "$OPENBOX_PID" 2>/dev/null || true
|
||||
fi
|
||||
if [ -n "$XVFB_PID" ]; then
|
||||
kill "$XVFB_PID" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
lint-macros:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
name: MCP Server Release
|
||||
name: Robust MCP Server Release
|
||||
|
||||
# Trigger on tag push matching the component-specific pattern
|
||||
on:
|
||||
@@ -176,7 +176,7 @@ jobs:
|
||||
name: Publish to TestPyPI
|
||||
needs: [validate-tag, build, test-install]
|
||||
runs-on: ubuntu-latest
|
||||
if: contains(needs.validate-tag.outputs.version, '-alpha')
|
||||
if: contains(needs.validate-tag.outputs.version, '-')
|
||||
environment:
|
||||
name: testpypi
|
||||
url: https://test.pypi.org/p/freecad-robust-mcp
|
||||
@@ -199,7 +199,7 @@ jobs:
|
||||
name: Publish to PyPI
|
||||
needs: [validate-tag, build, test-install]
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ !contains(needs.validate-tag.outputs.version, '-alpha') }}
|
||||
if: ${{ !contains(needs.validate-tag.outputs.version, '-') }}
|
||||
environment:
|
||||
name: pypi
|
||||
url: https://pypi.org/p/freecad-robust-mcp
|
||||
@@ -299,7 +299,7 @@ jobs:
|
||||
run: |
|
||||
VERSION="${{ needs.validate-tag.outputs.version }}"
|
||||
# Match header exactly as it appears in CHANGELOG.md
|
||||
HEADER="### MCP Server v${VERSION}"
|
||||
HEADER="### Robust MCP Server v${VERSION}"
|
||||
|
||||
# Extract section between this version header and the next component header or separator
|
||||
# Only exit on: "---" separator OR "### " followed by component name (capital letter)
|
||||
@@ -327,7 +327,7 @@ jobs:
|
||||
- name: Create GitHub Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
name: "MCP Server v${{ needs.validate-tag.outputs.version }}"
|
||||
name: "Robust MCP Server v${{ needs.validate-tag.outputs.version }}"
|
||||
tag_name: ${{ github.ref_name }}
|
||||
prerelease: ${{ needs.validate-tag.outputs.is_prerelease == 'true' }}
|
||||
generate_release_notes: true
|
||||
@@ -349,14 +349,14 @@ jobs:
|
||||
IS_PRERELEASE: ${{ needs.validate-tag.outputs.is_prerelease }}
|
||||
run: |
|
||||
{
|
||||
echo "## MCP Server Release Summary"
|
||||
echo "## Robust MCP Server Release Summary"
|
||||
echo ""
|
||||
echo "**Version:** $VERSION"
|
||||
echo "**Prerelease:** $IS_PRERELEASE"
|
||||
echo ""
|
||||
} >> "$GITHUB_STEP_SUMMARY"
|
||||
|
||||
if [[ "$VERSION" == *"-alpha"* ]]; then
|
||||
if [[ "$VERSION" == *"-"* ]]; then
|
||||
{
|
||||
echo "### Install from TestPyPI"
|
||||
echo ""
|
||||
|
||||
@@ -96,7 +96,7 @@ jobs:
|
||||
|
||||
# Create README for the archive
|
||||
cat > "staging/freecad-mcp-workbench-${VERSION}/README.md" << EOF
|
||||
# FreeCAD MCP Bridge Workbench
|
||||
# Robust MCP Bridge Workbench
|
||||
|
||||
**Version:** ${VERSION}
|
||||
|
||||
@@ -106,7 +106,7 @@ jobs:
|
||||
|
||||
1. Open FreeCAD
|
||||
2. Go to **Tools → Addon Manager**
|
||||
3. Search for "MCP Bridge"
|
||||
3. Search for "Robust MCP Bridge"
|
||||
4. Click **Install**
|
||||
5. Restart FreeCAD
|
||||
|
||||
@@ -120,7 +120,7 @@ jobs:
|
||||
|
||||
## Usage
|
||||
|
||||
1. Switch to the **MCP Bridge** workbench
|
||||
1. Switch to the **Robust MCP Bridge** workbench
|
||||
2. Click **Start MCP Bridge** in the toolbar
|
||||
3. Connect your MCP client (Claude Code, etc.)
|
||||
|
||||
@@ -152,7 +152,7 @@ jobs:
|
||||
run: |
|
||||
VERSION="${{ steps.version.outputs.version }}"
|
||||
# Match header exactly as it appears in CHANGELOG.md (with optional space before v)
|
||||
HEADER="### MCP Bridge Workbench v${VERSION}"
|
||||
HEADER="### Robust MCP Bridge Workbench v${VERSION}"
|
||||
|
||||
# Extract section between this version header and the next component header or separator
|
||||
# Only exit on: "---" separator OR "### " followed by component name (capital letter)
|
||||
@@ -167,19 +167,19 @@ jobs:
|
||||
|
||||
# Build release body with changelog content if available
|
||||
cat > release_body.md << 'STATIC_EOF'
|
||||
## FreeCAD MCP Bridge Workbench v${{ steps.version.outputs.version }}
|
||||
## Robust MCP Bridge Workbench v${{ steps.version.outputs.version }}
|
||||
|
||||
This release contains the MCP Bridge workbench for FreeCAD.
|
||||
This release contains the Robust MCP Bridge workbench for FreeCAD.
|
||||
|
||||
### Installation
|
||||
|
||||
**Recommended:** Install via FreeCAD's Addon Manager (search for "MCP Bridge").
|
||||
**Recommended:** Install via FreeCAD's Addon Manager (search for "Robust MCP Bridge").
|
||||
|
||||
**Manual:** Download and extract to your FreeCAD Mod directory.
|
||||
|
||||
### What's Included
|
||||
|
||||
- MCP Bridge workbench for GUI and headless FreeCAD
|
||||
- Robust MCP Bridge workbench for GUI and headless FreeCAD
|
||||
- XML-RPC and JSON-RPC server support
|
||||
- Toolbar commands for bridge control
|
||||
|
||||
@@ -198,7 +198,7 @@ jobs:
|
||||
- name: Create GitHub Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
name: "MCP Bridge Workbench v${{ steps.version.outputs.version }}"
|
||||
name: "Robust MCP Bridge Workbench v${{ steps.version.outputs.version }}"
|
||||
tag_name: ${{ github.ref_name }}
|
||||
prerelease: ${{ steps.version.outputs.is_prerelease == 'true' }}
|
||||
generate_release_notes: true
|
||||
@@ -214,7 +214,7 @@ jobs:
|
||||
VERSION="${{ steps.version.outputs.version }}"
|
||||
|
||||
{
|
||||
echo "## MCP Bridge Workbench Release"
|
||||
echo "## Robust MCP Bridge Workbench Release"
|
||||
echo ""
|
||||
echo "**Version:** ${VERSION}"
|
||||
echo ""
|
||||
|
||||
@@ -47,6 +47,8 @@ jobs:
|
||||
# Skip hooks that don't work well in CI:
|
||||
# - no-commit-to-branch: Always fails in CI (we're on main/master)
|
||||
# - trufflehog: Has wasm/go-re2 panic bug in GitHub Actions environment
|
||||
# Note: shellcheck, hadolint, trivy use mise-managed binaries which ARE
|
||||
# installed by mise-action above, so they should work in CI.
|
||||
SKIP: no-commit-to-branch,trufflehog
|
||||
# Safety CLI API key for dependency vulnerability scanning
|
||||
SAFETY_API_KEY: ${{ secrets.SAFETY_API_KEY }}
|
||||
|
||||
@@ -55,5 +55,7 @@ jobs:
|
||||
run: uv run mypy src/
|
||||
|
||||
# Note: FreeCAD integration tests are handled by the "Integration Tests" workflow
|
||||
# (macro-test.yaml) which runs on every PR. That workflow sets up FreeCAD
|
||||
# AppImage and runs tests/integration/ tests with proper headless configuration.
|
||||
# (macro-test.yaml) which runs on every PR. That workflow provides:
|
||||
# - Headless tests: test_headless_mode.py, test_cut_object_for_magnets.py, test_multi_export.py
|
||||
# - GUI tests: test_gui_mode.py (uses Xvfb virtual display)
|
||||
# See .github/workflows/macro-test.yaml for details.
|
||||
|
||||
Reference in New Issue
Block a user