hawdb 0.41.0

An embedded Rust graph database for local data-plane workloads
Documentation
name: MoonBit Native SDK

on:
  # Engine changes are compiled against the adapter by the Native Bindings
  # workflow on every PR. The externally installed MoonBit toolchain only
  # gates SDK changes, plus mainline engine changes after they land.
  push:
    branches: [main]
    paths:
      - "bindings/moonbit/**"
      - "Cargo.toml"
      - "Cargo.lock"
      - "crates/**"
      - "src/**"
      - ".github/workflows/moonbit-native.yml"
  pull_request:
    paths:
      - "bindings/moonbit/**"
      - ".github/workflows/moonbit-native.yml"
  workflow_dispatch:

concurrency:
  group: moonbit-native-${{ github.ref }}
  cancel-in-progress: true

permissions:
  contents: read

jobs:
  bazel-conformance:
    name: Bazel native conformance (${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    timeout-minutes: 120
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-24.04, macos-latest]
    env:
      USE_BAZEL_VERSION: "9.3.1"
    steps:
      - uses: actions/checkout@v7
      - name: Install Bazel
        uses: bazel-contrib/setup-bazel@0.19.2
        with:
          bazelisk-cache: true
          disk-cache: ${{ github.workflow }}-${{ github.job }}
          repository-cache: true
          external-cache: true
      - name: Install MoonBit
        shell: bash
        run: |
          set -euo pipefail
          curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash
          echo "$HOME/.moon/bin" >> "$GITHUB_PATH"
      - name: Run real embedded HawDB conformance
        shell: bash
        run: |
          set -euo pipefail
          moon version --all
          bazel test --test_output=errors --test_env=PATH --test_env=HOME \
            //bindings/moonbit:hawdb_moonbit_tests

  windows-conformance:
    name: Full native conformance (windows-2025)
    runs-on: windows-2025
    timeout-minutes: 120
    steps:
      - name: Disable Git automatic CRLF conversion
        shell: pwsh
        run: git config --global core.autocrlf false
      - uses: actions/checkout@v7
      # Match colmugx/posoco's Windows native toolchain initialization.
      - uses: ilammy/msvc-dev-cmd@v1
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt
      - uses: Swatinem/rust-cache@v2
        with:
          workspaces: bindings/moonbit/native
      - name: Install MoonBit for Windows
        shell: pwsh
        run: |
          Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
          irm https://cli.moonbitlang.com/install/powershell.ps1 | iex
          "$env:USERPROFILE\.moon\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
      - name: Validate MoonBit toolchain
        working-directory: bindings/moonbit
        shell: pwsh
        run: |
          $ErrorActionPreference = "Stop"
          moon version --all
          rustc --version
          cargo --version
          python --version
          moon check --target native
          if ($LASTEXITCODE -ne 0) { throw "MoonBit native check failed" }
      - name: Build against current HawDB source
        working-directory: bindings/moonbit/native
        shell: pwsh
        run: |
          git ls-files --error-unmatch Cargo.lock 2>$null
          if ($LASTEXITCODE -eq 0) { throw "SDK Cargo.lock must not be committed" }
          # Bazel builds this adapter from the same crates as bindings/ffi, so
          # seed Cargo from that maintained lock: only the adapter's own entry
          # is added and every shared dependency keeps its locked version.
          Copy-Item ../../ffi/Cargo.lock Cargo.lock
          cargo update --workspace
          if ($LASTEXITCODE -ne 0) { throw "Seeding the SDK lock failed" }
          cargo fmt --all -- --check
          if ($LASTEXITCODE -ne 0) { throw "Rust formatting failed" }
          cargo test --locked --release --lib
          if ($LASTEXITCODE -ne 0) { throw "Native lifecycle tests failed" }
          cargo build --locked --release
          if ($LASTEXITCODE -ne 0) { throw "Rust staticlib build failed" }
          if (!(Test-Path "target/release/hawdb_moonbit.lib")) { throw "Missing Rust .lib output" }
      - name: Run real embedded HawDB conformance
        working-directory: bindings/moonbit
        shell: pwsh
        run: |
          $ErrorActionPreference = "Stop"
          if (Test-Path tests/conformance-db) {
            Remove-Item -Recurse -Force tests/conformance-db
          }
          moon run --target native tests/conformance 2>&1 | Tee-Object -FilePath conformance.log
          if ($LASTEXITCODE -ne 0) { throw "MoonBit/HawDB native executable failed" }
          $log = Get-Content -Path conformance.log -Raw
          if ($log -match '(?m)^CASE_FAIL ') { throw "Native conformance contains CASE_FAIL" }
          if ($log -notmatch '(?m)^HAWDB_MOONBIT_BUSINESS_SUITE_PASS\r?$') {
            throw "Missing real-engine conformance success marker"
          }