-
Notifications
You must be signed in to change notification settings - Fork 2.5k
208 lines (157 loc) · 4.67 KB
/
c-std.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
name: C Standard
# Compile with as many C standards as possible.
# The worflow is setup to fail on any compilation warnings.
on:
workflow_dispatch:
push:
pull_request:
jobs:
main:
name: ${{ matrix.os.name }} ${{ matrix.compiler }} ${{ matrix.arch.name }} ${{ matrix.std.name }} ${{ matrix.builder }}
runs-on: ${{ matrix.os.value }}
strategy:
fail-fast: false
matrix:
os:
- name: Linux
value: ubuntu-latest
- name: MacOS
value: macos-latest
- name: Windows
value: windows-latest
cmake-opt: -G Ninja
compiler:
- gcc
- clang
arch:
- name: 64-bit
tag: amd64
compiler-opt: -m64
cmake-opt: -A x64
- name: 32-bit
tag: i386
compiler-opt: -m32
cmake-opt: -A Win32
builder:
- configure
- cmake
std:
- name: c89
value: c89
- name: gnu89
value: gnu89
- name: c94
value: iso9899:199409
- name: c99
value: c99
- name: gnu99
value: gnu99
- name: c11
value: c11
- name: gnu11
value: gnu11
- name: c17
value: c17
- name: gnu17
value: gnu17
- name: c2x
value: c2x
- name: gnu2x
value: gnu2x
exclude:
# Don't run 32-bit on MacOS
- { os: { name: MacOS },
arch: { tag: i386 } }
# Don't run configure on Windows
- { os: { name: Windows },
builder: configure }
# Don't run gcc 32-bit on Windows
- { os: { name: Windows },
arch: { tag: i386 } }
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
show-progress: 'false'
- name: Install packages (Linux)
if: runner.os == 'Linux' && matrix.arch.tag == 'i386'
run: |
sudo apt-get update
sudo apt install gcc-multilib libc6-dev-i386-cross
- name: Install packages (Windows)
if: runner.os == 'Windows'
run: |
choco install --no-progress ninja
- name: Generate project files (configure)
if: matrix.builder == 'configure'
run: |
./configure
env:
CC: ${{ matrix.compiler }}
CFLAGS: -std=${{ matrix.std.value }} ${{ matrix.arch.compiler-opt }} -Werror -Wall -Wextra
- name: Compile source code (configure)
if: matrix.builder == 'configure'
run: make -j2
- name: Run test cases (configure)
if: matrix.builder == 'configure'
run: |
make test
make cover
- name: Generate project files (cmake)
if: matrix.builder == 'cmake'
run: |
cmake -S . -B . -D CMAKE_BUILD_TYPE=Release -D ZLIB_BUILD_EXAMPLES=OFF ${{ matrix.os.cmake-opt }}
env:
CC: ${{ matrix.compiler }}
CFLAGS: -std=${{ matrix.std.value }} ${{ matrix.arch.compiler-opt }} -Werror -Wall -Wextra
- name: Compile source code (cmake)
if: matrix.builder == 'cmake'
run: cmake --build . --config Release
- name: Run test cases (cmake)
if: matrix.builder == 'cmake'
run: ctest -C Release --output-on-failure --max-width 120
msvc:
name: ${{ matrix.os.name }} ${{ matrix.compiler }} ${{ matrix.arch.name }} ${{ matrix.std.name }} ${{ matrix.builder }}
runs-on: ${{ matrix.os.value }}
strategy:
fail-fast: false
matrix:
os:
- name: Windows
value: windows-latest
compiler:
- cl
arch:
- name: 32-bit
value: -A Win32
- name: 64-bit
value: -A x64
builder:
- cmake
std:
- name: default
value: ""
- name: C11
value: /std:c11
- name: C17
value: /std:c17
# not available on the runner yet
# - name: C20
# value: /std:c20
- name: latest
value: /std:clatest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
show-progress: 'false'
- name: Generate project files (cmake)
run: |
cmake -S . -B . ${{ matrix.arch.value }} -D CMAKE_BUILD_TYPE=Release
env:
CC: ${{ matrix.compiler }}
CFLAGS: /WX ${{ matrix.std.value }}
- name: Compile source code (cmake)
run: cmake --build . --config Release -v
- name: Run test cases (cmake)
run: ctest -C Release --output-on-failure --max-width 120