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