Build and Test #7
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: Build and Test | |
| on: | |
| workflow_dispatch: | |
| workflow_call: | |
| outputs: | |
| addon-artifact: | |
| description: "Name of the addon artifact" | |
| value: godot-addon | |
| jobs: | |
| test-runtime: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Run runtime tests | |
| run: cargo test --manifest-path runtime/Cargo.toml | |
| # Build Docker image once and share across all Docker-based build jobs | |
| build-docker-image: | |
| needs: test-runtime | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: docker/ | |
| load: true | |
| tags: bobbin-build | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Save Docker image | |
| run: docker save bobbin-build -o bobbin-build.tar | |
| - name: Upload Docker image | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: docker-image | |
| path: bobbin-build.tar | |
| retention-days: 1 | |
| build-linux-release: | |
| needs: build-docker-image | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download Docker image | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: docker-image | |
| - name: Load Docker image | |
| run: docker load -i bobbin-build.tar | |
| - name: Build Linux release | |
| run: docker run --rm -v ${{ github.workspace }}:/workspace bobbin-build linux release --ci | |
| - name: Upload Linux release binary | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: linux-release | |
| path: bindings/godot/addons/bobbin/bin/libbobbin_godot.so | |
| build-linux-debug: | |
| needs: build-docker-image | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download Docker image | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: docker-image | |
| - name: Load Docker image | |
| run: docker load -i bobbin-build.tar | |
| - name: Build Linux debug | |
| run: docker run --rm -v ${{ github.workspace }}:/workspace bobbin-build linux debug --ci | |
| - name: Upload Linux debug binary | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: linux-debug | |
| path: bindings/godot/addons/bobbin/bin/libbobbin_godot.debug.so | |
| build-windows-release: | |
| needs: build-docker-image | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download Docker image | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: docker-image | |
| - name: Load Docker image | |
| run: docker load -i bobbin-build.tar | |
| - name: Build Windows release | |
| run: docker run --rm -v ${{ github.workspace }}:/workspace bobbin-build windows release --ci | |
| - name: Upload Windows release binary | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: windows-release | |
| path: bindings/godot/addons/bobbin/bin/bobbin_godot.dll | |
| build-windows-debug: | |
| needs: build-docker-image | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download Docker image | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: docker-image | |
| - name: Load Docker image | |
| run: docker load -i bobbin-build.tar | |
| - name: Build Windows debug | |
| run: docker run --rm -v ${{ github.workspace }}:/workspace bobbin-build windows debug --ci | |
| - name: Upload Windows debug binary | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: windows-debug | |
| path: bindings/godot/addons/bobbin/bin/bobbin_godot.debug.dll | |
| build-wasm: | |
| needs: build-docker-image | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download Docker image | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: docker-image | |
| - name: Load Docker image | |
| run: docker load -i bobbin-build.tar | |
| - name: Build WASM | |
| run: docker run --rm -v ${{ github.workspace }}:/workspace bobbin-build wasm --ci | |
| - name: Upload WASM binary | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wasm-binary | |
| path: bindings/godot/addons/bobbin/bin/bobbin_godot.wasm | |
| build-macos: | |
| needs: test-runtime | |
| runs-on: macos-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download Godot 4.3 | |
| run: | | |
| curl -L -o godot.zip https://github.com/godotengine/godot/releases/download/4.3-stable/Godot_v4.3-stable_macos.universal.zip | |
| unzip godot.zip | |
| echo "GODOT4_BIN=${{ github.workspace }}/Godot.app/Contents/MacOS/Godot" >> $GITHUB_ENV | |
| - name: Install Rust nightly | |
| run: | | |
| rustup toolchain install nightly | |
| rustup component add rust-src --toolchain nightly | |
| - name: Set LLVM path | |
| run: echo "LLVM_PATH=$(brew --prefix llvm)" >> $GITHUB_ENV | |
| - name: Build release | |
| run: cargo +nightly build --manifest-path bindings/godot/Cargo.toml --release | |
| - name: Build debug | |
| run: cargo +nightly build --manifest-path bindings/godot/Cargo.toml | |
| - name: Upload macOS binaries | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: macos-binaries | |
| path: | | |
| bindings/godot/target/release/libbobbin_godot.dylib | |
| bindings/godot/target/debug/libbobbin_godot.dylib | |
| test-linux: | |
| needs: build-linux-debug | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup addon directory | |
| run: | | |
| mkdir -p tests/godot_project/addons/bobbin/bin/ | |
| cp -r bindings/godot/addons/bobbin/* tests/godot_project/addons/bobbin/ | |
| - name: Download Linux debug binary | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: linux-debug | |
| path: tests/godot_project/addons/bobbin/bin/ | |
| - name: Verify addon setup | |
| run: ls -la tests/godot_project/addons/bobbin/bin/ | |
| - name: Download Godot 4.3 | |
| run: | | |
| wget -q https://github.com/godotengine/godot/releases/download/4.3-stable/Godot_v4.3-stable_linux.x86_64.zip | |
| unzip Godot_v4.3-stable_linux.x86_64.zip | |
| chmod +x Godot_v4.3-stable_linux.x86_64 | |
| - name: Import project | |
| run: ./Godot_v4.3-stable_linux.x86_64 --headless --path tests/godot_project --import --quit || true | |
| - name: Run smoke test | |
| run: | | |
| # gdext may crash during shutdown even when tests pass, so check output | |
| output=$(./Godot_v4.3-stable_linux.x86_64 --headless --path tests/godot_project -s res://smoke_test.gd --quit 2>&1) || true | |
| echo "$output" | |
| if echo "$output" | grep -q "All smoke tests passed"; then | |
| echo "Tests passed!" | |
| exit 0 | |
| else | |
| echo "Tests failed!" | |
| exit 1 | |
| fi | |
| test-windows: | |
| needs: build-windows-debug | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup addon directory | |
| shell: pwsh | |
| run: | | |
| New-Item -ItemType Directory -Force -Path tests/godot_project/addons/bobbin/bin/ | |
| Copy-Item -Path bindings/godot/addons/bobbin/* -Destination tests/godot_project/addons/bobbin/ -Recurse -Force | |
| - name: Download Windows debug binary | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: windows-debug | |
| path: tests/godot_project/addons/bobbin/bin/ | |
| - name: Verify addon setup | |
| shell: pwsh | |
| run: | | |
| Write-Host "=== Addon bin directory ===" | |
| Get-ChildItem tests/godot_project/addons/bobbin/bin/ -ErrorAction SilentlyContinue | |
| Write-Host "=== Full addon structure ===" | |
| Get-ChildItem tests/godot_project/addons/bobbin/ -Recurse | |
| Write-Host "=== GDExtension file contents ===" | |
| Get-Content tests/godot_project/addons/bobbin/bobbin.gdextension | |
| - name: Download Godot 4.3 | |
| shell: pwsh | |
| run: | | |
| Invoke-WebRequest -Uri "https://github.com/godotengine/godot/releases/download/4.3-stable/Godot_v4.3-stable_win64.exe.zip" -OutFile godot.zip | |
| Expand-Archive godot.zip -DestinationPath . | |
| - name: Import project | |
| shell: pwsh | |
| run: ./Godot_v4.3-stable_win64.exe --headless --path tests/godot_project --import --quit; exit 0 | |
| - name: Run smoke test | |
| shell: pwsh | |
| run: | | |
| # gdext may crash during shutdown even when tests pass, so check output | |
| $output = & ./Godot_v4.3-stable_win64.exe --headless --path tests/godot_project -s res://smoke_test.gd --quit 2>&1 | Out-String | |
| Write-Host $output | |
| if ($output -match "All smoke tests passed") { | |
| Write-Host "Tests passed!" | |
| exit 0 | |
| } else { | |
| Write-Host "Tests failed!" | |
| exit 1 | |
| } | |
| # Verifies WASM binary works for Web export | |
| # Also downloads Linux binary so Godot can load the extension on the host | |
| test-wasm-export: | |
| needs: [build-wasm, build-linux-debug] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup addon directory | |
| run: | | |
| mkdir -p tests/godot_project/addons/bobbin/bin/ | |
| cp -r bindings/godot/addons/bobbin/* tests/godot_project/addons/bobbin/ | |
| - name: Download WASM binary | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: wasm-binary | |
| path: tests/godot_project/addons/bobbin/bin/ | |
| - name: Download Linux debug binary | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: linux-debug | |
| path: tests/godot_project/addons/bobbin/bin/ | |
| - name: Verify addon setup | |
| run: ls -la tests/godot_project/addons/bobbin/bin/ | |
| - name: Setup Godot with export templates | |
| uses: chickensoft-games/setup-godot@v2 | |
| with: | |
| version: 4.3.0 | |
| use-dotnet: false | |
| include-templates: true | |
| - name: Verify Godot setup | |
| run: godot --version | |
| - name: Import project | |
| run: godot --headless --path tests/godot_project --import --quit || true | |
| - name: Export to Web (WASM verification) | |
| run: | | |
| mkdir -p tests/godot_project/build/web | |
| godot --headless --path tests/godot_project --export-release "Web" build/web/index.html | |
| echo "WASM export succeeded - GDExtension loaded correctly" | |
| - name: Verify export output | |
| run: | | |
| ls -la tests/godot_project/build/web/ | |
| test -f tests/godot_project/build/web/index.html | |
| test -f tests/godot_project/build/web/index.wasm | |
| echo "PASS: Web export files generated successfully" | |
| test-macos: | |
| needs: build-macos | |
| runs-on: macos-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup addon directory | |
| run: | | |
| mkdir -p tests/godot_project/addons/bobbin/bin/ | |
| cp -r bindings/godot/addons/bobbin/* tests/godot_project/addons/bobbin/ | |
| - name: Download macOS binaries | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: macos-binaries | |
| path: macos-bin/ | |
| - name: Debug artifact contents | |
| run: | | |
| echo "=== Artifact contents ===" | |
| find macos-bin -type f | |
| - name: Install macOS binaries | |
| run: | | |
| cp macos-bin/release/libbobbin_godot.dylib tests/godot_project/addons/bobbin/bin/ | |
| cp macos-bin/debug/libbobbin_godot.dylib tests/godot_project/addons/bobbin/bin/libbobbin_godot.debug.dylib | |
| - name: Verify addon setup | |
| run: ls -la tests/godot_project/addons/bobbin/bin/ | |
| - name: Download Godot 4.3 | |
| run: | | |
| curl -L -o godot.zip https://github.com/godotengine/godot/releases/download/4.3-stable/Godot_v4.3-stable_macos.universal.zip | |
| unzip godot.zip | |
| - name: Remove quarantine | |
| run: xattr -dr com.apple.quarantine Godot.app tests/godot_project/addons/bobbin/bin/*.dylib || true | |
| - name: Import project | |
| run: ./Godot.app/Contents/MacOS/Godot --headless --path tests/godot_project --import --quit || true | |
| - name: Run smoke test | |
| run: | | |
| # gdext may crash during shutdown even when tests pass, so check output | |
| output=$(./Godot.app/Contents/MacOS/Godot --headless --path tests/godot_project -s res://smoke_test.gd --quit 2>&1) || true | |
| echo "$output" | |
| if echo "$output" | grep -q "All smoke tests passed"; then | |
| echo "Tests passed!" | |
| exit 0 | |
| else | |
| echo "Tests failed!" | |
| exit 1 | |
| fi | |
| # Assembles the complete addon with all platform binaries for release | |
| # Waits for all tests to pass and all release builds to complete | |
| assemble-addon: | |
| needs: [test-linux, test-windows, test-wasm-export, test-macos, build-linux-release, build-windows-release] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Create bin directory | |
| run: mkdir -p bindings/godot/addons/bobbin/bin/ | |
| - name: Download Linux release | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: linux-release | |
| path: bindings/godot/addons/bobbin/bin/ | |
| - name: Download Linux debug | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: linux-debug | |
| path: bindings/godot/addons/bobbin/bin/ | |
| - name: Download Windows release | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: windows-release | |
| path: bindings/godot/addons/bobbin/bin/ | |
| - name: Download Windows debug | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: windows-debug | |
| path: bindings/godot/addons/bobbin/bin/ | |
| - name: Download WASM binary | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: wasm-binary | |
| path: bindings/godot/addons/bobbin/bin/ | |
| - name: Download macOS binaries | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: macos-binaries | |
| path: macos-bin/ | |
| - name: Install macOS binaries | |
| run: | | |
| cp macos-bin/release/libbobbin_godot.dylib bindings/godot/addons/bobbin/bin/ | |
| cp macos-bin/debug/libbobbin_godot.dylib bindings/godot/addons/bobbin/bin/libbobbin_godot.debug.dylib | |
| - name: Show final addon contents | |
| run: | | |
| echo "=== Complete addon structure ===" | |
| find bindings/godot/addons -type f | |
| echo "=== Bin directory ===" | |
| ls -la bindings/godot/addons/bobbin/bin/ | |
| - name: Upload complete addon | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: godot-addon | |
| path: bindings/godot/addons/ |