Skip to content

Commit c2b8b59

Browse files
committed
build: modernize GitHub Actions CI
The previous workflow pinned `ubuntu-18.04`, which GitHub retired in April 2023, so the job had been failing to start since. It also never installed protobuf on any runner, meaning the silent `JPP_USE_PROTOBUF` fallback kicked in and the protobuf codepath was never actually exercised in CI. This rewrite: * Targets `ubuntu-22.04`, `macos-latest`, and `windows-latest`, and upgrades `actions/checkout` to v4. * Installs protobuf via apt on Ubuntu and brew on macOS so the protobuf-based components build in CI for real. Windows keeps `-DJPP_USE_PROTOBUF=OFF` — no Windows consumer uses those components, and avoiding vcpkg keeps the job fast. * Adds a Linux matrix entry that builds with `RelWithDebInfo` plus AddressSanitizer, so memory-safety bugs on the hot analyzer path (e.g. #157) get caught in CI instead of only on end users. * Moves `travis/cmake.conf` to `.github/cmake.conf`; the `travis/` directory is now gone. `fail-fast: false` so one runner's failure doesn't mask the others.
1 parent 117f0df commit c2b8b59

File tree

2 files changed

+72
-30
lines changed

2 files changed

+72
-30
lines changed
File renamed without changes.

.github/workflows/cmake.yml

Lines changed: 72 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,81 @@ on:
66
pull_request:
77
branches: [ master ]
88

9-
env:
10-
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
11-
BUILD_TYPE: Release
12-
139
jobs:
1410
build:
11+
name: ${{ matrix.name }}
12+
runs-on: ${{ matrix.os }}
13+
1514
strategy:
15+
fail-fast: false
1616
matrix:
17-
os:
18-
- ubuntu-18.04
19-
- windows-latest
20-
- macos-latest
21-
# The CMake configure and build commands are platform agnostic and should work equally
22-
# well on Windows or Mac. You can convert this to a matrix build if you need
23-
# cross-platform coverage.
24-
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
25-
runs-on: ${{matrix.os}}
17+
include:
18+
- name: linux-release
19+
os: ubuntu-22.04
20+
build_type: Release
21+
extra_cxxflags: ""
22+
extra_ldflags: ""
23+
extra_cmake_args: ""
24+
25+
# Optimized + ASan so memory-safety bugs on the hot path are caught
26+
# in CI (see ku-nlp/jumanpp#157).
27+
- name: linux-release-asan
28+
os: ubuntu-22.04
29+
build_type: RelWithDebInfo
30+
extra_cxxflags: "-fsanitize=address -fno-omit-frame-pointer"
31+
extra_ldflags: "-fsanitize=address"
32+
extra_cmake_args: ""
33+
34+
- name: macos-release
35+
os: macos-latest
36+
build_type: Release
37+
extra_cxxflags: ""
38+
extra_ldflags: ""
39+
extra_cmake_args: ""
40+
41+
# No Windows consumer uses the Protobuf-based components, so skip
42+
# the vcpkg dance and disable them.
43+
- name: windows-release
44+
os: windows-latest
45+
build_type: Release
46+
extra_cxxflags: ""
47+
extra_ldflags: ""
48+
extra_cmake_args: "-DJPP_USE_PROTOBUF=OFF"
49+
50+
defaults:
51+
run:
52+
shell: bash
2653

2754
steps:
28-
- uses: actions/checkout@v2
29-
30-
- name: Configure CMake
31-
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
32-
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
33-
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -C ${{github.workspace}}/travis/cmake.conf --warn-uninitialized
34-
35-
- name: Build
36-
# Build your program with the given configuration
37-
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j
38-
39-
- name: Test
40-
working-directory: ${{github.workspace}}/build
41-
# Execute tests defined by the CMake configuration.
42-
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
43-
run: ctest -C ${{env.BUILD_TYPE}} --extra-verbose --output-on-failure
44-
55+
- uses: actions/checkout@v4
56+
57+
- name: Install dependencies (Ubuntu)
58+
if: startsWith(matrix.os, 'ubuntu-')
59+
run: |
60+
sudo apt-get update
61+
sudo apt-get install -y libprotobuf-dev protobuf-compiler
62+
63+
- name: Install dependencies (macOS)
64+
if: startsWith(matrix.os, 'macos-')
65+
run: brew install protobuf
66+
67+
- name: Configure CMake
68+
env:
69+
EXTRA_CXXFLAGS: ${{ matrix.extra_cxxflags }}
70+
EXTRA_LDFLAGS: ${{ matrix.extra_ldflags }}
71+
EXTRA_CMAKE_ARGS: ${{ matrix.extra_cmake_args }}
72+
run: |
73+
cmake -B "${{ github.workspace }}/build" \
74+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
75+
-DCMAKE_CXX_FLAGS="$EXTRA_CXXFLAGS" \
76+
-DCMAKE_EXE_LINKER_FLAGS="$EXTRA_LDFLAGS" \
77+
-C "${{ github.workspace }}/.github/cmake.conf" \
78+
--warn-uninitialized \
79+
$EXTRA_CMAKE_ARGS
80+
81+
- name: Build
82+
run: cmake --build "${{ github.workspace }}/build" --config ${{ matrix.build_type }} -j
83+
84+
- name: Test
85+
working-directory: ${{ github.workspace }}/build
86+
run: ctest -C ${{ matrix.build_type }} --output-on-failure

0 commit comments

Comments
 (0)