@@ -162,31 +162,6 @@ def getParallelTests(String image) {
162162 }
163163 },
164164
165- ' Build with Bazel' : {
166- node {
167- withDockerContainer(args : ' -u root -v /var/run/docker.sock:/var/run/docker.sock' , image : image) {
168- stage(' Setup Bazel Build' ) {
169- echo " Build with Bazel" ;
170- sh label : ' Configure git' , script : " git config --system --add safe.directory '*'" ;
171- checkout scm;
172- }
173- stage(' Bazel Build' ) {
174- timeout(time : 120 , unit : ' MINUTES' ) {
175- sh label : ' Bazel Build' , script : '''
176- bazel test \
177- --keep_going \
178- --show_timestamps \
179- --test_output=errors \
180- --curses=no \
181- --force_pic \
182- ...
183- ''' ;
184- }
185- }
186- }
187- }
188- },
189-
190165 ' Check message IDs' : {
191166 dir(' src' ) {
192167 sh label : ' Find duplicated message IDs' , script : ' ../etc/find_messages.py > messages.txt' ;
@@ -274,21 +249,35 @@ def getParallelTests(String image) {
274249 return ret;
275250}
276251
277- node {
278-
279- def isDefaultBranch = (env. BRANCH_NAME == ' master' )
280- def daysToKeep = ' 20' ;
281- def numToKeep = (isDefaultBranch ? ' -1' : ' 10' );
282-
283- properties([
284- buildDiscarder(logRotator(
285- daysToKeepStr : daysToKeep,
286- artifactDaysToKeepStr : daysToKeep,
252+ def bazelTest = {
253+ node {
254+ stage(' Setup' ) {
255+ checkout scm;
256+ sh label : ' Setup Docker Image' , script : ' docker build -f docker/Dockerfile.bazel -t openroad/bazel-ci .' ;
257+ }
258+ withDockerContainer(args : ' -u root -v /var/run/docker.sock:/var/run/docker.sock' , image : ' openroad/bazel-ci:latest' ) {
259+ stage(' bazelisk test ...' ) {
260+ withCredentials([file(credentialsId : ' bazel-cache-sa' , variable : ' GCS_SA_KEY' )]) {
261+ timeout(time : 120 , unit : ' MINUTES' ) {
262+ def cmd = ' bazelisk test --config=ci --show_timestamps --test_output=errors --curses=no --force_pic' ;
263+ if (env. BRANCH_NAME != ' master' ) {
264+ cmd + = ' --remote_upload_local_results=false' ;
265+ }
266+ cmd + = ' --google_credentials=$GCS_SA_KEY' ;
267+ try {
268+ sh label : ' Bazel Build' , script : cmd + ' ...' ;
269+ } catch (e) {
270+ currentBuild. result = ' FAILURE' ;
271+ sh label : ' Bazel Build (keep_going)' , script : cmd + ' --keep_going ...' ;
272+ }
273+ }
274+ }
275+ }
276+ }
277+ }
278+ }
287279
288- numToKeepStr : numToKeep,
289- artifactNumToKeepStr : numToKeep
290- ))
291- ]);
280+ def dockerTests = {
292281 stage(' Checkout' ) {
293282 checkout scm;
294283 }
@@ -317,6 +306,24 @@ node {
317306 echo " Docker image is ${ DOCKER_IMAGE} " ;
318307 }
319308 parallel(getParallelTests(DOCKER_IMAGE ));
309+ }
310+
311+ node {
312+ def isDefaultBranch = (env. BRANCH_NAME == ' master' )
313+ def daysToKeep = ' 20' ;
314+ def numToKeep = (isDefaultBranch ? ' -1' : ' 10' );
315+ properties([
316+ buildDiscarder(logRotator(
317+ daysToKeepStr : daysToKeep,
318+ artifactDaysToKeepStr : daysToKeep,
319+ numToKeepStr : numToKeep,
320+ artifactNumToKeepStr : numToKeep
321+ ))
322+ ]);
323+ parallel(
324+ " Bazel" : bazelTest,
325+ " Docker Tests" : dockerTests
326+ );
320327 stage(' Send Email Report' ) {
321328 sendEmail();
322329 }
0 commit comments