]> git.sesse.net Git - stockfish/blob - .github/workflows/stockfish_test.yml
Add bmi2 to CI generated binaries
[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: Setup msys and install required packages
107         if: runner.os == 'Windows'
108         uses: msys2/setup-msys2@v2
109         with:
110           msystem: ${{ matrix.config.msys_sys }}
111           install: mingw-w64-${{ matrix.config.msys_env }} make git expect
112
113       - name: Download the used network from the fishtest framework
114         run: make net
115
116       - name: Extract the bench number from the commit history
117         run: |
118           benchref=$(git log HEAD | grep -m 1 -o -x "[[:space:]]*\b[Bb]ench[ :]\+[1-9][0-9]\{5,7\}\b[[:space:]]*" | sed "s/[^0-9]//g") || true
119           [[ -n "$benchref" ]] && echo "benchref=$benchref" >> $GITHUB_ENV && echo "Reference bench: $benchref" || echo "No bench found"
120
121       - name: Check compiler
122         run: |
123           if [ $COMP == ndk ]; then
124             export PATH=${{ env.ANDROID_NDK_BIN }}:$PATH
125           fi
126           $COMPILER -v
127
128       - name: Test help target
129         run: make help
130
131       - name: Check git
132         run: git --version
133
134       # x86-32 tests
135
136       - name: Test debug x86-32 build
137         if: matrix.config.run_32bit_tests
138         run: |
139           export CXXFLAGS="-Werror -D_GLIBCXX_DEBUG"
140           make clean
141           make -j2 ARCH=x86-32 optimize=no debug=yes build
142           ../tests/signature.sh $benchref
143
144       - name: Test x86-32 build
145         if: matrix.config.run_32bit_tests
146         run: |
147           make clean
148           make -j2 ARCH=x86-32 build
149           ../tests/signature.sh $benchref
150
151       - name: Test x86-32-sse41-popcnt build
152         if: matrix.config.run_32bit_tests
153         run: |
154           make clean
155           make -j2 ARCH=x86-32-sse41-popcnt build
156           ../tests/signature.sh $benchref
157
158       - name: Test x86-32-sse2 build
159         if: matrix.config.run_32bit_tests
160         run: |
161           make clean
162           make -j2 ARCH=x86-32-sse2 build
163           ../tests/signature.sh $benchref
164
165       - name: Test general-32 build
166         if: matrix.config.run_32bit_tests
167         run: |
168           make clean
169           make -j2 ARCH=general-32 build
170           ../tests/signature.sh $benchref
171
172       # x86-64 tests
173
174       - name: Test debug x86-64-modern build
175         if: matrix.config.run_64bit_tests
176         run: |
177           export CXXFLAGS="-Werror -D_GLIBCXX_DEBUG"
178           make clean
179           make -j2 ARCH=x86-64-modern optimize=no debug=yes build
180           ../tests/signature.sh $benchref
181
182       - name: Test x86-64-bmi2 build
183         if: matrix.config.run_64bit_tests && runner.os != 'macOS'
184         run: |
185           make clean
186           make -j2 ARCH=x86-64-bmi2 build
187           ../tests/signature.sh $benchref
188
189       - name: Test x86-64-avx2 build
190         if: matrix.config.run_64bit_tests && runner.os != 'macOS'
191         run: |
192           make clean
193           make -j2 ARCH=x86-64-avx2 build
194           ../tests/signature.sh $benchref
195
196       - name: Test x86-64-modern build
197         if: matrix.config.run_64bit_tests
198         run: |
199           make clean
200           make -j2 ARCH=x86-64-modern build
201           ../tests/signature.sh $benchref
202
203       - name: Test x86-64-ssse3 build
204         if: matrix.config.run_64bit_tests
205         run: |
206           make clean
207           make -j2 ARCH=x86-64-ssse3 build
208           ../tests/signature.sh $benchref
209
210       - name: Test x86-64-sse3-popcnt build
211         if: matrix.config.run_64bit_tests
212         run: |
213           make clean
214           make -j2 ARCH=x86-64-sse3-popcnt build
215           ../tests/signature.sh $benchref
216
217       - name: Test x86-64 build
218         if: matrix.config.run_64bit_tests
219         run: |
220           make clean
221           make -j2 ARCH=x86-64 build
222           ../tests/signature.sh $benchref
223
224       - name: Test general-64 build
225         if: matrix.config.run_64bit_tests
226         run: |
227           make clean
228           make -j2 ARCH=general-64 build
229           ../tests/signature.sh $benchref
230
231       # armv8 tests
232
233       - name: Test armv8 build
234         if: ${{ matrix.config.run_armv8_tests }}
235         run: |
236           export PATH=${{ env.ANDROID_NDK_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           export PATH=${{ env.ANDROID_NDK_BIN }}:$PATH
248           export LDFLAGS="-static -Wno-unused-command-line-argument"
249           make clean
250           make -j2 ARCH=armv7 build
251           ../tests/signature.sh $benchref
252
253       - name: Test armv7-neon build
254         if: ${{ matrix.config.run_armv7_tests }}
255         run: |
256           export PATH=${{ env.ANDROID_NDK_BIN }}:$PATH
257           export LDFLAGS="-static -Wno-unused-command-line-argument"
258           make clean
259           make -j2 ARCH=armv7-neon build
260           ../tests/signature.sh $benchref
261
262       # Other tests
263
264       - name: Check perft and search reproducibility
265         if: matrix.config.run_64bit_tests
266         run: |
267           make clean
268           make -j2 ARCH=x86-64-modern build
269           ../tests/perft.sh
270           ../tests/reprosearch.sh