build: modernize GitHub Actions CI #36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CMake | |
| on: | |
| push: | |
| branches: [ master ] | |
| pull_request: | |
| branches: [ master ] | |
| jobs: | |
| build: | |
| name: ${{ matrix.name }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - name: linux-release | |
| os: ubuntu-22.04 | |
| build_type: Release | |
| extra_cxxflags: "" | |
| extra_ldflags: "" | |
| extra_cmake_args: "" | |
| # Optimized + ASan so memory-safety bugs on the hot path are caught | |
| # in CI (see ku-nlp/jumanpp#157). | |
| - name: linux-release-asan | |
| os: ubuntu-22.04 | |
| build_type: RelWithDebInfo | |
| extra_cxxflags: "-fsanitize=address -fno-omit-frame-pointer" | |
| extra_ldflags: "-fsanitize=address" | |
| extra_cmake_args: "" | |
| - name: macos-release | |
| os: macos-latest | |
| build_type: Release | |
| extra_cxxflags: "" | |
| extra_ldflags: "" | |
| extra_cmake_args: "" | |
| # No Windows consumer uses the Protobuf-based components, so skip | |
| # the vcpkg dance and disable them. | |
| - name: windows-release | |
| os: windows-latest | |
| build_type: Release | |
| extra_cxxflags: "" | |
| extra_ldflags: "" | |
| extra_cmake_args: "-DJPP_USE_PROTOBUF=OFF" | |
| defaults: | |
| run: | |
| shell: bash | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install dependencies (Ubuntu) | |
| if: startsWith(matrix.os, 'ubuntu-') | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libprotobuf-dev protobuf-compiler | |
| - name: Install dependencies (macOS) | |
| if: startsWith(matrix.os, 'macos-') | |
| run: brew install protobuf | |
| - name: Configure CMake | |
| env: | |
| EXTRA_CXXFLAGS: ${{ matrix.extra_cxxflags }} | |
| EXTRA_LDFLAGS: ${{ matrix.extra_ldflags }} | |
| EXTRA_CMAKE_ARGS: ${{ matrix.extra_cmake_args }} | |
| run: | | |
| cmake -B "${{ github.workspace }}/build" \ | |
| -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ | |
| -DCMAKE_CXX_FLAGS="$EXTRA_CXXFLAGS" \ | |
| -DCMAKE_EXE_LINKER_FLAGS="$EXTRA_LDFLAGS" \ | |
| -C "${{ github.workspace }}/.github/cmake.conf" \ | |
| --warn-uninitialized \ | |
| $EXTRA_CMAKE_ARGS | |
| - name: Build | |
| run: cmake --build "${{ github.workspace }}/build" --config ${{ matrix.build_type }} -j | |
| - name: Test | |
| working-directory: ${{ github.workspace }}/build | |
| run: ctest -C ${{ matrix.build_type }} --output-on-failure |