|
1 | | - |
2 | | - |
3 | | -def logHostname() { |
4 | | - sh label: "Running on ${env.NODE_NAME}", script: "echo 'Node context established.'" |
5 | | -} |
6 | | - |
7 | | -def baseTests(String image) { |
8 | | - Map base_tests = [failFast: false]; |
9 | | - |
10 | | - base_tests['Unit Tests CTest'] = { |
11 | | - withDockerContainer(args: '-u root', image: image) { |
12 | | - stage('Setup CTest') { |
13 | | - echo 'Nothing to be done.'; |
14 | | - } |
15 | | - stage('Unit Tests CTest') { |
16 | | - try { |
17 | | - catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { |
18 | | - timeout(time: 10, unit: 'MINUTES') { |
19 | | - sh label: 'Run ctest', script: 'ctest --test-dir build -j $(nproc) --output-on-failure'; |
20 | | - } |
21 | | - } |
22 | | - } catch (e) { |
23 | | - echo 'Failed regressions'; |
24 | | - currentBuild.result = 'FAILURE'; |
25 | | - } |
26 | | - sh label: 'Save ctest results', script: 'tar zcvf results-ctest.tgz build/Testing'; |
27 | | - sh label: 'Save results', script: "find . -name results -type d -exec tar zcvf {}.tgz {} ';'"; |
28 | | - archiveArtifacts artifacts: 'results-ctest.tgz, **/results.tgz'; |
29 | | - } |
30 | | - } |
31 | | - } |
32 | | - |
33 | | - def flow_tests = [ |
34 | | - 'aes_nangate45', |
35 | | - 'gcd_nangate45', |
36 | | - 'tinyRocket_nangate45', |
37 | | - 'aes_sky130hd', |
38 | | - 'gcd_sky130hd', |
39 | | - 'ibex_sky130hd', |
40 | | - 'jpeg_sky130hd', |
41 | | - 'aes_sky130hs', |
42 | | - 'gcd_sky130hs', |
43 | | - 'ibex_sky130hs', |
44 | | - 'jpeg_sky130hs' |
45 | | - ]; |
46 | | - |
47 | | - flow_tests.each { current_test -> |
48 | | - base_tests["Flow Test - ${current_test}"] = { |
49 | | - node { |
50 | | - logHostname() |
51 | | - withDockerContainer(args: '-u root', image: image) { |
52 | | - stage("Setup ${current_test}") { |
53 | | - sh label: 'Configure git', script: "git config --system --add safe.directory '*'"; |
54 | | - checkout scm; |
55 | | - unstash 'install'; |
56 | | - } |
57 | | - stage("Flow Test - ${current_test}") { |
58 | | - try { |
59 | | - catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { |
60 | | - timeout(time: 1, unit: 'HOURS') { |
61 | | - sh label: "Flow ${current_test}", script: "./test/regression ${current_test}"; |
62 | | - } |
63 | | - } |
64 | | - } |
65 | | - catch (e) { |
66 | | - echo 'Failed regressions'; |
67 | | - currentBuild.result = 'FAILURE'; |
68 | | - } |
69 | | - sh label: "Save ${current_test} results", script: "find . -name results -type d -exec tar zcvf ${current_test}.tgz {} ';'"; |
70 | | - archiveArtifacts artifacts: "${current_test}.tgz"; |
71 | | - } |
72 | | - } |
73 | | - } |
74 | | - } |
75 | | - } |
76 | | - |
77 | | - return base_tests; |
78 | | - |
79 | | -} |
80 | | - |
81 | | -def getParallelTests(String image) { |
82 | | - |
83 | | - def ret = [ |
84 | | - 'Docs Tester': { |
85 | | - node { |
86 | | - logHostname() |
87 | | - withDockerContainer(args: '-u root', image: image) { |
88 | | - stage('Setup Docs Test') { |
89 | | - echo "Setting up Docs Tester environment in ${image}"; |
90 | | - sh label: 'Configure git', script: "git config --system --add safe.directory '*'"; |
91 | | - checkout([ |
92 | | - $class: 'GitSCM', |
93 | | - branches: [[name: scm.branches[0].name]], |
94 | | - extensions: [[$class: 'SubmoduleOption', recursiveSubmodules: true]], |
95 | | - userRemoteConfigs: scm.userRemoteConfigs |
96 | | - ]); |
97 | | - } |
98 | | - stage('Run Docs Tests') { |
99 | | - sh label: 'Build messages', script: 'python3 docs/src/test/make_messages.py'; |
100 | | - sh label: 'Preprocess docs', script: 'cd docs && make preprocess -j$(nproc)'; |
101 | | - sh label: 'Run Tcl syntax parser', script: 'python3 docs/src/test/man_tcl_params.py'; |
102 | | - sh label: 'Run readme parser', script: 'cd docs && make clean && python3 src/test/readme_check.py'; |
103 | | - } |
104 | | - } |
105 | | - } |
106 | | - }, |
107 | | - |
108 | | - 'Build without GUI': { |
109 | | - node { |
110 | | - logHostname() |
111 | | - withDockerContainer(args: '-u root', image: image) { |
112 | | - stage('Setup no-GUI Build') { |
113 | | - echo "Build without GUI"; |
114 | | - sh label: 'Configure git', script: "git config --system --add safe.directory '*'"; |
115 | | - checkout scm; |
116 | | - } |
117 | | - stage('no-GUI Build') { |
118 | | - timeout(time: 20, unit: 'MINUTES') { |
119 | | - sh label: 'no-GUI Build', script: './etc/Build.sh -no-warnings -no-gui -dir=build-without-gui'; |
120 | | - } |
121 | | - } |
122 | | - } |
123 | | - } |
124 | | - }, |
125 | | - |
126 | | - 'Build without Test': { |
127 | | - node { |
128 | | - logHostname() |
129 | | - withDockerContainer(args: '-u root', image: image) { |
130 | | - stage('Setup no-test Build') { |
131 | | - echo "Build without Tests"; |
132 | | - sh label: 'Configure git', script: "git config --system --add safe.directory '*'"; |
133 | | - checkout scm; |
134 | | - } |
135 | | - stage('no-test Build') { |
136 | | - timeout(time: 20, unit: 'MINUTES') { |
137 | | - catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { |
138 | | - sh label: 'no-test Build', script: './etc/Build.sh -no-warnings -no-tests'; |
139 | | - } |
140 | | - } |
141 | | - sh 'mv build/openroad_build.log no_test.log' |
142 | | - archiveArtifacts artifacts: 'no_test.log'; |
143 | | - } |
144 | | - } |
145 | | - } |
146 | | - }, |
147 | | - |
148 | | - 'Build on RHEL8': { |
149 | | - node ('rhel8') { |
150 | | - logHostname() |
151 | | - stage('Setup RHEL8 Build') { |
152 | | - checkout scm; |
153 | | - } |
154 | | - stage('Build on RHEL8') { |
155 | | - catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { |
156 | | - timeout(time: 20, unit: 'MINUTES') { |
157 | | - sh label: 'Build on RHEL8', script: './etc/Build.sh 2>&1 | tee rhel8-build.log'; |
158 | | - } |
159 | | - } |
160 | | - archiveArtifacts artifacts: 'rhel8-build.log'; |
161 | | - } |
162 | | - stage('Unit Tests CTest') { |
163 | | - catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { |
164 | | - timeout(time: 10, unit: 'MINUTES') { |
165 | | - sh label: 'Run ctest', script: 'ctest --test-dir build -j $(nproc) --output-on-failure'; |
166 | | - } |
167 | | - } |
168 | | - sh label: 'Save ctest results', script: 'tar zcvf results-ctest-rhel8.tgz build/Testing'; |
169 | | - sh label: 'Save results', script: "find . -name results -type d -exec tar zcvf {}.tgz {} ';'"; |
170 | | - archiveArtifacts artifacts: 'results-ctest-rhel8.tgz, **/results.tgz'; |
171 | | - } |
172 | | - } |
173 | | - }, |
174 | | - |
175 | | - 'Check message IDs': { |
176 | | - dir('src') { |
177 | | - sh label: 'Find duplicated message IDs', script: '../etc/find_messages.py > messages.txt'; |
178 | | - archiveArtifacts artifacts: 'messages.txt'; |
179 | | - } |
180 | | - }, |
181 | | - |
182 | | - 'Unit Tests Ninja': { |
183 | | - node { |
184 | | - logHostname() |
185 | | - withDockerContainer(args: '-u root', image: image) { |
186 | | - stage('Setup Ninja Tests') { |
187 | | - sh label: 'Configure git', script: "git config --system --add safe.directory '*'"; |
188 | | - checkout scm; |
189 | | - } |
190 | | - stage('C++ Build and Unit Tests') { |
191 | | - sh label: 'C++ Build with Ninja', script: './etc/Build.sh -no-warnings -ninja'; |
192 | | - } |
193 | | - } |
194 | | - } |
195 | | - }, |
196 | | - |
197 | | - 'Build and Test': { |
198 | | - stage('Build and Stash bins') { |
199 | | - buildBinsOR(image, "-no-warnings"); |
200 | | - } |
201 | | - stage('Tests') { |
202 | | - parallel(baseTests(image)); |
203 | | - } |
204 | | - }, |
205 | | - |
206 | | - 'Compile with C++20': { |
207 | | - node { |
208 | | - logHostname() |
209 | | - withDockerContainer(args: '-u root', image: image) { |
210 | | - stage('Setup C++20 Compile') { |
211 | | - sh label: 'Configure git', script: "git config --system --add safe.directory '*'"; |
212 | | - checkout scm; |
213 | | - } |
214 | | - stage('Compile with C++20') { |
215 | | - sh label: 'Compile C++20', script: "./etc/Build.sh -cpp20" |
216 | | - } |
217 | | - } |
218 | | - } |
219 | | - } |
220 | | - ]; |
221 | | - |
222 | | - return ret; |
223 | | -} |
224 | | - |
225 | | -def bazelTest = { |
226 | | - node { |
227 | | - logHostname() |
228 | | - stage('Setup') { |
229 | | - checkout scm; |
230 | | - sh label: 'Setup Docker Image', script: 'docker build -f docker/Dockerfile.bazel -t openroad/bazel-ci .'; |
231 | | - } |
232 | | - try { |
233 | | - withDockerContainer(args: '-u root -v /var/run/docker.sock:/var/run/docker.sock', image: 'openroad/bazel-ci:latest') { |
234 | | - stage('bazelisk test ...') { |
235 | | - withCredentials([string(credentialsId: 'bazel-auth-token-b64', variable: 'BAZEL_AUTH_TOKEN_B64')]) { |
236 | | - timeout(time: 120, unit: 'MINUTES') { |
237 | | - def cmd = 'bazelisk test --config=ci --show_timestamps --test_output=errors --curses=no --force_pic --remote_header="Authorization=Basic $BAZEL_AUTH_TOKEN_B64" --profile=build.profile' |
238 | | - try { |
239 | | - try { |
240 | | - sh label: 'Test, using cached results and building a minimum of dependencies', script: cmd + ' ...'; |
241 | | - } finally { |
242 | | - sh label: 'Analyze build times', script: 'bazelisk analyze-profile build.profile'; |
243 | | - } |
244 | | - } catch (e) { |
245 | | - try { |
246 | | - sh label: 'Test (keep_going)', script: cmd + ' --keep_going ...'; |
247 | | - } catch (e2) { |
248 | | - currentBuild.result = 'FAILURE'; |
249 | | - } finally { |
250 | | - sh label: 'Analyze build times', script: 'bazelisk analyze-profile build.profile'; |
251 | | - } |
252 | | - } |
253 | | - } |
254 | | - } |
255 | | - } |
256 | | - } |
257 | | - } catch (IOException e) { |
258 | | - echo "Caught: ${e}"; |
259 | | - } |
260 | | - } |
261 | | -} |
262 | | - |
263 | | -def dockerTests = { |
264 | | - stage('Checkout') { |
265 | | - checkout scm; |
266 | | - } |
267 | | - def DOCKER_IMAGE; |
268 | | - stage('Build, Test and Push Docker Image') { |
269 | | - Map build_docker_images = [failFast: false]; |
270 | | - test_os = [ |
271 | | - [name: 'Ubuntu 20.04', base: 'ubuntu:20.04', image: 'ubuntu20.04'], |
272 | | - [name: 'Ubuntu 22.04', base: 'ubuntu:22.04', image: 'ubuntu22.04'], |
273 | | - [name: 'Ubuntu 24.04', base: 'ubuntu:24.04', image: 'ubuntu24.04'], |
274 | | - [name: 'RockyLinux 9', base: 'rockylinux:9', image: 'rockylinux9'], |
275 | | - [name: 'Debian 11', base: 'debian:11', image: 'debian11'] |
276 | | - ]; |
277 | | - test_os.each { os -> |
278 | | - build_docker_images["Test Installer - ${os.name}"] = { |
279 | | - node { |
280 | | - logHostname() |
281 | | - checkout scm; |
282 | | - sh label: 'Build Docker image', script: "./etc/DockerHelper.sh create -target=builder -os=${os.image}"; |
283 | | - sh label: 'Test Docker image', script: "./etc/DockerHelper.sh test -target=builder -os=${os.image} -smoke"; |
284 | | - dockerPush("${os.image}", 'openroad'); |
285 | | - } |
286 | | - } |
287 | | - } |
288 | | - parallel(build_docker_images); |
289 | | - DOCKER_IMAGE = dockerPush('ubuntu22.04', 'openroad'); |
290 | | - echo "Docker image is ${DOCKER_IMAGE}"; |
291 | | - } |
292 | | - parallel(getParallelTests(DOCKER_IMAGE)); |
293 | | -} |
294 | | - |
295 | | -node { |
296 | | - def isDefaultBranch = (env.BRANCH_NAME == 'master') |
297 | | - def daysToKeep = '20'; |
298 | | - def numToKeep = (isDefaultBranch ? '-1' : '10'); |
299 | | - properties([ |
300 | | - buildDiscarder(logRotator( |
301 | | - daysToKeepStr: daysToKeep, |
302 | | - artifactDaysToKeepStr: daysToKeep, |
303 | | - numToKeepStr: numToKeep, |
304 | | - artifactNumToKeepStr: numToKeep |
305 | | - )) |
306 | | - ]); |
307 | | - parallel( |
308 | | - "Bazel": bazelTest, |
309 | | - "Docker Tests": dockerTests |
310 | | - ); |
311 | | - stage('Send Email Report') { |
312 | | - sendEmail(); |
313 | | - } |
| 1 | +@Library('utils@main') _ |
| 2 | +node() { |
| 3 | + pipelineOR() |
314 | 4 | } |
0 commit comments