Skip to content

Commit e6ebe1d

Browse files
authored
Simplify CI for format checking (#98)
1 parent c2f513a commit e6ebe1d

2 files changed

Lines changed: 18 additions & 46 deletions

File tree

.github/workflows/format.yml

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -25,43 +25,15 @@ jobs:
2525
with:
2626
llvm-version: 22
2727

28-
- name: Setup Rust
29-
uses: dtolnay/rust-toolchain@master
30-
with:
31-
toolchain: 1.95.0
32-
components: rustfmt, clippy
33-
34-
- name: Setup nightly Rust for rule-preprocessor clippy
35-
uses: dtolnay/rust-toolchain@master
36-
with:
37-
toolchain: nightly
38-
components: rustfmt, clippy, rustc-dev
28+
- name: Setup Python
29+
run: pip install ruff
3930

40-
- name: Check C++ formatting
41-
run: find cpp2rust tests -name '*.cpp' -o -name '*.h' -o -name '*.c' | xargs clang-format --dry-run --Werror
31+
- name: Configure
32+
run: cmake -GNinja -B build -S .
4233

43-
- name: Check Rust formatting
44-
run: |
45-
cargo fmt --manifest-path rules/Cargo.toml -- --check
46-
cargo fmt --manifest-path rule-preprocessor/Cargo.toml -- --check
47-
cargo fmt --manifest-path libcc2rs/Cargo.toml -- --check
48-
cargo fmt --manifest-path libcc2rs-macros/Cargo.toml -- --check
49-
find tests -name '*.rs' -print0 | xargs -0 rustfmt --check
34+
- name: Format files
35+
run: ninja format
36+
working-directory: build
5037

51-
- name: Check Rust lints
52-
run: |
53-
cargo clippy --manifest-path rules/Cargo.toml --all-targets --all-features -- -Dwarnings
54-
cargo +nightly clippy --manifest-path rule-preprocessor/Cargo.toml --all-targets --all-features -- -Dwarnings
55-
cargo clippy --manifest-path libcc2rs/Cargo.toml --all-targets --all-features -- -Dwarnings
56-
cargo clippy --manifest-path libcc2rs-macros/Cargo.toml --all-targets --all-features -- -Dwarnings
57-
58-
- name: Check Python (ruff)
59-
uses: astral-sh/ruff-action@v3
60-
with:
61-
args: 'check'
62-
src: tests/lit/lit/formats/Cpp2RustTest.py
63-
- name: Check Python formatting (ruff)
64-
uses: astral-sh/ruff-action@v3
65-
with:
66-
args: 'format --check'
67-
src: tests/lit/lit/formats/Cpp2RustTest.py
38+
- name: Check format
39+
run: git diff --exit-code

CMakeLists.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ set(RUST_STAMP_FILE "${CMAKE_BINARY_DIR}/.rust-toolchain.stamp")
6868

6969
add_custom_command(
7070
OUTPUT "${RUST_STAMP_FILE}"
71-
COMMAND rustup toolchain install ${RUST_STABLE_VERSION}
72-
COMMAND rustup toolchain install ${RUST_NIGHTLY_VERSION} --component rustc-dev --component llvm-tools
71+
COMMAND rustup toolchain install ${RUST_STABLE_VERSION} --component clippy --component rustfmt
72+
COMMAND rustup toolchain install ${RUST_NIGHTLY_VERSION} --component rustc-dev --component llvm-tools --component clippy --component rustfmt
7373
COMMAND ${CMAKE_COMMAND} -E touch "${RUST_STAMP_FILE}"
7474
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/rust-toolchain.cmake"
7575
USES_TERMINAL
@@ -91,16 +91,16 @@ set(PYTHON_SOURCES ${PROJECT_SOURCE_DIR}/tests/lit/lit/formats/Cpp2RustTest.py)
9191
add_custom_target("format"
9292
COMMAND ${CLANG_FORMAT} -i ${ALL_CXX_SOURCES}
9393
COMMAND cargo +${RUST_STABLE_VERSION} fmt --manifest-path ${PROJECT_SOURCE_DIR}/rules/Cargo.toml
94-
COMMAND cargo +${RUST_STABLE_VERSION} --manifest-path ${PROJECT_SOURCE_DIR}/rule-preprocessor/Cargo.toml
94+
COMMAND cargo +${RUST_NIGHTLY_VERSION} fmt --manifest-path ${PROJECT_SOURCE_DIR}/rule-preprocessor/Cargo.toml
9595
COMMAND cargo +${RUST_STABLE_VERSION} fmt --manifest-path ${PROJECT_SOURCE_DIR}/libcc2rs/Cargo.toml
9696
COMMAND cargo +${RUST_STABLE_VERSION} fmt --manifest-path ${PROJECT_SOURCE_DIR}/libcc2rs-macros/Cargo.toml
97-
COMMAND cargo +${RUST_STABLE_VERSION} clippy --fix --allow-dirty --allow-staged --all-targets --all-features
97+
COMMAND cargo +${RUST_STABLE_VERSION} clippy --fix --allow-dirty --allow-no-vcs --allow-staged --all-targets --all-features
9898
--manifest-path ${PROJECT_SOURCE_DIR}/rules/Cargo.toml -- -Dwarnings
99-
COMMAND cargo +${RUST_STABLE_VERSION} clippy --fix --allow-dirty --allow-staged --all-targets --all-features
100-
--manifest-path chdir ${PROJECT_SOURCE_DIR}/rule-preprocessor/Cargo.toml -- -Dwarnings
101-
COMMAND cargo +${RUST_STABLE_VERSION} clippy --fix --allow-dirty --allow-staged --all-targets --all-features
102-
--manifest-path $${PROJECT_SOURCE_DIR}/libcc2rs/Cargo.toml -- -Dwarnings
103-
COMMAND cargo +${RUST_STABLE_VERSION} clippy --fix --allow-dirty --allow-staged --all-targets --all-features
99+
COMMAND cargo +${RUST_NIGHTLY_VERSION} clippy --fix --allow-dirty --allow-no-vcs --allow-staged --all-targets --all-features
100+
--manifest-path ${PROJECT_SOURCE_DIR}/rule-preprocessor/Cargo.toml -- -Dwarnings
101+
COMMAND cargo +${RUST_STABLE_VERSION} clippy --fix --allow-dirty --allow-no-vcs --allow-staged --all-targets --all-features
102+
--manifest-path ${PROJECT_SOURCE_DIR}/libcc2rs/Cargo.toml -- -Dwarnings
103+
COMMAND cargo +${RUST_STABLE_VERSION} clippy --fix --allow-dirty --allow-no-vcs --allow-staged --all-targets --all-features
104104
--manifest-path ${PROJECT_SOURCE_DIR}/libcc2rs-macros/Cargo.toml -- -Dwarnings
105105
COMMAND ${RUFF} --silent check --fix ${PYTHON_SOURCES}
106106
COMMAND ${RUFF} --silent format ${PYTHON_SOURCES}

0 commit comments

Comments
 (0)