md-viewer 0.2.2

Fast, lightweight markdown viewer for Linux with tabs, file explorer, and live reload
name: CI
on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

env:
  CARGO_TERM_COLOR: always

jobs:
  check:
    runs-on: ubuntu-latest
    timeout-minutes: 30
    permissions:
      contents: read
    steps:
      - uses: actions/checkout@v4

      - name: Install system dependencies
        run: |
          sudo apt-get update
          sudo apt-get install -y clang pkg-config libxcb1-dev libxcb-render0-dev \
            libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev libssl-dev \
            libgtk-3-dev libfontconfig1-dev libdbus-1-dev

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

      - uses: Swatinem/rust-cache@v2

      - name: Remove local-only MCP dependency
        run: |
          # Remove the path dependency line but keep the feature (as empty)
          # First, change the mcp feature to empty (must do before removing dep line)
          sed -i 's/mcp = \["dep:egui-mcp-bridge"\]/mcp = []/' Cargo.toml
          # Then remove the optional dependency line
          sed -i '/^egui-mcp-bridge = /d' Cargo.toml

      - run: cargo fmt --check
      - run: cargo clippy -- -D warnings
      - run: cargo build --release
      - run: cargo test

  renderer:
    runs-on: ubuntu-latest
    timeout-minutes: 30
    permissions:
      contents: read
    env:
      RENDERER_FEATURES: better_syntax_highlighting,svg,svg_text,load-images,fetch,mermaid,math,macros
    steps:
      - uses: actions/checkout@v4

      - name: Install system dependencies
        run: |
          sudo apt-get update
          sudo apt-get install -y clang pkg-config libxcb1-dev libxcb-render0-dev \
            libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev libssl-dev \
            libgtk-3-dev libfontconfig1-dev libdbus-1-dev

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

      - uses: Swatinem/rust-cache@v2
        with:
          workspaces: crates/egui_commonmark -> target

      - name: Lint renderer crates
        run: |
          cargo clippy --manifest-path crates/egui_commonmark/Cargo.toml -p egui_commonmark_extended --all-targets --features "$RENDERER_FEATURES"
          cargo clippy --manifest-path crates/egui_commonmark/Cargo.toml -p egui_commonmark_backend_extended --all-targets --all-features
          cargo clippy --manifest-path crates/egui_commonmark/Cargo.toml -p egui_commonmark_macros_extended --all-targets

      - name: Test renderer crates
        run: |
          cargo test --manifest-path crates/egui_commonmark/Cargo.toml -p egui_commonmark_extended --features "$RENDERER_FEATURES"
          cargo test --manifest-path crates/egui_commonmark/Cargo.toml -p egui_commonmark_backend_extended --no-default-features
          cargo test --manifest-path crates/egui_commonmark/Cargo.toml -p egui_commonmark_backend_extended --all-features
          cargo test --manifest-path crates/egui_commonmark/Cargo.toml -p egui_commonmark_macros_extended

  version-sync:
    runs-on: ubuntu-latest
    timeout-minutes: 5
    permissions:
      contents: read
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - name: Check app/renderer workspace dependency contract
        run: bash scripts/check-workspace-sync.sh
      - name: Check versions match
        run: |
          # Robust extraction tolerating quotes and spacing
          CARGO_VER=$(awk -F'"' '/^version[[:space:]]*=[[:space:]]*"/{print $2; exit}' Cargo.toml)
          SNAP_VER=$(sed -n "s/^version:[[:space:]]*['\"]\\?\\([0-9]\\+\\.[0-9]\\+\\.[0-9]\\+\\)['\"]\\?/\\1/p" snap/snapcraft.yaml)

          echo "Cargo.toml: $CARGO_VER"
          echo "snapcraft.yaml: $SNAP_VER"

          if [ "$CARGO_VER" != "$SNAP_VER" ]; then
            echo "::error::Version mismatch! Cargo=$CARGO_VER Snap=$SNAP_VER"
            exit 1
          fi