Skip to content

Commit 12f2b10

Browse files
authored
Rework CI (#674)
- Split ubuntu and macos CI actions, even though they use very similar steps - Remove macos-11, keep -12, and add -14 - Have all macos platforms build with and without C++17 - Remove duplicated dependency lines in ubuntu matrix entries; push this down to the steps - Ensure that all added ubuntu matrix tuples have non-empty build-type - Add all jobs to all-checks' "needs:" to ensure we wait for everything
1 parent 7fbca11 commit 12f2b10

File tree

1 file changed

+57
-29
lines changed

1 file changed

+57
-29
lines changed

.github/workflows/main.yml

Lines changed: 57 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,79 +12,64 @@ on:
1212
workflow_dispatch:
1313

1414
jobs:
15-
linux:
15+
ubuntu:
1616
strategy:
1717
matrix:
1818
# Build each combination of OS and release/debug variants
19-
os: [ "ubuntu-latest", "ubuntu-20.04", "macos-11", "macos-12" ]
20-
build-type: [ Release, Debug ]
19+
os: [ "ubuntu-latest", "ubuntu-20.04" ]
20+
build-type: [ "Release", "Debug" ]
2121
# Extra cmake flags. GitHub Actions matrix overloads `include` to mean
2222
# 'add extra things to a job' and 'add jobs'. You can add extra things
2323
# to a job by specifying things that exist in a job created from the
2424
# matrix definition and adding things. You can specify extra jobs by
2525
# specifying properties that don't match existing jobs. We use
2626
# `cmake-flags` to add cmake flags to all jobs matching a pattern and
2727
# `extra-cmake-flags` to specify a new job with custom CMake flags.
28+
#
29+
# Note that adding new jobs does not *refine* existing matrix entries,
30+
# but rather adds new tuples wholesale. That is, specifying "os" alone
31+
# will result in a tuple without set "build-type" rather than one for
32+
# each existing "build-type" value!
2833
extra-cmake-flags: [ "" ]
2934
# Modify the complete matrix
3035
include:
31-
# Provide the dependency installation for each platform
32-
- os: "ubuntu-20.04"
33-
dependencies: "sudo apt install ninja-build"
34-
cmake-flags: "-DSNMALLOC_USE_CXX17=ON"
3536
- os: "ubuntu-20.04"
36-
dependencies: "sudo apt install ninja-build"
37-
- os: "ubuntu-latest" # 22.04 at time of writing
38-
dependencies: "sudo apt install ninja-build"
39-
- os: "macos-11"
40-
# The homebrew packages are broken at the moment and error out
41-
# after trying to install Python as a dependency of ninja because
42-
# 2to3 exists. As a quick hack, delete it first. This should be
43-
# removed once the homebrew install is fixed.
44-
dependencies: "rm -f /usr/local/bin/2to3 ; brew update && brew install ninja"
45-
- os: "macos-12"
46-
dependencies: "rm -f /usr/local/bin/2to3 ; brew update && brew install ninja"
47-
- os: "macos-12"
4837
variant: "C++17"
49-
dependencies: "rm -f /usr/local/bin/2to3 ; brew update && brew install ninja"
50-
cmake-flags: "-DSNMALLOC_USE_CXX17=ON"
38+
build-type: "Debug"
39+
extra-cmake-flags: "-DSNMALLOC_USE_CXX17=ON"
5140
# Add the self-host build, using the bounds-checked memcpy in
5241
# maximally paranoid mode (checking loads and stores)
5342
- os: "ubuntu-latest"
5443
build-type: Debug
5544
self-host: true
5645
extra-cmake-flags: "-DSNMALLOC_MEMCPY_BOUNDS=ON -DSNMALLOC_CHECK_LOADS=ON"
57-
dependencies: "sudo apt install ninja-build"
5846
# Extra build to check using pthread library for destructing local state.
5947
- os: "ubuntu-latest"
6048
variant: "with pthread destructors"
61-
dependencies: "sudo apt install ninja-build"
6249
build-type: Debug
6350
self-host: true
6451
extra-cmake-flags: "-DSNMALLOC_USE_PTHREAD_DESTRUCTORS=On"
6552
# Extra build to check using individual mitigations works.
6653
- os: "ubuntu-latest"
6754
variant: "individual mitigations"
68-
dependencies: "sudo apt install ninja-build"
6955
build-type: Release
7056
self-host: true
7157
extra-cmake-flags: "-DSNMALLOC_BENCHMARK_INDIVIDUAL_MITIGATIONS=On -DSNMALLOC_BUILD_TESTING=Off"
7258
# Check that we can build specifically with libstdc++
7359
- os: "ubuntu-latest"
7460
variant: "libstdc++ (Build only)"
75-
dependencies: "sudo apt install ninja-build"
61+
build-type: Release
7662
extra-cmake-flags: "-DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS=-stdlib=libstdc++"
7763
build-only: yes
7864
# Replay some of the above tests with clang-10 specifically
7965
- os: "ubuntu-20.04"
8066
variant: "clang-10 (with pthread destructors)."
81-
dependencies: "sudo apt install ninja-build"
8267
build-type: Debug
8368
self-host: true
8469
extra-cmake-flags: "-DSNMALLOC_USE_PTHREAD_DESTRUCTORS=On -DCMAKE_CXX_COMPILER=clang++-10 -DCMAKE_C_COMPILER=clang-10"
8570
- os: "ubuntu-20.04"
8671
variant: "clang-10 libstdc++ (Build only)"
87-
dependencies: "sudo apt install ninja-build"
72+
build-type: Release
8873
extra-cmake-flags: "-DCMAKE_CXX_COMPILER=clang++-10 -DCMAKE_C_COMPILER=clang-10 -DCMAKE_CXX_FLAGS=-stdlib=libstdc++"
8974
build-only: yes
9075
# Don't abort runners if a single one fails
@@ -94,7 +79,7 @@ jobs:
9479
steps:
9580
- uses: actions/checkout@v3
9681
- name: Install build dependencies
97-
run: ${{ matrix.dependencies }}
82+
run: "sudo apt install ninja-build"
9883

9984
- uses: mjp41/workaround8649@c8550b715ccdc17f89c8d5c28d7a48eeff9c94a8
10085
with:
@@ -121,6 +106,49 @@ jobs:
121106
mkdir libs
122107
cp libsnmallocshim*.so libs
123108
for lib in `ls libs`; do echo; echo Testing $lib; ninja clean; LD_PRELOAD=libs/$lib ninja libsnmallocshim.so; done
109+
110+
# If this looks remarkably familiar, that's because it is. Sigh.
111+
macos:
112+
strategy:
113+
matrix:
114+
os: [ "macos-12", "macos-14" ]
115+
build-type: [ "Release", "Debug" ]
116+
extra-cmake-flags: [ "", "-DSNMALLOC_USE_CXX17=ON" ]
117+
fail-fast: false
118+
runs-on: ${{ matrix.os }}
119+
name: ${{ matrix.os }} ${{ matrix.build-type }} ${{ matrix.extra-cmake-flags }}
120+
steps:
121+
- uses: actions/checkout@v3
122+
- name: Install build dependencies
123+
# The homebrew packages are broken at the moment and error out
124+
# after trying to install Python as a dependency of ninja because
125+
# 2to3 exists. As a quick hack, delete it first. This should be
126+
# removed once the homebrew install is fixed.
127+
run: "rm -f /usr/local/bin/2to3 ; brew update && brew install ninja"
128+
129+
- name: Configure CMake
130+
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build-type}} -G Ninja ${{ matrix.cmake-flags }} ${{ matrix.extra-cmake-flags }}
131+
# Build with a nice ninja status line
132+
- name: Build
133+
working-directory: ${{github.workspace}}/build
134+
run: NINJA_STATUS="%p [%f:%s/%t] %o/s, %es" ninja
135+
- name: Test file size of binaries is sane
136+
working-directory: ${{github.workspace}}/build
137+
run: "ls -l libsnmallocshim.* ; [ $(ls -l libsnmallocshim.* | awk '{ print $5}') -lt 10000000 ]"
138+
# If the tests are enabled for this job, run them
139+
- name: Test
140+
if: ${{ matrix.build-only != 'yes' }}
141+
working-directory: ${{github.workspace}}/build
142+
run: ctest --output-on-failure -j 4 -C ${{ matrix.build-type }} --timeout 400
143+
- name: Selfhost
144+
if: ${{ matrix.self-host }}
145+
working-directory: ${{github.workspace}}/build
146+
run: |
147+
mkdir libs
148+
cp libsnmallocshim*.so libs
149+
for lib in `ls libs`; do echo; echo Testing $lib; ninja clean; LD_PRELOAD=libs/$lib ninja libsnmallocshim.so; done
150+
151+
124152
# GitHub doesn't natively support *BSD, but we can run them in VMs on Mac /
125153
# Linux runners
126154
freebsd:
@@ -459,7 +487,7 @@ jobs:
459487
460488
all-checks:
461489
# Currently FreeBSD and NetBSD CI are not working, so we do not require them to pass.
462-
needs: [linux, qemu-crossbuild, windows, format, sanitizer]
490+
needs: [ubuntu, macos, freebsd, netbsd, sanitizer, qemu-crossbuild, windows, format]
463491
runs-on: ubuntu-latest
464492
steps:
465493
- name: Dummy step

0 commit comments

Comments
 (0)