name: bench
on:
  pull_request:
  push:
    branches:
      - main

jobs:
  bench:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Cache .cargo and target
        uses: actions/cache@v2
        with:
          path: |
            ~/.cargo
            ./target
          key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-bench-${{ hashFiles('**/Cargo.lock') }}
            ${{ runner.os }}-cargo-bench

      - name: "Bench de-facto (File Server only)"
        run: ./scripts/bench.sh

      - name: "Bench w/ Cross-Origin-Resource-Sharing"
        run: ./scripts/bench.sh --cors

      - name: "Bench w/ GZip Compression"
        run: ./scripts/bench.sh --gzip

      - name: "Bench w/ Basic Authentication"
        run: ./scripts/bench.sh '--username "john" --password "appleseed"'

      - name: "Bench w/ Logger"
        run: ./scripts/bench.sh '--logger'
