nbr 0.4.3

CLI for NoneBot2 - A Rust implementation
Documentation
name: CI

on:
  push:
    branches: [main]
    paths-ignore:
      - "README.md"
  pull_request:
  workflow_dispatch:

concurrency:
  group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number || github.sha }}
  cancel-in-progress: true

env:
  # UV_VERSION should not greater than MAX_UV_VERSION in `languages/python/uv`.
  # Otherwise, tests jobs will install their own uv, and now it has concurrent issue.
  UV_VERSION: "0.9.16"
  PYTHON_VERSION: "3.12"

jobs:
  typos:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: crate-ci/typos@master

  lint:
    name: "lint"
    timeout-minutes: 30
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
      - name: "Install Rustfmt"
        run: rustup component add rustfmt
      - name: "rustfmt"
        run: cargo fmt --all --check

  cargo-clippy-linux:
    name: "cargo clippy | ubuntu"
    timeout-minutes: 10
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
      - uses: rui314/setup-mold@v1
      - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2

      - name: "Install Rust toolchain"
        run: rustup component add clippy
      - name: "Clippy"
        run: cargo clippy --workspace --all-targets --all-features --locked -- -D warnings

  cargo-clippy-windows:
    timeout-minutes: 15
    runs-on: windows-latest
    name: "cargo clippy | windows"
    steps:
      - uses: actions/checkout@v6

      # - name: Create Dev Drive
      #   run: ${{ github.workspace }}/.github/workflows/setup-dev-drive.ps1

      - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2

      - name: "Install Rust toolchain"
        run: rustup component add clippy

      - name: "Clippy"
        run: cargo clippy --workspace --all-targets --all-features --locked -- -D warnings

  cargo-shear:
    name: "cargo shear"
    timeout-minutes: 10
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: cargo-bins/cargo-binstall@main
      - run: cargo binstall --no-confirm cargo-shear
      - run: cargo shear

  cargo-test-linux:
    timeout-minutes: 10
    runs-on: ubuntu-latest
    permissions:
      id-token: write
    name: "cargo test | ubuntu"
    steps:
      - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
      - uses: rui314/setup-mold@v1
      - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2

      - name: "Install Rust toolchain"
        run: rustup show

      - name: "Install cargo nextest"
        uses: taiki-e/install-action@50708e9ba8d7b6587a2cb575ddaa9a62e927bc06 # v2.62.63
        with:
          tool: cargo-nextest

      - name: "Install cargo-llvm-cov"
        uses: taiki-e/install-action@50708e9ba8d7b6587a2cb575ddaa9a62e927bc06 # v2.62.63
        with:
          tool: cargo-llvm-cov

      - name: "Install uv"
        uses: astral-sh/setup-uv@ed21f2f24f8dd64503750218de024bcf64c7250a # v7.1.5
        with:
          version: ${{ env.UV_VERSION }}

      - name: "Cargo test create_project"
        run: cargo test cli::create::tests::test_create_project

      - name: "Cargo test"
        run: |
          cargo llvm-cov nextest \
            --no-report \
            --workspace \
            --status-level skip --failure-output immediate --no-fail-fast -j 8 --final-status-level slow

          cargo llvm-cov report --lcov --output-path lcov.info

      - name: Upload coverage reports to Codecov
        uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
        with:
          files: lcov.info
          use_oidc: true

  cargo-test-macos:
    timeout-minutes: 10
    runs-on: macos-latest
    name: "cargo test | macos"
    steps:
      - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6

      - uses: rui314/setup-mold@v1

      - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2

      - name: "Install Rust toolchain"
        run: rustup show

      - name: "Install cargo nextest"
        uses: taiki-e/install-action@50708e9ba8d7b6587a2cb575ddaa9a62e927bc06 # v2.62.63
        with:
          tool: cargo-nextest

      - name: "Install uv"
        uses: astral-sh/setup-uv@ed21f2f24f8dd64503750218de024bcf64c7250a # v7.1.5
        with:
          enable-cache: true
          version: ${{ env.UV_VERSION }}
      
      - name: "Cargo test create_project"
        run: cargo test cli::create::tests::test_create_project
  
      - name: "Cargo test"
        run: |
          cargo nextest show-config test-groups
          cargo nextest run \
            --workspace \
            --status-level skip --failure-output immediate --no-fail-fast -j 8 --final-status-level slow


  cargo-test-windows:
    timeout-minutes: 15
    runs-on: windows-latest
    name: "cargo test | windows"
    steps:
      - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6

      # - name: Create Dev Drive
      #   run: ${{ github.workspace }}/.github/workflows/setup-dev-drive.ps1

      - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2

      - name: "Install Rust toolchain"
        run: rustup show

      - name: "Install cargo nextest"
        uses: taiki-e/install-action@50708e9ba8d7b6587a2cb575ddaa9a62e927bc06 # v2.62.63
        with:
          tool: cargo-nextest

      - name: "Install uv"
        uses: astral-sh/setup-uv@ed21f2f24f8dd64503750218de024bcf64c7250a # v7.1.5
        with:
          enable-cache: true
          version: ${{ env.UV_VERSION }}

      - name: "Cargo test create_project"
        run: cargo test cli::create::tests::test_create_project
  
      - name: "Cargo test"
        run: |
          cargo nextest show-config test-groups
          cargo nextest run --workspace --status-level skip --failure-output immediate --no-fail-fast -j 8 --final-status-level slow