Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
wangfenjin committed Mar 25, 2022
1 parent 62a07a2 commit 6b21748
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
22 changes: 16 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,22 @@ jobs:
buildDirectory: "${{ github.workspace }}/build"
buildWithCMake: true
buildWithCMakeArgs: --config Release
cmakeAppendedArgs: " -DCODE_COVERAGE=OFF -DBUILD_SHELL=OFF"
# cmakeAppendedArgs: " -DCODE_COVERAGE=OFF -DBUILD_SHELL=OFF -DBUILD_TEST_EXAMPLE=OFF -DBUILD_STATIC"
cmakeAppendedArgs: " -DCODE_COVERAGE=OFF -DBUILD_SHELL=OFF -DBUILD_TEST_EXAMPLE=OFF"
- name: "Check file existence"
uses: andstor/file-existence-action@v1
with:
allow_failure: true
# files: "${{ github.workspace }}/build/src/libsimple.a, ${{ github.workspace }}/build/src/libPINYIN_TEXT.a, ${{ github.workspace }}/build/test/dict/jieba.dict.utf8"
files: "${{ github.workspace }}/build/src/libsimple.so, ${{ github.workspace }}/build/test/dict/jieba.dict.utf8"
- name: Package
if: startsWith(github.ref, 'refs/tags/')
run: |
mkdir libsimple-linux-${{ matrix.xcc }}
# cp -r src/libsimple.a src/libPINYIN_TEXT.a test/dict/ libsimple-linux-${{ matrix.xcc }}/
cp -r src/libsimple.so test/dict/ libsimple-linux-${{ matrix.xcc }}/
zip -r libsimple-linux-${{ matrix.xcc }}.zip libsimple-linux-${{ matrix.xcc }}
working-directory: "${{ github.workspace }}/build"
- name: Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
Expand Down Expand Up @@ -242,22 +252,22 @@ jobs:
cmakeAppendedArgs: " -DCODE_COVERAGE=OFF "

- name: 'Run CTest'
if: startsWith(github.ref, 'refs/tags/') != true && ${{ matrix.os }} == 'ubuntu-latest'
if: ${{ startsWith(github.ref, 'refs/tags/') != true && matrix.os == 'ubuntu-latest' }}
run: ctest -V -C ${{ env.BUILD_TYPE }}
working-directory: "${{ github.workspace }}/build"

# CODE COVERAGE
- name: Code coverage - Capture coverage info
if: startsWith(github.ref, 'refs/tags/') != true && ${{ matrix.os }} == 'ubuntu-latest'
if: ${{ startsWith(github.ref, 'refs/tags/') != true && matrix.os == 'ubuntu-latest' }}
run: lcov --directory . --capture --output-file coverage.info
- name: Code coverage - Filter out system, external, and unit test source files
if: startsWith(github.ref, 'refs/tags/') != true && ${{ matrix.os }} == 'ubuntu-latest'
if: ${{ startsWith(github.ref, 'refs/tags/') != true && matrix.os == 'ubuntu-latest' }}
run: lcov --remove coverage.info --output-file coverage_filter.info '/Library/*' '/usr/*' '*/test/*' '*/cmrc/*' '*/entry.cc' '*/simple_highlight.*'
- name: Code coverage - Output coverage data for debugging
if: startsWith(github.ref, 'refs/tags/') != true && ${{ matrix.os }} == 'ubuntu-latest'
if: ${{ startsWith(github.ref, 'refs/tags/') != true && matrix.os == 'ubuntu-latest' }}
run: lcov --list coverage_filter.info
- name: Code coverage - Upload to CodeCov
if: startsWith(github.ref, 'refs/tags/') != true && ${{ matrix.os }} == 'ubuntu-latest'
if: ${{ startsWith(github.ref, 'refs/tags/') != true && matrix.os == 'ubuntu-latest' }}
run: bash <(curl -s https://codecov.io/bash) -f coverage_filter.info || echo "Codecov did not collect coverage reports"

- name: "Check file existence"
Expand Down
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ endif()

add_subdirectory(src)

if (NOT IOS)
OPTION(BUILD_TEST_EXAMPLE "Option to build tests and examples" ON)
if (NOT IOS AND BUILD_TEST_EXAMPLE)
add_subdirectory(examples/cpp)
enable_testing()
add_subdirectory(test)
Expand Down
5 changes: 3 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ set(SOURCE_FILES
entry.cc
)

if (IOS)
OPTION(BUILD_STATIC "Option to build static lib" OFF)
if (IOS OR BUILD_STATIC)
# iOS only support static library.
add_library(simple STATIC ${SOURCE_FILES})
else()
Expand All @@ -50,7 +51,7 @@ target_link_libraries(simple PUBLIC coverage_config PRIVATE PINYIN_TEXT SQLite3)

install(TARGETS simple DESTINATION bin)

if (IOS)
if (IOS OR BUILD_STATIC)
# iOS build as static library. so we need install PINYIN_TEXT too.
install(TARGETS PINYIN_TEXT DESTINATION bin)
endif()
Expand Down

0 comments on commit 6b21748

Please sign in to comment.