alice-edge 0.1.0

Embedded Model Generator - Don't send data, send the law
name: CI

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

env:
  CARGO_TERM_COLOR: always

jobs:
  test:
    name: Test (${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [macos-latest, ubuntu-latest]
    steps:
      - uses: actions/checkout@v4

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

      - uses: Swatinem/rust-cache@v2

      - name: Create dependency stubs
        shell: bash
        run: |
          for crate_info in \
            "ALICE-Zip/libalice:alice-zip" \
            "ALICE-Codec:alice-codec" \
            "ALICE-DB:alice-db" \
            "ALICE-SDF:alice-sdf" \
            "ALICE-ML:alice-ml" \
            "ALICE-Streaming-Protocol:libasp" \
            "ALICE-Analytics:alice-analytics"; do
            dir=$(echo "$crate_info" | cut -d: -f1)
            pkg=$(echo "$crate_info" | cut -d: -f2)
            mkdir -p "../$dir/src"
            cat > "../$dir/Cargo.toml" << TOML
          [package]
          name = "$pkg"
          version = "0.1.0"
          edition = "2021"
          [features]
          default = []
          std = []
          svo = []
          [lib]
          path = "src/lib.rs"
          TOML
            echo "" > "../$dir/src/lib.rs"
          done

      - name: Check (no default features) [T0]
        run: cargo check --lib --no-default-features
        continue-on-error: true

      - name: Build (std) [T1]
        run: cargo build --lib --features "std"

      - name: Test (std) [T1]
        run: cargo test --lib --features "std"

      - name: Build (std + sensors) [T3]
        run: cargo build --lib --features "std,sensors"
        continue-on-error: true

      - name: Build (std + all bridges) [T3]
        run: cargo build --lib --features "std,zip,codec,db,ml"
        continue-on-error: true

      - name: Build (std + telemetry) [T3]
        run: cargo build --lib --features "std,mqtt,dashboard"
        continue-on-error: true

      - name: Build (edge-pipeline) [T2]
        run: cargo build --lib --features "edge-pipeline"
        continue-on-error: true

      - name: Test (edge-pipeline) [T2]
        run: cargo test --lib --features "edge-pipeline"
        continue-on-error: true

      - name: Test (std + ml) [T2]
        run: cargo test --lib --features "std,ml"
        continue-on-error: true

      - name: Doc tests
        run: cargo test --doc --features "std"

  no-std-cross:
    name: no_std cross-compile (thumbv7em)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust toolchain + target
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: thumbv7em-none-eabihf

      - name: Create dependency stubs
        run: |
          for crate_info in \
            "ALICE-Zip/libalice:alice-zip" \
            "ALICE-Codec:alice-codec" \
            "ALICE-DB:alice-db" \
            "ALICE-SDF:alice-sdf" \
            "ALICE-ML:alice-ml" \
            "ALICE-Streaming-Protocol:libasp" \
            "ALICE-Analytics:alice-analytics"; do
            dir=$(echo "$crate_info" | cut -d: -f1)
            pkg=$(echo "$crate_info" | cut -d: -f2)
            mkdir -p "../$dir/src"
            cat > "../$dir/Cargo.toml" << TOML
          [package]
          name = "$pkg"
          version = "0.1.0"
          edition = "2021"
          [features]
          default = []
          std = []
          svo = []
          [lib]
          path = "src/lib.rs"
          TOML
            echo "" > "../$dir/src/lib.rs"
          done

      - name: Build no_std (thumbv7em-none-eabihf)
        run: cargo build --lib --target thumbv7em-none-eabihf --no-default-features

  clippy:
    name: Clippy
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

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

      - uses: Swatinem/rust-cache@v2

      - name: Create dependency stubs
        run: |
          for crate_info in \
            "ALICE-Zip/libalice:alice-zip" \
            "ALICE-Codec:alice-codec" \
            "ALICE-DB:alice-db" \
            "ALICE-SDF:alice-sdf" \
            "ALICE-ML:alice-ml" \
            "ALICE-Streaming-Protocol:libasp" \
            "ALICE-Analytics:alice-analytics"; do
            dir=$(echo "$crate_info" | cut -d: -f1)
            pkg=$(echo "$crate_info" | cut -d: -f2)
            mkdir -p "../$dir/src"
            cat > "../$dir/Cargo.toml" << TOML
          [package]
          name = "$pkg"
          version = "0.1.0"
          edition = "2021"
          [features]
          default = []
          std = []
          svo = []
          [lib]
          path = "src/lib.rs"
          TOML
            echo "" > "../$dir/src/lib.rs"
          done

      - name: Clippy
        run: cargo clippy --lib -- --cap-lints warn
        continue-on-error: true

  fmt:
    name: Format
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

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

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

  doc:
    name: Doc (RUSTDOCFLAGS=-Dwarnings)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2

      - name: Create dependency stubs
        run: |
          for crate_info in \
            "ALICE-Zip/libalice:alice-zip" \
            "ALICE-Codec:alice-codec" \
            "ALICE-DB:alice-db" \
            "ALICE-SDF:alice-sdf" \
            "ALICE-ML:alice-ml" \
            "ALICE-Streaming-Protocol:libasp" \
            "ALICE-Analytics:alice-analytics"; do
            dir=$(echo "$crate_info" | cut -d: -f1)
            pkg=$(echo "$crate_info" | cut -d: -f2)
            mkdir -p "../$dir/src"
            cat > "../$dir/Cargo.toml" << TOML
          [package]
          name = "$pkg"
          version = "0.1.0"
          edition = "2021"
          [features]
          default = []
          std = []
          svo = []
          [lib]
          path = "src/lib.rs"
          TOML
            echo "" > "../$dir/src/lib.rs"
          done

      - name: cargo doc (lib, no-deps)
        run: cargo doc --lib --no-deps --features "std"
        env:
          RUSTDOCFLAGS: "-Dwarnings"

  actionlint:
    name: actionlint (workflow YAML 検証)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Run actionlint
        uses: reviewdog/action-actionlint@v1
        with:
          fail_level: error
          reporter: github-check