]> git.sesse.net Git - stockfish/blob - .github/workflows/stockfish_test.yml
Switch to macos 13 for CI
[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 13 Apple Clang
42             os: macos-13
43             compiler: clang++
44             comp: clang
45             run_64bit_tests: true
46             shell: bash
47           - name: MacOS 13 GCC 11
48             os: macos-13
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 hash in $(git rev-list -100 HEAD); do
123             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
124           done
125           [[ -n "$benchref" ]] && echo "benchref=$benchref" >> $GITHUB_ENV && echo "From commit: $hash" && 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-avx2 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-avx2 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
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
197         run: |
198           make clean
199           make -j2 ARCH=x86-64-avx2 build
200           ../tests/signature.sh $benchref
201
202       # Test a deprecated arch
203       - name: Test x86-64-modern build
204         if: matrix.config.run_64bit_tests
205         run: |
206           make clean
207           make -j2 ARCH=x86-64-modern build
208           ../tests/signature.sh $benchref
209
210       - name: Test x86-64-sse41-popcnt build
211         if: matrix.config.run_64bit_tests
212         run: |
213           make clean
214           make -j2 ARCH=x86-64-sse41-popcnt build
215           ../tests/signature.sh $benchref
216
217       - name: Test x86-64-ssse3 build
218         if: matrix.config.run_64bit_tests
219         run: |
220           make clean
221           make -j2 ARCH=x86-64-ssse3 build
222           ../tests/signature.sh $benchref
223
224       - name: Test x86-64-sse3-popcnt build
225         if: matrix.config.run_64bit_tests
226         run: |
227           make clean
228           make -j2 ARCH=x86-64-sse3-popcnt build
229           ../tests/signature.sh $benchref
230
231       - name: Test x86-64 build
232         if: matrix.config.run_64bit_tests
233         run: |
234           make clean
235           make -j2 ARCH=x86-64 build
236           ../tests/signature.sh $benchref
237
238       - name: Test general-64 build
239         if: matrix.config.run_64bit_tests
240         run: |
241           make clean
242           make -j2 ARCH=general-64 build
243           ../tests/signature.sh $benchref
244
245       # armv8 tests
246
247       - name: Test armv8 build
248         if: matrix.config.run_armv8_tests
249         run: |
250           export PATH=${{ env.ANDROID_NDK_BIN }}:$PATH
251           export LDFLAGS="-static -Wno-unused-command-line-argument"
252           make clean
253           make -j2 ARCH=armv8 build
254           ../tests/signature.sh $benchref
255
256       # armv7 tests
257
258       - name: Test armv7 build
259         if: matrix.config.run_armv7_tests
260         run: |
261           export PATH=${{ env.ANDROID_NDK_BIN }}:$PATH
262           export LDFLAGS="-static -Wno-unused-command-line-argument"
263           make clean
264           make -j2 ARCH=armv7 build
265           ../tests/signature.sh $benchref
266
267       - name: Test armv7-neon build
268         if: matrix.config.run_armv7_tests
269         run: |
270           export PATH=${{ env.ANDROID_NDK_BIN }}:$PATH
271           export LDFLAGS="-static -Wno-unused-command-line-argument"
272           make clean
273           make -j2 ARCH=armv7-neon build
274           ../tests/signature.sh $benchref
275
276       # Other tests
277
278       - name: Check perft and search reproducibility
279         if: matrix.config.run_64bit_tests
280         run: |
281           make clean
282           make -j2 ARCH=x86-64-avx2 build
283           ../tests/perft.sh
284           ../tests/reprosearch.sh