Skip to content

Commit 9756c46

Browse files
authored
Merge pull request #7732 from vvbandeira/bazel-early
ci: run Bazel earlier
2 parents 9bde810 + ca0ab31 commit 9756c46

File tree

2 files changed

+73
-39
lines changed

2 files changed

+73
-39
lines changed

Jenkinsfile

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
withCredentials([file(credentialsId: 'bazel-cache-sa', variable: 'GCS_SA_KEY')]) {
175-
timeout(time: 120, unit: 'MINUTES') {
176-
def cmd = 'bazelisk test --config=ci --show_timestamps --test_output=errors --curses=no --force_pic'
177-
178-
if (env.BRANCH_NAME != 'master') {
179-
cmd += ' --remote_upload_local_results=false'
180-
}
181-
182-
sh label: 'Bazel Build', script: cmd + ' --google_credentials=$GCS_SA_KEY ...'
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,31 @@ 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+
stage ('Build with Bazel') {
254+
node {
255+
stage('Setup Bazel Build') {
256+
checkout scm;
257+
sh label: 'Setup Docker Image', script: 'docker build -f docker/Dockerfile.bazel -t openroad/bazel-ci .';
258+
}
259+
withDockerContainer(args: '-u root -v /var/run/docker.sock:/var/run/docker.sock', image: 'openroad/bazel-ci:latest') {
260+
stage('Bazel Build') {
261+
withCredentials([file(credentialsId: 'bazel-cache-sa', variable: 'GCS_SA_KEY')]) {
262+
timeout(time: 120, unit: 'MINUTES') {
263+
def cmd = 'bazelisk test --config=ci --show_timestamps --test_output=errors --curses=no --force_pic';
264+
if (env.BRANCH_NAME != 'master') {
265+
cmd += ' --remote_upload_local_results=false';
266+
}
267+
sh label: 'Bazel Build', script: cmd + ' --google_credentials=$GCS_SA_KEY ...';
268+
}
269+
}
270+
}
271+
}
272+
}
273+
}
274+
}
287275

288-
numToKeepStr: numToKeep,
289-
artifactNumToKeepStr: numToKeep
290-
))
291-
]);
276+
def dockerTests = {
292277
stage('Checkout') {
293278
checkout scm;
294279
}
@@ -317,6 +302,24 @@ node {
317302
echo "Docker image is ${DOCKER_IMAGE}";
318303
}
319304
parallel(getParallelTests(DOCKER_IMAGE));
305+
}
306+
307+
node {
308+
def isDefaultBranch = (env.BRANCH_NAME == 'master')
309+
def daysToKeep = '20';
310+
def numToKeep = (isDefaultBranch ? '-1' : '10');
311+
properties([
312+
buildDiscarder(logRotator(
313+
daysToKeepStr: daysToKeep,
314+
artifactDaysToKeepStr: daysToKeep,
315+
numToKeepStr: numToKeep,
316+
artifactNumToKeepStr: numToKeep
317+
))
318+
]);
319+
parallel(
320+
"Bazel Tests": bazelTest,
321+
"Docker Tests": dockerTests
322+
);
320323
stage('Send Email Report') {
321324
sendEmail();
322325
}

docker/Dockerfile.bazel

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
FROM ubuntu:24.04
2+
3+
ENV DEBIAN_FRONTEND=noninteractive
4+
5+
RUN apt-get -y update \
6+
&& apt-get -y install curl git
7+
8+
RUN curl -Lo bazelisk https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-amd64 \
9+
&& chmod +x bazelisk \
10+
&& mv bazelisk /usr/local/bin/bazelisk
11+
12+
RUN install -m 0755 -d /etc/apt/keyrings \
13+
&& curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
14+
-o /etc/apt/keyrings/docker.asc \
15+
&& chmod a+r /etc/apt/keyrings/docker.asc \
16+
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
17+
$(. /etc/os-release && echo "${VERSION_CODENAME}") stable" | \
18+
tee /etc/apt/sources.list.d/docker.list > /dev/null
19+
20+
RUN apt-get -y update \
21+
&& apt-get -y install --no-install-recommends \
22+
build-essential \
23+
clang \
24+
containerd.io \
25+
docker-buildx-plugin \
26+
docker-ce \
27+
docker-ce-cli \
28+
openjdk-21-jre-headless \
29+
python3 \
30+
python3-yaml \
31+
time

0 commit comments

Comments
 (0)