Skip to content

Commit

Permalink
Update github ci
Browse files Browse the repository at this point in the history
  • Loading branch information
btrkeks committed Aug 25, 2024
1 parent 8a0532a commit ae5f6d1
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 74 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ jobs:
- run: gcc --version
- run: clang-format --version

- run: make analyse
- run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug
- run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON
- run: cmake --build build
- run: ctest --test-dir build
- run: cmake --build build --target check-all

on:
push:
Expand Down
138 changes: 71 additions & 67 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,26 @@ set(DICTPOPUP_CREATE_SRCS
src/dictpopup_create/yomichan_parser.c
)

# ##############################################################################
# Auxiliary files
# ##############################################################################
set(GENERATED_DIR ${CMAKE_CURRENT_BINARY_DIR}/generated)
file(MAKE_DIRECTORY ${GENERATED_DIR})

############# DEINFLECTION RULES #################
set(DEINFLECTION_RULES_GPERF ${CMAKE_CURRENT_SOURCE_DIR}/src/deinflector/deinflection_rules.gperf)
set(DEINFLECTION_RULES_C ${GENERATED_DIR}/deinflection_rules.c)
add_custom_command(
OUTPUT ${DEINFLECTION_RULES_C}
COMMAND ${GPERF}
ARGS
-t
--output-file=${DEINFLECTION_RULES_C}
${DEINFLECTION_RULES_GPERF}
MAIN_DEPENDENCY ${DEINFLECTION_RULES_GPERF}
VERBATIM
)

# ##############################################################################
# Cppcheck
# ##############################################################################
Expand Down Expand Up @@ -176,23 +196,69 @@ endif ()
# set_source_files_properties(lib/yyjson.c lib/yyjson.h PROPERTIES SKIP_LINTING ON)
#endif ()

# ##############################################################################
# Tests
# ##############################################################################
option(BUILD_TESTS "Build the testing tree." OFF)
if (BUILD_TESTS)
include(CTest)
enable_testing()
find_package(cgreen REQUIRED)
add_executable(c_tests
src/jppron/jppron_objects.c
src/utils/util.c
src/utils/utf8.c
src/utils/str.c
src/deinflector/kata2hira.c
lib/yyjson.c
src/objects/dict.c
tests/main.c
tests/deinflector_tests.c
${DEINFLECTION_RULES_C}
tests/ankiconnect_tests.c
tests/yomichan_parser_tests.c
tests/jppron_tests/ajt_audio_index_parser_tests.c
tests/utils_tests/enclose_word_in_string_tests.c
tests/dictpopup_tests.c
tests/jppron_tests/jppron_tests.c
src/deinflector/deinflector.c
tests/anki_card_preparation_tests.c
)
target_compile_definitions(c_tests PRIVATE UNIT_TEST CLIPBOARD)
target_include_directories(c_tests PRIVATE
${GTK3_INCLUDE_DIRS}
${CGREEN_INCLUDE_DIRS}
lib/
include/
src/
src/jppron
)
target_link_libraries(c_tests PRIVATE
${CGREEN_LIBRARIES}
MECAB::MECAB
PkgConfig::GTK3
libzip::zip
)
add_test(NAME run_c_tests COMMAND $<TARGET_FILE:c_tests>)
endif ()

# add_test(NAME run_shell_test COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tests/full_cycle_test.sh)

# ##############################################################################
# check-all
# ##############################################################################
add_custom_target(
check-all
COMMAND ${CMAKE_COMMAND} --build . --target format-check
COMMAND ${CMAKE_COMMAND} --build . --target cppcheck
COMMAND ${CMAKE_COMMAND} --build . --target clang-tidy
DEPENDS format-check cppcheck clang-tidy
# COMMAND ${CMAKE_COMMAND} --build . --target cppcheck
# COMMAND ${CMAKE_COMMAND} --build . --target clang-tidy
COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
COMMENT "Running format check, static analysis, and tests"
)

# ##############################################################################
# dictpopup
# ##############################################################################
set(GENERATED_DIR ${CMAKE_CURRENT_BINARY_DIR}/generated)
file(MAKE_DIRECTORY ${GENERATED_DIR})

############# UI #################
set(GRESOURCE_XML ${CMAKE_CURRENT_SOURCE_DIR}/src/frontends/gtk3popup/dictpopup.gresource.xml)
Expand Down Expand Up @@ -231,20 +297,6 @@ add_custom_target(gsettings-schemas ALL DEPENDS ${COMPILED_SETTINGS_SCHEMA})
install(FILES ${GSETTINGS_SCHEMA} DESTINATION ${GSETTINGS_DIR})
install(CODE "execute_process(COMMAND ${GLIB_COMPILE_SCHEMAS} ${CMAKE_INSTALL_PREFIX}/${GSETTINGS_DIR})")

############# DEINFLECTION RULES #################
set(DEINFLECTION_RULES_GPERF ${CMAKE_CURRENT_SOURCE_DIR}/src/deinflector/deinflection_rules.gperf)
set(DEINFLECTION_RULES_C ${GENERATED_DIR}/deinflection_rules.c)
add_custom_command(
OUTPUT ${DEINFLECTION_RULES_C}
COMMAND ${GPERF}
ARGS
-t
--output-file=${DEINFLECTION_RULES_C}
${DEINFLECTION_RULES_GPERF}
MAIN_DEPENDENCY ${DEINFLECTION_RULES_GPERF}
VERBATIM
)

############# MAIN #################
add_executable(dictpopup
src/frontends/gtk3popup/dictpopup-application.c
Expand Down Expand Up @@ -334,54 +386,6 @@ target_include_directories(
target_link_directories(dictpopup-cli PRIVATE ${GTK3_LIBRARY_DIRS})
target_link_libraries(dictpopup-cli PRIVATE ${GTK3_LIBRARIES} ${NOTIFY_LIBRARIES})

# ##############################################################################
# Tests
# ##############################################################################
option(BUILD_TESTS "Build the testing tree." OFF)
if (BUILD_TESTS)
include(CTest)
enable_testing()
find_package(cgreen REQUIRED)
add_executable(c_tests
src/jppron/jppron_objects.c
src/utils/util.c
src/utils/utf8.c
src/utils/str.c
src/deinflector/kata2hira.c
lib/yyjson.c
src/objects/dict.c
tests/main.c
tests/deinflector_tests.c
tests/ankiconnect_tests.c
tests/yomichan_parser_tests.c
tests/jppron_tests/ajt_audio_index_parser_tests.c
tests/utils_tests/enclose_word_in_string_tests.c
tests/dictpopup_tests.c
tests/jppron_tests/jppron_tests.c
${DEINFLECTION_RULES_C}
src/deinflector/deinflector.c
tests/anki_card_preparation_tests.c
)
target_compile_definitions(c_tests PRIVATE UNIT_TEST CLIPBOARD)
target_include_directories(c_tests PRIVATE
${GTK3_INCLUDE_DIRS}
${CGREEN_INCLUDE_DIRS}
lib/
include/
src/
src/jppron
)
target_link_libraries(c_tests PRIVATE
${CGREEN_LIBRARIES}
MECAB::MECAB
PkgConfig::GTK3
libzip::zip
)
add_test(NAME run_c_tests COMMAND $<TARGET_FILE:c_tests>)
endif ()

# add_test(NAME run_shell_test COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tests/full_cycle_test.sh)

# ##############################################################################
# Install
# ##############################################################################
Expand Down
4 changes: 0 additions & 4 deletions tests/jppron_tests/jppron_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ void jdb_remove(s8 dbpath) {
mock(dbpath.s);
}

void play_audio_sync(s8 filepath) {
mock(filepath.s);
}

TestSuite *jppron_tests(void) {
TestSuite *suite = create_test_suite();
return suite;
Expand Down

0 comments on commit ae5f6d1

Please sign in to comment.