Update GitHub Actions workflows to install requirements and enforce n… #4
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
| name: Required Native Library Tests | |
| on: | |
| push: | |
| branches: [ "master", "main" ] | |
| paths: | |
| - 'pyhelios/**' | |
| - 'build_scripts/**' | |
| - 'helios-core/**' | |
| - 'tests/**' | |
| - 'setup.py' | |
| - 'requirements*.txt' | |
| pull_request: | |
| branches: [ "master", "main" ] | |
| workflow_dispatch: | |
| jobs: | |
| test-native-libraries: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| name: Required Native Build and Test on ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.11" | |
| - name: Install dependencies using Helios script (Linux/macOS) | |
| if: matrix.os != 'windows-latest' | |
| run: | | |
| cd helios-core | |
| chmod +x utilities/dependencies.sh | |
| # Install VIS dependencies (includes base + OpenGL/X11 for visualization) | |
| bash utilities/dependencies.sh VIS | |
| - name: Set up MSVC (Windows) | |
| if: matrix.os == 'windows-latest' | |
| uses: ilammy/msvc-dev-cmd@v1 | |
| - name: Install basic dependencies (Windows) | |
| if: matrix.os == 'windows-latest' | |
| run: | | |
| # Note: dependencies.sh doesn't handle Windows package installation | |
| # but provides guidance. MSVC is already set up above. | |
| echo "Windows dependencies: Visual Studio (MSVC) is already configured" | |
| - name: Install Python dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install pytest pytest-cov | |
| pip install -e . | |
| - name: Check initial PyHelios status (should be in mock mode) | |
| run: | | |
| python -c " | |
| from pyhelios.plugins import get_plugin_info | |
| info = get_plugin_info() | |
| print(f'Platform: {info[\"platform\"]}') | |
| print(f'Mock mode: {info[\"is_mock\"]}') | |
| print(f'Native available: {info[\"native_available\"]}') | |
| assert info['is_mock'] == True, 'Should start in mock mode' | |
| print('✓ Correctly starting in mock mode') | |
| " | |
| - name: Build native Helios libraries | |
| id: build | |
| run: | | |
| echo "Building native libraries..." | |
| python build_scripts/build_helios.py --verbose | |
| echo "build_success=true" >> $GITHUB_OUTPUT | |
| - name: Check library files after build | |
| if: steps.build.outcome == 'success' | |
| run: | | |
| echo "Checking for built library files..." | |
| find pyhelios/plugins/ -name "*.dll" -o -name "*.so" -o -name "*.dylib" | head -10 | |
| ls -la pyhelios/plugins/ | |
| - name: Test PyHelios with native libraries | |
| run: | | |
| python -c " | |
| from pyhelios.plugins import get_plugin_info | |
| info = get_plugin_info() | |
| print(f'Platform: {info[\"platform\"]}') | |
| print(f'Mock mode: {info[\"is_mock\"]}') | |
| print(f'Native available: {info[\"native_available\"]}') | |
| if not info['is_mock']: | |
| print('✓ Successfully loaded native libraries!') | |
| # Test basic Context functionality | |
| from pyhelios import Context, DataTypes | |
| with Context() as ctx: | |
| print(f'Context created successfully') | |
| count = ctx.getPrimitiveCount() | |
| print(f'Initial primitive count: {count}') | |
| # Test adding a patch | |
| center = DataTypes.vec3(1, 2, 3) | |
| size = DataTypes.vec2(1, 1) | |
| color = DataTypes.RGBcolor(0.5, 0.5, 0.5) | |
| patch_id = ctx.addPatch(center=center, size=size, color=color) | |
| print(f'Added patch with ID: {patch_id}') | |
| new_count = ctx.getPrimitiveCount() | |
| print(f'New primitive count: {new_count}') | |
| assert new_count == count + 1, f'Expected {count + 1}, got {new_count}' | |
| print('✓ Native Context functionality working!') | |
| else: | |
| print('ERROR: Still in mock mode - native libraries not loaded') | |
| exit(1) | |
| " | |
| - name: Run native-specific tests | |
| run: | | |
| pytest tests/ -v -m "native_only or integration" --tb=short | |
| - name: Run all tests (should have fewer skips if native libraries available) | |
| run: | | |
| pytest tests/ -v --tb=short | |
| - name: Test WeberPennTree with native libraries | |
| run: | | |
| python -c " | |
| try: | |
| from pyhelios import Context, WeberPennTree, WPTType | |
| from pyhelios.plugins import is_native_library_available | |
| if is_native_library_available(): | |
| print('Testing WeberPennTree with native libraries...') | |
| with Context() as ctx: | |
| with WeberPennTree(ctx) as wpt: | |
| tree_id = wpt.buildTree(WPTType.LEMON) | |
| print(f'✓ Built tree with ID: {tree_id}') | |
| trunk_uuids = wpt.getTrunkUUIDs(tree_id) | |
| print(f'✓ Tree has {len(trunk_uuids)} trunk segments') | |
| else: | |
| print('ERROR: Native libraries not available for WeberPennTree testing') | |
| exit(1) | |
| except Exception as e: | |
| print(f'WeberPennTree test failed: {e}') | |
| exit(1) | |
| " | |
| - name: Generate build artifacts | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: native-libraries-${{ matrix.os }} | |
| path: | | |
| pyhelios/plugins/*.dll | |
| pyhelios/plugins/*.so | |
| pyhelios/plugins/*.dylib | |
| retention-days: 7 | |
| - name: Summary | |
| run: | | |
| echo "## Build and Test Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "✅ Native library build and tests: SUCCESS" >> $GITHUB_STEP_SUMMARY | |
| echo "- Native Helios libraries were built successfully" >> $GITHUB_STEP_SUMMARY | |
| echo "- Full PyHelios functionality is available and tested" >> $GITHUB_STEP_SUMMARY | |
| echo "- All native integration tests passed" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "This workflow ensures that PyHelios maintains full native library integration." >> $GITHUB_STEP_SUMMARY |