git-bot-feedback 0.7.0

A library designed for CI tools that posts comments on a Pull Request.
Documentation
name: Rust

permissions:
  contents: read

on:
  push:
    branches: [main]
    paths:
      - "**/*.rs"
      - Cargo.toml
      - .github/workflows/rust.yml
    tags:
      - "git-bot-feedback/v*"
  pull_request:
    branches: [main]
    paths:
      - "**/*.rs"
      - Cargo.toml
      - .github/workflows/rust.yml

env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: 1

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: ${{ github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/') }}

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
        with:
          persist-credentials: false
      - name: Setup Rust
        run: rustup update --no-self-update
      - name: Install cargo-binstall
        uses: cargo-bins/cargo-binstall@732870f031d2fb36309d0deaf36abcc704a7be65 # v1.20.1
      - name: Install cargo-llvm-cov, cargo-nextest, and nur
        env:
          GITHUB_TOKEN: ${{ github.token }}
        run: cargo binstall -y cargo-nextest cargo-llvm-cov nur --locked
      - name: Cache deps
        uses: actions/cache@v5.0.5 # zizmor: ignore[cache-poisoning]
        with:
          path: ~/.cargo
          key: cargo-nextest-${{ hashFiles('src/**', 'Cargo.toml') }}
      - run: rustup component add llvm-tools-preview
        # this enables a tool (for default toolchain) needed to measure code coverage.
      - name: run docs examples
        run: nur test docs
      - name: build examples
        run: nur examples
      - name: Run tests
        run: nur test --profile ci
      - name: Generate coverage reports
        run: nur test lcov
      - name: Upload coverage reports as artifacts
        uses: actions/upload-artifact@v7
        with:
          name: lcov.info
          path: lcov.info

  coverage:
    needs: [test]
    runs-on: ubuntu-latest
    environment:
      name: test-coverage
      url: https://app.codecov.io/gh/2bndy5/git-bot-feedback
    steps:
      - uses: actions/checkout@v7
        with:
          persist-credentials: false
      - name: Download coverage reports
        uses: actions/download-artifact@v8
        with:
          name: lcov.info
          path: lcov.info
      - name: Upload coverage reports
        uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          files: lcov.info
          fail_ci_if_error: true

  deploy:
    needs: [test]
    runs-on: ubuntu-latest
    if: startsWith(github.ref, 'refs/tags/')
    environment:
      name: release
      url: https://crates.io/crates/git-bot-feedback
    permissions:
      # Required for OIDC token exchange
      id-token: write
    steps:
      - uses: actions/checkout@v7
        with:
          persist-credentials: false
      - name: Setup Rust
        run: rustup update --no-self-update
      - name: Establish trusted publishing token
        uses: rust-lang/crates-io-auth-action@c6f97d42243bad5fab37ca0427f495c86d5b1a18 # v1.0.5
        id: auth
      - name: Publish to crates.io
        env:
          CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
        run: cargo publish