]> git.sesse.net Git - stockfish/blob - .github/workflows/stockfish_test.yml
Add new CPU archs in CI Tests workflow
[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 make_sf.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 [ $COMP == ndk ]; then
164             export PATH=${{ env.ANDROID_NDK_BIN }}:$PATH
165           fi
166           $COMPILER -v
167
168       - name: Test help target
169         run: make help
170
171       - name: Check git
172         run: git --version
173
174       # x86-32 tests
175
176       - name: Test debug x86-32 build
177         if: matrix.config.run_32bit_tests
178         run: |
179           export CXXFLAGS="-Werror -D_GLIBCXX_DEBUG"
180           make clean
181           make -j2 ARCH=x86-32 optimize=no debug=yes build
182           ../tests/signature.sh $benchref
183
184       - name: Test x86-32 build
185         if: matrix.config.run_32bit_tests
186         run: |
187           make clean
188           make -j2 ARCH=x86-32 build
189           ../tests/signature.sh $benchref
190
191       - name: Test x86-32-sse41-popcnt build
192         if: matrix.config.run_32bit_tests
193         run: |
194           make clean
195           make -j2 ARCH=x86-32-sse41-popcnt build
196           ../tests/signature.sh $benchref
197
198       - name: Test x86-32-sse2 build
199         if: matrix.config.run_32bit_tests
200         run: |
201           make clean
202           make -j2 ARCH=x86-32-sse2 build
203           ../tests/signature.sh $benchref
204
205       - name: Test general-32 build
206         if: matrix.config.run_32bit_tests
207         run: |
208           make clean
209           make -j2 ARCH=general-32 build
210           ../tests/signature.sh $benchref
211
212       # x86-64 tests
213
214       - name: Test debug x86-64-avx2 build
215         if: matrix.config.run_64bit_tests
216         run: |
217           export CXXFLAGS="-Werror -D_GLIBCXX_DEBUG"
218           make clean
219           make -j2 ARCH=x86-64-avx2 optimize=no debug=yes build
220           ../tests/signature.sh $benchref
221
222       - name: Test x86-64-bmi2 build
223         if: matrix.config.run_64bit_tests
224         run: |
225           make clean
226           make -j2 ARCH=x86-64-bmi2 build
227           ../tests/signature.sh $benchref
228
229       - name: Test x86-64-avx2 build
230         if: matrix.config.run_64bit_tests
231         run: |
232           make clean
233           make -j2 ARCH=x86-64-avx2 build
234           ../tests/signature.sh $benchref
235
236       # Test a deprecated arch
237       - name: Test x86-64-modern build
238         if: matrix.config.run_64bit_tests
239         run: |
240           make clean
241           make -j2 ARCH=x86-64-modern build
242           ../tests/signature.sh $benchref
243
244       - name: Test x86-64-sse41-popcnt build
245         if: matrix.config.run_64bit_tests
246         run: |
247           make clean
248           make -j2 ARCH=x86-64-sse41-popcnt build
249           ../tests/signature.sh $benchref
250
251       - name: Test x86-64-ssse3 build
252         if: matrix.config.run_64bit_tests
253         run: |
254           make clean
255           make -j2 ARCH=x86-64-ssse3 build
256           ../tests/signature.sh $benchref
257
258       - name: Test x86-64-sse3-popcnt build
259         if: matrix.config.run_64bit_tests
260         run: |
261           make clean
262           make -j2 ARCH=x86-64-sse3-popcnt build
263           ../tests/signature.sh $benchref
264
265       - name: Test x86-64 build
266         if: matrix.config.run_64bit_tests
267         run: |
268           make clean
269           make -j2 ARCH=x86-64 build
270           ../tests/signature.sh $benchref
271
272       - name: Test general-64 build
273         if: matrix.config.run_64bit_tests
274         run: |
275           make clean
276           make -j2 ARCH=general-64 build
277           ../tests/signature.sh $benchref
278
279       # armv8 tests
280
281       - name: Test armv8 build
282         if: matrix.config.run_armv8_tests
283         run: |
284           export PATH=${{ env.ANDROID_NDK_BIN }}:$PATH
285           export LDFLAGS="-static -Wno-unused-command-line-argument"
286           make clean
287           make -j2 ARCH=armv8 build
288           ../tests/signature.sh $benchref
289
290       - name: Test armv8-dotprod build
291         if: matrix.config.run_armv8_tests
292         run: |
293           export PATH=${{ env.ANDROID_NDK_BIN }}:$PATH
294           export LDFLAGS="-static -Wno-unused-command-line-argument"
295           make clean
296           make -j2 ARCH=armv8-dotprod build
297           ../tests/signature.sh $benchref
298
299       # armv7 tests
300
301       - name: Test armv7 build
302         if: matrix.config.run_armv7_tests
303         run: |
304           export PATH=${{ env.ANDROID_NDK_BIN }}:$PATH
305           export LDFLAGS="-static -Wno-unused-command-line-argument"
306           make clean
307           make -j2 ARCH=armv7 build
308           ../tests/signature.sh $benchref
309
310       - name: Test armv7-neon build
311         if: matrix.config.run_armv7_tests
312         run: |
313           export PATH=${{ env.ANDROID_NDK_BIN }}:$PATH
314           export LDFLAGS="-static -Wno-unused-command-line-argument"
315           make clean
316           make -j2 ARCH=armv7-neon build
317           ../tests/signature.sh $benchref
318
319       # riscv64 tests
320
321       - name: Test riscv64 build
322         if: matrix.config.run_riscv64_tests
323         run: |
324           echo "export LDFLAGS='-static' && make clean && make -j2 ARCH=riscv64 build" > make_sf.sh
325           docker run --rm --platform ${{ matrix.config.platform }} -v ${{ github.workspace }}/src:/app sf_builder
326           ../tests/signature.sh $benchref
327
328       # ppc64 tests
329
330       - name: Test ppc64 build
331         if: matrix.config.run_ppc64_tests
332         run: |
333           echo "export LDFLAGS='-static' && make clean && make -j2 ARCH=ppc-64 build" > make_sf.sh
334           docker run --rm --platform ${{ matrix.config.platform }} -v ${{ github.workspace }}/src:/app sf_builder
335           ../tests/signature.sh $benchref
336
337       # Other tests
338
339       - name: Check perft and search reproducibility
340         if: matrix.config.run_64bit_tests
341         run: |
342           make clean
343           make -j2 ARCH=x86-64-avx2 build
344           ../tests/perft.sh
345           ../tests/reprosearch.sh