tree2 1.0.12

A beautiful and feature-rich directory tree visualization tool with colors, emojis, and comprehensive ignore file support
name: CI

on:
  push:
    branches: [ master, main ]
  pull_request:
    branches: [ master, main ]

env:
  CARGO_TERM_COLOR: always

permissions:
  contents: read
  pull-requests: read

jobs:
  test:
    name: Test
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest, macos-latest]
        rust: [stable]
    steps:
    - uses: actions/checkout@v4

    - name: Install Rust
      uses: dtolnay/rust-toolchain@stable
      with:
        toolchain: ${{ matrix.rust }}
        components: rustfmt, clippy

    - name: Cache cargo registry
      uses: actions/cache@v4
      with:
        path: ~/.cargo/registry
        key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}

    - name: Cache cargo index
      uses: actions/cache@v4
      with:
        path: ~/.cargo/git
        key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}

    - name: Cache cargo build
      uses: actions/cache@v4
      with:
        path: target
        key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}

    - name: Build
      run: cargo build --verbose

    - name: Run tests
      run: cargo test --verbose
      continue-on-error: false

  fmt:
    name: Rustfmt
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: dtolnay/rust-toolchain@stable
      with:
        components: rustfmt
    - name: Check formatting
      run: cargo fmt --all -- --check

  clippy:
    name: Clippy
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: dtolnay/rust-toolchain@stable
      with:
        components: clippy
    - name: Run clippy
      run: cargo clippy -- -D warnings

  build-release:
    name: Build Release
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        include:
          # Linux x86_64
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            bin_name: tree2
            asset_suffix: linux-amd64
          # Windows x86_64
          - os: windows-latest
            target: x86_64-pc-windows-msvc
            bin_name: tree2.exe
            asset_suffix: windows-amd64
          # macOS x86_64
          - os: macos-latest
            target: x86_64-apple-darwin
            bin_name: tree2
            asset_suffix: macos-amd64
    steps:
    - uses: actions/checkout@v4

    - name: Install Rust
      uses: dtolnay/rust-toolchain@stable
      with:
        targets: ${{ matrix.target }}

    - name: Build release
      run: cargo build --release --target ${{ matrix.target }}

    - name: Strip binaries (Linux/macOS)
      if: matrix.os != 'windows-latest'
      run: |
        strip target/${{ matrix.target }}/release/${{ matrix.bin_name }}

    - name: Upload tree2 artifact
      uses: actions/upload-artifact@v4
      with:
        name: tree2-${{ matrix.asset_suffix }}
        path: target/${{ matrix.target }}/release/${{ matrix.bin_name }}
        if-no-files-found: error