]> git.sesse.net Git - stockfish/blob - .github/workflows/stockfish.yml
b007ec789379af48cd0dc39dff533a7d3934adc2
[stockfish] / .github / workflows / stockfish.yml
1 name: Stockfish
2 on:
3   push:
4     branches:
5       - master
6       - tools
7       - github_ci
8   pull_request:
9     branches:
10       - master
11       - tools
12 jobs:
13   Stockfish:
14     name: ${{ matrix.config.name }}
15     runs-on: ${{ matrix.config.os }}
16     env:
17       COMPILER: ${{ matrix.config.compiler }}
18       COMP: ${{ matrix.config.comp }}
19       CXXFLAGS: "-Werror"
20     strategy:
21       matrix:
22         config:
23           # set the variable for the required tests:
24           # run_expensive_tests: true
25           # run_32bit_tests: true
26           # run_64bit_tests: true
27           # run_armv8_tests: true
28           # run_armv7_tests: true
29           - {
30               name: "Ubuntu 20.04 GCC",
31               os: ubuntu-20.04,
32               compiler: g++,
33               comp: gcc,
34               run_expensive_tests: true,
35               run_32bit_tests: true,
36               run_64bit_tests: true,
37               shell: 'bash {0}'
38             }
39           - {
40               name: "Ubuntu 20.04 Clang",
41               os: ubuntu-20.04,
42               compiler: clang++,
43               comp: clang,
44               run_32bit_tests: true,
45               run_64bit_tests: true,
46               shell: 'bash {0}'
47             }
48           - {
49               name: "Ubuntu 20.04 NDK armv8",
50               os: ubuntu-20.04,
51               compiler: aarch64-linux-android21-clang++,
52               comp: ndk,
53               run_armv8_tests: false,
54               shell: 'bash {0}'
55             }
56           - {
57               name: "Ubuntu 20.04 NDK armv7",
58               os: ubuntu-20.04,
59               compiler: armv7a-linux-androideabi21-clang++,
60               comp: ndk,
61               run_armv7_tests: false,
62               shell: 'bash {0}'
63             }
64           - {
65               name: "MacOS 10.15 Apple Clang",
66               os: macos-10.15,
67               compiler: clang++,
68               comp: clang,
69               run_64bit_tests: true,
70               shell: 'bash {0}'
71             }
72           - {
73               name: "MacOS 10.15 GCC 10",
74               os: macos-10.15,
75               compiler: g++-10,
76               comp: gcc,
77               run_64bit_tests: true,
78               shell: 'bash {0}'
79             }
80           - {
81               name: "Windows 2022 Mingw-w64 GCC x86_64",
82               os: windows-2022,
83               compiler: g++,
84               comp: mingw,
85               run_64bit_tests: true,
86               msys_sys: 'mingw64',
87               msys_env: 'x86_64-gcc',
88               shell: 'msys2 {0}'
89             }
90           - {
91               name: "Windows 2022 Mingw-w64 GCC i686",
92               os: windows-2022,
93               compiler: g++,
94               comp: mingw,
95               run_32bit_tests: true,
96               msys_sys: 'mingw32',
97               msys_env: 'i686-gcc',
98               shell: 'msys2 {0}'
99             }
100           - {
101               name: "Windows 2022 Mingw-w64 Clang x86_64",
102               os: windows-2022,
103               compiler: clang++,
104               comp: clang,
105               run_64bit_tests: true,
106               msys_sys: 'clang64',
107               msys_env: 'clang-x86_64-clang',
108               shell: 'msys2 {0}'
109             }
110
111     defaults:
112       run:
113         working-directory: src
114         shell: ${{ matrix.config.shell }}
115     steps:
116       - uses: actions/checkout@v2
117         with:
118           fetch-depth: 0
119
120       - name: Download required linux packages
121         if: runner.os == 'Linux'
122         run: |
123           sudo apt update
124           sudo apt install expect valgrind g++-multilib qemu-user
125
126       - name: Setup msys and install required packages
127         if: runner.os == 'Windows'
128         uses: msys2/setup-msys2@v2
129         with:
130           msystem: ${{matrix.config.msys_sys}}
131           install: mingw-w64-${{matrix.config.msys_env}} make git expect
132
133       - name: Download the used network from the fishtest framework
134         run: |
135           make net
136
137       - name: Extract the bench number from the commit history
138         run: |
139           git log HEAD | grep "\b[Bb]ench[ :]\+[0-9]\{7\}" | head -n 1 | sed "s/[^0-9]*\([0-9]*\).*/\1/g" > git_sig
140           [ -s git_sig ] && echo "benchref=$(cat git_sig)" >> $GITHUB_ENV && echo "Reference bench:" $(cat git_sig) || echo "No bench found"
141
142       - name: Check compiler
143         run: |
144           export PATH=$PATH:$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin
145           $COMPILER -v
146
147       - name: Test help target
148         run: |
149           make help
150
151       # x86-32 tests
152
153       - name: Test debug x86-32 build
154         if: ${{ matrix.config.run_32bit_tests }}
155         run: |
156           export CXXFLAGS="-Werror -D_GLIBCXX_DEBUG"
157           make clean
158           make -j2 ARCH=x86-32 optimize=no debug=yes build
159           ../tests/signature.sh $benchref
160
161       - name: Test x86-32 build
162         if: ${{ matrix.config.run_32bit_tests }}
163         run: |
164           make clean
165           make -j2 ARCH=x86-32 build
166           ../tests/signature.sh $benchref
167
168       - name: Test x86-32-sse41-popcnt build
169         if: ${{ matrix.config.run_32bit_tests }}
170         run: |
171           make clean
172           make -j2 ARCH=x86-32-sse41-popcnt build
173           ../tests/signature.sh $benchref
174
175       - name: Test x86-32-sse2 build
176         if: ${{ matrix.config.run_32bit_tests }}
177         run: |
178           make clean
179           make -j2 ARCH=x86-32-sse2 build
180           ../tests/signature.sh $benchref
181
182       - name: Test general-32 build
183         if: ${{ matrix.config.run_32bit_tests }}
184         run: |
185           make clean
186           make -j2 ARCH=general-32 build
187           ../tests/signature.sh $benchref
188
189       # x86-64 tests
190
191       - name: Test debug x86-64-modern build
192         if: ${{ matrix.config.run_64bit_tests }}
193         run: |
194           export CXXFLAGS="-Werror -D_GLIBCXX_DEBUG"
195           make clean
196           make -j2 ARCH=x86-64-modern optimize=no debug=yes build
197           ../tests/signature.sh $benchref
198
199       - name: Test x86-64-modern build
200         if: ${{ matrix.config.run_64bit_tests }}
201         run: |
202           make clean
203           make -j2 ARCH=x86-64-modern build
204           ../tests/signature.sh $benchref
205
206       - name: Test x86-64-ssse3 build
207         if: ${{ matrix.config.run_64bit_tests }}
208         run: |
209           make clean
210           make -j2 ARCH=x86-64-ssse3 build
211           ../tests/signature.sh $benchref
212
213       - name: Test x86-64-sse3-popcnt build
214         if: ${{ matrix.config.run_64bit_tests }}
215         run: |
216           make clean
217           make -j2 ARCH=x86-64-sse3-popcnt build
218           ../tests/signature.sh $benchref
219
220       - name: Test x86-64 build
221         if: ${{ matrix.config.run_64bit_tests }}
222         run: |
223           make clean
224           make -j2 ARCH=x86-64 build
225           ../tests/signature.sh $benchref
226
227       - name: Test general-64 build
228         if: matrix.config.run_64bit_tests
229         run: |
230           make clean
231           make -j2 ARCH=general-64 build
232           ../tests/signature.sh $benchref
233
234       # x86-64 with newer extensions tests
235
236       - name: Compile x86-64-avx2 build
237         if: ${{ matrix.config.run_64bit_tests }}
238         run: |
239           make clean
240           make -j2 ARCH=x86-64-avx2 build
241
242       - name: Compile x86-64-bmi2 build
243         if: ${{ matrix.config.run_64bit_tests }}
244         run: |
245           make clean
246           make -j2 ARCH=x86-64-bmi2 build
247
248       - name: Compile x86-64-avx512 build
249         if: ${{ matrix.config.run_64bit_tests }}
250         run: |
251           make clean
252           make -j2 ARCH=x86-64-avx512 build
253
254       - name: Compile x86-64-vnni512 build
255         if: ${{ matrix.config.run_64bit_tests }}
256         run: |
257           make clean
258           make -j2 ARCH=x86-64-vnni512 build
259
260       - name: Compile x86-64-vnni256 build
261         if: ${{ matrix.config.run_64bit_tests }}
262         run: |
263           make clean
264           make -j2 ARCH=x86-64-vnni256 build
265
266       # armv8 tests
267
268       - name: Test armv8 build
269         if: ${{ matrix.config.run_armv8_tests }}
270         run: |
271           ANDROID_ROOT=/usr/local/lib/android
272           ANDROID_SDK_ROOT=${ANDROID_ROOT}/sdk
273           SDKMANAGER=${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager
274           echo "y" | $SDKMANAGER "ndk;21.4.7075529"
275           ANDROID_NDK_ROOT=${ANDROID_SDK_ROOT}/ndk-bundle
276           ln -sfn $ANDROID_SDK_ROOT/ndk/21.4.7075529 $ANDROID_NDK_ROOT
277           export PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH
278           export LDFLAGS="-static -Wno-unused-command-line-argument"
279           make clean
280           make -j2 ARCH=armv8 build
281           ../tests/signature.sh $benchref
282
283       # armv7 tests
284
285       - name: Test armv7 build
286         if: ${{ matrix.config.run_armv7_tests }}
287         run: |
288           ANDROID_ROOT=/usr/local/lib/android
289           ANDROID_SDK_ROOT=${ANDROID_ROOT}/sdk
290           SDKMANAGER=${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager
291           echo "y" | $SDKMANAGER "ndk;21.4.7075529"
292           ANDROID_NDK_ROOT=${ANDROID_SDK_ROOT}/ndk-bundle
293           ln -sfn $ANDROID_SDK_ROOT/ndk/21.4.7075529 $ANDROID_NDK_ROOT
294           export PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH
295           export LDFLAGS="-static -Wno-unused-command-line-argument"
296           make clean
297           make -j2 ARCH=armv7 build
298           ../tests/signature.sh $benchref
299
300       - name: Test armv7-neon build
301         if: ${{ matrix.config.run_armv7_tests }}
302         run: |
303           ANDROID_ROOT=/usr/local/lib/android
304           ANDROID_SDK_ROOT=${ANDROID_ROOT}/sdk
305           SDKMANAGER=${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager
306           echo "y" | $SDKMANAGER "ndk;21.4.7075529"
307           ANDROID_NDK_ROOT=${ANDROID_SDK_ROOT}/ndk-bundle
308           ln -sfn $ANDROID_SDK_ROOT/ndk/21.4.7075529 $ANDROID_NDK_ROOT
309           export PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH
310           export LDFLAGS="-static -Wno-unused-command-line-argument"
311           make clean
312           make -j2 ARCH=armv7-neon build
313           ../tests/signature.sh $benchref
314
315       # Other tests
316
317       - name: Check perft and search reproducibility
318         if: ${{ matrix.config.run_64bit_tests }}
319         run: |
320           make clean
321           make -j2 ARCH=x86-64-modern build
322           ../tests/perft.sh
323           ../tests/reprosearch.sh
324
325       # Sanitizers
326
327       - name: Run under valgrind
328         if: ${{ matrix.config.run_expensive_tests }}
329         run: |
330           export CXXFLAGS="-O1 -fno-inline"
331           make clean
332           make -j2 ARCH=x86-64-modern debug=yes optimize=no build > /dev/null
333           ../tests/instrumented.sh --valgrind
334           ../tests/instrumented.sh --valgrind-thread
335
336       - name: Run with UB sanitizer
337         if: ${{ matrix.config.run_expensive_tests }}
338         run: |
339           export CXXFLAGS="-O1 -fno-inline"
340           make clean
341           make -j2 ARCH=x86-64-modern sanitize=undefined optimize=no debug=yes build > /dev/null
342           ../tests/instrumented.sh --sanitizer-undefined
343
344       - name: Run with thread sanitizer
345         if: ${{ matrix.config.run_expensive_tests }}
346         run: |
347           export CXXFLAGS="-O1 -fno-inline"
348           make clean
349           make -j2 ARCH=x86-64-modern sanitize=thread optimize=no debug=yes build > /dev/null
350           ../tests/instrumented.sh --sanitizer-thread