benchie 0.5.0

A benchmarking tool
Documentation
name: CI

on:
#  push:
#  schedule:
#    # trigger weekly at 12am
#    # this build should run with caches disabled
#    - cron: "0 0 * * 0"
  workflow_dispatch:

env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: 1

jobs:
  ci:
    name: Build and Test
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest]
    runs-on: ${{ matrix.os }}
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - uses: ./.github/actions/setup-rust/
        with:
          cache: true

      - name: Check Format
        uses: actions-rs/cargo@v1
        with:
          command: fmt
          args: -- --check

      - name: Clippy on Linux
        if: ${{ contains(matrix.os, 'ubuntu') }}
        uses: actions-rs/clippy-check@v1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          args: --all-targets -- -D warnings
          name: Clippy

      - name: Clippy on operating systems
        if: ${{ !contains(matrix.os, 'ubuntu') }}
        uses: actions-rs/cargo@v1
        with:
          command: clippy
          args: --all-targets -- -D warnings

      - name: Build
        uses: actions-rs/cargo@v1
        with:
          command: build
          args: --locked

      - name: Doc
        uses: actions-rs/cargo@v1
        with:
          command: doc
          args: --locked

      - name: Test
        uses: actions-rs/cargo@v1
        env:
          RUSTFLAGS: "-C instrument-coverage"
          LLVM_PROFILE_FILE: "target/debug/coverage/benchie-%m.profraw"
        with:
          command: test
          args: --tests --locked

      - name: Code Coverage Report
        if: contains(matrix.os, 'ubuntu')
        run: |
          cargo install --force cargo-binutils cargo-llvm-codecov-converter
          cargo profdata -- merge -sparse target/debug/coverage/benchie-*.profraw -o target/debug/coverage/benchie.profdata
          cargo cov -- export \
          $( \
            for file in \
              $( \
                RUSTFLAGS="-C instrument-coverage" \
                  cargo test --tests --no-run --message-format=json \
                  | jq -r "select(.profile.test == true) | .filenames[]" \
                  | grep -v dSYM - \
              ); \
              do \
              printf "%s %s " -object $file; \
            done \
          ) \
          --instr-profile=target/debug/coverage/benchie.profdata \
          --ignore-filename-regex=/.cargo/registry \
          --ignore-filename-regex=/tests/ \
          --ignore-filename-regex=rustc \
          --skip-functions \
          | cargo llvm-codecov-converter > target/debug/coverage/report.txt

      - uses: codecov/codecov-action@v3
        with:
          files: target/debug/coverage/report.txt
          verbose: true

  security-scan:
    name: Security Scan of Dependencies
    runs-on: ubuntu-latest
    if: ${{ false }}  # disable for now
    steps:
      - uses: actions/checkout@v3

      - name: Check Github Permissions
        id: check-permissions
        uses: scherermichael-oss/action-has-permission@136e061bfe093832d87f090dd768e14e27a740d3
        with:
          required-permission: write
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      # this action needs write permissions for the given GitHub token
      - uses: actions-rs/audit-check@v1
        if: ${{ steps.check-permissions.outputs.has-permission }}
        with:
          token: ${{ secrets.GITHUB_TOKEN }}