aigitcommit 1.7.1

A simple git commit message generator by OpenAI compaction model.
Documentation
#!#
# Copyright (c) 2025 Hangzhou Guanwaii Technology Co., Ltd.
#
# This source code is licensed under the MIT License,
# which is located in the LICENSE file in the source tree's root directory.
#
# File: rust.yml
# Author: mingcheng <mingcheng@apache.org>
# File Created: 2025-03-05 11:10:40
#
# Modified By: mingcheng <mingcheng@apache.org>
# Last Modified: 2025-10-22 00:33:40
##

name: Cargo Build & Test

on:
  push:
    branches:
      - main
      - master
      - develop
      - "feature/**"
  pull_request:
    branches:
      - main
      - master
      - develop
  workflow_dispatch:

env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: 1

jobs:
  # Code quality checks (clippy and rustfmt)
  lint:
    name: Lint (clippy & rustfmt)
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v5

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: stable

      - name: Rust cache
        uses: Swatinem/rust-cache@v2
        with:
          cache-on-failure: true

      - name: Run cargo fmt check
        run: cargo fmt --all -- --check

      - name: Run cargo clippy
        run: cargo clippy --all-targets --all-features -- -D warnings

  # Security audit
  security_audit:
    name: Security Audit
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v5

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: stable

      - name: Rust cache
        uses: Swatinem/rust-cache@v2
        with:
          cache-on-failure: true

      - name: Install cargo-audit
        run: cargo install cargo-audit --locked

      - name: Run cargo audit
        run: cargo audit

  # Build and test on stable/beta/nightly
  build_and_test:
    name: Build & Test (${{ matrix.toolchain }})
    runs-on: ubuntu-latest
    needs:
      - lint
      - security_audit
    strategy:
      fail-fast: false
      matrix:
        toolchain:
          - stable
          - beta
          - nightly
    continue-on-error: ${{ matrix.toolchain == 'nightly' }}
    steps:
      - name: Checkout code
        uses: actions/checkout@v5

      - name: Setup Rust toolchain (${{ matrix.toolchain }})
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: ${{ matrix.toolchain }}

      - name: Rust cache
        uses: Swatinem/rust-cache@v2
        with:
          cache-on-failure: true

      - name: Show Rust version
        run: |
          rustc --version
          cargo --version

      - name: Run tests
        run: cargo test --all --locked

      - name: Verify package can be built
        run: cargo package --locked --allow-dirty