]> git.sesse.net Git - stockfish/blob - .github/workflows/stockfish_test.yml
Extract bench according to wiki instructions
[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: MacOS 12 Apple Clang
42             os: macos-12
43             compiler: clang++
44             comp: clang
45             run_64bit_tests: true
46             shell: bash
47           - name: MacOS 12 GCC 11
48             os: macos-12
49             compiler: g++-11
50             comp: gcc
51             run_64bit_tests: true
52             shell: bash
53           - name: Windows 2022 Mingw-w64 GCC x86_64
54             os: windows-2022
55             compiler: g++
56             comp: mingw
57             run_64bit_tests: true
58             msys_sys: mingw64
59             msys_env: x86_64-gcc
60             shell: msys2 {0}
61           - name: Windows 2022 Mingw-w64 GCC i686
62             os: windows-2022
63             compiler: g++
64             comp: mingw
65             run_32bit_tests: true
66             msys_sys: mingw32
67             msys_env: i686-gcc
68             shell: msys2 {0}
69           - name: Windows 2022 Mingw-w64 Clang x86_64
70             os: windows-2022
71             compiler: clang++
72             comp: clang
73             run_64bit_tests: true
74             msys_sys: clang64
75             msys_env: clang-x86_64-clang
76             shell: msys2 {0}
77     defaults:
78       run:
79         working-directory: src
80         shell: ${{ matrix.config.shell }}
81     steps:
82       - uses: actions/checkout@v3
83         with:
84           fetch-depth: 0
85
86       - name: Download required linux packages
87         if: runner.os == 'Linux'
88         run: |
89           sudo apt update
90           sudo apt install expect valgrind g++-multilib qemu-user
91
92       - name: Install NDK
93         if: runner.os == 'Linux'
94         run: |
95           if [ $COMP == ndk ]; then
96             NDKV="21.4.7075529"
97             ANDROID_ROOT=/usr/local/lib/android
98             ANDROID_SDK_ROOT=$ANDROID_ROOT/sdk
99             SDKMANAGER=$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager
100             echo "y" | $SDKMANAGER "ndk;$NDKV"
101             ANDROID_NDK_ROOT=$ANDROID_SDK_ROOT/ndk/$NDKV
102             ANDROID_NDK_BIN=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin
103             echo "ANDROID_NDK_BIN=$ANDROID_NDK_BIN" >> $GITHUB_ENV
104           fi
105
106       - name: Download required macOS packages
107         if: runner.os == 'macOS'
108         run: brew install coreutils
109
110       - name: Setup msys and install required packages
111         if: runner.os == 'Windows'
112         uses: msys2/setup-msys2@v2
113         with:
114           msystem: ${{ matrix.config.msys_sys }}
115           install: mingw-w64-${{ matrix.config.msys_env }} make git expect
116
117       - name: Download the used network from the fishtest framework
118         run: make net
119
120       - name: Extract the bench number from the commit history
121         run: |
122           for ((n=0; n<100; n++)); do
123             benchref=$(git log HEAD~$n -1 | 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
124           done
125           [[ -n "$benchref" ]] && echo "benchref=$benchref" >> $GITHUB_ENV && echo "From commit: $(git rev-parse HEAD~$n)" && echo "Reference bench: $benchref" || echo "No bench found"
126
127       - name: Check compiler
128         run: |
129           if [ $COMP == ndk ]; then
130             export PATH=${{ env.ANDROID_NDK_BIN }}:$PATH
131           fi
132           $COMPILER -v
133
134       - name: Test help target
135         run: make help
136
137       - name: Check git
138         run: git --version
139
140       # x86-32 tests
141
142       - name: Test debug x86-32 build
143         if: matrix.config.run_32bit_tests
144         run: |
145           export CXXFLAGS="-Werror -D_GLIBCXX_DEBUG"
146           make clean
147           make -j2 ARCH=x86-32 optimize=no debug=yes build
148           ../tests/signature.sh $benchref
149
150       - name: Test x86-32 build
151         if: matrix.config.run_32bit_tests
152         run: |
153           make clean
154           make -j2 ARCH=x86-32 build
155           ../tests/signature.sh $benchref
156
157       - name: Test x86-32-sse41-popcnt build
158         if: matrix.config.run_32bit_tests
159         run: |
160           make clean
161           make -j2 ARCH=x86-32-sse41-popcnt build
162           ../tests/signature.sh $benchref
163
164       - name: Test x86-32-sse2 build
165         if: matrix.config.run_32bit_tests
166         run: |
167           make clean
168           make -j2 ARCH=x86-32-sse2 build
169           ../tests/signature.sh $benchref
170
171       - name: Test general-32 build
172         if: matrix.config.run_32bit_tests
173         run: |
174           make clean
175           make -j2 ARCH=general-32 build
176           ../tests/signature.sh $benchref
177
178       # x86-64 tests
179
180       - name: Test debug x86-64-modern build
181         if: matrix.config.run_64bit_tests
182         run: |
183           export CXXFLAGS="-Werror -D_GLIBCXX_DEBUG"
184           make clean
185           make -j2 ARCH=x86-64-modern optimize=no debug=yes build
186           ../tests/signature.sh $benchref
187
188       - name: Test x86-64-bmi2 build
189         if: matrix.config.run_64bit_tests && runner.os != 'macOS'
190         run: |
191           make clean
192           make -j2 ARCH=x86-64-bmi2 build
193           ../tests/signature.sh $benchref
194
195       - name: Test x86-64-avx2 build
196         if: matrix.config.run_64bit_tests && runner.os != 'macOS'
197         run: |
198           make clean
199           make -j2 ARCH=x86-64-avx2 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       # armv8 tests
238
239       - name: Test armv8 build
240         if: ${{ matrix.config.run_armv8_tests }}
241         run: |
242           export PATH=${{ env.ANDROID_NDK_BIN }}:$PATH
243           export LDFLAGS="-static -Wno-unused-command-line-argument"
244           make clean
245           make -j2 ARCH=armv8 build
246           ../tests/signature.sh $benchref
247
248       # armv7 tests
249
250       - name: Test armv7 build
251         if: ${{ matrix.config.run_armv7_tests }}
252         run: |
253           export PATH=${{ env.ANDROID_NDK_BIN }}:$PATH
254           export LDFLAGS="-static -Wno-unused-command-line-argument"
255           make clean
256           make -j2 ARCH=armv7 build
257           ../tests/signature.sh $benchref
258
259       - name: Test armv7-neon build
260         if: ${{ matrix.config.run_armv7_tests }}
261         run: |
262           export PATH=${{ env.ANDROID_NDK_BIN }}:$PATH
263           export LDFLAGS="-static -Wno-unused-command-line-argument"
264           make clean
265           make -j2 ARCH=armv7-neon build
266           ../tests/signature.sh $benchref
267
268       # Other tests
269
270       - name: Check perft and search reproducibility
271         if: matrix.config.run_64bit_tests
272         run: |
273           make clean
274           make -j2 ARCH=x86-64-modern build
275           ../tests/perft.sh
276           ../tests/reprosearch.sh