|
| 1 | +name: CI |
| 2 | + |
| 3 | +permissions: |
| 4 | + contents: read |
| 5 | + |
| 6 | +on: |
| 7 | + pull_request: |
| 8 | + push: |
| 9 | + branches: |
| 10 | + - main |
| 11 | + |
| 12 | +env: |
| 13 | + RUST_BACKTRACE: 1 |
| 14 | + CARGO_TERM_COLOR: always |
| 15 | + CLICOLOR: 1 |
| 16 | + |
| 17 | +jobs: |
| 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@v3 |
| 38 | + - name: Install Rust |
| 39 | + uses: dtolnay/rust-toolchain@stable |
| 40 | + with: |
| 41 | + toolchain: ${{ matrix.rust }} |
| 42 | + - uses: Swatinem/rust-cache@v2 |
| 43 | + - name: Build |
| 44 | + run: cargo test --no-run --workspace --all-features |
| 45 | + - name: Default features |
| 46 | + run: cargo test --workspace |
| 47 | + - name: All features |
| 48 | + run: cargo test --workspace --all-features |
| 49 | + - name: No-default features |
| 50 | + run: cargo test --workspace --no-default-features |
| 51 | + msrv: |
| 52 | + name: "Check MSRV: 1.64.0" |
| 53 | + runs-on: ubuntu-latest |
| 54 | + steps: |
| 55 | + - name: Checkout repository |
| 56 | + uses: actions/checkout@v3 |
| 57 | + - name: Install Rust |
| 58 | + uses: dtolnay/rust-toolchain@stable |
| 59 | + with: |
| 60 | + toolchain: 1.64.0 # MSRV |
| 61 | + - uses: Swatinem/rust-cache@v2 |
| 62 | + - name: Default features |
| 63 | + run: cargo check --workspace --all-targets |
| 64 | + - name: All features |
| 65 | + run: cargo check --workspace --all-targets --all-features |
| 66 | + - name: No-default features |
| 67 | + run: cargo check --workspace --all-targets --no-default-features |
| 68 | + docs: |
| 69 | + name: Docs |
| 70 | + runs-on: ubuntu-latest |
| 71 | + steps: |
| 72 | + - name: Checkout repository |
| 73 | + uses: actions/checkout@v3 |
| 74 | + - name: Install Rust |
| 75 | + uses: dtolnay/rust-toolchain@stable |
| 76 | + with: |
| 77 | + toolchain: stable |
| 78 | + - uses: Swatinem/rust-cache@v2 |
| 79 | + - name: Check documentation |
| 80 | + env: |
| 81 | + RUSTDOCFLAGS: -D warnings |
| 82 | + run: cargo doc --workspace --all-features --no-deps --document-private-items |
| 83 | + rustfmt: |
| 84 | + name: rustfmt |
| 85 | + runs-on: ubuntu-latest |
| 86 | + steps: |
| 87 | + - name: Checkout repository |
| 88 | + uses: actions/checkout@v3 |
| 89 | + - name: Install Rust |
| 90 | + uses: dtolnay/rust-toolchain@stable |
| 91 | + with: |
| 92 | + # Not MSRV because its harder to jump between versions and people are |
| 93 | + # more likely to have stable |
| 94 | + toolchain: stable |
| 95 | + components: rustfmt |
| 96 | + - uses: Swatinem/rust-cache@v2 |
| 97 | + - name: Check formatting |
| 98 | + run: cargo fmt --all -- --check |
| 99 | + clippy: |
| 100 | + name: clippy |
| 101 | + runs-on: ubuntu-latest |
| 102 | + permissions: |
| 103 | + security-events: write # to upload sarif results |
| 104 | + steps: |
| 105 | + - name: Checkout repository |
| 106 | + uses: actions/checkout@v3 |
| 107 | + - name: Install Rust |
| 108 | + uses: dtolnay/rust-toolchain@stable |
| 109 | + with: |
| 110 | + toolchain: 1.64.0 # MSRV |
| 111 | + components: clippy |
| 112 | + - uses: Swatinem/rust-cache@v2 |
| 113 | + - name: Install SARIF tools |
| 114 | + run: cargo install clippy-sarif --version 0.3.4 --locked # Held back due to msrv |
| 115 | + - name: Install SARIF tools |
| 116 | + run: cargo install sarif-fmt --version 0.3.4 --locked # Held back due to msrv |
| 117 | + - name: Check |
| 118 | + run: > |
| 119 | + cargo clippy --workspace --all-features --all-targets --message-format=json -- -D warnings --allow deprecated |
| 120 | + | clippy-sarif |
| 121 | + | tee clippy-results.sarif |
| 122 | + | sarif-fmt |
| 123 | + continue-on-error: true |
| 124 | + - name: Upload |
| 125 | + uses: github/codeql-action/upload-sarif@v2 |
| 126 | + with: |
| 127 | + sarif_file: clippy-results.sarif |
| 128 | + wait-for-processing: true |
0 commit comments