Swadhin Biswas feat: add --git flag, overhaul CI/CD, rewrite website, prepare for crates.io · 3/7/2026
d0f56db
124 lines · 3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
name: CI

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

env:
  CARGO_TERM_COLOR: always
  RUSTFLAGS: -Dwarnings

jobs:
  fmt:
    name: Rustfmt
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt
      - 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
      - uses: Swatinem/rust-cache@v2
      - run: cargo clippy --all-targets -- -D warnings

  test:
    name: Test (${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest]
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - run: cargo test --verbose
      - name: Run binary smoke tests
        run: |
          cargo run -- --help
          cargo run -- --version
          cargo run -- -l src/
          cargo run -- --tree --depth 1 src/

  build:
    name: Build (${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest]
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - run: cargo build --release
      - name: Upload binary
        uses: actions/upload-artifact@v4
        with:
          name: lsf-${{ matrix.os }}
          path: target/release/lsf

  audit:
    name: Security Audit
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: rustsec/[email protected]
        with:
          token: ${{ secrets.GITHUB_TOKEN }}

  msrv:
    name: MSRV Check
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/[email protected]
      - uses: Swatinem/rust-cache@v2
      - run: cargo check

  # This job gates merges — add it as a required status check in branch protection
  ci-pass:
    name: CI Pass
    if: always()
    needs: [fmt, clippy, test, build, audit, msrv]
    runs-on: ubuntu-latest
    steps:
      - name: Check all jobs passed
        run: |
          if [[ "${{ needs.fmt.result }}" != "success" ]]; then
            echo "fmt failed"
            exit 1
          fi
          if [[ "${{ needs.clippy.result }}" != "success" ]]; then
            echo "clippy failed"
            exit 1
          fi
          if [[ "${{ needs.test.result }}" != "success" ]]; then
            echo "test failed"
            exit 1
          fi
          if [[ "${{ needs.build.result }}" != "success" ]]; then
            echo "build failed"
            exit 1
          fi
          if [[ "${{ needs.audit.result }}" != "success" ]]; then
            echo "audit failed"
            exit 1
          fi
          if [[ "${{ needs.msrv.result }}" != "success" ]]; then
            echo "msrv check failed"
            exit 1
          fi
          echo "All CI checks passed!"