readseek 0.7.7

structural source reader with stable line hashes
name: CI

on:
  push:
  pull_request:

env:
  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true

jobs:
  test:
    name: Test (${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-latest
            cargo_args: ""
          - os: macos-latest
            cargo_args: --features metal
          - os: windows-2025
            cargo_args: ""

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

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@master
        with:
          toolchain: stable
          components: clippy, rustfmt
          targets: x86_64-pc-windows-msvc

      - name: Install native build dependencies
        if: runner.os == 'Linux'
        run: sudo apt-get update && sudo apt-get install -y cmake libclang-dev

      - name: Build
        run: cargo build

      - name: Check native backend
        if: matrix.cargo_args != ''
        run: cargo check ${{ matrix.cargo_args }}

      - name: Test (unit)
        run: cargo test

      - name: Clippy
        run: cargo clippy --all-targets

      - name: Check Windows target
        if: runner.os == 'Windows'
        run: cargo check --target x86_64-pc-windows-msvc

      - name: Clippy Windows target
        if: runner.os == 'Windows'
        run: cargo clippy --target x86_64-pc-windows-msvc --all-targets

      - name: Format check
        run: cargo fmt --check

  linux-arm64:
    name: Test Linux arm64 package
    runs-on: ubuntu-24.04-arm

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

      - name: Install Node.js
        uses: actions/setup-node@v4
        with:
          node-version: 24

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: aarch64-unknown-linux-gnu

      - name: Install native build dependencies
        run: sudo apt-get update && sudo apt-get install -y cmake libclang-dev

      - name: Build static binary
        env:
          RUSTFLAGS: "-C target-feature=+crt-static"
        run: cargo build --release --target aarch64-unknown-linux-gnu

      - name: Test npm wrapper
        run: |
          mkdir -p npm/linux-arm64/bin
          cp target/aarch64-unknown-linux-gnu/release/readseek npm/linux-arm64/bin/readseek
          chmod 755 npm/linux-arm64/bin/readseek
          npm install --package-lock=false --ignore-scripts --no-save ./npm/linux-arm64
          node bin/readseek.js --version

      - name: Test Pi extension
        run: |
          npm install --prefix packages/pi-readseek --package-lock=false --ignore-scripts --no-save ./ ./npm/linux-arm64
          npm --prefix packages/pi-readseek test

  pi-readseek:
    name: Test pi-readseek
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: packages/pi-readseek

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

      - name: Install Node.js
        uses: actions/setup-node@v4
        with:
          node-version: 24
          cache: npm
          cache-dependency-path: packages/pi-readseek/package-lock.json

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

      - name: Install native build dependencies
        run: sudo apt-get update && sudo apt-get install -y cmake libclang-dev

      - name: Stage readseek binary
        working-directory: .
        run: |
          cargo build
          mkdir -p npm/linux-x64/bin
          cp target/debug/readseek npm/linux-x64/bin/readseek
          chmod 755 npm/linux-x64/bin/readseek

      - name: Install local readseek packages
        working-directory: .
        run: |
          npm install --package-lock=false --ignore-scripts --no-save ./npm/linux-x64
          npm install --prefix packages/pi-readseek --package-lock=false --ignore-scripts --no-save ./

      - name: Type check
        run: npm run typecheck

      - name: Test
        run: npm test

  readseek-vim:
    name: Test readseek.vim
    runs-on: ubuntu-latest

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

      - name: Test
        run: vim -Nu NONE -n -i NONE -es -S test/readseek.vim


  opencode-readseek:
    name: Test opencode-readseek
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: packages/opencode-readseek

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

      - name: Install Node.js
        uses: actions/setup-node@v4
        with:
          node-version: 24
          cache: npm
          cache-dependency-path: packages/opencode-readseek/package-lock.json

      - name: Install Bun
        uses: oven-sh/setup-bun@v2

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

      - name: Install native build dependencies
        run: sudo apt-get update && sudo apt-get install -y cmake libclang-dev

      - name: Stage readseek binary
        working-directory: .
        run: |
          cargo build
          mkdir -p npm/linux-x64/bin
          cp target/debug/readseek npm/linux-x64/bin/readseek
          chmod 755 npm/linux-x64/bin/readseek

      - name: Install local readseek packages
        working-directory: .
        run: |
          npm install --package-lock=false --ignore-scripts --no-save ./npm/linux-x64
          npm install --prefix packages/opencode-readseek --package-lock=false --ignore-scripts --no-save ./

      - name: Type check
        run: npm run typecheck

      - name: Test
        run: bun test