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