nftblock 0.1.2

Atomically apply CIDR lists with nftables netlink batches
Documentation
name: CI

on:
  push:
    branches:
      - main
  pull_request:

permissions:
  contents: read

jobs:
  rust:
    name: Rust checks
    runs-on: ubuntu-latest
    steps:
      - name: Check out repository
        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false

      - name: Install native dependencies
        run: sudo apt-get update && sudo apt-get install -y libmnl-dev libnftnl-dev nftables iproute2 iputils-ping pkg-config

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c # stable
        with:
          toolchain: stable

      - name: Cache Cargo artifacts
        uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2

      - name: Check formatting
        run: cargo fmt --check

      - name: Run Rust tests
        run: cargo test --locked

      - name: Build debug binary
        run: cargo build --locked --bin nftblock

      - name: Run network namespace test
        run: sudo env NFTBLOCK_BIN="$PWD/target/debug/nftblock" ./tests/netns.sh

      - name: Build release binary
        run: cargo build --release --locked --bins

  containers:
    name: Container build (${{ matrix.variant }})
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        variant:
          - debian
          - alpine
    steps:
      - name: Check out repository
        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0

      - name: Build container
        uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
        with:
          context: .
          file: Dockerfile.${{ matrix.variant }}
          platforms: linux/amd64
          push: false
          cache-from: type=gha,scope=${{ matrix.variant }}
          cache-to: type=gha,mode=max,scope=${{ matrix.variant }}