tideorm-cli 0.9.0

Command-line interface for TideORM
name: CI

on:
  push:
    branches:
      - main
  pull_request:

env:
  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"

jobs:
  fmt:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v6

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

      # `cargo fmt` never resolves dependencies, so this job does not need the
      # sibling ORM checkout that the other jobs set up.
      - name: Check formatting
        run: cargo fmt --all --check

  clippy:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout tideorm-cli
        uses: actions/checkout@v6
        with:
          path: tideorm-cli

      # The CLI is not standalone: it imports `tideorm::internal` and drives
      # migrations through the ORM's own connection machinery, so it has to be
      # built against the ORM checkout that sits next to it locally.
      - name: Checkout tideorm
        uses: actions/checkout@v6
        with:
          repository: mohamadzoh/tideorm
          ref: master
          path: tideorm

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

      - name: Cache cargo
        uses: Swatinem/rust-cache@v2
        with:
          workspaces: tideorm-cli

      # The committed manifest takes tideorm from crates.io; developers run with a
      # permanently-uncommitted `path = "../tideorm"` override, and that is the
      # combination this job has to lint. Recreating the override here is what makes
      # an ORM change that breaks the CLI visible.
      - name: Point the tideorm dependency at the sibling checkout
        working-directory: tideorm-cli
        run: |
          sed -i -E 's|^tideorm = \{.*\}$|tideorm = { path = "../tideorm", default-features = false, features = ["postgres", "mysql", "sqlite", "runtime-tokio"] }|' Cargo.toml
          grep -q 'path = "../tideorm"' Cargo.toml

      - name: Run clippy
        working-directory: tideorm-cli
        run: cargo clippy --all-targets -- -D warnings

  test:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout tideorm-cli
        uses: actions/checkout@v6
        with:
          path: tideorm-cli

      - name: Checkout tideorm
        uses: actions/checkout@v6
        with:
          repository: mohamadzoh/tideorm
          ref: master
          path: tideorm

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

      - name: Cache cargo
        uses: Swatinem/rust-cache@v2
        with:
          workspaces: tideorm-cli

      - name: Point the tideorm dependency at the sibling checkout
        working-directory: tideorm-cli
        run: |
          sed -i -E 's|^tideorm = \{.*\}$|tideorm = { path = "../tideorm", default-features = false, features = ["postgres", "mysql", "sqlite", "runtime-tokio"] }|' Cargo.toml
          grep -q 'path = "../tideorm"' Cargo.toml

      # `tests/generated_project.rs` scaffolds a project into a tempdir and runs
      # `cargo check --offline` inside it, so everything it needs has to be in the
      # registry cache before the suite starts.
      - name: Warm the cargo registry cache
        working-directory: tideorm-cli
        run: cargo fetch

      - name: Run tests
        working-directory: tideorm-cli
        run: cargo test