tonic-debug 0.2.1

A debugging and diagnostics middleware for tonic gRPC servers
Documentation
name: CI

on:
  workflow_dispatch:
  pull_request:
  push:
    branches:
      - main
  # schedule:
    # - cron: '0 6 * * 1-5'  # run once per day Monday-Friday at 6:00am

env:
  RUST_BACKTRACE: 1
  CARGO_TERM_COLOR: always
  RUSTFLAGS: -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort
  RUSTDOCFLAGS: -Cpanic=abort

permissions:
  contents: write
  pull-requests: write 

jobs:
  tests:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        toolchain:
          - nightly
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      # - name: Check semver
        # uses: obi1kenobi/cargo-semver-checks-action@v2

      - name: Install Rust
        uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: ${{ matrix.toolchain }} 
          override: true
          components: llvm-tools-preview

      - name: Download & Install grcov
        run: |
          mkdir -p "${HOME}/.local/bin"
          curl -sL https://github.com/mozilla/grcov/releases/latest/download/grcov-x86_64-unknown-linux-gnu.tar.bz2 | tar jxf - -C "${HOME}/.local/bin"
          echo "$HOME/.local/bin" >> $GITHUB_PATH

      - name: Setup LCOV
        uses: hrishikesh-kadam/setup-lcov@v1

      - name: Cache dependencies
        uses: actions/cache@v4
        env:
          cache-name: cache-dependencies
        with:
          path: |
            ~/.cargo/.crates.toml
            ~/.cargo/.crates2.json
            ~/.cargo/bin
            ~/.cargo/registry/index
            ~/.cargo/registry/cache
            target
          key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Cargo.lock') }}

      - name: Run tests
        env:
          CARGO_INCREMENTAL: 0
          RUSTFLAGS: '-Cinstrument-coverage'
          LLVM_PROFILE_FILE: 'cargo-test-%p-%m.profraw'
        run: cargo test --all-features

      - name: Install cargo-llvm-cov
        uses: taiki-e/install-action@cargo-llvm-cov

      - name: Generate code coverage
        run: cargo llvm-cov --all-features --workspace --lcov --output-path ./target/debug/lcov.info

      - name: remove full path from coverage
        run: sed -i "s;$PWD/;;g" ./target/debug/lcov.info

      - name: Report code coverage
        uses: zgosalvez/github-actions-report-lcov@v4
        with:
          coverage-files: ./target/debug/lcov.info
          minimum-coverage: 14
          artifact-name: code-coverage-report
          github-token: ${{ secrets.GITHUB_TOKEN }}
          update-comment: true

  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        toolchain:
          # - stable
          - nightly
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      # - name: Check semver
        # uses: obi1kenobi/cargo-semver-checks-action@v2

      - name: Install Rust
        uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: ${{ matrix.toolchain }} 
          override: true
          components: llvm-tools-preview

      - name: Cache dependencies
        uses: actions/cache@v4
        env:
          cache-name: cache-dependencies
        with:
          path: |
            ~/.cargo/.crates.toml
            ~/.cargo/.crates2.json
            ~/.cargo/bin
            ~/.cargo/registry/index
            ~/.cargo/registry/cache
            target
          key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Cargo.lock') }}

      - name: Run build
        env:
          CARGO_INCREMENTAL: 0
        run: cargo build