Debian Codegraph @

Documentation/infrastructure/builders.md

raw symbols SCIP
1 # Jenkins builder setup and configuration
2
3 ## How to set up a new jenkins builder
4
5 ### Contact a jenkins admin
6
7 Let a jenkins admin know that you’re interested in setting up a jenkins
8 build system.
9
10 For a permanent build system, this should generally be a dedicated
11 machine workstation or server class machine that is not generally being
12 used for other purposes. The coreboot builds are very intensive.
13
14 It's also best to be aware that although we don't know of any security
15 issues, the jenkins-node image is run with the privileged flag which
16 gives the container root access to the build machine. See
17 [this article](https://blog.trendmicro.com/trendlabs-security-intelligence/why-running-a-privileged-container-in-docker-is-a-bad-idea/)
18 about why this is discouraged.
19
20 It's recommended that you give an admin root access on your machine so
21 that they can reset it in case of a failure. This is not a requirement,
22 as the system can just be disabled until someone is available to fix any
23 issues.
24
25 Currently active Jenkins admins:
26 * Martin Roth:
27 * Email: [[email protected]](mailto:[email protected])
28 * IRC: martinr
29
30 ### Build Machine requirements
31
32 For a builder, we need a very fast system with lots of threads and
33 plenty of RAM. The builder builds and stores the git repos and output
34 in tmpfs along with the ccache save area, so if there isn't enough
35 memory, the builds will slow down because of smaller ccache areas and
36 can run into "out of storage space" errors.
37
38 #### Current Build Machines
39
40 To give an idea of what a suitable build machine might be, currently the
41 coreboot project has 6 active jenkins build machines.
42
43 These times are taken from the week of Feb 21 - Feb 28, 2022
44
45 * Congenialbuilder - 128 threads, 256GiB RAM
46 * Coverity Builds, Toolchain builds, Scanbuild-builds
47 * Fastest Passing coreboot gerrit build: 6 min, 47 sec
48 * Slowest Passing coreboot gerrit build: 14 min
49
50 * Gleefulbuilder - 64 threads, 64GiB RAM
51 * Fastest Passing coreboot gerrit build: 10 min
52 * Slowest Passing coreboot gerrit build: 46 min
53
54 * Fabulousbuilder - 64 threads, 64GiB RAM
55 * Fastest Passing coreboot gerrit build: 7 min, 56 sec
56 * Slowest Passing coreboot gerrit build: 56 min (No ccache)
57
58 * Ultron (9elements) - 48 threads, 128GiB RAM
59 * Fastest Passing coreboot gerrit build: 12 min
60 * Slowest Passing coreboot gerrit build: 58 min
61
62 * Bob - 64 threads, 128GiB RAM
63 * Fastest Passing coreboot gerrit build: 7 min
64 * Slowest Passing coreboot gerrit build: 34 min
65
66 * Pokeybuilder - 32 Threads, 96GiB RAM
67 * Runs coreboot-checkpatch and other lighter builds
68
69
70 ### Jenkins Builds
71
72 There are a number of builds handled by the coreboot jenkins builders,
73 for a number of different projects - coreboot, flashrom, memtest86+,
74 em100, etc. Many of these have builders for their current main branch
75 as well as Gerrit and [Coverity](coverity.md) builds.
76
77
78 #### Long builds - over 90 minutes on congenialbuilder
79 There are a few builds that take a long time even on the fastest
80 machines. These tasks run overnight in the US timezones.
81 * coreboot_coverity - 9 to 12 hours
82 * coreboot_scanbuild - ~3 hours
83 * coreboot_toolchain - ~1 hour 45 minutes
84
85
86 #### All builds
87
88 You can see all the builds in the main jenkins interface:
89 [https://qa.coreboot.org/](https://qa.coreboot.org/)
90
91 Most of the time on the builders is taken up by the coreboot main and
92 coreboot gerrit builds.
93
94 * [coreboot gerrit build](https://qa.coreboot.org/job/coreboot-gerrit/)
95 ([Time trend](https://qa.coreboot.org/job/coreboot-gerrit/buildTimeTrend))
96
97
98 * [coreboot main build](https://qa.coreboot.org/job/coreboot/)
99 ([Time trend](https://qa.coreboot.org/job/coreboot/buildTimeTrend))
100
101
102 ### Stress test the machine
103
104 Test the machine to make sure that building won't stress the hardware
105 too much. Install stress-ng, then run the stress test for at least an
106 hour.
107
108 On a system with 32 cores, it was tested with this command:
109
110 ```sh
111 stress-ng --cpu 20 --io 6 --vm 6 --vm-bytes 1G --verify --metrics-brief -t 60m
112 ```
113
114 You can watch the temperature with the sensors package or with ‘acpi -t’
115 if your machine supports that.
116
117 You can check for thermal throttling by running this command and seeing
118 if the values go down on any of the cores after it's been running for a
119 while.
120
121 ```sh
122 while [ true ]; do clear; cat /proc/cpuinfo | grep 'cpu MHz' ; sleep 1; done
123 ```
124
125 If the machine throttles or resets, you probably need to upgrade the
126 cooling system.
127
128
129 ## jenkins-server docker installation
130
131
132 ### Manual Installation
133
134 If you’ve met all the above requirements, and an admin has agreed to set
135 up the builder in jenkins, you’re ready to go on to the next steps.
136
137
138 ### Set up your network so jenkins can talk to the container
139
140 Expose a local port through any firewalls you might have on your router.
141 This would generally be in the port forwarding section, and you'd just
142 forward a port (typically 49151) from the internet directly to the
143 builder’s IP address.
144
145 You might also want to set up a port to forward to port 22 on your
146 machine and set up openssh so you or the jenkins admins can manage
147 the machine remotely (if you allow them).
148
149
150 ### Install and set up docker
151
152 Install docker by following [the
153 directions](https://docs.docker.com/engine/install/) on the docker site.
154 These instructions keep changing, so just check the latest information.
155
156
157 ### Set up the system for the jenkins builder
158
159 As a regular user - *Not root*, run:
160
161 ```sh
162 sudo mkdir -p ${COREBOOT_JENKINS_CACHE_DIR}
163 sudo mkdir -p ${COREBOOT_JENKINS_CCACHE_DIR}
164 sudo chown $(whoami):$(whoami) ${COREBOOT_JENKINS_CCACHE_DIR}
165 sudo chown $(whoami):$(whoami) ${COREBOOT_JENKINS_CACHE_DIR}
166 wget http://www.dediprog.com/save/78.rar/to/EM100Pro.rar
167 mv EM100Pro.rar ${COREBOOT_JENKINS_CACHE_DIR}
168 ```
169
170
171 #### Set up environment variables
172
173 To make configuration and the later commands easier, these should go in
174 your shell's .rc file. Note that you only need to set them if you're
175 using something other than the default.
176
177 ```sh
178 # Set the port used on your machine to connect to jenkins.
179 export COREBOOT_JENKINS_PORT=49151
180
181 # Set the revision of the container from [docker hub](https://hub.docker.com/repository/docker/coreboot/coreboot-sdk)
182 export DOCKER_COMMIT=2021-09-23_b0d87f753c
183
184 # Set the location of where the jenkins cache directory will be.
185 export COREBOOT_JENKINS_CACHE_DIR="/srv/docker/coreboot-builder/cache"
186
187 # Set the name of the container
188 export COREBOOT_JENKINS_CONTAINER="coreboot_jenkins"
189 ```
190
191 Make sure any variables needed are set in your environment before
192 continuing to the next step.
193
194
195 ### Using the Makefile for docker installation
196
197 From the coreboot directory, run
198
199 ```sh
200 make -C util/docker help
201 ```
202
203 This will show you the available targets and variables needed:
204
205 ```text
206 Commands for working with docker images:
207 coreboot-sdk - Build coreboot-sdk container
208 upload-coreboot-sdk - Upload coreboot-sdk to hub.docker.com
209 coreboot-jenkins-node - Build coreboot-jenkins-node container
210 upload-coreboot-jenkins-node - Upload coreboot-jenkins-node to hub.docker.com
211 doc.coreboot.org - Build doc.coreboot.org container
212 clean-coreboot-containers - Remove all docker coreboot containers
213 clean-coreboot-images - Remove all docker coreboot images
214 docker-clean - Remove docker coreboot containers & images
215
216 Commands for using docker images
217 docker-build-coreboot - Build coreboot under coreboot-sdk
218 <BUILD_CMD=target>
219 docker-abuild - Run abuild under coreboot-sdk
220 <ABUILD_ARGS='-a -B'>
221 docker-what-jenkins-does - Run 'what-jenkins-does' target
222 docker-shell - Bash prompt in coreboot-jenkins-node
223 <USER=root or USER=coreboot>
224 docker-jenkins-server - Run coreboot-jenkins-node image (for server)
225 docker-jenkins-attach - Open shell in running jenkins server
226 docker-build-docs - Build the documentation
227 docker-livehtml-docs - Run sphinx-autobuild
228
229 Variables:
230 COREBOOT_JENKINS_PORT=49151
231 COREBOOT_JENKINS_CACHE_DIR=/srv/docker/coreboot-builder/cache
232 COREBOOT_JENKINS_CONTAINER=coreboot_jenkins
233 COREBOOT_IMAGE_TAG=f2741aa632f
234 DOCKER_COMMIT=65718760fa
235 ```
236
237
238 ### Install the coreboot jenkins builder
239
240 ```sh
241 make -C util/docker docker-jenkins-server
242 ```
243
244 Your installation is complete on your side.
245
246 ### Tell the Admins that the machine is set up
247 Let the admins know that the builder is set up so they can set up the
248 machine profile on qa.coreboot.org.
249
250 They need to know:
251 * Your external IP address or domain name. If you don’t have a static
252 IP, make sure you have a dynamic dns hostname configured.
253 * The port on your machine and firewall that’s exposed for jenkins:
254 `$COREBOOT_JENKINS_PORT`
255 * The core count of the machine.
256 * How much memory is available on the machine. This helps determine
257 the amount of memory used for ccache.
258
259
260 ### First build
261 On the first build after a machine is reset, it will frequently take
262 an hour to do the entire what-jenkins-does build while the ccache
263 is getting filled up and the entire coreboot repo gets downloaded. As
264 the ccache gets populated, the build time will drop.
265
266
267 ## Additional Information
268
269
270 ### How to log in to the docker instance for debugging
271
272 ```sh
273 make -C util/docker docker-jenkins-attach
274 su coreboot
275 cd ~/slave-root/workspace
276 bash
277 ```
278
279
280 WARNING: This should not be used to make changes to the build system,
281 but just to debug issues. Changes to the build system image are highly
282 discouraged as it leads to situations where patches can pass the build
283 testing on one builder and fail on another builder. Any changes that are
284 made in the image will be lost on the next update, so if you
285 accidentally change something, you can remove the containers and images,
286 then update to get a fresh installation.
287
288
289 ### How to download containers/images for a fresh installation and remove old containers
290
291 To delete the old containers & images:
292
293 ```sh
294 docker stop $COREBOOT_JENKINS_CONTAINER
295 docker rm $COREBOOT_JENKINS_CONTAINER
296 docker images # lists all existing images
297 docker rmi XXXX # Use the image ID found in the above command.
298 ```
299
300 To get and run the new coreboot-jenkins image, change the value in the
301 `DOCKER_COMMIT` variable to the new image value.
302
303 ```sh
304 make -C util/docker docker-jenkins-server
305 ```
306
307 #### Getting ready to push the docker images
308
309 Set up an account on hub.docker.com
310
311 Get an admin to add the account to the coreboot team on hub.docker.com
312
313 [https://hub.docker.com/u/coreboot/dashboard/teams/?team=owners](https://hub.docker.com/u/coreboot/dashboard/teams/?team=owners)
314
315 Make sure your credentials are configured on your host machine by
316 running
317
318 ```sh
319 docker login
320 ```
321
322 This will prompt you for your docker username, password, and your email
323 address, and write out to ~/.docker/config.json. Without this file, you
324 won’t be able to push the images.
325
326 #### Updating the Dockerfiles
327
328 The coreboot-sdk Dockerfile will need to be updated when any additional
329 dependencies are added. Both the coreboot-sdk and the
330 coreboot-jenkins-node Dockerfiles will need to be updated to the new
331 version number and git commit id anytime the toolchain is updated. Both
332 files are stored in the coreboot repo under coreboot/util/docker.
333
334 Read the [dockerfile best practices](https://docs.docker.com/v1.8/articles/dockerfile_best-practices/)
335 page before updating the files.
336
337 #### Rebuilding the coreboot-sdk docker image to update the toolchain
338
339 ```sh
340 make -C util/docker coreboot-sdk
341 ```
342
343 This takes a relatively long time.
344
345 #### Test the coreboot-sdk docker image
346
347 There are two methods of running the docker image - interactively as a
348 shell, or doing the build directly. Running interactively as a shell is
349 useful for early testing, because it allows you to update the image
350 (without any changes getting saved) and re-test builds. This saves the
351 time of having to rebuild the image for every issue you find.
352
353 #### Running the docker image interactively
354
355 Run:
356
357 ```sh
358 make -C util/docker docker-jenkins-server
359 make -C util/docker docker-jenkins-attach
360 ```
361
362 #### Running the build directly
363
364 From the coreboot directory:
365
366 ```sh
367 make -C util/docker docker-build-coreboot
368 ```
369
370 You’ll also want to test building the other projects and payloads:
371 ChromeEC, flashrom, memtest86+, em100, Grub2, SeaBIOS, iPXE, coreinfo,
372 nvramcui, tint...
373
374 #### Pushing the coreboot-sdk image to hub.docker.com for use
375
376 When you’re satisfied with the testing, push the coreboot-sdk image to
377 the hub.docker.com
378
379 ```sh
380 make -C util/docker upload-coreboot-sdk
381 ```
382
383 #### Building and pushing the coreboot-jenkins-node docker image
384
385 This docker image is pretty simple, so there’s not really any testing
386 that needs to be done.
387
388 ```sh
389 make -C util/docker coreboot-jenkins-node
390 make -C util/docker upload-coreboot-jenkins-node
391 ```
392
393 ### Coverity Setup
394
395 To run coverity jobs, the builder needs to have the tools available, and
396 to be marked as a coverity builder.
397
398
399 #### Set up the Coverity tools
400
401 Download the Linux-64 coverity build tool and decompress it into your
402 cache directory as defined by the `$COREBOOT_JENKINS_CACHE_DIR` variable
403 on the jenkins server.
404
405 [https://scan.coverity.com/download](https://scan.coverity.com/download)
406
407 Rename the directory from its original name
408 (cov-analysis-linux64-7.7.0.4) to ‘coverity’, or better, create a
409 symlink:
410
411 ```sh
412 ln -s cov-analysis-linux64-7.7.0.4 coverity
413 ```
414
415
416 Let the admins know that the ‘coverity’ label can be added to the
417 builder.