pfctl 0.7.0

Library for interfacing with the Packet Filter (PF) firewall on macOS
Documentation
---
name: Build and test
on:
  pull_request:
    paths:
      - .github/workflows/build-and-test.yml
      - '**/*.rs'
      - Cargo.toml
      - Cargo.lock
  workflow_dispatch:

env:
  CARGO_TERM_COLOR: always
  RUSTFLAGS: --deny warnings

jobs:
  build-and-test:
    strategy:
      matrix:
        # Keep MSRV in sync with rust-version in Cargo.toml as much as possible.
        rust: [stable, beta, nightly, 1.85.0]
        # NOTE: macos-13 is using Intel Mac as of 2025-05-20:
        #       https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners
        os: [macos-13, macos-latest]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4

      - uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af #v1.0.7
        with:
          toolchain: ${{ matrix.rust }}
          profile: minimal
          default: true

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

      - name: Test
        # Since the tests modify global state (the system firewall) they cannot run in parallel.
        # The integration tests must run as root since they write firewall state (/dev/pf)
        run: sudo cargo test -- --test-threads=1

  # Make sure the library builds with all dependencies downgraded to their
  # oldest versions allowed by the semver spec. This ensures we have not
  # under-specified any dependency
  minimal-versions:
    runs-on: macos-latest
    steps:
      - uses: actions/checkout@v4

      - uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af #v1.0.7
        with:
          toolchain: nightly
          profile: minimal
          default: true

      - name: Downgrade dependencies to minimal versions
        run: cargo +nightly update -Z minimal-versions

      - name: Compile with minimal versions
        run: cargo build --all-targets