Remove some slop from the interface rust <-> java #9
Workflow file for this run
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: Native build | ||
|
Check failure on line 1 in .github/workflows/native.yaml
|
||
| # Cross-compiles the Rust shared-core wrapper (sdk-core/src/main/rust) for every supported | ||
| # platform, smoke-tests the produced library, and uploads it as an artifact. The release pipeline | ||
| # downloads these artifacts and overlays them into the single (uber) sdk-core jar. | ||
| on: | ||
| pull_request: | ||
| paths: | ||
| - 'sdk-core/src/main/rust/**' | ||
| - '.github/workflows/native.yaml' | ||
| workflow_dispatch: | ||
| workflow_call: | ||
| jobs: | ||
| build: | ||
| name: "Build native (${{ matrix.target }})" | ||
| runs-on: ${{ matrix.runner }} | ||
| timeout-minutes: 30 | ||
| # Linux targets always build. macOS runners are expensive, so they only build on main, release | ||
| # branches and tags (where the release artifacts are assembled). | ||
| # TODO(shared-core-jni): the last clause keeps macOS builds on for this PR for testing; remove | ||
| # it before merging. | ||
| if: >- | ||
| ${{ !startsWith(matrix.runner, 'macos') | ||
| || github.ref == 'refs/heads/main' | ||
| || startsWith(github.ref, 'refs/heads/release') | ||
| || startsWith(github.ref, 'refs/tags/') | ||
| || github.head_ref == 'shared-core-jni' }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - target: x86_64-unknown-linux-gnu | ||
| runner: ubuntu-latest | ||
| cross: false | ||
| rustflags: "" | ||
| - target: aarch64-unknown-linux-gnu | ||
| runner: ubuntu-latest | ||
| cross: true | ||
| rustflags: "" | ||
| # musl is statically linked by default, which can't produce a cdylib (.so); disabling | ||
| # crt-static makes the target dynamically linkable so the shared library can be built. | ||
| - target: x86_64-unknown-linux-musl | ||
| runner: ubuntu-latest | ||
| cross: true | ||
| rustflags: "-C target-feature=-crt-static" | ||
| - target: aarch64-unknown-linux-musl | ||
| runner: ubuntu-latest | ||
| cross: true | ||
| rustflags: "-C target-feature=-crt-static" | ||
| - target: x86_64-apple-darwin | ||
| runner: macos-13 | ||
| cross: false | ||
| rustflags: "" | ||
| - target: aarch64-apple-darwin | ||
| runner: macos-14 | ||
| cross: false | ||
| rustflags: "" | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Install Rust toolchain | ||
| uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
| with: | ||
| target: ${{ matrix.target }} | ||
| - name: Install cross | ||
| if: ${{ matrix.cross }} | ||
| run: cargo install cross --git https://github.com/cross-rs/cross --locked | ||
| - name: Build cdylib | ||
| working-directory: sdk-core/src/main/rust | ||
| env: | ||
| # `cross` forwards RUSTFLAGS into the build container. | ||
| RUSTFLAGS: ${{ matrix.rustflags }} | ||
| run: | | ||
| if [ "${{ matrix.cross }}" = "true" ]; then | ||
| cross build --release --target ${{ matrix.target }} | ||
| else | ||
| cargo build --release --target ${{ matrix.target }} | ||
| fi | ||
| - name: Locate library | ||
| id: lib | ||
| working-directory: sdk-core/src/main/rust | ||
| run: | | ||
| dir="target/${{ matrix.target }}/release" | ||
| file=$(ls "$dir"/librestate_sdk_core.so "$dir"/librestate_sdk_core.dylib 2>/dev/null | head -1) | ||
| if [ -z "$file" ]; then echo "no library produced for ${{ matrix.target }}"; exit 1; fi | ||
| echo "path=sdk-core/src/main/rust/$file" >> "$GITHUB_OUTPUT" | ||
| echo "file=$file" >> "$GITHUB_OUTPUT" | ||
| - name: Smoke test (exported C symbols present) | ||
| working-directory: sdk-core/src/main/rust | ||
| run: | | ||
| f="${{ steps.lib.outputs.file }}" | ||
| # Linux uses `nm -D` (no symbol prefix); macOS uses `nm -gU` (leading underscore). | ||
| if [ "$RUNNER_OS" = "macOS" ]; then list="nm -gU"; pre="_"; else list="nm -D"; pre=""; fi | ||
| for sym in init vm_new vm_free free_buffer vm_sys_call vm_take_notification; do | ||
| $list "$f" 2>/dev/null | grep -qE "[ ]${pre}${sym}$" || { echo "missing exported symbol: $sym"; exit 1; } | ||
| done | ||
| echo "All expected symbols present in $f" | ||
| - name: Upload native library | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: native-${{ matrix.target }} | ||
| path: ${{ steps.lib.outputs.path }} | ||
| if-no-files-found: error | ||