-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add cmake target for ruff and ruff-format
- Loading branch information
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Additional target to run python linters and formatters on python files | ||
# | ||
# Requires ruff to be available in the environment | ||
|
||
# Get all our Python files | ||
file(GLOB_RECURSE ALL_PYTHON_FILES ${PROJECT_SOURCE_DIR}/python/*.py | ||
${PROJECT_SOURCE_DIR}/scripts/*.py ${PROJECT_SOURCE_DIR}/test/*.py) | ||
|
||
find_program(RUFF_EXECUTABLE ruff) | ||
if(RUFF_EXECUTABLE) | ||
add_custom_target( | ||
ruff | ||
COMMAND ${RUFF_EXECUTABLE} | ||
check --force-exclude ${ALL_PYTHON_FILES} | ||
) | ||
set_target_properties(ruff PROPERTIES EXCLUDE_FROM_ALL TRUE) | ||
add_custom_target( | ||
ruff-format | ||
COMMAND ${RUFF_EXECUTABLE} | ||
format --force-exclude ${ALL_PYTHON_FILES} | ||
) | ||
set_target_properties(ruff-format PROPERTIES EXCLUDE_FROM_ALL TRUE) | ||
else() | ||
message(STATUS "Failed to find ruff executable - no target to run ruff can be set") | ||
endif() |