disposition 0.1.0

SVG diagram generator
Documentation
on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - "**"

name: CI

jobs:
  audit:
    name: Audit
    runs-on: ubuntu-latest
    timeout-minutes: 10
    permissions:
      issues: write
      checks: write
    steps:
      - uses: actions/checkout@v6
      - name: "Generate Cargo.lock"
        run: cargo generate-lockfile

      - name: cargo-audit cache restore
        id: cargo-audit_cache_restore
        uses: actions/cache/restore@v5
        with:
          path: ~/.cargo/bin/cargo-audit
          key: ${{ runner.os }}-cargo-audit

      - run: cargo install cargo-audit
        if: steps.cargo-audit_cache_restore.outputs.cache-hit != 'true'

      - name: cargo-audit cache save
        id: cargo-audit_cache_save
        uses: actions/cache/save@v5
        if: always() && steps.cargo-audit_cache_restore.outputs.cache-hit != 'true'
        with:
          path: ~/.cargo/bin/cargo-audit
          key: ${{ runner.os }}-cargo-audit

      - uses: rustsec/audit-check@v2
        with:
          token: ${{ secrets.GITHUB_TOKEN }}

  licenses:
    name: Licenses
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: EmbarkStudios/cargo-deny-action@v2

      - name: cargo-about cache restore
        id: cargo_about_cache_restore
        uses: actions/cache/restore@v5
        with:
          path: ~/.cargo/bin/cargo-about
          key: ${{ runner.os }}-cargo-about

      - run: cargo install --locked cargo-about
        if: steps.cargo_about_cache_restore.outputs.cache-hit != 'true'

      - name: cargo-about cache save
        id: cargo_about_cache_save
        uses: actions/cache/save@v5
        if: always() && steps.cargo_about_cache_restore.outputs.cache-hit != 'true'
        with:
          path: ~/.cargo/bin/cargo-about
          key: ${{ runner.os }}-cargo-about

      - name: cargo-about generate licenses
        run: cargo about generate --workspace about.hbs > doc/src/licenses.html

  fmt:
    name: Rustfmt
    runs-on: ubuntu-latest
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@master
        with:
          toolchain: nightly
          components: rustfmt

      - run: cargo fmt --all -- --check

  docs_and_spell_check:
    name: Docs and Spell Check
    runs-on: ubuntu-latest
    timeout-minutes: 20
    env:
      RUSTDOCFLAGS: "-Dwarnings"
    steps:
      - name: Checkout Actions Repository
        uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable

      - name: Check spelling
        uses: crate-ci/typos@master

      - run: cargo doc --no-deps

  clippy:
    name: Clippy
    runs-on: ubuntu-latest
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@master
        with:
          toolchain: nightly
          components: clippy

      - name: "Run clippy"
        run: |
          cargo clippy --workspace -- -D warnings

  build_and_test_linux:
    name: Build and Test (Linux)
    runs-on: ubuntu-latest
    timeout-minutes: 20
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable

      # Needed by dioxus
      #
      # Copied from <https://github.com/DioxusLabs/dioxus/blob/v0.7.2/.github/workflows/publish.yml#L89>
      - name: "Update gtk libraries for dioxus"
        uses: awalsh128/cache-apt-pkgs-action@latest
        with:
          packages: libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev libxdo-dev libglib2.0-dev musl-tools
          version: 1.0

      - uses: taiki-e/install-action@nextest
      - name: "Build and test"
        run: cargo nextest run --workspace --all-features --no-tests warn

  build_and_test_windows:
    name: Build and Test (Windows)
    runs-on: windows-latest
    timeout-minutes: 30
    steps:
      - name: Prepare symlink configuration
        run: git config --global core.symlinks true

      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable

      - uses: taiki-e/install-action@nextest
      - name: "Build and test"
        run: cargo nextest run --workspace --all-features --no-tests warn

  doc_tests_linux:
    name: Doc Tests (Linux)
    runs-on: ubuntu-latest
    timeout-minutes: 20
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable
      - name: "Doc tests"
        run: cargo test --doc --workspace --all-features