Skip to content

Commit

Permalink
Merge pull request #239 from yan12125/github-actions
Browse files Browse the repository at this point in the history
Enable GitHub Actions
  • Loading branch information
jserv authored Feb 5, 2023
2 parents 738c10f + d07f02b commit c6b7e9b
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 2 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Continuous Integration

on:
push:
branches: [ "master" ]
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 lcov
gcc --version
g++ --version
gcov --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}} -DENABLE_GCOV=yes

- 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

- name: Collect coverage stats
run: scripts/lcov.sh
if: ${{ matrix.os == 'ubuntu-latest' }}

- name: Coveralls
uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: coverage.info
if: ${{ matrix.os == 'ubuntu-latest' }}
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -110,6 +112,8 @@ include_directories(
${Qt5Widgets_INCLUDES}
)

link_directories(${CHEWING_LIBRARY_DIRS})

include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/platform_apple.cmake)

# resources
Expand Down
2 changes: 1 addition & 1 deletion scripts/lcov.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit c6b7e9b

Please sign in to comment.