name: CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: "-D warnings"
jobs:
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
- 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
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
- 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
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"