name: ci

# Phase 27.x.browser-windows-discovery S12 — pull-request +
# push validation. Runs `cargo nextest run --lib` on a 3-OS
# matrix so the per-platform discovery cfg-branches
# (`bundled_candidates`, `path_lookup_names` in
# `src/chrome/discovery.rs`) all stay green when a contributor
# changes the candidate lists.
#
# Tag-driven release artifacts live in `release.yml`. This
# workflow is test-only — no publishing, no artifact upload.

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]
  workflow_dispatch:

permissions:
  contents: read

env:
  CARGO_TERM_COLOR: always
  CARGO_NET_RETRY: "10"
  CARGO_NET_TIMEOUT: "60"

jobs:
  test:
    name: cargo nextest (${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os:
          - ubuntu-latest
          - macos-14
          - windows-latest
    steps:
      - name: Checkout plugin
        uses: actions/checkout@v4
        with:
          path: nexo-plugin-browser

      # Path deps in `Cargo.toml` reference `../proyecto/...`
      # — checkout the daemon workspace alongside so cargo can
      # resolve them. Mirrors `release.yml`. Same workflow on
      # every OS so a Windows-specific path-dep bug surfaces
      # here, not at tag time.
      - name: Checkout proyecto (path-dep workspace)
        uses: actions/checkout@v4
        with:
          repository: lordmacu/nexo-rs
          path: proyecto

      - uses: dtolnay/rust-toolchain@stable

      - uses: Swatinem/rust-cache@v2
        with:
          workspaces: nexo-plugin-browser
          key: ci-${{ matrix.os }}-${{ hashFiles('nexo-plugin-browser/Cargo.lock') }}

      - name: Install cargo-nextest
        uses: taiki-e/install-action@v2
        with:
          tool: nextest

      - name: cargo build (lib)
        working-directory: nexo-plugin-browser
        run: cargo build --lib --tests

      - name: cargo nextest run (lib)
        working-directory: nexo-plugin-browser
        run: cargo nextest run --lib --no-fail-fast
