]> git.sesse.net Git - stockfish/blob - .github/workflows/stockfish_test.yml
Make posix and msys2 shells consistent in 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 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-modern build
183         if: ${{ matrix.config.run_64bit_tests }}
184         run: |
185           make clean
186           make -j2 ARCH=x86-64-modern build
187           ../tests/signature.sh $benchref
188
189       - name: Test x86-64-ssse3 build
190         if: ${{ matrix.config.run_64bit_tests }}
191         run: |
192           make clean
193           make -j2 ARCH=x86-64-ssse3 build
194           ../tests/signature.sh $benchref
195
196       - name: Test x86-64-sse3-popcnt build
197         if: ${{ matrix.config.run_64bit_tests }}
198         run: |
199           make clean
200           make -j2 ARCH=x86-64-sse3-popcnt build
201           ../tests/signature.sh $benchref
202
203       - name: Test x86-64 build
204         if: ${{ matrix.config.run_64bit_tests }}
205         run: |
206           make clean
207           make -j2 ARCH=x86-64 build
208           ../tests/signature.sh $benchref
209
210       - name: Test general-64 build
211         if: matrix.config.run_64bit_tests
212         run: |
213           make clean
214           make -j2 ARCH=general-64 build
215           ../tests/signature.sh $benchref
216
217       # armv8 tests
218
219       - name: Test armv8 build
220         if: ${{ matrix.config.run_armv8_tests }}
221         run: |
222           export PATH=${{ env.ANDROID_NDK_BIN }}:$PATH
223           export LDFLAGS="-static -Wno-unused-command-line-argument"
224           make clean
225           make -j2 ARCH=armv8 build
226           ../tests/signature.sh $benchref
227
228       # armv7 tests
229
230       - name: Test armv7 build
231         if: ${{ matrix.config.run_armv7_tests }}
232         run: |
233           export PATH=${{ env.ANDROID_NDK_BIN }}:$PATH
234           export LDFLAGS="-static -Wno-unused-command-line-argument"
235           make clean
236           make -j2 ARCH=armv7 build
237           ../tests/signature.sh $benchref
238
239       - name: Test armv7-neon build
240         if: ${{ matrix.config.run_armv7_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=armv7-neon build
246           ../tests/signature.sh $benchref
247
248       # Other tests
249
250       - name: Check perft and search reproducibility
251         if: ${{ matrix.config.run_64bit_tests }}
252         run: |
253           make clean
254           make -j2 ARCH=x86-64-modern build
255           ../tests/perft.sh
256           ../tests/reprosearch.sh