cdp-browser-lite 0.1.1

Control total del ciclo de vida de instancias de Chrome y acceso CDP
Documentation
name: CI

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

env:
  CARGO_TERM_COLOR: always
  RUSTFLAGS: "-D warnings"

jobs:
  # ---------------------------------------------------------------------------
  # 1. Lint, build and test on the three major platforms.
  # ---------------------------------------------------------------------------
  test:
    name: Test (${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
    steps:
    - uses: actions/checkout@v4

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

    - name: Cache cargo registry and build
      uses: Swatinem/rust-cache@v2

    # Formatting only needs to be checked once, on Linux.
    - name: Check format
      if: matrix.os == 'ubuntu-latest'
      run: cargo fmt --all --check

    - name: Clippy
      run: cargo clippy --all-targets --all-features -- -D warnings

    - name: Build
      run: cargo build --all-targets --verbose

    - name: Run tests
      run: cargo test --all-targets --verbose

  # ---------------------------------------------------------------------------
  # 2. Prove the library links into runnable executables on every platform.
  #
  # cdp-browser-lite is a library, so we build the shipped example (`simple`)
  # and the `fake_chrome_helper` binary natively on each OS/arch. A successful
  # native build + a present, non-empty artifact is the strongest evidence that
  # the compiled library can form executable binaries for that target.
  # ---------------------------------------------------------------------------
  build-binaries:
    name: Build binaries (${{ matrix.target }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
          - os: macos-latest
            target: aarch64-apple-darwin
          - os: macos-latest
            target: x86_64-apple-darwin
          - os: windows-latest
            target: x86_64-pc-windows-msvc
    steps:
    - uses: actions/checkout@v4

    - uses: dtolnay/rust-toolchain@stable
      with:
        targets: ${{ matrix.target }}

    - name: Cache cargo registry and build
      uses: Swatinem/rust-cache@v2
      with:
        key: ${{ matrix.target }}

    - name: Build release binaries
      run: cargo build --release --target ${{ matrix.target }} --bins --examples --verbose

    # Verify the produced files really exist, are non-empty and (on Unix)
    # carry the executable bit, then stage them into ./dist.
    - name: Verify executables
      shell: bash
      run: |
        set -euo pipefail
        BINDIR="target/${{ matrix.target }}/release"
        EXT=""
        if [[ "${{ matrix.target }}" == *windows* ]]; then EXT=".exe"; fi

        # Regular binaries live in the release dir; examples in release/examples.
        FILES=(
          "$BINDIR/fake_chrome_helper$EXT"
          "$BINDIR/examples/simple$EXT"
        )

        mkdir -p dist
        for f in "${FILES[@]}"; do
          echo "Checking $f"
          test -f "$f"        || { echo "::error::missing binary: $f"; exit 1; }
          test -s "$f"        || { echo "::error::empty binary: $f"; exit 1; }
          if [[ "$EXT" != ".exe" ]]; then
            test -x "$f"      || { echo "::error::not executable: $f"; exit 1; }
          fi
          cp "$f" "dist/$(basename "$f")"
        done

        echo "All executables built successfully for ${{ matrix.target }}:"
        ls -la dist

    - name: Upload binaries
      uses: actions/upload-artifact@v4
      with:
        name: binaries-${{ matrix.target }}
        path: dist/*
        if-no-files-found: error

  # ---------------------------------------------------------------------------
  # 3. End-to-end tests that drive a real Chrome (Linux only).
  # ---------------------------------------------------------------------------
  e2e:
    name: E2E Tests
    runs-on: ubuntu-latest
    needs: test
    steps:
    - uses: actions/checkout@v4

    - uses: dtolnay/rust-toolchain@stable

    - name: Cache cargo registry and build
      uses: Swatinem/rust-cache@v2

    - name: Install Chrome
      uses: browser-actions/setup-chrome@v1

    - name: Run ignored tests
      run: cargo test -- --ignored
      env:
        CDP_BROWSER_LITE_E2E: "1"