Add basic github workflow
[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             }
30           - {
31               name: "Ubuntu 20.04 Clang",
32               os: ubuntu-20.04,
33               compiler: clang++,
34               comp: clang,
35               run_expensive_tests: false
36             }
37
38     defaults:
39       run:
40         working-directory: src
41     steps:
42       - uses: actions/checkout@v2
43         with:
44           fetch-depth: 0
45
46       - name: Download required packages
47         run: |
48           sudo apt update
49           sudo apt install expect valgrind g++-multilib
50
51       - name: Download the used network from the fishtest framework
52         run: |
53           make net
54
55       - name: Extract the bench number from the commit history
56         run: |
57           git log HEAD | grep "\b[Bb]ench[ :]\+[0-9]\{7\}" | head -n 1 | sed "s/[^0-9]*\([0-9]*\).*/\1/g" > git_sig
58           [ -s git_sig ] && echo "benchref=$(cat git_sig)" >> $GITHUB_ENV && echo "Reference bench:" $(cat git_sig) || echo "No bench found"
59
60       - name: Check compiler
61         run: |
62           $COMPILER -v
63
64       - name: Test help target
65         run: |
66           make help
67
68       # x86-32 tests
69
70       - name: Test debug x86-32 build
71         run: |
72           export CXXFLAGS="-Werror -D_GLIBCXX_DEBUG"
73           make clean
74           make -j2 ARCH=x86-32 optimize=no debug=yes build
75           ../tests/signature.sh $benchref
76
77       - name: Test x86-32 build
78         run: |
79           make clean
80           make -j2 ARCH=x86-32 build
81           ../tests/signature.sh $benchref
82
83       - name: Test x86-32-sse41-popcnt build
84         run: |
85           make clean
86           make -j2 ARCH=x86-32-sse41-popcnt build
87           ../tests/signature.sh $benchref
88
89       - name: Test x86-32-sse2 build
90         run: |
91           make clean
92           make -j2 ARCH=x86-32-sse2 build
93           ../tests/signature.sh $benchref
94
95       - name: Test general-32 build
96         run: |
97           make clean
98           make -j2 ARCH=general-32 build
99           ../tests/signature.sh $benchref
100
101       # x86-64 tests
102
103       - name: Test debug x86-64-modern build
104         run: |
105           export CXXFLAGS="-Werror -D_GLIBCXX_DEBUG"
106           make clean
107           make -j2 ARCH=x86-64-modern optimize=no debug=yes build
108           ../tests/signature.sh $benchref
109
110       - name: Test x86-64-modern build
111         run: |
112           make clean
113           make -j2 ARCH=x86-64-modern build
114           ../tests/signature.sh $benchref
115
116       - name: Test x86-64-ssse3 build
117         run: |
118           make clean
119           make -j2 ARCH=x86-64-ssse3 build
120           ../tests/signature.sh $benchref
121
122       - name: Test x86-64-sse3-popcnt build
123         run: |
124           make clean
125           make -j2 ARCH=x86-64-sse3-popcnt build
126           ../tests/signature.sh $benchref
127
128       - name: Test x86-64 build
129         run: |
130           make clean
131           make -j2 ARCH=x86-64 build
132           ../tests/signature.sh $benchref
133
134       - name: Test general-64 build
135         run: |
136           make clean
137           make -j2 ARCH=general-64 build
138           ../tests/signature.sh $benchref
139
140       # x86-64 with newer extensions tests
141
142       - name: Compile x86-64-avx2 build
143         run: |
144           make clean
145           make -j2 ARCH=x86-64-avx2 build
146
147       - name: Compile x86-64-bmi2 build
148         run: |
149           make clean
150           make -j2 ARCH=x86-64-bmi2 build
151
152       - name: Compile x86-64-avx512 build
153         run: |
154           make clean
155           make -j2 ARCH=x86-64-avx512 build
156
157       - name: Compile x86-64-vnni512 build
158         run: |
159           make clean
160           make -j2 ARCH=x86-64-vnni512 build
161
162       - name: Compile x86-64-vnni256 build
163         run: |
164           make clean
165           make -j2 ARCH=x86-64-vnni256 build
166
167       # Other tests
168
169       - name: Check perft and search reproducibility
170         run: |
171           make clean
172           make -j2 ARCH=x86-64-modern build
173           ../tests/perft.sh
174           ../tests/reprosearch.sh
175
176       # Sanitizers
177
178       - name: Run under valgrind
179         if: ${{ matrix.config.run_expensive_tests }}
180         run: |
181           export CXXFLAGS="-O1 -fno-inline"
182           make clean
183           make -j2 ARCH=x86-64-modern debug=yes optimize=no build > /dev/null
184           ../tests/instrumented.sh --valgrind
185           ../tests/instrumented.sh --valgrind-thread
186
187       - name: Run with UB sanitizer
188         if: ${{ matrix.config.run_expensive_tests }}
189         run: |
190           export CXXFLAGS="-O1 -fno-inline"
191           make clean
192           make -j2 ARCH=x86-64-modern sanitize=undefined optimize=no debug=yes build > /dev/null
193           ../tests/instrumented.sh --sanitizer-undefined
194
195       - name: Run with thread sanitizer
196         if: ${{ matrix.config.run_expensive_tests }}
197         run: |
198           export CXXFLAGS="-O1 -fno-inline"
199           make clean
200           make -j2 ARCH=x86-64-modern sanitize=thread optimize=no debug=yes build > /dev/null
201           ../tests/instrumented.sh --sanitizer-thread