Skip to content

Commit 6a7b502

Browse files
authored
Run ruff on Cpp2RustTest.py (#72)
1 parent dd667fb commit 6a7b502

4 files changed

Lines changed: 231 additions & 174 deletions

File tree

.github/workflows/format.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,14 @@ jobs:
5454
cargo +nightly clippy --manifest-path rule-preprocessor/Cargo.toml --all-targets --all-features -- -Dwarnings
5555
cargo clippy --manifest-path libcc2rs/Cargo.toml --all-targets --all-features -- -Dwarnings
5656
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

CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,23 @@ add_subdirectory(libcc2rs)
8686
add_subdirectory(tests)
8787

8888
find_program(CLANG_FORMAT NAMES clang-format-22 clang-format)
89+
find_program(RUFF NAMES ruff)
8990

9091
file(GLOB_RECURSE ALL_CXX_SOURCES
9192
cpp2rust/*.cpp cpp2rust/*.h tests/*.cpp tests/*.c)
9293

94+
set(PYTHON_SOURCES ${PROJECT_SOURCE_DIR}/tests/lit/lit/formats/Cpp2RustTest.py)
95+
9396
add_custom_target("format"
9497
COMMAND ${CLANG_FORMAT} -i ${ALL_CXX_SOURCES}
9598
COMMAND rustup run ${RUST_STABLE_VERSION} cargo fmt --manifest-path ${PROJECT_SOURCE_DIR}/rules/Cargo.toml
9699
COMMAND rustup run ${RUST_STABLE_VERSION} cargo fmt --manifest-path ${PROJECT_SOURCE_DIR}/rule-preprocessor/Cargo.toml
97100
COMMAND rustup run ${RUST_STABLE_VERSION} cargo fmt --manifest-path ${PROJECT_SOURCE_DIR}/libcc2rs/Cargo.toml
98101
COMMAND rustup run ${RUST_STABLE_VERSION} cargo fmt --manifest-path ${PROJECT_SOURCE_DIR}/libcc2rs-macros/Cargo.toml
102+
COMMAND ${RUFF} --silent check --fix ${PYTHON_SOURCES}
103+
COMMAND ${RUFF} --silent format ${PYTHON_SOURCES}
99104
DEPENDS "${RUST_STAMP_FILE}"
100-
COMMENT "Running clang-format and cargo fmt on all source files"
105+
COMMENT "Running clang-format, cargo fmt, and ruff on all source files"
101106
VERBATIM
102107
)
103108

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ On Ubuntu, install the required dependencies with:
3838
```bash
3939
sudo apt install libclang-22-dev clang++-22 ninja-build cmake python3-tomli
4040
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.95.0
41+
curl -LsSf https://astral.sh/ruff/install.sh | sh
4142
```
4243

4344

0 commit comments

Comments
 (0)