Files
freecad-robust-mcp-fc111/.github/workflows/mcp-server-release.yaml
T
8c338f6da7 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>
2026-01-10 15:26:33 -08:00

385 lines
12 KiB
YAML

name: Robust MCP Server Release
# Trigger on tag push matching the component-specific pattern
on:
push:
tags:
- 'robust-mcp-server-v*'
workflow_dispatch:
workflow_call:
# Cancel in-progress runs for the same tag
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
DOCKERHUB_REPO: spkane/freecad-robust-mcp
jobs:
validate-tag:
name: Validate Tag Format
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
is_prerelease: ${{ steps.version.outputs.is_prerelease }}
steps:
- name: Validate semantic version tag
id: version
run: |
TAG="${GITHUB_REF#refs/tags/}"
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
# Extract version from tag (robust-mcp-server-v1.2.3 -> 1.2.3)
if [[ ! "$TAG" =~ ^robust-mcp-server-v([0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?)$ ]]; then
echo "ERROR: Tag '$TAG' does not match expected format (robust-mcp-server-vX.Y.Z or robust-mcp-server-vX.Y.Z-prerelease)"
exit 1
fi
VERSION="${BASH_REMATCH[1]}"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
# Check if this is a prerelease
if [[ "$VERSION" =~ -[a-zA-Z0-9.]+ ]]; then
echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
IS_PRERELEASE="true"
else
echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
IS_PRERELEASE="false"
fi
echo "Parsed version: $VERSION (prerelease: $IS_PRERELEASE)"
build:
name: Build Distribution
needs: validate-tag
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: "latest"
- name: Set up Python
run: uv python install 3.11
- name: Cache uv dependencies
uses: actions/cache@v4
with:
path: |
~/.cache/uv
.venv
key: ${{ runner.os }}-uv-${{ hashFiles('pyproject.toml', 'uv.lock') }}
restore-keys: |
${{ runner.os }}-uv-
- name: Install build dependencies
run: uv sync --all-extras
- name: Build package
env:
# Override setuptools-scm version for component-specific tag
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ needs.validate-tag.outputs.version }}
run: uv build
- name: Verify built package version
env:
TAG_VERSION: ${{ needs.validate-tag.outputs.version }}
run: |
# Extract version from built wheel filename
shopt -s nullglob
WHEEL_FILES=(dist/*.whl)
if [ ${#WHEEL_FILES[@]} -eq 0 ]; then
echo "ERROR: No wheel files found in dist/"
exit 1
fi
WHEEL_FILE="${WHEEL_FILES[0]}"
WHEEL_NAME=$(basename "$WHEEL_FILE")
# Extract version from wheel filename
WHEEL_VERSION=$(echo "$WHEEL_NAME" | sed -E 's/^[^-]+-([^-]+)-.*/\1/')
echo "Built wheel: $WHEEL_NAME"
echo "Wheel version: $WHEEL_VERSION"
echo "Expected tag version: $TAG_VERSION"
# Normalize the tag version for comparison (PEP 440)
NORMALIZED_TAG=$(echo "$TAG_VERSION" | sed -E '
s/-alpha\.([0-9]+)/a\1/
s/-alpha/a0/
s/-beta\.([0-9]+)/b\1/
s/-beta/b0/
s/-rc\.([0-9]+)/rc\1/
s/-rc/rc0/
')
echo "Normalized tag version: $NORMALIZED_TAG"
if [ "$WHEEL_VERSION" != "$NORMALIZED_TAG" ]; then
echo "ERROR: Built package version does not match git tag!"
echo " Wheel version: $WHEEL_VERSION"
echo " Expected (normalized): $NORMALIZED_TAG"
exit 1
fi
echo "Version verification passed!"
- name: Check package
run: uv run twine check dist/*
- name: List built artifacts
run: ls -la dist/
- name: Upload distribution artifacts
uses: actions/upload-artifact@v6
with:
name: python-package-distributions
path: dist/
test-install:
name: Test Installation
needs: [validate-tag, build]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ["3.11"]
steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Download distribution artifacts
uses: actions/download-artifact@v7
with:
name: python-package-distributions
path: dist/
- name: Install package from wheel
run: pip install dist/*.whl
- name: Verify installation
run: |
set -e
pip show freecad-robust-mcp
freecad-mcp --help
python -c "import freecad_mcp; print(f'freecad-robust-mcp version: {freecad_mcp.__version__ if hasattr(freecad_mcp, \"__version__\") else \"unknown\"}')"
publish-testpypi:
name: Publish to TestPyPI
needs: [validate-tag, build, test-install]
runs-on: ubuntu-latest
if: contains(needs.validate-tag.outputs.version, '-')
environment:
name: testpypi
url: https://test.pypi.org/p/freecad-robust-mcp
permissions:
id-token: write
steps:
- name: Download distribution artifacts
uses: actions/download-artifact@v7
with:
name: python-package-distributions
path: dist/
- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
publish-pypi:
name: Publish to PyPI
needs: [validate-tag, build, test-install]
runs-on: ubuntu-latest
if: ${{ !contains(needs.validate-tag.outputs.version, '-') }}
environment:
name: pypi
url: https://pypi.org/p/freecad-robust-mcp
permissions:
id-token: write
steps:
- name: Download distribution artifacts
uses: actions/download-artifact@v7
with:
name: python-package-distributions
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
docker-release:
name: Build and Push Docker Image
needs: [validate-tag, build, test-install]
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKERHUB_REPO }}
tags: |
type=raw,value=${{ needs.validate-tag.outputs.version }}
type=raw,value=${{ needs.validate-tag.outputs.version }},suffix=-mcp-server
type=raw,value=latest,enable=${{ needs.validate-tag.outputs.is_prerelease == 'false' }}
labels: |
org.opencontainers.image.title=FreeCAD Robust MCP Server
org.opencontainers.image.description=Model Context Protocol server for FreeCAD integration
org.opencontainers.image.vendor=spkane
org.opencontainers.image.version=${{ needs.validate-tag.outputs.version }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: true
sbom: true
- name: Test pushed image
run: |
docker pull ${{ env.DOCKERHUB_REPO }}:${{ needs.validate-tag.outputs.version }}
echo '{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}' | \
timeout 30 docker run --rm -i \
-e FREECAD_MODE=xmlrpc \
${{ env.DOCKERHUB_REPO }}:${{ needs.validate-tag.outputs.version }} 2>&1 | \
grep -q '"result"'
echo "Container test passed"
create-github-release:
name: Create GitHub Release
needs: [validate-tag, build, test-install]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Download distribution artifacts
uses: actions/download-artifact@v7
with:
name: python-package-distributions
path: dist/
- name: Extract changelog section
id: changelog
run: |
VERSION="${{ needs.validate-tag.outputs.version }}"
# Match header exactly as it appears in CHANGELOG.md
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)
# This allows #### Added, #### Changed, etc. to be included
CHANGELOG_CONTENT=$(awk -v header="$HEADER" '
BEGIN { found=0 }
$0 == header || $0 == header " " { found=1; next }
found && /^---$/ { exit }
found && /^### [A-Z]/ { exit }
found { print }
' CHANGELOG.md)
# Write to file for the release body (handles multiline)
echo "$CHANGELOG_CONTENT" > changelog_section.md
# Check if we got content
if [ -n "$CHANGELOG_CONTENT" ]; then
echo "found=true" >> "$GITHUB_OUTPUT"
echo "Extracted changelog section for $HEADER"
else
echo "found=false" >> "$GITHUB_OUTPUT"
echo "No changelog section found for $HEADER"
fi
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
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
body_path: ${{ steps.changelog.outputs.found == 'true' && 'changelog_section.md' || '' }}
files: dist/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
generate-summary:
name: Generate Release Summary
needs: [validate-tag, publish-pypi, publish-testpypi, docker-release, create-github-release]
if: always()
runs-on: ubuntu-latest
steps:
- name: Generate release summary
env:
VERSION: ${{ needs.validate-tag.outputs.version }}
IS_PRERELEASE: ${{ needs.validate-tag.outputs.is_prerelease }}
run: |
{
echo "## Robust MCP Server Release Summary"
echo ""
echo "**Version:** $VERSION"
echo "**Prerelease:** $IS_PRERELEASE"
echo ""
} >> "$GITHUB_STEP_SUMMARY"
if [[ "$VERSION" == *"-"* ]]; then
{
echo "### Install from TestPyPI"
echo ""
echo "\`\`\`bash"
echo "pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ freecad-robust-mcp"
echo "\`\`\`"
} >> "$GITHUB_STEP_SUMMARY"
else
{
echo "### Install from PyPI"
echo ""
echo "\`\`\`bash"
echo "pip install freecad-robust-mcp"
echo "\`\`\`"
} >> "$GITHUB_STEP_SUMMARY"
fi
{
echo ""
echo "### Docker"
echo ""
echo "\`\`\`bash"
echo "docker pull spkane/freecad-robust-mcp:$VERSION"
echo "\`\`\`"
} >> "$GITHUB_STEP_SUMMARY"