* 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>
216 lines
9.4 KiB
YAML
216 lines
9.4 KiB
YAML
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
|