dot_ix 0.10.0

Interactive dot graphs
Documentation
on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - "**"

name: CI

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

      - name: cargo-audit cache restore
        id: cargo-audit_cache_restore
        uses: actions/cache/restore@v4
        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@v4
        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@v4
      - uses: EmbarkStudios/cargo-deny-action@v2

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

      - name: cargo-about install
        if: steps.cargo-about-cache.outputs.cache-hit != 'true'
        run: cargo install --locked 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@v4
      - 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@v4
      - 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@v4
      - uses: dtolnay/rust-toolchain@master
        with:
          toolchain: nightly
          components: clippy

      - name: "Run clippy (client side graphviz)"
        run: |
          cargo clippy --workspace -- -D warnings

      - name: "Run clippy (server side graphviz)"
        # we cannot use `--all-features` because `dot_ix` has features that are mutually exclusive.
        run: |
          cargo clippy --workspace -- -D warnings

  coverage:
    name: Coverage
    runs-on: ubuntu-latest
    timeout-minutes: 30
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@master
        with:
          toolchain: nightly
          components: llvm-tools-preview

      - uses: taiki-e/install-action@cargo-llvm-cov

      - name: "Collect coverage"
        run: ./coverage.sh

      - name: "Print directory sizes"
        run: du -sh target/coverage target/llvm-cov-target

      - name: Upload to codecov.io
        uses: codecov/codecov-action@v5
        with:
          files: ./target/coverage/lcov.info
          token: ${{ secrets.CODECOV_TOKEN }}

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

      - name: "Build and test"
        run: cargo test --workspace

  build_playground_linux_leptos:
    name: Build Playground (Linux) - cargo-leptos
    # On `ubuntu-latest`, this job fails because the CI runner is CPU bound
    # when `monaco` is built.
    #
    # Trying 22.04 to see if it alleviates the problem.
    #
    # See <https://github.com/actions/runner-images/issues/6680>
    runs-on: ubuntu-22.04
    timeout-minutes: 25
    env:
      # Seems to solve this issue:
      #
      # ```text
      # 0: Unexpected token Semicolon at :1360:9
      # ```
      LEPTOS_TAILWIND_VERSION: "v4.1.4"
    steps:
      - uses: actions/checkout@v4
      - name: "Install Rust"
        uses: dtolnay/rust-toolchain@master
        with:
          toolchain: stable
          targets: wasm32-unknown-unknown

      - name: cargo-leptos cache restore
        id: cargo_leptos_cache_restore
        uses: actions/cache/restore@v4
        with:
          path: ~/.cargo/bin/cargo-leptos
          key: ${{ runner.os }}-cargo-leptos

      - run: cargo install cargo-leptos
        if: steps.cargo_leptos_cache_restore.outputs.cache-hit != 'true'

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

      - name: "Build playground"
        working-directory: ./playground
        run: cargo leptos build -v

  build_playground_linux_trunk:
    name: Build Playground (Linux) - trunk
    # On `ubuntu-latest`, this job fails because the CI runner is CPU bound
    # when `monaco` is built.
    #
    # Trying 22.04 to see if it alleviates the problem.
    #
    # See <https://github.com/actions/runner-images/issues/6680>
    runs-on: ubuntu-22.04
    timeout-minutes: 25
    steps:
      - uses: actions/checkout@v4
      - name: "Install Rust"
        uses: dtolnay/rust-toolchain@master
        with:
          toolchain: stable
          targets: wasm32-unknown-unknown

      - name: trunk cache restore
        id: trunk_cache_restore
        uses: actions/cache/restore@v4
        with:
          path: ~/.cargo/bin/trunk
          key: ${{ runner.os }}-trunk

      - run: cargo install trunk
        if: steps.trunk_cache_restore.outputs.cache-hit != 'true'

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

      - name: "Build playground"
        working-directory: ./playground
        run: trunk build -v

  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@v4
      - uses: dtolnay/rust-toolchain@stable

      - name: "Build and test"
        run: cargo test --workspace

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

      - uses: actions/checkout@v4
      - name: "Install Rust"
        uses: dtolnay/rust-toolchain@master
        with:
          toolchain: stable
          targets: wasm32-unknown-unknown

      - name: trunk cache restore
        id: trunk_cache_restore
        uses: actions/cache/restore@v4
        with:
          path: 'C:\Users\runneradmin\.cargo\bin\trunk.exe'
          key: ${{ runner.os }}-trunk

      - run: cargo install trunk
        if: steps.trunk_cache_restore.outputs.cache-hit != 'true'

      - name: trunk cache save
        id: trunk_cache_save
        uses: actions/cache/save@v4
        if: always() && steps.trunk_cache_restore.outputs.cache-hit != 'true'
        with:
          path: 'C:\Users\runneradmin\.cargo\bin\trunk.exe'
          key: ${{ runner.os }}-trunk

      - name: "Build playground"
        working-directory: ./playground
        run: trunk build -v