diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 4ef33ade..d0c10758 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -25,43 +25,15 @@ jobs: with: llvm-version: 22 - - name: Setup Rust - uses: dtolnay/rust-toolchain@master - with: - toolchain: 1.95.0 - components: rustfmt, clippy - - - name: Setup nightly Rust for rule-preprocessor clippy - uses: dtolnay/rust-toolchain@master - with: - toolchain: nightly - components: rustfmt, clippy, rustc-dev + - name: Setup Python + run: pip install ruff - - name: Check C++ formatting - run: find cpp2rust tests -name '*.cpp' -o -name '*.h' -o -name '*.c' | xargs clang-format --dry-run --Werror + - name: Configure + run: cmake -GNinja -B build -S . - - name: Check Rust formatting - run: | - cargo fmt --manifest-path rules/Cargo.toml -- --check - cargo fmt --manifest-path rule-preprocessor/Cargo.toml -- --check - cargo fmt --manifest-path libcc2rs/Cargo.toml -- --check - cargo fmt --manifest-path libcc2rs-macros/Cargo.toml -- --check - find tests -name '*.rs' -print0 | xargs -0 rustfmt --check + - name: Format files + run: ninja format + working-directory: build - - name: Check Rust lints - run: | - cargo clippy --manifest-path rules/Cargo.toml --all-targets --all-features -- -Dwarnings - cargo +nightly clippy --manifest-path rule-preprocessor/Cargo.toml --all-targets --all-features -- -Dwarnings - cargo clippy --manifest-path libcc2rs/Cargo.toml --all-targets --all-features -- -Dwarnings - cargo clippy --manifest-path libcc2rs-macros/Cargo.toml --all-targets --all-features -- -Dwarnings - - - name: Check Python (ruff) - uses: astral-sh/ruff-action@v3 - with: - args: 'check' - src: tests/lit/lit/formats/Cpp2RustTest.py - - name: Check Python formatting (ruff) - uses: astral-sh/ruff-action@v3 - with: - args: 'format --check' - src: tests/lit/lit/formats/Cpp2RustTest.py + - name: Check format + run: git diff --exit-code diff --git a/CMakeLists.txt b/CMakeLists.txt index e16dda8d..accae667 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,8 +68,8 @@ set(RUST_STAMP_FILE "${CMAKE_BINARY_DIR}/.rust-toolchain.stamp") add_custom_command( OUTPUT "${RUST_STAMP_FILE}" - COMMAND rustup toolchain install ${RUST_STABLE_VERSION} - COMMAND rustup toolchain install ${RUST_NIGHTLY_VERSION} --component rustc-dev --component llvm-tools + COMMAND rustup toolchain install ${RUST_STABLE_VERSION} --component clippy --component rustfmt + COMMAND rustup toolchain install ${RUST_NIGHTLY_VERSION} --component rustc-dev --component llvm-tools --component clippy --component rustfmt COMMAND ${CMAKE_COMMAND} -E touch "${RUST_STAMP_FILE}" DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/rust-toolchain.cmake" USES_TERMINAL @@ -91,16 +91,16 @@ set(PYTHON_SOURCES ${PROJECT_SOURCE_DIR}/tests/lit/lit/formats/Cpp2RustTest.py) add_custom_target("format" COMMAND ${CLANG_FORMAT} -i ${ALL_CXX_SOURCES} COMMAND cargo +${RUST_STABLE_VERSION} fmt --manifest-path ${PROJECT_SOURCE_DIR}/rules/Cargo.toml - COMMAND cargo +${RUST_STABLE_VERSION} --manifest-path ${PROJECT_SOURCE_DIR}/rule-preprocessor/Cargo.toml + COMMAND cargo +${RUST_NIGHTLY_VERSION} fmt --manifest-path ${PROJECT_SOURCE_DIR}/rule-preprocessor/Cargo.toml COMMAND cargo +${RUST_STABLE_VERSION} fmt --manifest-path ${PROJECT_SOURCE_DIR}/libcc2rs/Cargo.toml COMMAND cargo +${RUST_STABLE_VERSION} fmt --manifest-path ${PROJECT_SOURCE_DIR}/libcc2rs-macros/Cargo.toml - COMMAND cargo +${RUST_STABLE_VERSION} clippy --fix --allow-dirty --allow-staged --all-targets --all-features + COMMAND cargo +${RUST_STABLE_VERSION} clippy --fix --allow-dirty --allow-no-vcs --allow-staged --all-targets --all-features --manifest-path ${PROJECT_SOURCE_DIR}/rules/Cargo.toml -- -Dwarnings - COMMAND cargo +${RUST_STABLE_VERSION} clippy --fix --allow-dirty --allow-staged --all-targets --all-features - --manifest-path chdir ${PROJECT_SOURCE_DIR}/rule-preprocessor/Cargo.toml -- -Dwarnings - COMMAND cargo +${RUST_STABLE_VERSION} clippy --fix --allow-dirty --allow-staged --all-targets --all-features - --manifest-path $${PROJECT_SOURCE_DIR}/libcc2rs/Cargo.toml -- -Dwarnings - COMMAND cargo +${RUST_STABLE_VERSION} clippy --fix --allow-dirty --allow-staged --all-targets --all-features + COMMAND cargo +${RUST_NIGHTLY_VERSION} clippy --fix --allow-dirty --allow-no-vcs --allow-staged --all-targets --all-features + --manifest-path ${PROJECT_SOURCE_DIR}/rule-preprocessor/Cargo.toml -- -Dwarnings + COMMAND cargo +${RUST_STABLE_VERSION} clippy --fix --allow-dirty --allow-no-vcs --allow-staged --all-targets --all-features + --manifest-path ${PROJECT_SOURCE_DIR}/libcc2rs/Cargo.toml -- -Dwarnings + COMMAND cargo +${RUST_STABLE_VERSION} clippy --fix --allow-dirty --allow-no-vcs --allow-staged --all-targets --all-features --manifest-path ${PROJECT_SOURCE_DIR}/libcc2rs-macros/Cargo.toml -- -Dwarnings COMMAND ${RUFF} --silent check --fix ${PYTHON_SOURCES} COMMAND ${RUFF} --silent format ${PYTHON_SOURCES}