Skip to content

Commit 6e0ee05

Browse files
committed
ci: add meson tests
1 parent 584570a commit 6e0ee05

File tree

1 file changed

+149
-0
lines changed

1 file changed

+149
-0
lines changed

.github/workflows/meson.yml

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
name: Meson
2+
3+
on:
4+
pull_request:
5+
push:
6+
7+
jobs:
8+
meson-build-and-tests:
9+
runs-on: ${{ matrix.platform }}
10+
name: ${{ matrix.platform }}, ${{ matrix.mode.name }} ${{ matrix.flavor }}
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
flavor:
15+
- debug
16+
- release
17+
mode:
18+
- name: default
19+
extra_envs: {}
20+
21+
# Alternative compiler setups
22+
- name: gcc
23+
extra_envs:
24+
CC: gcc
25+
CXX: g++
26+
- name: clang
27+
extra_envs:
28+
CC: clang
29+
CXX: clang++
30+
31+
- name: sanitize
32+
args: >-
33+
"-Db_sanitize=address,undefined"
34+
extra_envs: {}
35+
36+
# This is for MSVC, which only supports AddressSanitizer.
37+
# https://learn.microsoft.com/en-us/cpp/sanitizers/
38+
- name: sanitize+asanonly
39+
args: -Db_sanitize=address
40+
extra_envs:
41+
ASAN_OPTIONS: report_globals=0:halt_on_error=1:abort_on_error=1:print_summary=1
42+
43+
- name: clang+sanitize
44+
args: >-
45+
"-Db_sanitize=address,undefined"
46+
extra_envs:
47+
CC: clang
48+
CXX: clang++
49+
50+
# default clang on GitHub hosted runners is from MSYS2.
51+
# Use Visual Studio supplied clang-cl instead.
52+
- name: clang-cl+sanitize
53+
args: >-
54+
"-Db_sanitize=address,undefined"
55+
extra_envs:
56+
CC: clang-cl
57+
CXX: clang-cl
58+
platform:
59+
- ubuntu-22.04
60+
- windows-2022
61+
- macos-latest
62+
63+
exclude:
64+
# clang-cl only makes sense on windows.
65+
- platform: ubuntu-22.04
66+
mode:
67+
name: clang-cl+sanitize
68+
- platform: macos-latest
69+
mode:
70+
name: clang-cl+sanitize
71+
72+
# Use clang-cl instead of MSYS2 clang.
73+
#
74+
# we already tested clang+sanitize on linux,
75+
# if this doesn't work, it should be an issue for MSYS2 team to consider.
76+
- platform: windows-2022
77+
mode:
78+
name: clang
79+
- platform: windows-2022
80+
mode:
81+
name: clang+sanitize
82+
83+
# MSVC-only sanitizers
84+
- platform: ubuntu-22.04
85+
mode:
86+
name: sanitize+asanonly
87+
- platform: macos-latest
88+
mode:
89+
name: sanitize+asanonly
90+
- platform: windows-2022
91+
mode:
92+
name: sanitize
93+
94+
# clang is the default on macos
95+
# also gcc is an alias to clang
96+
- platform: macos-latest
97+
mode:
98+
name: clang
99+
- platform: macos-latest
100+
mode:
101+
name: gcc
102+
103+
# gcc is the default on linux
104+
- platform: ubuntu-22.04
105+
mode:
106+
name: gcc
107+
108+
# only run sanitizer tests on linux
109+
#
110+
# gcc/clang's codegen shouldn't massively change across platforms,
111+
# and linux supports most of the sanitizers.
112+
- platform: macos-latest
113+
mode:
114+
name: clang+sanitize
115+
- platform: macos-latest
116+
mode:
117+
name: sanitize
118+
steps:
119+
- name: Setup meson
120+
run: |
121+
pipx install meson ninja
122+
- name: Setup sanitizers
123+
if: ${{ matrix.platform == 'ubuntu-22.04' }}
124+
run: |
125+
sudo apt update && sudo apt install libasan8 libubsan1 -y
126+
- name: Checkout
127+
uses: actions/checkout@v4
128+
- name: Activate MSVC and Configure
129+
if: ${{ matrix.platform == 'windows-2022' }}
130+
env: ${{ matrix.mode.extra_envs }}
131+
run: |
132+
meson setup build-${{ matrix.flavor }} --buildtype=${{ matrix.flavor }} -Ddefault_library=static ${{ matrix.mode.args }} --vsenv
133+
- name: Configuring
134+
if: ${{ matrix.platform != 'windows-2022' }}
135+
env: ${{ matrix.mode.extra_envs }}
136+
run: |
137+
meson setup build-${{ matrix.flavor }} --buildtype=${{ matrix.flavor }} ${{ matrix.mode.args }}
138+
- name: Building
139+
run: |
140+
meson compile -C build-${{ matrix.flavor }}
141+
- name: Running tests
142+
env: ${{ matrix.mode.extra_envs }}
143+
run: |
144+
meson test -C build-${{ matrix.flavor }} --timeout-multiplier 0
145+
- uses: actions/upload-artifact@v4
146+
if: failure()
147+
with:
148+
name: ${{ matrix.platform }}-${{ matrix.mode.name }}-${{ matrix.flavor }}-logs
149+
path: build-${{ matrix.flavor }}/meson-logs

0 commit comments

Comments
 (0)