Skip to content

Commit

Permalink
Make clang-tidy its own job (#1527)
Browse files Browse the repository at this point in the history
  • Loading branch information
nsmithtt authored Dec 9, 2024
1 parent 231fa95 commit fecec9c
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 9 deletions.
58 changes: 50 additions & 8 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,56 @@ jobs:
echo "DOCKER_CI_IMAGE $DOCKER_CI_IMAGE"
echo "docker-image=$DOCKER_CI_IMAGE" >> "$GITHUB_OUTPUT"
lint:
needs: build-image
timeout-minutes: 120
strategy:
fail-fast: false
name: Lint (clang-tidy)
runs-on: ubuntu-latest
container:
image: ${{ needs.build-image.outputs.docker-image }}

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set reusable strings
id: strings
shell: bash
run: |
echo "work-dir=$(pwd)" >> "$GITHUB_OUTPUT"
echo "build-output-dir=$(pwd)/build" >> "$GITHUB_OUTPUT"
echo "install-output-dir=$(pwd)/install" >> "$GITHUB_OUTPUT"
- name: Git safe dir
run: git config --global --add safe.directory ${{ steps.strings.outputs.work-dir }}

- name: Configure CMake
shell: bash
run: |
source env/activate
cmake -G Ninja \
-B ${{ steps.strings.outputs.build-output-dir }} \
-DCMAKE_CXX_COMPILER=clang++-17 \
-DCMAKE_C_COMPILER=clang-17 \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${{ steps.strings.outputs.install-output-dir }} \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DTTMLIR_ENABLE_RUNTIME=ON \
-DTTMLIR_ENABLE_RUNTIME_TESTS=ON \
-DTTMLIR_ENABLE_STABLEHLO=ON \
-DTTMLIR_ENABLE_OP_MODEL=ON \
-S ${{ steps.strings.outputs.work-dir }}
- name: Lint
id: lint
shell: bash
run: |
source env/activate
cmake --build ${{ steps.strings.outputs.build-output-dir }} -- clang-tidy
build-ttmlir:
needs: build-image
timeout-minutes: 120
Expand Down Expand Up @@ -119,14 +169,6 @@ jobs:
cmake --build ${{ steps.strings.outputs.build-output-dir }}
cmake --install ${{ steps.strings.outputs.build-output-dir }} --component Test
- name: Lint
id: lint
shell: bash
if: matrix.build.enable_perf == 'OFF'
run: |
source env/activate
cmake --build ${{ steps.strings.outputs.build-output-dir }} -- clang-tidy
- name: Unique-ify clang-tidy fixes
shell: bash
if: failure() && steps.lint.outcome == 'failure'
Expand Down
10 changes: 9 additions & 1 deletion cmake/modules/LintTools.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# clang-tidy setup
add_custom_target(clang-tidy-filter-out-external-srcs COMMAND python3 ${TTMLIR_SOURCE_DIR}/tools/scripts/filter-compile-commands.py ${TTMLIR_BINARY_DIR}/compile_commands.json "${TTMLIR_SOURCE_DIR}")
add_custom_target(clang-tidy COMMAND run-clang-tidy.py -p ${PROJECT_BINARY_DIR} -export-fixes clang-tidy-fixes.yaml -warnings-as-errors '*' -extra-arg-before=-DDISABLE_STATIC_ASSERT_TESTS -extra-arg-before=-D__cpp_structured_bindings=202400 DEPENDS clang-tidy-filter-out-external-srcs)
add_custom_target(clang-tidy COMMAND run-clang-tidy.py -p ${PROJECT_BINARY_DIR} -export-fixes clang-tidy-fixes.yaml -warnings-as-errors '*' -extra-arg-before=-DDISABLE_STATIC_ASSERT_TESTS -extra-arg-before=-D__cpp_structured_bindings=202400
DEPENDS
clang-tidy-filter-out-external-srcs
mlir-headers
mlir-generic-headers
tt-metal-download
tt-metal-configure
FBS_GENERATION
)
add_custom_target(clang-format COMMAND git-clang-format)
2 changes: 2 additions & 0 deletions include/ttmlir/Conversion/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ include_directories(${TTMLIR_SOURCE_DIR}/include)
set(LLVM_TARGET_DEFINITIONS Passes.td)
if (TTMLIR_ENABLE_STABLEHLO)
mlir_tablegen(Passes.h.inc -gen-pass-decls -name TTMLIRConversion -DTTMLIR_ENABLE_STABLEHLO)
add_dependencies(mlir-headers PassesIncGen)
else()
mlir_tablegen(Passes.h.inc -gen-pass-decls -name TTMLIRConversion)
endif()
add_public_tablegen_target(TTMLIRConversionPassIncGen)
add_dependencies(mlir-headers TTMLIRConversionPassIncGen)
4 changes: 4 additions & 0 deletions third_party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ ExternalProject_Add(
BUILD_BYPRODUCTS ${TTNN_LIBRARY_PATH} ${TTMETAL_LIBRARY_PATH} ${TRACY_LIBRARY_PATH} ${DEVICE_LIBRARY_PATH}
)

ExternalProject_Add_StepTargets(tt-metal download configure)
set_target_properties(tt-metal-download PROPERTIES EXCLUDE_FROM_ALL TRUE)
set_target_properties(tt-metal-configure PROPERTIES EXCLUDE_FROM_ALL TRUE)

set_target_properties(tt-metal PROPERTIES EXCLUDE_FROM_ALL TRUE)

list(APPEND library_names TTNN_LIBRARY TTMETAL_LIBRARY DEVICE_LIBRARY)
Expand Down

0 comments on commit fecec9c

Please sign in to comment.