Skip to content

Commit

Permalink
some more testing after local experiments with cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
Taepper committed Jun 19, 2024
1 parent 2cc9358 commit c726b71
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 45 deletions.
44 changes: 14 additions & 30 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,6 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Get changed files
id: changed-files1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.number }}
run: |
echo "Github Event ${{ github.event }}"
echo "Github Event number ${{ github.event.number }}"
echo "github.repository_owner ${{ github.repository_owner }}"
echo "github.repository ${{ github.repository }}"
echo "Changed files in PR #${PR_NUMBER}:"
files=$(curl -s \
"https://api.github.com/repos/${{ github.repository }}/pulls/${PR_NUMBER}/files" \
| jq -r '.[].filename')
echo "$files"
echo "::set-output name=files::$files"
- name: Generate dependency files hash
id: files-hash
run: |
Expand Down Expand Up @@ -97,31 +80,32 @@ jobs:
- uses: actions/checkout@v4

- name: Get changed files
id: changed-files1
id: changed-files
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.number }}
run: |
echo "Github Event ${{ github.event }}"
echo "Github Event number ${{ github.event.number }}"
echo "github.repository_owner ${{ github.repository_owner }}"
echo "github.repository ${{ github.repository }}"
echo "Changed files in PR #${PR_NUMBER}:"
$files=$(curl -s \
"https://api.github.com/repos/${{ github.repository_owner }}/${{ github.repository }}/pulls/${PR_NUMBER}/files" \
files=$(curl -s \
"https://api.github.com/repos/${{ github.repository }}/pulls/${PR_NUMBER}/files" \
| jq -r '.[].filename')
echo "${$files}"
echo "::set-output name=files::$files"
- name: Get list of changed files
id: changed-files2
run: |
files=$(jq -r '.pull_request.files[] | select(.status == "added" or .status == "modified") | .filename' $GITHUB_EVENT_PATH)
echo "$files"
echo "::set-output name=files::$files"
- name: Configure and run clang-tidy on changed files
run: |
mkdir -p build
cd build
changed_files="${{ steps.changed-files1.outputs.files }}"
changed_files="${{ steps.changed-files.outputs.files }}"
IFS=$'\n' read -d '' -r -a file_array <<< "$changed_files"
for file in "${file_array[@]}"; do
cmake -DCMAKE_CXX_CLANG_TIDY="clang-tidy" ..
cmake --build . --target $(basename $file)
if [[ $file == *.cpp ]]; then
echo "Now linting the file: $file"
cmake -DCMAKE_CXX_CLANG_TIDY="clang-tidy" ..
cmake --build . --target $(basename $file)
fi
done
24 changes: 9 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,24 +60,18 @@ file(GLOB_RECURSE SRC_SILO "src/*.cpp")
list(REMOVE_ITEM SRC_SILO ${SRC_TEST})

# ---------------------------------------------------------------------------
# Linter
# Targets
# ---------------------------------------------------------------------------

option(BUILD_WITH_CLANG_TIDY "Build process clang-tidy")
if (NOT CMAKE_BUILD_TYPE STREQUAL Release AND BUILD_WITH_CLANG_TIDY)
find_program(CLANG_TIDY_EXE NAMES clang-tidy-19)
if (NOT CLANG_TIDY_EXE)
message(SEND_ERROR "clang-tidy not found, aborting. You can run the build with '-D BUILD_WITH_CLANG_TIDY=OFF' to disable clang-tidy.")
else ()
message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}")
message(STATUS "run clang tidy with: ${CLANG_TIDY_EXE}")
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE}")
endif ()
endif ()
foreach(source_file IN LISTS SRC_SILO)
get_filename_component(target_name ${source_file} NAME)

# ---------------------------------------------------------------------------
# Targets
# ---------------------------------------------------------------------------
# Create a custom target for this source file
add_custom_target(${target_name}
COMMAND ${CMAKE_COMMAND} -E echo "Building ${target_name}"
DEPENDS ${source_file}
)
endforeach()

add_executable(siloApi src/silo_api/api.cpp ${SRC_SILO})
target_link_libraries(
Expand Down

0 comments on commit c726b71

Please sign in to comment.