]> git.sesse.net Git - stockfish/blob - .github/workflows/stockfish.yml
33126a11e3510d09a8a50651d308c81dcb55b74b
[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           - {
24               name: "Ubuntu 20.04 GCC",
25               os: ubuntu-20.04,
26               compiler: g++,
27               comp: gcc,
28               run_expensive_tests: true,
29               run_32bit_tests: true,
30               run_64bit_tests: true,
31               shell: 'bash {0}'
32             }
33           - {
34               name: "Ubuntu 20.04 Clang",
35               os: ubuntu-20.04,
36               compiler: clang++,
37               comp: clang,
38               run_expensive_tests: false,
39               run_32bit_tests: true,
40               run_64bit_tests: true,
41               shell: 'bash {0}'
42             }
43           - {
44               name: "MacOS 10.15 Apple Clang",
45               os: macos-10.15,
46               compiler: clang++,
47               comp: clang,
48               run_expensive_tests: false,
49               run_32bit_tests: false,
50               run_64bit_tests: true,
51               shell: 'bash {0}'
52             }
53           - {
54               name: "MacOS 10.15 GCC 10",
55               os: macos-10.15,
56               compiler: g++-10,
57               comp: gcc,
58               run_expensive_tests: false,
59               run_32bit_tests: false,
60               run_64bit_tests: true,
61               shell: 'bash {0}'
62             }
63           - {
64               name: "Windows 2022 Mingw-w64 GCC x86_64",
65               os: windows-2022,
66               compiler: g++,
67               comp: gcc,
68               run_expensive_tests: false,
69               run_32bit_tests: false,
70               run_64bit_tests: true,
71               msys_sys: 'mingw64',
72               msys_env: 'x86_64',
73               shell: 'msys2 {0}'
74             }
75           - {
76               name: "Windows 2022 Mingw-w64 GCC i686",
77               os: windows-2022,
78               compiler: g++,
79               comp: gcc,
80               run_expensive_tests: false,
81               run_32bit_tests: true,
82               run_64bit_tests: false,
83               msys_sys: 'mingw32',
84               msys_env: 'i686',
85               shell: 'msys2 {0}'
86             }
87           - {
88               name: "Windows 2022 Mingw-w64 Clang x86_64",
89               os: windows-2022,
90               compiler: clang++,
91               comp: clang,
92               run_expensive_tests: false,
93               run_32bit_tests: false,
94               run_64bit_tests: true,
95               msys_sys: 'clang64',
96               msys_env: 'clang-x86_64',
97               shell: 'msys2 {0}'
98             }
99
100     defaults:
101       run:
102         working-directory: src
103         shell: ${{ matrix.config.shell }}
104     steps:
105       - uses: actions/checkout@v2
106         with:
107           fetch-depth: 0
108
109       - name: Download required linux packages
110         if: runner.os == 'Linux'
111         run: |
112           sudo apt update
113           sudo apt install expect valgrind g++-multilib
114
115       - name: Setup msys and install required packages
116         if: runner.os == 'Windows'
117         uses: msys2/setup-msys2@v2
118         with:
119           msystem: ${{matrix.config.msys_sys}}
120           install: mingw-w64-${{matrix.config.msys_env}}-${{matrix.config.comp}} make git expect
121
122       - name: Download the used network from the fishtest framework
123         run: |
124           make net
125
126       - name: Extract the bench number from the commit history
127         run: |
128           git log HEAD | grep "\b[Bb]ench[ :]\+[0-9]\{7\}" | head -n 1 | sed "s/[^0-9]*\([0-9]*\).*/\1/g" > git_sig
129           [ -s git_sig ] && echo "benchref=$(cat git_sig)" >> $GITHUB_ENV && echo "Reference bench:" $(cat git_sig) || echo "No bench found"
130
131       - name: Check compiler
132         run: |
133           $COMPILER -v
134
135       - name: Test help target
136         run: |
137           make help
138
139       # x86-32 tests
140
141       - name: Test debug x86-32 build
142         if: ${{ matrix.config.run_32bit_tests }}
143         run: |
144           export CXXFLAGS="-Werror -D_GLIBCXX_DEBUG"
145           make clean
146           make -j2 ARCH=x86-32 optimize=no debug=yes build
147           ../tests/signature.sh $benchref
148
149       - name: Test x86-32 build
150         if: ${{ matrix.config.run_32bit_tests }}
151         run: |
152           make clean
153           make -j2 ARCH=x86-32 build
154           ../tests/signature.sh $benchref
155
156       - name: Test x86-32-sse41-popcnt build
157         if: ${{ matrix.config.run_32bit_tests }}
158         run: |
159           make clean
160           make -j2 ARCH=x86-32-sse41-popcnt build
161           ../tests/signature.sh $benchref
162
163       - name: Test x86-32-sse2 build
164         if: ${{ matrix.config.run_32bit_tests }}
165         run: |
166           make clean
167           make -j2 ARCH=x86-32-sse2 build
168           ../tests/signature.sh $benchref
169
170       - name: Test general-32 build
171         if: ${{ matrix.config.run_32bit_tests }}
172         run: |
173           make clean
174           make -j2 ARCH=general-32 build
175           ../tests/signature.sh $benchref
176
177       # x86-64 tests
178
179       - name: Test debug x86-64-modern build
180         if: ${{ matrix.config.run_64bit_tests }}
181         run: |
182           export CXXFLAGS="-Werror -D_GLIBCXX_DEBUG"
183           make clean
184           make -j2 ARCH=x86-64-modern optimize=no debug=yes build
185           ../tests/signature.sh $benchref
186
187       - name: Test x86-64-modern build
188         if: ${{ matrix.config.run_64bit_tests }}
189         run: |
190           make clean
191           make -j2 ARCH=x86-64-modern build
192           ../tests/signature.sh $benchref
193
194       - name: Test x86-64-ssse3 build
195         if: ${{ matrix.config.run_64bit_tests }}
196         run: |
197           make clean
198           make -j2 ARCH=x86-64-ssse3 build
199           ../tests/signature.sh $benchref
200
201       - name: Test x86-64-sse3-popcnt build
202         if: ${{ matrix.config.run_64bit_tests }}
203         run: |
204           make clean
205           make -j2 ARCH=x86-64-sse3-popcnt build
206           ../tests/signature.sh $benchref
207
208       - name: Test x86-64 build
209         if: ${{ matrix.config.run_64bit_tests }}
210         run: |
211           make clean
212           make -j2 ARCH=x86-64 build
213           ../tests/signature.sh $benchref
214
215       - name: Test general-64 build
216         if: matrix.config.run_64bit_tests
217         run: |
218           make clean
219           make -j2 ARCH=general-64 build
220           ../tests/signature.sh $benchref
221
222       # x86-64 with newer extensions tests
223
224       - name: Compile x86-64-avx2 build
225         if: ${{ matrix.config.run_64bit_tests }}
226         run: |
227           make clean
228           make -j2 ARCH=x86-64-avx2 build
229
230       - name: Compile x86-64-bmi2 build
231         if: ${{ matrix.config.run_64bit_tests }}
232         run: |
233           make clean
234           make -j2 ARCH=x86-64-bmi2 build
235
236       - name: Compile x86-64-avx512 build
237         if: ${{ matrix.config.run_64bit_tests }}
238         run: |
239           make clean
240           make -j2 ARCH=x86-64-avx512 build
241
242       - name: Compile x86-64-vnni512 build
243         if: ${{ matrix.config.run_64bit_tests }}
244         run: |
245           make clean
246           make -j2 ARCH=x86-64-vnni512 build
247
248       - name: Compile x86-64-vnni256 build
249         if: ${{ matrix.config.run_64bit_tests }}
250         run: |
251           make clean
252           make -j2 ARCH=x86-64-vnni256 build
253
254       # Other tests
255
256       - name: Check perft and search reproducibility
257         if: ${{ matrix.config.run_64bit_tests }}
258         run: |
259           make clean
260           make -j2 ARCH=x86-64-modern build
261           ../tests/perft.sh
262           ../tests/reprosearch.sh
263
264       # Sanitizers
265
266       - name: Run under valgrind
267         if: ${{ matrix.config.run_expensive_tests }}
268         run: |
269           export CXXFLAGS="-O1 -fno-inline"
270           make clean
271           make -j2 ARCH=x86-64-modern debug=yes optimize=no build > /dev/null
272           ../tests/instrumented.sh --valgrind
273           ../tests/instrumented.sh --valgrind-thread
274
275       - name: Run with UB sanitizer
276         if: ${{ matrix.config.run_expensive_tests }}
277         run: |
278           export CXXFLAGS="-O1 -fno-inline"
279           make clean
280           make -j2 ARCH=x86-64-modern sanitize=undefined optimize=no debug=yes build > /dev/null
281           ../tests/instrumented.sh --sanitizer-undefined
282
283       - name: Run with thread sanitizer
284         if: ${{ matrix.config.run_expensive_tests }}
285         run: |
286           export CXXFLAGS="-O1 -fno-inline"
287           make clean
288           make -j2 ARCH=x86-64-modern sanitize=thread optimize=no debug=yes build > /dev/null
289           ../tests/instrumented.sh --sanitizer-thread