|
1 | 1 | name: Format Check |
2 | 2 |
|
3 | | -on: [push, pull_request] |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + pull_request: |
| 8 | + branches: [ "**" ] |
4 | 9 |
|
5 | 10 | jobs: |
6 | 11 | format: |
7 | 12 | runs-on: ubuntu-latest |
8 | 13 | permissions: |
9 | | - contents: read |
| 14 | + contents: write |
10 | 15 |
|
11 | 16 | steps: |
12 | 17 | - name: Checkout code |
|
20 | 25 | - name: Setup Rust |
21 | 26 | uses: dtolnay/rust-toolchain@master |
22 | 27 | with: |
23 | | - toolchain: 1.94.0 |
24 | | - components: rustfmt |
| 28 | + toolchain: 1.95.0 |
| 29 | + components: rustfmt, clippy |
| 30 | + |
| 31 | + - name: Setup nightly Rust for rule-preprocessor clippy |
| 32 | + uses: dtolnay/rust-toolchain@master |
| 33 | + with: |
| 34 | + toolchain: nightly |
| 35 | + components: rustfmt, clippy, rustc-dev |
| 36 | + |
| 37 | + - name: Apply C++ formatting fixes |
| 38 | + run: find cpp2rust tests -name '*.cpp' -o -name '*.h' -o -name '*.c' | xargs clang-format -i |
| 39 | + |
| 40 | + - name: Apply Rust lint fixes |
| 41 | + run: | |
| 42 | + cargo clippy --fix --allow-dirty --manifest-path rules/Cargo.toml --all-targets |
| 43 | + cargo +nightly clippy --fix --allow-dirty --manifest-path rule-preprocessor/Cargo.toml --all-targets |
| 44 | + cargo clippy --fix --allow-dirty --manifest-path libcc2rs/Cargo.toml --all-targets |
| 45 | +
|
| 46 | + - name: Apply Rust formatting fixes |
| 47 | + run: | |
| 48 | + cargo fmt --manifest-path rules/Cargo.toml |
| 49 | + cargo fmt --manifest-path rule-preprocessor/Cargo.toml |
| 50 | + cargo fmt --manifest-path libcc2rs/Cargo.toml |
| 51 | + find tests -name '*.rs' -print0 | xargs -0 rustfmt |
| 52 | +
|
| 53 | + - name: Commit auto-fixes |
| 54 | + if: github.ref != 'refs/heads/master' |
| 55 | + uses: stefanzweifel/git-auto-commit-action@v5 |
| 56 | + with: |
| 57 | + commit_message: "Automatically apply formatting and lint fixes" |
25 | 58 |
|
26 | 59 | - name: Check C++ formatting |
27 | 60 | run: find cpp2rust tests -name '*.cpp' -o -name '*.h' -o -name '*.c' | xargs clang-format --dry-run --Werror |
|
31 | 64 | cargo fmt --manifest-path rules/Cargo.toml -- --check |
32 | 65 | cargo fmt --manifest-path rule-preprocessor/Cargo.toml -- --check |
33 | 66 | cargo fmt --manifest-path libcc2rs/Cargo.toml -- --check |
| 67 | + find tests -name '*.rs' -print0 | xargs -0 rustfmt --check |
| 68 | +
|
| 69 | + - name: Check Rust lints |
| 70 | + run: | |
| 71 | + cargo clippy --manifest-path rules/Cargo.toml --all-targets --all-features -- -Dwarnings |
| 72 | + cargo +nightly clippy --manifest-path rule-preprocessor/Cargo.toml --all-targets --all-features -- -Dwarnings |
| 73 | + cargo clippy --manifest-path libcc2rs/Cargo.toml --all-targets --all-features -- -Dwarnings |
0 commit comments