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