-
Notifications
You must be signed in to change notification settings - Fork 1
Implement verify automatically on macOS and Linux #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b221faf
Add Python native platform search paths
aeb3d15
Add Python SDK example verification
337d821
Fix Python example verifier workflow syntax
585a804
Clean up Python native verifier probe
53d5091
Verify Python examples against PR checkout
6240539
Relax Python example verification on PRs
bece3a9
Strengthen Python example live verification
2f813e8
Verify Linux native dependencies in examples
23a788a
Redact live example verifier output
24a11b4
Clean up failed Python example verification projects
a45537e
Stabilize Python example missing-env checks
ed5427f
Use stable draft id for Python live verification
b53582c
Relax Linux example native rpath checks
ef31875
Fail PR example verification on bundled OpenSSL
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,196 @@ | ||
| name: Verify SDK Examples | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [main] | ||
| push: | ||
| branches: [iml_verify_auto] | ||
|
dIvYaNshhh marked this conversation as resolved.
dIvYaNshhh marked this conversation as resolved.
|
||
| workflow_dispatch: | ||
| inputs: | ||
| mode: | ||
| description: 'offline, live, or auto' | ||
| required: true | ||
| default: 'auto' | ||
| pypi_version: | ||
| description: 'PyPI version to verify' | ||
| required: true | ||
| default: 'latest' | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| verify-examples: | ||
| name: ${{ matrix.platform }} | ||
| runs-on: ${{ matrix.os }} | ||
| timeout-minutes: 30 | ||
| env: | ||
| VERIFY_EXAMPLES_MODE: ${{ github.event_name == 'workflow_dispatch' && inputs.mode || 'auto' }} | ||
| VERIFY_PYPI_VERSION: ${{ github.event_name == 'workflow_dispatch' && inputs.pypi_version || 'latest' }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - platform: darwin-arm64 | ||
| os: macos-15 | ||
| native_module: gopher_mcp_python_native_darwin_arm64 | ||
| - platform: linux-x64 | ||
| os: ubuntu-22.04 | ||
| native_module: gopher_mcp_python_native_linux_x64 | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.11' | ||
|
|
||
| - name: Remove Homebrew on macOS | ||
| if: runner.os == 'macOS' && runner.environment == 'github-hosted' | ||
| shell: bash | ||
| run: | | ||
| echo "=== Removing Homebrew to simulate clean machine ===" | ||
| sudo rm -rf /opt/homebrew /usr/local/Homebrew /usr/local/Cellar | ||
| sudo rm -f /usr/local/bin/brew /opt/homebrew/bin/brew | ||
| echo "Homebrew removed" | ||
|
|
||
| - name: Install SDK package for native preflight | ||
| shell: bash | ||
| run: | | ||
| python -m venv native-preflight | ||
| source native-preflight/bin/activate | ||
| python -m pip install --upgrade pip | ||
| if [ "${{ github.event_name }}" = "pull_request" ]; then | ||
| python -m pip install -e . "gopher-mcp-python-native-${{ matrix.platform }}" | ||
| elif [ "$VERIFY_PYPI_VERSION" = "latest" ]; then | ||
| python -m pip install gopher-mcp-python gopher-mcp-python-native-${{ matrix.platform }} | ||
|
dIvYaNshhh marked this conversation as resolved.
|
||
| else | ||
| python -m pip install "gopher-mcp-python==${VERIFY_PYPI_VERSION}" "gopher-mcp-python-native-${{ matrix.platform }}==${VERIFY_PYPI_VERSION}" | ||
| fi | ||
|
|
||
| - name: Verify macOS native package | ||
| if: runner.os == 'macOS' | ||
| shell: bash | ||
| run: | | ||
| source native-preflight/bin/activate | ||
| native_lib_dir="$( | ||
| python -c 'import importlib; module = importlib.import_module("${{ matrix.native_module }}"); print(module.get_lib_path())' | ||
| )" | ||
| cd "$native_lib_dir" | ||
|
|
||
| echo "=== Code Signatures ===" | ||
| failed=0 | ||
| for f in *.dylib; do | ||
| if codesign -v "$f" 2>&1; then | ||
| echo "OK $f" | ||
| else | ||
| echo "FAILED $f: $(codesign -v "$f" 2>&1)" | ||
| failed=1 | ||
| fi | ||
| done | ||
| [ "$failed" -eq 0 ] || exit 1 | ||
|
|
||
| echo "=== Homebrew Path Check ===" | ||
| for f in *.dylib; do | ||
| [ -L "$f" ] && continue | ||
| if otool -L "$f" | grep -qE '/usr/local/|/opt/homebrew/'; then | ||
| echo "FAILED $f has Homebrew paths:" | ||
| otool -L "$f" | grep -E '/usr/local/|/opt/homebrew/' | ||
| exit 1 | ||
| fi | ||
| done | ||
|
|
||
| echo "=== Bundled @loader_path Dependencies ===" | ||
| missing=0 | ||
| for f in *.dylib; do | ||
| [ -L "$f" ] && continue | ||
| while read -r dep rest; do | ||
| name="${dep#@loader_path/}" | ||
| if [ ! -f "$name" ]; then | ||
| echo "MISSING $name needed by $f" | ||
| missing=1 | ||
| fi | ||
| done < <(otool -L "$f" | grep "@loader_path/" || true) | ||
| done | ||
| [ "$missing" -eq 0 ] || exit 1 | ||
|
|
||
| - name: Verify Linux native package | ||
|
dIvYaNshhh marked this conversation as resolved.
|
||
| if: runner.os == 'Linux' | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| source native-preflight/bin/activate | ||
| native_lib_dir="$( | ||
| python -c 'import importlib; module = importlib.import_module("${{ matrix.native_module }}"); print(module.get_lib_path())' | ||
| )" | ||
| cd "$native_lib_dir" | ||
|
|
||
| echo "=== Linux Native Dependencies ===" | ||
| found=0 | ||
| for sofile in *.so *.so.*; do | ||
| [ -L "$sofile" ] && continue | ||
| [ -f "$sofile" ] || continue | ||
| found=1 | ||
| echo "--- $sofile" | ||
| rpath="$(readelf -d "$sofile" | grep -E 'RUNPATH|RPATH' || true)" | ||
| if [ -n "$rpath" ]; then | ||
| echo "$rpath" | ||
| if ! grep -Fq '$ORIGIN' <<<"$rpath"; then | ||
| echo "Linux native library $sofile has RPATH/RUNPATH without \$ORIGIN" | ||
| exit 1 | ||
| fi | ||
| else | ||
| echo "No RPATH/RUNPATH declared for $sofile" | ||
| fi | ||
| LD_LIBRARY_PATH="$native_lib_dir:${LD_LIBRARY_PATH:-}" ldd "$sofile" | tee /tmp/ldd.out | ||
| missing="$(awk '/not found/ {print $1}' /tmp/ldd.out | grep -Ev '^(libssl\.so|libcrypto\.so)' || true)" | ||
| if [ -n "$missing" ]; then | ||
| echo "$missing" | ||
| echo "Missing shared dependency for $sofile" | ||
| exit 1 | ||
| fi | ||
| done | ||
|
|
||
| if find "$native_lib_dir" -maxdepth 1 -type f \( -name 'libssl.so*' -o -name 'libcrypto.so*' \) | grep .; then | ||
| if [ "${{ github.event_name }}" = "pull_request" ]; then | ||
| echo "OpenSSL libraries must remain system-provided in PR-built packages." | ||
| exit 1 | ||
| fi | ||
| echo "WARNING: OpenSSL libraries should remain system-provided in newly published packages." | ||
|
dIvYaNshhh marked this conversation as resolved.
|
||
| fi | ||
|
|
||
| if [ "$found" -ne 1 ]; then | ||
| echo "No Linux shared libraries found in $native_lib_dir" | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Verify native loading | ||
| shell: bash | ||
| run: | | ||
| source native-preflight/bin/activate | ||
| python scripts/verify-example-native-probe.py | ||
|
|
||
| - name: Verify examples | ||
| shell: bash | ||
| env: | ||
| LLM_PROVIDER: ${{ secrets.LLM_PROVIDER || 'AnthropicProvider' }} | ||
| LLM_MODEL: ${{ secrets.LLM_MODEL }} | ||
| ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} | ||
| GOPHER_API_KEY: ${{ secrets.GOPHER_API_KEY }} | ||
| GOPHER_MCP_URL: ${{ secrets.GOPHER_MCP_URL }} | ||
| GOPHER_SDK_TEST: true | ||
| SDK_INSTALL_SPEC: ${{ github.event_name == 'pull_request' && github.workspace || '' }} | ||
| run: | | ||
| VERIFY_LIVE_PROMPT="list my draft mails" \ | ||
| VERIFY_EXPECTED_ANSWER="r-2553040815323886578" \ | ||
| scripts/verify-examples.sh --mode "$VERIFY_EXAMPLES_MODE" --only create_by_api_key | ||
| VERIFY_LIVE_PROMPT="list my draft mails" \ | ||
| VERIFY_EXPECTED_ANSWER="r-2553040815323886578" \ | ||
| scripts/verify-examples.sh --mode "$VERIFY_EXAMPLES_MODE" --only create_by_url | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| #!/usr/bin/env python3 | ||
| """Verify that the installed Python SDK can load the native gopher-orch library.""" | ||
|
|
||
| import sys | ||
|
|
||
| from gopher_mcp_python.ffi.library import GopherOrchLibrary | ||
|
|
||
|
|
||
| def fail(message: str) -> None: | ||
| print(f"[verify-native] error: {message}", file=sys.stderr) | ||
| sys.exit(1) | ||
|
|
||
|
|
||
| def main() -> None: | ||
| library = GopherOrchLibrary.get_instance() | ||
| if library is None: | ||
| fail(GopherOrchLibrary.get_load_error_message()) | ||
|
|
||
| print("[verify-native] native library loaded") | ||
|
|
||
| required_symbols = ( | ||
| "gopher_orch_agent_create_by_json", | ||
| "gopher_orch_agent_create_by_api_key", | ||
| "gopher_orch_agent_run", | ||
| "gopher_orch_agent_release", | ||
| "gopher_orch_api_fetch_servers", | ||
| "gopher_orch_last_error", | ||
| "gopher_orch_clear_error", | ||
| "gopher_orch_free", | ||
| ) | ||
| native_library = getattr(library, "_lib", None) | ||
| missing = [ | ||
| symbol | ||
| for symbol in required_symbols | ||
| if native_library is None or not hasattr(native_library, symbol) | ||
| ] | ||
| if missing: | ||
| fail(f"native library missing required symbols: {', '.join(missing)}") | ||
|
|
||
| print("[verify-native] required symbols present") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.