Add macOS and windows to CI
[stockfish] / .github / workflows / stockfish.yml
1 name: Stockfish
2 on:
3   push:
4     branches:
5       - master
6       - tools
7       - github_ci
8   pull_request:
9     branches:
10       - master
11       - tools
12 jobs:
13   Stockfish:
14     name: ${{ matrix.config.name }}
15     runs-on: ${{ matrix.config.os }}
16     env:
17       COMPILER: ${{ matrix.config.compiler }}
18       COMP: ${{ matrix.config.comp }}
19       CXXFLAGS: "-Werror"
20     strategy:
21       matrix:
22         config:
23           - {
24               name: "Ubuntu 20.04 GCC",
25               os: ubuntu-20.04,
26               compiler: g++,
27               comp: gcc,
28               run_expensive_tests: true,
29               run_32bit_tests: true,
30               run_64bit_tests: true,
31               shell: 'bash {0}'
32             }
33           - {
34               name: "Ubuntu 20.04 Clang",
35               os: ubuntu-20.04,
36               compiler: clang++,
37               comp: clang,
38               run_expensive_tests: false,
39               run_32bit_tests: true,
40               run_64bit_tests: true,
41               shell: 'bash {0}'
42             }
43           - {
44               name: "MacOS 10.15 Apple Clang",
45               os: macos-10.15,
46               compiler: clang++,
47               comp: clang,
48               run_expensive_tests: false,
49               run_32bit_tests: false,
50               run_64bit_tests: true,
51               shell: 'bash {0}'
52             }
53           - {
54               name: "MacOS 10.15 GCC 10",
55               os: macos-10.15,
56               compiler: g++-10,
57               comp: gcc,
58               run_expensive_tests: false,
59               run_32bit_tests: false,
60               run_64bit_tests: true,
61               shell: 'bash {0}'
62             }
63           - {
64               name: "Windows 2019 Mingw-w64 GCC x86_64",
65               os: windows-2019,
66               compiler: g++,
67               comp: gcc,
68               run_expensive_tests: false,
69               run_32bit_tests: false,
70               run_64bit_tests: true,
71               msys_sys: 'mingw64',
72               msys_env: 'x86_64',
73               shell: 'msys2 {0}'
74             }
75           - {
76               name: "Windows 2019 Mingw-w64 GCC i686",
77               os: windows-2019,
78               compiler: g++,
79               comp: gcc,
80               run_expensive_tests: false,
81               run_32bit_tests: true,
82               run_64bit_tests: false,
83               msys_sys: 'mingw32',
84               msys_env: 'i686',
85               shell: 'msys2 {0}'
86             }
87
88     defaults:
89       run:
90         working-directory: src
91         shell: ${{ matrix.config.shell }}
92     steps:
93       - uses: actions/checkout@v2
94         with:
95           fetch-depth: 0
96
97       - name: Download required linux packages
98         if: runner.os == 'Linux'
99         run: |
100           sudo apt update
101           sudo apt install expect valgrind g++-multilib
102
103       - name: Setup msys and install required packages
104         if: runner.os == 'Windows'
105         uses: msys2/setup-msys2@v2
106         with:
107           msystem: ${{matrix.config.msys_sys}}
108           install: mingw-w64-${{matrix.config.msys_env}}-gcc make git expect
109
110       - name: Download the used network from the fishtest framework
111         run: |
112           make net
113
114       - name: Extract the bench number from the commit history
115         run: |
116           git log HEAD | grep "\b[Bb]ench[ :]\+[0-9]\{7\}" | head -n 1 | sed "s/[^0-9]*\([0-9]*\).*/\1/g" > git_sig
117           [ -s git_sig ] && echo "benchref=$(cat git_sig)" >> $GITHUB_ENV && echo "Reference bench:" $(cat git_sig) || echo "No bench found"
118
119       - name: Check compiler
120         run: |
121           $COMPILER -v
122
123       - name: Test help target
124         run: |
125           make help
126
127       # x86-32 tests
128
129       - name: Test debug x86-32 build
130         if: ${{ matrix.config.run_32bit_tests }}
131         run: |
132           export CXXFLAGS="-Werror -D_GLIBCXX_DEBUG"
133           make clean
134           make -j2 ARCH=x86-32 optimize=no debug=yes build
135           ../tests/signature.sh $benchref
136
137       - name: Test x86-32 build
138         if: ${{ matrix.config.run_32bit_tests }}
139         run: |
140           make clean
141           make -j2 ARCH=x86-32 build
142           ../tests/signature.sh $benchref
143
144       - name: Test x86-32-sse41-popcnt build
145         if: ${{ matrix.config.run_32bit_tests }}
146         run: |
147           make clean
148           make -j2 ARCH=x86-32-sse41-popcnt build
149           ../tests/signature.sh $benchref
150
151       - name: Test x86-32-sse2 build
152         if: ${{ matrix.config.run_32bit_tests }}
153         run: |
154           make clean
155           make -j2 ARCH=x86-32-sse2 build
156           ../tests/signature.sh $benchref
157
158       - name: Test general-32 build
159         if: ${{ matrix.config.run_32bit_tests }}
160         run: |
161           make clean
162           make -j2 ARCH=general-32 build
163           ../tests/signature.sh $benchref
164
165       # x86-64 tests
166
167       - name: Test debug x86-64-modern build
168         if: ${{ matrix.config.run_64bit_tests }}
169         run: |
170           export CXXFLAGS="-Werror -D_GLIBCXX_DEBUG"
171           make clean
172           make -j2 ARCH=x86-64-modern optimize=no debug=yes build
173           ../tests/signature.sh $benchref
174
175       - name: Test x86-64-modern build
176         if: ${{ matrix.config.run_64bit_tests }}
177         run: |
178           make clean
179           make -j2 ARCH=x86-64-modern build
180           ../tests/signature.sh $benchref
181
182       - name: Test x86-64-ssse3 build
183         if: ${{ matrix.config.run_64bit_tests }}
184         run: |
185           make clean
186           make -j2 ARCH=x86-64-ssse3 build
187           ../tests/signature.sh $benchref
188
189       - name: Test x86-64-sse3-popcnt build
190         if: ${{ matrix.config.run_64bit_tests }}
191         run: |
192           make clean
193           make -j2 ARCH=x86-64-sse3-popcnt build
194           ../tests/signature.sh $benchref
195
196       - name: Test x86-64 build
197         if: ${{ matrix.config.run_64bit_tests }}
198         run: |
199           make clean
200           make -j2 ARCH=x86-64 build
201           ../tests/signature.sh $benchref
202
203       - name: Test general-64 build
204         if: matrix.config.run_64bit_tests
205         run: |
206           make clean
207           make -j2 ARCH=general-64 build
208           ../tests/signature.sh $benchref
209
210       # x86-64 with newer extensions tests
211
212       - name: Compile x86-64-avx2 build
213         if: ${{ matrix.config.run_64bit_tests }}
214         run: |
215           make clean
216           make -j2 ARCH=x86-64-avx2 build
217
218       - name: Compile x86-64-bmi2 build
219         if: ${{ matrix.config.run_64bit_tests }}
220         run: |
221           make clean
222           make -j2 ARCH=x86-64-bmi2 build
223
224       - name: Compile x86-64-avx512 build
225         if: ${{ matrix.config.run_64bit_tests }}
226         run: |
227           make clean
228           make -j2 ARCH=x86-64-avx512 build
229
230       - name: Compile x86-64-vnni512 build
231         if: ${{ matrix.config.run_64bit_tests }}
232         run: |
233           make clean
234           make -j2 ARCH=x86-64-vnni512 build
235
236       - name: Compile x86-64-vnni256 build
237         if: ${{ matrix.config.run_64bit_tests }}
238         run: |
239           make clean
240           make -j2 ARCH=x86-64-vnni256 build
241
242       # Other tests
243
244       - name: Check perft and search reproducibility
245         if: ${{ matrix.config.run_64bit_tests }}
246         run: |
247           make clean
248           make -j2 ARCH=x86-64-modern build
249           ../tests/perft.sh
250           ../tests/reprosearch.sh
251
252       # Sanitizers
253
254       - name: Run under valgrind
255         if: ${{ matrix.config.run_expensive_tests }}
256         run: |
257           export CXXFLAGS="-O1 -fno-inline"
258           make clean
259           make -j2 ARCH=x86-64-modern debug=yes optimize=no build > /dev/null
260           ../tests/instrumented.sh --valgrind
261           ../tests/instrumented.sh --valgrind-thread
262
263       - name: Run with UB sanitizer
264         if: ${{ matrix.config.run_expensive_tests }}
265         run: |
266           export CXXFLAGS="-O1 -fno-inline"
267           make clean
268           make -j2 ARCH=x86-64-modern sanitize=undefined optimize=no debug=yes build > /dev/null
269           ../tests/instrumented.sh --sanitizer-undefined
270
271       - name: Run with thread sanitizer
272         if: ${{ matrix.config.run_expensive_tests }}
273         run: |
274           export CXXFLAGS="-O1 -fno-inline"
275           make clean
276           make -j2 ARCH=x86-64-modern sanitize=thread optimize=no debug=yes build > /dev/null
277           ../tests/instrumented.sh --sanitizer-thread