]> git.sesse.net Git - stockfish/blob - .github/workflows/stockfish_test.yml
GitHub Action: upload ARM artifacts
[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: "Android NDK aarch64",
35               os: ubuntu-20.04,
36               compiler: aarch64-linux-android21-clang++,
37               comp: ndk,
38               run_armv8_tests: true,
39               shell: 'bash {0}'
40             }
41           - {
42               name: "Android NDK arm",
43               os: ubuntu-20.04,
44               compiler: armv7a-linux-androideabi21-clang++,
45               comp: ndk,
46               run_armv7_tests: true,
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     defaults:
96       run:
97         working-directory: src
98         shell: ${{ matrix.config.shell }}
99     steps:
100       - uses: actions/checkout@v3
101         with:
102           fetch-depth: 0
103
104       - name: Download required linux packages
105         if: runner.os == 'Linux'
106         run: |
107           sudo apt update
108           sudo apt install expect valgrind g++-multilib qemu-user
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: |
119           make net
120
121       - name: Extract the bench number from the commit history
122         run: |
123           git log HEAD | grep "\b[Bb]ench[ :]\+[0-9]\{7\}" | head -n 1 | sed "s/[^0-9]*\([0-9]*\).*/\1/g" > git_sig
124           [ -s git_sig ] && echo "benchref=$(cat git_sig)" >> $GITHUB_ENV && echo "Reference bench:" $(cat git_sig) || echo "No bench found"
125
126       - name: Check compiler
127         run: |
128           if [ $COMP == ndk ]; then
129             ANDROID_ROOT=/usr/local/lib/android
130             ANDROID_SDK_ROOT=$ANDROID_ROOT/sdk
131             SDKMANAGER=$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager
132             echo "y" | $SDKMANAGER "ndk;21.4.7075529"
133             ANDROID_NDK_ROOT=$ANDROID_SDK_ROOT/ndk/21.4.7075529
134             export PATH=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH
135           fi
136           $COMPILER -v
137
138       - name: Test help target
139         run: |
140           make help
141
142       # x86-32 tests
143
144       - name: Test debug x86-32 build
145         if: ${{ matrix.config.run_32bit_tests }}
146         run: |
147           export CXXFLAGS="-Werror -D_GLIBCXX_DEBUG"
148           make clean
149           make -j2 ARCH=x86-32 optimize=no debug=yes build
150           ../tests/signature.sh $benchref
151
152       - name: Test x86-32 build
153         if: ${{ matrix.config.run_32bit_tests }}
154         run: |
155           make clean
156           make -j2 ARCH=x86-32 build
157           ../tests/signature.sh $benchref
158
159       - name: Test x86-32-sse41-popcnt build
160         if: ${{ matrix.config.run_32bit_tests }}
161         run: |
162           make clean
163           make -j2 ARCH=x86-32-sse41-popcnt build
164           ../tests/signature.sh $benchref
165
166       - name: Test x86-32-sse2 build
167         if: ${{ matrix.config.run_32bit_tests }}
168         run: |
169           make clean
170           make -j2 ARCH=x86-32-sse2 build
171           ../tests/signature.sh $benchref
172
173       - name: Test general-32 build
174         if: ${{ matrix.config.run_32bit_tests }}
175         run: |
176           make clean
177           make -j2 ARCH=general-32 build
178           ../tests/signature.sh $benchref
179
180       # x86-64 tests
181
182       - name: Test debug x86-64-modern build
183         if: ${{ matrix.config.run_64bit_tests }}
184         run: |
185           export CXXFLAGS="-Werror -D_GLIBCXX_DEBUG"
186           make clean
187           make -j2 ARCH=x86-64-modern optimize=no debug=yes build
188           ../tests/signature.sh $benchref
189
190       - name: Test x86-64-modern build
191         if: ${{ matrix.config.run_64bit_tests }}
192         run: |
193           make clean
194           make -j2 ARCH=x86-64-modern build
195           ../tests/signature.sh $benchref
196
197       - name: Test x86-64-ssse3 build
198         if: ${{ matrix.config.run_64bit_tests }}
199         run: |
200           make clean
201           make -j2 ARCH=x86-64-ssse3 build
202           ../tests/signature.sh $benchref
203
204       - name: Test x86-64-sse3-popcnt build
205         if: ${{ matrix.config.run_64bit_tests }}
206         run: |
207           make clean
208           make -j2 ARCH=x86-64-sse3-popcnt build
209           ../tests/signature.sh $benchref
210
211       - name: Test x86-64 build
212         if: ${{ matrix.config.run_64bit_tests }}
213         run: |
214           make clean
215           make -j2 ARCH=x86-64 build
216           ../tests/signature.sh $benchref
217
218       - name: Test general-64 build
219         if: matrix.config.run_64bit_tests
220         run: |
221           make clean
222           make -j2 ARCH=general-64 build
223           ../tests/signature.sh $benchref
224
225       # armv8 tests
226
227       - name: Test armv8 build
228         if: ${{ matrix.config.run_armv8_tests }}
229         run: |
230           ANDROID_ROOT=/usr/local/lib/android
231           ANDROID_SDK_ROOT=$ANDROID_ROOT/sdk
232           SDKMANAGER=$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager
233           echo "y" | $SDKMANAGER "ndk;21.4.7075529"
234           ANDROID_NDK_ROOT=$ANDROID_SDK_ROOT/ndk/21.4.7075529
235           export PATH=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH
236           export LDFLAGS="-static -Wno-unused-command-line-argument"
237           make clean
238           make -j2 ARCH=armv8 build
239           ../tests/signature.sh $benchref
240
241       # armv7 tests
242
243       - name: Test armv7 build
244         if: ${{ matrix.config.run_armv7_tests }}
245         run: |
246           ANDROID_ROOT=/usr/local/lib/android
247           ANDROID_SDK_ROOT=$ANDROID_ROOT/sdk
248           SDKMANAGER=$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager
249           echo "y" | $SDKMANAGER "ndk;21.4.7075529"
250           ANDROID_NDK_ROOT=$ANDROID_SDK_ROOT/ndk/21.4.7075529
251           export PATH=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH
252           export LDFLAGS="-static -Wno-unused-command-line-argument"
253           make clean
254           make -j2 ARCH=armv7 build
255           ../tests/signature.sh $benchref
256
257       - name: Test armv7-neon build
258         if: ${{ matrix.config.run_armv7_tests }}
259         run: |
260           ANDROID_ROOT=/usr/local/lib/android
261           ANDROID_SDK_ROOT=$ANDROID_ROOT/sdk
262           SDKMANAGER=$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager
263           echo "y" | $SDKMANAGER "ndk;21.4.7075529"
264           ANDROID_NDK_ROOT=$ANDROID_SDK_ROOT/ndk/21.4.7075529
265           export PATH=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH
266           export LDFLAGS="-static -Wno-unused-command-line-argument"
267           make clean
268           make -j2 ARCH=armv7-neon build
269           ../tests/signature.sh $benchref
270
271       # Other tests
272
273       - name: Check perft and search reproducibility
274         if: ${{ matrix.config.run_64bit_tests }}
275         run: |
276           make clean
277           make -j2 ARCH=x86-64-modern build
278           ../tests/perft.sh
279           ../tests/reprosearch.sh