tii 0.0.6

A Low-Latency Web Server.
Documentation
name: Check

on:
  push:
    branches: [ "*" ]
  pull_request:
    branches: [ "*" ]
env:
  CARGO_TERM_COLOR: always

jobs:
  test_linux:
    name: Test Linux
    runs-on: ubuntu-latest
    strategy:
      matrix:
        target:
          - "x86_64-unknown-linux-gnu"
          - "i686-unknown-linux-gnu"
    env:
      RUSTFLAGS: "-D warnings"
      RUSTDOCFLAGS: "-D warnings"
    steps:
      - name: Update sources
        run: sudo apt update
      - name: Install libc6-dev-i386
        run: sudo apt install libc6-dev-i386
        if: ${{ contains(matrix.target, 'i686') }}
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}
          toolchain: 1.86
      - name: Test gnu
        run: |
          cargo test --all-features --no-fail-fast --target ${{ matrix.target }}
          cargo test --no-default-features --no-fail-fast --target ${{ matrix.target }}
          cd examples
          cargo run --bin shutdown --target ${{ matrix.target }}

  valgrind_linux:
    name: Valgrind
    runs-on: ubuntu-latest
    env:
      RUSTFLAGS: "-D warnings"
      RUSTDOCFLAGS: "-D warnings"
      VALGRINDFLAGS: "--error-exitcode=1 --leak-check=full --show-leak-kinds=all"
    steps:
      - name: Update sources
        run: sudo apt update
      - name: Install valgrind
        run: sudo apt install valgrind
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: 1.86
      - name: Install cargo valgrind
        run: cargo install cargo-valgrind --version 2.4.0
      - name: 64-bit Valgrind
        run: |
          cargo valgrind test --all-features
          cd examples
          cargo build
          valgrind --errors-for-leak-kinds=all --error-exitcode=1 --leak-check=full --show-leak-kinds=all target/debug/shutdown
          valgrind --errors-for-leak-kinds=all --error-exitcode=1 --leak-check=full --show-leak-kinds=all target/debug/shutdown_multiple
          valgrind --errors-for-leak-kinds=all --error-exitcode=1 --leak-check=full --show-leak-kinds=all target/debug/shutdown_unix
          valgrind --errors-for-leak-kinds=all --error-exitcode=1 --leak-check=full --show-leak-kinds=all target/debug/websocket_broadcast 5


  build_linux:
    name: Build Linux
    runs-on: ubuntu-latest
    strategy:
      matrix:
        target:
          - "x86_64-unknown-linux-gnu"
          - "i686-unknown-linux-gnu"
          - "x86_64-unknown-linux-musl"
          - "i686-unknown-linux-musl"
          - "aarch64-unknown-linux-gnu"
    env:
      RUSTFLAGS: "-D warnings"
      RUSTDOCFLAGS: "-D warnings"
    steps:
      - name: Update sources
        run: sudo apt update
      - name: Install musl deps
        run: sudo apt install musl-dev musl-tools
        if: ${{ contains(matrix.target, 'musl') }}
      - name: Install libc6-dev-i386
        run: sudo apt install libc6-dev-i386
        if: ${{ contains(matrix.target, 'i686') }}
      - name: Install libc6-dev-armhf-cross
        run: sudo apt install libc6-dev-armhf-cross gcc-arm-linux-gnueabihf
        if: ${{ contains(matrix.target, 'arm') }}
      - name: Install libc6-dev-arm64-cross
        run: sudo apt install libc6-dev-arm64-cross gcc-aarch64-linux-gnu
        if: ${{ contains(matrix.target, 'aarch64') }}
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}
          toolchain: 1.86
      - name: Build with all features
        run: |
          cargo build --all-features --target ${{ matrix.target }}
          cd examples
          cargo build --all-features --target ${{ matrix.target }}
        if: ${{ !(contains(matrix.target, 'musl') || contains(matrix.target, 'aarch64')) }}
      - name: Build with no and default features
        run: |
          cargo build --target ${{ matrix.target }}
          cargo build --no-default-features --target ${{ matrix.target }}

  build_windows:
    name: Build Windows
    runs-on: windows-latest
    strategy:
      matrix:
        target: ["x86_64-pc-windows-msvc", "i686-pc-windows-msvc"]
    env:
      RUSTFLAGS: "-D warnings"
      RUSTDOCFLAGS: "-D warnings"
    steps:
      - name: Install NASM for aws-lc-rs on Windows
        if: runner.os == 'Windows'
        uses: ilammy/setup-nasm@v1

      - name: Install ninja-build tool for aws-lc-fips-sys on Windows
        if: runner.os == 'Windows'
        uses: seanmiddleditch/gha-setup-ninja@v5

      - name: Install golang toolchain
        uses: actions/setup-go@v5
        with:
          go-version: "1.21"
          cache: false

      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}
          toolchain: 1.86
      - name: Build Windows
        run: |
          cargo build --all-features --target ${{ matrix.target }}
          cargo build --no-default-features --target ${{ matrix.target }}
          cd examples
          cargo build --target ${{ matrix.target }}

  test_windows:
    name: Test Windows
    runs-on: windows-latest
    strategy:
      matrix:
        target: ["x86_64-pc-windows-msvc", "i686-pc-windows-msvc"]
    env:
      RUSTFLAGS: "-D warnings"
      RUSTDOCFLAGS: "-D warnings"
    steps:
      - name: Install NASM for aws-lc-rs on Windows
        if: runner.os == 'Windows'
        uses: ilammy/setup-nasm@v1

      - name: Install ninja-build tool for aws-lc-fips-sys on Windows
        if: runner.os == 'Windows'
        uses: seanmiddleditch/gha-setup-ninja@v5

      - name: Install golang toolchain
        uses: actions/setup-go@v5
        with:
          go-version: "1.21"
          cache: false

      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}
          toolchain: 1.86
      - name: Test Windows
        run: |
          cargo test --all-features --no-fail-fast --target ${{ matrix.target }}
          cargo test --no-default-features --no-fail-fast --target ${{ matrix.target }}
          cd examples
          cargo run --bin shutdown --target ${{ matrix.target }}

  fmt:
      runs-on: ubuntu-latest
      name: fmt
      steps:
        - uses: actions/checkout@v4
        - uses: dtolnay/rust-toolchain@stable
          with:
            components: rustfmt
        - run: |
            cargo fmt --check
            cd examples
            cargo fmt --check

  clippy_check:
      name: clippy
      runs-on: ubuntu-latest
      steps:
        - uses: actions/checkout@v4
        - uses: dtolnay/rust-toolchain@stable
          with:
            components: clippy
            toolchain: 1.86
        - run: cargo clippy --all-features -- --deny warnings
        - run: cargo clippy --no-default-features -- --deny warnings
        - run: cd examples && cargo clippy -- --deny warnings

  docs_check:
      name: docs
      runs-on: ubuntu-latest
      env:
        RUSTDOCFLAGS: -D warnings
      steps:
        - uses: actions/checkout@v4
        - uses: dtolnay/rust-toolchain@stable
          with:
            toolchain: 1.86
        - run: cargo doc --all-features --no-deps