|
| 1 | +name: Rust Checks |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [opened, synchronize, reopened, ready_for_review] |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: read |
| 9 | + |
| 10 | +defaults: |
| 11 | + run: |
| 12 | + working-directory: ./rust |
| 13 | + |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - name: Harden the runner (Audit all outbound calls) |
| 19 | + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 |
| 20 | + with: |
| 21 | + egress-policy: audit |
| 22 | + |
| 23 | + - name: Checkout |
| 24 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 25 | + |
| 26 | + - name: Setup Rust |
| 27 | + uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable |
| 28 | + with: |
| 29 | + toolchain: stable |
| 30 | + components: clippy, rustfmt |
| 31 | + |
| 32 | + - name: Cache Cargo dependencies |
| 33 | + uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 |
| 34 | + with: |
| 35 | + path: | |
| 36 | + ~/.cargo/bin/ |
| 37 | + ~/.cargo/registry/index/ |
| 38 | + ~/.cargo/registry/cache/ |
| 39 | + ~/.cargo/git/db/ |
| 40 | + rust/target/ |
| 41 | + key: ${{ runner.os }}-cargo-${{ hashFiles('rust/Cargo.lock') }} |
| 42 | + |
| 43 | + - name: Build |
| 44 | + run: cargo build --verbose |
| 45 | + |
| 46 | + lint: |
| 47 | + runs-on: ubuntu-latest |
| 48 | + steps: |
| 49 | + - name: Harden the runner (Audit all outbound calls) |
| 50 | + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 |
| 51 | + with: |
| 52 | + egress-policy: audit |
| 53 | + |
| 54 | + - name: Checkout |
| 55 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 56 | + |
| 57 | + - name: Setup Rust |
| 58 | + uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable |
| 59 | + with: |
| 60 | + toolchain: stable |
| 61 | + components: clippy, rustfmt |
| 62 | + |
| 63 | + - name: Cache Cargo dependencies |
| 64 | + uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 |
| 65 | + with: |
| 66 | + path: | |
| 67 | + ~/.cargo/bin/ |
| 68 | + ~/.cargo/registry/index/ |
| 69 | + ~/.cargo/registry/cache/ |
| 70 | + ~/.cargo/git/db/ |
| 71 | + rust/target/ |
| 72 | + key: ${{ runner.os }}-cargo-${{ hashFiles('rust/Cargo.lock') }} |
| 73 | + |
| 74 | + - name: Lint |
| 75 | + run: cargo clippy --all-targets --all-features -- -D warnings |
| 76 | + |
| 77 | + format: |
| 78 | + runs-on: ubuntu-latest |
| 79 | + steps: |
| 80 | + - name: Harden the runner (Audit all outbound calls) |
| 81 | + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 |
| 82 | + with: |
| 83 | + egress-policy: audit |
| 84 | + |
| 85 | + - name: Checkout |
| 86 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 87 | + |
| 88 | + - name: Setup Rust |
| 89 | + uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable |
| 90 | + with: |
| 91 | + toolchain: stable |
| 92 | + components: clippy, rustfmt |
| 93 | + |
| 94 | + - name: Check formatting |
| 95 | + run: cargo fmt --all -- --check |
| 96 | + |
| 97 | + lint-examples: |
| 98 | + runs-on: ubuntu-latest |
| 99 | + defaults: |
| 100 | + run: |
| 101 | + working-directory: ./examples/rust |
| 102 | + steps: |
| 103 | + - name: Harden the runner (Audit all outbound calls) |
| 104 | + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 |
| 105 | + with: |
| 106 | + egress-policy: audit |
| 107 | + |
| 108 | + - name: Checkout |
| 109 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 110 | + |
| 111 | + - name: Setup Rust |
| 112 | + uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable |
| 113 | + with: |
| 114 | + toolchain: stable |
| 115 | + components: clippy, rustfmt |
| 116 | + |
| 117 | + - name: Cache Cargo dependencies |
| 118 | + uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 |
| 119 | + with: |
| 120 | + path: | |
| 121 | + ~/.cargo/bin/ |
| 122 | + ~/.cargo/registry/index/ |
| 123 | + ~/.cargo/registry/cache/ |
| 124 | + ~/.cargo/git/db/ |
| 125 | + rust/target/ |
| 126 | + key: ${{ runner.os }}-cargo-${{ hashFiles('rust/Cargo.lock') }} |
| 127 | + |
| 128 | + - name: Lint |
| 129 | + run: cargo clippy --all-targets --all-features -- -D warnings |
| 130 | + |
| 131 | + format-examples: |
| 132 | + runs-on: ubuntu-latest |
| 133 | + defaults: |
| 134 | + run: |
| 135 | + working-directory: ./examples/rust |
| 136 | + steps: |
| 137 | + - name: Harden the runner (Audit all outbound calls) |
| 138 | + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 |
| 139 | + with: |
| 140 | + egress-policy: audit |
| 141 | + |
| 142 | + - name: Checkout |
| 143 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 144 | + |
| 145 | + - name: Setup Rust |
| 146 | + uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable |
| 147 | + with: |
| 148 | + toolchain: stable |
| 149 | + components: clippy, rustfmt |
| 150 | + |
| 151 | + - name: Check formatting |
| 152 | + run: cargo fmt --all -- --check |
| 153 | + |
| 154 | + lockfile: |
| 155 | + runs-on: ubuntu-latest |
| 156 | + steps: |
| 157 | + - name: Harden the runner (Audit all outbound calls) |
| 158 | + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 |
| 159 | + with: |
| 160 | + egress-policy: audit |
| 161 | + |
| 162 | + - name: Checkout |
| 163 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 164 | + |
| 165 | + - name: Setup Rust |
| 166 | + uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable |
| 167 | + with: |
| 168 | + toolchain: stable |
| 169 | + |
| 170 | + - name: Check Cargo.lock |
| 171 | + run: | |
| 172 | + cargo check |
| 173 | + if [ -n "$(git diff Cargo.lock)" ]; then |
| 174 | + echo "Error: Cargo.lock was modified after running cargo check. Please commit the updated Cargo.lock file." |
| 175 | + exit 1 |
| 176 | + fi |
0 commit comments