• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1name: CI
2
3permissions:
4  contents: read
5
6on:
7  pull_request:
8  push:
9    branches:
10    - main
11
12env:
13  RUST_BACKTRACE: 1
14  CARGO_TERM_COLOR: always
15  CLICOLOR: 1
16
17jobs:
18  ci:
19    permissions:
20      contents: none
21    name: CI
22    needs: [test, msrv, docs, rustfmt, clippy]
23    runs-on: ubuntu-latest
24    steps:
25      - name: Done
26        run: exit 0
27  test:
28    name: Test
29    strategy:
30      matrix:
31        os: ["ubuntu-latest", "windows-latest", "macos-latest"]
32        rust: ["stable"]
33    continue-on-error: ${{ matrix.rust != 'stable' }}
34    runs-on: ${{ matrix.os }}
35    steps:
36    - name: Checkout repository
37      uses: actions/checkout@v4
38    - name: Install Rust
39      uses: dtolnay/rust-toolchain@stable
40      with:
41        toolchain: ${{ matrix.rust }}
42    - uses: Swatinem/rust-cache@v2
43    - uses: taiki-e/install-action@cargo-hack
44    - name: Build
45      run: cargo test --no-run --workspace --all-features
46    - name: Test
47      run: cargo hack test --workspace --feature-powerset
48    - name: Run crate example
49      run: cargo run --example default
50  msrv:
51    name: "Check MSRV: 1.60.0"
52    runs-on: ubuntu-latest
53    steps:
54    - name: Checkout repository
55      uses: actions/checkout@v4
56    - name: Install Rust
57      uses: dtolnay/rust-toolchain@stable
58      with:
59        toolchain: "1.60"  # MSRV
60    - uses: Swatinem/rust-cache@v2
61    - uses: taiki-e/install-action@cargo-hack
62    - name: Check
63      run: cargo hack check --workspace --all-targets --feature-powerset
64  lockfile:
65    runs-on: ubuntu-latest
66    steps:
67    - name: Checkout repository
68      uses: actions/checkout@v4
69    - name: Install Rust
70      uses: dtolnay/rust-toolchain@stable
71      with:
72        toolchain: stable
73    - uses: Swatinem/rust-cache@v2
74    - name: "Is lockfile updated?"
75      run: cargo fetch --locked
76  docs:
77    name: Docs
78    runs-on: ubuntu-latest
79    steps:
80    - name: Checkout repository
81      uses: actions/checkout@v4
82    - name: Install Rust
83      uses: dtolnay/rust-toolchain@stable
84      with:
85        toolchain: stable
86    - uses: Swatinem/rust-cache@v2
87    - name: Check documentation
88      env:
89        RUSTDOCFLAGS: -D warnings
90      run: cargo doc --workspace --all-features --no-deps --document-private-items
91  rustfmt:
92    name: rustfmt
93    runs-on: ubuntu-latest
94    steps:
95    - name: Checkout repository
96      uses: actions/checkout@v4
97    - name: Install Rust
98      uses: dtolnay/rust-toolchain@stable
99      with:
100        # Not MSRV because its harder to jump between versions and people are
101        # more likely to have stable
102        toolchain: stable
103        components: rustfmt
104    - uses: Swatinem/rust-cache@v2
105    - name: Check formatting
106      run: cargo fmt --all -- --check
107  clippy:
108    name: clippy
109    runs-on: ubuntu-latest
110    permissions:
111      security-events: write # to upload sarif results
112    steps:
113    - name: Checkout repository
114      uses: actions/checkout@v4
115    - name: Install Rust
116      uses: dtolnay/rust-toolchain@stable
117      with:
118        toolchain: "1.60"  # MSRV
119        components: clippy
120    - uses: Swatinem/rust-cache@v2
121    - name: Install SARIF tools
122      run: cargo install clippy-sarif --version 0.3.4 --locked  # Held back due to msrv
123    - name: Install SARIF tools
124      run: cargo install sarif-fmt --version 0.3.4 --locked # Held back due to msrv
125    - name: Check
126      run: >
127        cargo clippy --workspace --all-features --all-targets --message-format=json -- -D warnings --allow deprecated
128        | clippy-sarif
129        | tee clippy-results.sarif
130        | sarif-fmt
131      continue-on-error: true
132    - name: Upload
133      uses: github/codeql-action/upload-sarif@v3
134      with:
135        sarif_file: clippy-results.sarif
136        wait-for-processing: true
137    - name: Report status
138      run: cargo clippy --workspace --all-features --all-targets -- -D warnings --allow deprecated
139