From 4f7a069f3f5a1b29b53009777f32ae8df68baaa6 Mon Sep 17 00:00:00 2001 From: Chih-Hsuan Yen <645432-yan12125@users.noreply.gitlab.com> Date: Sun, 5 Feb 2023 14:36:12 +0800 Subject: [PATCH 1/3] Add GitHub Actions Based on the workflow of libchewing [1]. Compared to .travis.yml, some stuffs are not included: * ppc64le builds: not possible on GitHub Actions yet [2] * ccache: I assume it's not needed for such a small project [1] https://github.com/chewing/libchewing/pull/349 [2] https://github.com/actions/runner/issues/243 --- .github/workflows/ci.yml | 60 ++++++++++++++++++++++++++++++++++++++++ CMakeLists.txt | 6 +++- 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..445cf68 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,60 @@ +name: Continuous Integration + +on: + push: + branches: [ "master", "staging", "trying" ] + pull_request: + branches: [ "master" ] + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Release + CFLAGS: -fsanitize=address + CXXFLAGS: -fsanitize=address + +jobs: + build: + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v3 + with: + submodules: 'true' + + - name: Install dependencies for Ubuntu + run: | + sudo apt-get update + sudo apt-get install --yes help2man qtbase5-dev qttools5-dev qttools5-dev-tools libchewing3-dev + gcc --version + g++ --version + if: ${{ matrix.os == 'ubuntu-latest' }} + + - name: Install dependencies for macOS + run: | + # dependencies + brew update + brew install libchewing qt@5 + + # Qt + brew link --force qt@5 + # Homebrew does not link mkspecs and plugins https://github.com/Homebrew/homebrew-core/issues/93056 + export HOMEBREW_QT5_VERSION=$(brew list --versions qt@5 | rev | cut -d' ' -f1 | rev) + sudo ln -s /usr/local/Cellar/qt@5/$HOMEBREW_QT5_VERSION/mkspecs /usr/local/mkspecs + sudo ln -s /usr/local/Cellar/qt@5/$HOMEBREW_QT5_VERSION/plugins /usr/local/plugins + if: ${{ matrix.os == 'macos-latest' }} + + - name: Configure CMake + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + + - name: Show config + run: cmake -B ${{github.workspace}}/build -LA + + - name: Build + run: cmake --build ${{github.workspace}}/build -v --config ${{env.BUILD_TYPE}} + + - name: Test + working-directory: ${{github.workspace}}/build + run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure diff --git a/CMakeLists.txt b/CMakeLists.txt index 7dbb2f9..1a42b12 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,12 +50,14 @@ find_package(Qt5Widgets REQUIRED) find_package(Qt5LinguistTools) # libchewing +# MODIFY IF NEEDED, e.g. ${CMAKE_CURRENT_SOURCE_DIR}/libchewing/lib/ +set(CHEWING_LIBRARY_DIRS ) # MODIFY IF NEEDED, e.g. ${CMAKE_CURRENT_SOURCE_DIR}/libchewing/lib/*.lib set(CHEWING_LIBRARIES ) # MODIFY IF NEEDED, e.g. ${CMAKE_CURRENT_SOURCE_DIR}/libchewing/include/chewing set(CHEWING_INCLUDE_DIRS ) -if (CHEWING_INCLUDE_DIRS AND CHEWING_LIBRARIES) +if (CHEWING_INCLUDE_DIRS AND CHEWING_LIBRARIES AND CHEWING_LIBRARY_DIRS) # if all listed variables are TRUE find_package_handle_standard_args(chewing DEFAULT_MSG CHEWING_LIBRARIES CHEWING_INCLUDE_DIRS) mark_as_advanced(CHEWING_LIBRARIES CHEWING_INCLUDE_DIRS) @@ -110,6 +112,8 @@ include_directories( ${Qt5Widgets_INCLUDES} ) +link_directories(${CHEWING_LIBRARY_DIRS}) + include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/platform_apple.cmake) # resources From 967f7771dea6919df37869e388097859ef249171 Mon Sep 17 00:00:00 2001 From: Chih-Hsuan Yen <645432-yan12125@users.noreply.gitlab.com> Date: Sun, 5 Feb 2023 17:07:31 +0800 Subject: [PATCH 2/3] Enable Coveralls * I don't use `-O0` like what [1] did. I'm not sure why it's needed. [1] https://github.com/chewing/chewing-editor/commit/1499cf206a4f37d036e25bfb1d95dc25c9ef1572 --- .github/workflows/ci.yml | 16 ++++++++++++++-- scripts/lcov.sh | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 445cf68..f93aa28 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,9 +27,10 @@ jobs: - name: Install dependencies for Ubuntu run: | sudo apt-get update - sudo apt-get install --yes help2man qtbase5-dev qttools5-dev qttools5-dev-tools libchewing3-dev + sudo apt-get install --yes help2man qtbase5-dev qttools5-dev qttools5-dev-tools libchewing3-dev lcov gcc --version g++ --version + gcov --version if: ${{ matrix.os == 'ubuntu-latest' }} - name: Install dependencies for macOS @@ -47,7 +48,7 @@ jobs: if: ${{ matrix.os == 'macos-latest' }} - name: Configure CMake - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DENABLE_GCOV=yes - name: Show config run: cmake -B ${{github.workspace}}/build -LA @@ -58,3 +59,14 @@ jobs: - name: Test working-directory: ${{github.workspace}}/build run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure + + - name: Collect coverage stats + run: scripts/lcov.sh + if: ${{ matrix.os == 'ubuntu-latest' }} + + - name: Coveralls + uses: coverallsapp/github-action@1.1.3 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + path-to-lcov: coverage.info + if: ${{ matrix.os == 'ubuntu-latest' }} diff --git a/scripts/lcov.sh b/scripts/lcov.sh index ffa55bc..a5aa117 100755 --- a/scripts/lcov.sh +++ b/scripts/lcov.sh @@ -39,6 +39,6 @@ done ABSPATH=$(cd "$(dirname "$0")/.."; pwd) lcov --directory $PWD --capture --output-file coverage.info --no-checksum --compat-libtool -lcov --remove coverage.info "/usr/include/*" "$ABSPATH/gmock/*" --output-file coverage.info +lcov --remove coverage.info "/usr/include/*" "$ABSPATH/gmock/*" "$ABSPATH/test/*" --output-file coverage.info LANG=C genhtml --prefix $ABSPATH --output-directory coveragereport \ --title "Code Coverage" --legend --show-details coverage.info From d07f02bfac1ccc36c297d0c2ff292084f855fc8a Mon Sep 17 00:00:00 2001 From: Chih-Hsuan Yen <645432-yan12125@users.noreply.gitlab.com> Date: Sun, 5 Feb 2023 17:42:24 +0800 Subject: [PATCH 3/3] fixup! Add GitHub Actions --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f93aa28..ebf7aa0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,7 @@ name: Continuous Integration on: push: - branches: [ "master", "staging", "trying" ] + branches: [ "master" ] pull_request: branches: [ "master" ]