data-modelling-sdk 2.4.0

Shared SDK for model operations across platforms (API, WASM, Native)
Documentation
name: CI

on:
  pull_request:
    types: [opened, synchronize, reopened]

env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: 1

# Default permissions for all jobs (can be overridden per job)
permissions:
  contents: read
  pull-requests: read

jobs:
  # Version consistency check - runs first
  version-check:
    name: Version Check
    uses: ./.github/workflows/version-check.yml

  # Linting and formatting check
  lint:
    name: Lint and Format Check
    needs: version-check
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt, clippy

      - name: Cache cargo registry
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/bin/
            ~/.cargo/registry/index/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
          key: ${{ runner.os }}-cargo-registry-${{ hashFiles('Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-registry-

      - name: Cache cargo build (lint)
        uses: actions/cache@v4
        with:
          path: target/
          key: ${{ runner.os }}-cargo-lint-${{ hashFiles('Cargo.lock') }}-${{ hashFiles('src/**/*.rs') }}
          restore-keys: |
            ${{ runner.os }}-cargo-lint-${{ hashFiles('Cargo.lock') }}-
            ${{ runner.os }}-cargo-lint-

      - name: Check Rust formatting
        run: cargo fmt --all -- --check

      # Run clippy on core crate WITHOUT database features to avoid compiling DuckDB
      - name: Run Rust clippy (core crate)
        run: cargo clippy --package data-modelling-core --features "api-backend,native-fs,git,openapi,bpmn,dmn" -- -D warnings

      # Run cargo audit directly instead of using rustsec/audit-check action
      # The action uses Check API which fails on forked repos
      - name: Install cargo-audit
        run: cargo install cargo-audit --locked || true

      - name: Run cargo audit
        run: cargo audit

  # Core tests - runs without database features (fast)
  test:
    name: Test
    needs: version-check
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable

      - name: Cache cargo registry
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/bin/
            ~/.cargo/registry/index/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
          key: ${{ runner.os }}-cargo-registry-${{ hashFiles('Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-registry-

      - name: Cache cargo build (test)
        uses: actions/cache@v4
        with:
          path: target/
          key: ${{ runner.os }}-cargo-test-${{ hashFiles('Cargo.lock') }}-${{ hashFiles('src/**/*.rs') }}
          restore-keys: |
            ${{ runner.os }}-cargo-test-${{ hashFiles('Cargo.lock') }}-
            ${{ runner.os }}-cargo-test-

      # Run tests on core crate WITHOUT database features - DuckDB is too large for GitHub Actions
      # Database tests should be run locally with: cargo test --package data-modelling-core --features staging,inference
      - name: Run tests
        run: cargo test --package data-modelling-core --features "api-backend,native-fs,git,openapi,bpmn,dmn"

  # Build verification - only runs if tests pass
  build:
    name: Build Check
    runs-on: ubuntu-latest
    needs: [lint, test]
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable

      - name: Cache cargo registry
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/bin/
            ~/.cargo/registry/index/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
          key: ${{ runner.os }}-cargo-registry-${{ hashFiles('Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-registry-

      - name: Cache cargo build (release)
        uses: actions/cache@v4
        with:
          path: target/
          key: ${{ runner.os }}-cargo-release-${{ hashFiles('Cargo.lock') }}-${{ hashFiles('src/**/*.rs') }}
          restore-keys: |
            ${{ runner.os }}-cargo-release-${{ hashFiles('Cargo.lock') }}-
            ${{ runner.os }}-cargo-release-

      - name: Build core library
        run: cargo build --release --package data-modelling-core --features "api-backend,native-fs,git,openapi,bpmn,dmn"

      - name: Build CLI binary (odm)
        run: cargo build --release --package odm --features openapi

  # WASM build verification
  build-wasm:
    name: Build Check (WASM)
    runs-on: ubuntu-latest
    needs: [version-check, lint]
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable

      - name: Install wasm32 target
        run: rustup target add wasm32-unknown-unknown

      - name: Cache cargo registry
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/bin/
            ~/.cargo/registry/index/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
          key: ${{ runner.os }}-cargo-registry-${{ hashFiles('Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-registry-

      - name: Cache cargo build (wasm)
        uses: actions/cache@v4
        with:
          path: target/
          key: ${{ runner.os }}-cargo-wasm-${{ hashFiles('Cargo.lock') }}-${{ hashFiles('src/**/*.rs') }}
          restore-keys: |
            ${{ runner.os }}-cargo-wasm-${{ hashFiles('Cargo.lock') }}-
            ${{ runner.os }}-cargo-wasm-

      - name: Build WASM library
        run: cargo build --package data-modelling-wasm --release --target wasm32-unknown-unknown