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