docs: piglit -> Piglit
[platform/upstream/mesa.git] / docs / ci / index.rst
1 Continuous Integration
2 ======================
3
4 GitLab CI
5 ---------
6
7 GitLab provides a convenient framework for running commands in response to Git pushes.
8 We use it to test merge requests (MRs) before merging them (pre-merge testing),
9 as well as post-merge testing, for everything that hits ``main``
10 (this is necessary because we still allow commits to be pushed outside of MRs,
11 and even then the MR CI runs in the forked repository, which might have been
12 modified and thus is unreliable).
13
14 The CI runs a number of tests, from trivial build-testing to complex GPU rendering:
15
16 - Build testing for a number of build systems, configurations and platforms
17 - Sanity checks (``meson test``)
18 - Some drivers (Softpipe, LLVMpipe, Freedreno and Panfrost) are also tested
19   using `VK-GL-CTS <https://github.com/KhronosGroup/VK-GL-CTS>`__
20 - Replay of application traces
21
22 A typical run takes between 20 and 30 minutes, although it can go up very quickly
23 if the GitLab runners are overwhelmed, which happens sometimes. When it does happen,
24 not much can be done besides waiting it out, or cancel it.
25
26 Due to limited resources, we currently do not run the CI automatically
27 on every push; instead, we only run it automatically once the MR has
28 been assigned to ``Marge``, our merge bot.
29
30 If you're interested in the details, the main configuration file is ``.gitlab-ci.yml``,
31 and it references a number of other files in ``.gitlab-ci/``.
32
33 If the GitLab CI doesn't seem to be running on your fork (or MRs, as they run
34 in the context of your fork), you should check the "Settings" of your fork.
35 Under "CI / CD" → "General pipelines", make sure "Custom CI config path" is
36 empty (or set to the default ``.gitlab-ci.yml``), and that the
37 "Public pipelines" box is checked.
38
39 If you're having issues with the GitLab CI, your best bet is to ask
40 about it on ``#freedesktop`` on OFTC and tag `Daniel Stone
41 <https://gitlab.freedesktop.org/daniels>`__ (``daniels`` on IRC) or
42 `Emma Anholt <https://gitlab.freedesktop.org/anholt>`__ (``anholt`` on
43 IRC).
44
45 The three GitLab CI systems currently integrated are:
46
47
48 .. toctree::
49    :maxdepth: 1
50
51    bare-metal
52    LAVA
53    docker
54
55 Application traces replay
56 -------------------------
57
58 The CI replays application traces with various drivers in two different jobs. The first
59 job replays traces listed in ``src/<driver>/ci/traces-<driver>.yml`` files and if any
60 of those traces fail the pipeline fails as well. The second job replays traces listed in
61 ``src/<driver>/ci/restricted-traces-<driver>.yml`` and it is allowed to fail. This second
62 job is only created when the pipeline is triggered by `marge-bot` or any other user that
63 has been granted access to these traces.
64
65 A traces YAML file also includes a ``download-url`` pointing to a MinIO
66 instance where to download the traces from. While the first job should always work with
67 publicly accessible traces, the second job could point to an URL with restricted access.
68
69 Restricted traces are those that have been made available to Mesa developers without a
70 license to redistribute at will, and thus should not be exposed to the public. Failing to
71 access that URL would not prevent the pipeline to pass, therefore forks made by
72 contributors without permissions to download non-redistributable traces can be merged
73 without friction.
74
75 As an aside, only maintainers of such non-redistributable traces are responsible for
76 ensuring that replays are successful, since other contributors would not be able to
77 download and test them by themselves.
78
79 Those Mesa contributors that believe they could have permission to access such
80 non-redistributable traces can request permission to Daniel Stone <daniels@collabora.com>.
81
82 gitlab.freedesktop.org accounts that are to be granted access to these traces will be
83 added to the OPA policy for the MinIO repository as per
84 https://gitlab.freedesktop.org/freedesktop/helm-gitlab-config/-/commit/a3cd632743019f68ac8a829267deb262d9670958 .
85
86 So the jobs are created in personal repositories, the name of the user's account needs
87 to be added to the rules attribute of the GitLab CI job that accesses the restricted
88 accounts.
89
90 .. toctree::
91    :maxdepth: 1
92
93    local-traces
94
95 Intel CI
96 --------
97
98 The Intel CI is not yet integrated into the GitLab CI.
99 For now, special access must be manually given (file a issue in
100 `the Intel CI configuration repo <https://gitlab.freedesktop.org/Mesa_CI/mesa_jenkins>`__
101 if you think you or Mesa would benefit from you having access to the Intel CI).
102 Results can be seen on `mesa-ci.01.org <https://mesa-ci.01.org>`__
103 if you are *not* an Intel employee, but if you are you
104 can access a better interface on
105 `mesa-ci-results.jf.intel.com <http://mesa-ci-results.jf.intel.com>`__.
106
107 The Intel CI runs a much larger array of tests, on a number of generations
108 of Intel hardware and on multiple platforms (X11, Wayland, DRM & Android),
109 with the purpose of detecting regressions.
110 Tests include
111 `Crucible <https://gitlab.freedesktop.org/mesa/crucible>`__,
112 `VK-GL-CTS <https://github.com/KhronosGroup/VK-GL-CTS>`__,
113 `dEQP <https://android.googlesource.com/platform/external/deqp>`__,
114 `Piglit <https://gitlab.freedesktop.org/mesa/piglit>`__,
115 `Skia <https://skia.googlesource.com/skia>`__,
116 `VkRunner <https://github.com/Igalia/vkrunner>`__,
117 `WebGL <https://github.com/KhronosGroup/WebGL>`__,
118 and a few other tools.
119 A typical run takes between 30 minutes and an hour.
120
121 If you're having issues with the Intel CI, your best bet is to ask about
122 it on ``#dri-devel`` on OFTC and tag `Nico Cortes
123 <https://gitlab.freedesktop.org/ngcortes>`__ (``ngcortes`` on IRC).
124
125 .. _CI-farm-expectations:
126
127 CI farm expectations
128 --------------------
129
130 To make sure that testing of one vendor's drivers doesn't block
131 unrelated work by other vendors, we require that a given driver's test
132 farm produces a spurious failure no more than once a week.  If every
133 driver had CI and failed once a week, we would be seeing someone's
134 code getting blocked on a spurious failure daily, which is an
135 unacceptable cost to the project.
136
137 Additionally, the test farm needs to be able to provide a short enough
138 turnaround time that we can get our MRs through marge-bot without the
139 pipeline backing up.  As a result, we require that the test farm be
140 able to handle a whole pipeline's worth of jobs in less than 15 minutes
141 (to compare, the build stage is about 10 minutes).
142
143 If a test farm is short the HW to provide these guarantees, consider dropping
144 tests to reduce runtime.  dEQP job logs print the slowest tests at the end of
145 the run, and Piglit logs the runtime of tests in the results.json.bz2 in the
146 artifacts.  Or, you can add the following to your job to only run some fraction
147 (in this case, 1/10th) of the dEQP tests.
148
149 .. code-block:: yaml
150
151     variables:
152       DEQP_FRACTION: 10
153
154 to just run 1/10th of the test list.
155
156 If a HW CI farm goes offline (network dies and all CI pipelines end up
157 stalled) or its runners are consistently spuriously failing (disk
158 full?), and the maintainer is not immediately available to fix the
159 issue, please push through an MR disabling that farm's jobs by adding
160 '.' to the front of the jobs names until the maintainer can bring
161 things back up.  If this happens, the farm maintainer should provide a
162 report to mesa-dev@lists.freedesktop.org after the fact explaining
163 what happened and what the mitigation plan is for that failure next
164 time.
165
166 Personal runners
167 ----------------
168
169 Mesa's CI is currently run primarily on packet.net's m1xlarge nodes
170 (2.2Ghz Sandy Bridge), with each job getting 8 cores allocated.  You
171 can speed up your personal CI builds (and marge-bot merges) by using a
172 faster personal machine as a runner.  You can find the gitlab-runner
173 package in Debian, or use GitLab's own builds.
174
175 To do so, follow `GitLab's instructions
176 <https://docs.gitlab.com/ce/ci/runners/#create-a-specific-runner>`__ to
177 register your personal GitLab runner in your Mesa fork.  Then, tell
178 Mesa how many jobs it should serve (``concurrent=``) and how many
179 cores those jobs should use (``FDO_CI_CONCURRENT=``) by editing these
180 lines in ``/etc/gitlab-runner/config.toml``, for example::
181
182   concurrent = 2
183
184   [[runners]]
185     environment = ["FDO_CI_CONCURRENT=16"]
186
187
188 Docker caching
189 --------------
190
191 The CI system uses Docker images extensively to cache
192 infrequently-updated build content like the CTS.  The `freedesktop.org
193 CI templates
194 <https://gitlab.freedesktop.org/freedesktop/ci-templates/>`_ help us
195 manage the building of the images to reduce how frequently rebuilds
196 happen, and trim down the images (stripping out manpages, cleaning the
197 apt cache, and other such common pitfalls of building Docker images).
198
199 When running a container job, the templates will look for an existing
200 build of that image in the container registry under
201 ``MESA_IMAGE_TAG``.  If it's found it will be reused, and if
202 not, the associated `.gitlab-ci/containers/<jobname>.sh`` will be run
203 to build it.  So, when developing any change to container build
204 scripts, you need to update the associated ``MESA_IMAGE_TAG`` to
205 a new unique string.  We recommend using the current date plus some
206 string related to your branch (so that if you rebase on someone else's
207 container update from the same day, you will get a Git conflict
208 instead of silently reusing their container)
209
210 When developing a given change to your Docker image, you would have to
211 bump the tag on each ``git commit --amend`` to your development
212 branch, which can get tedious.  Instead, you can navigate to the
213 `container registry
214 <https://gitlab.freedesktop.org/mesa/mesa/container_registry>`_ for
215 your repository and delete the tag to force a rebuild.  When your code
216 is eventually merged to main, a full image rebuild will occur again
217 (forks inherit images from the main repo, but MRs don't propagate
218 images from the fork into the main repo's registry).
219
220 Building locally using CI docker images
221 ---------------------------------------
222
223 It can be frustrating to debug build failures on an environment you
224 don't personally have.  If you're experiencing this with the CI
225 builds, you can use Docker to use their build environment locally.  Go
226 to your job log, and at the top you'll see a line like::
227
228     Pulling docker image registry.freedesktop.org/anholt/mesa/debian/android_build:2020-09-11
229
230 We'll use a volume mount to make our current Mesa tree be what the
231 Docker container uses, so they'll share everything (their build will
232 go in _build, according to ``meson-build.sh``).  We're going to be
233 using the image non-interactively so we use ``run --rm $IMAGE
234 command`` instead of ``run -it $IMAGE bash`` (which you may also find
235 useful for debug).  Extract your build setup variables from
236 .gitlab-ci.yml and run the CI meson build script:
237
238 .. code-block:: console
239
240     IMAGE=registry.freedesktop.org/anholt/mesa/debian/android_build:2020-09-11
241     sudo docker pull $IMAGE
242     sudo docker run --rm -v `pwd`:/mesa -w /mesa $IMAGE env PKG_CONFIG_PATH=/usr/local/lib/aarch64-linux-android/pkgconfig/:/android-ndk-r21d/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/pkgconfig/ GALLIUM_DRIVERS=freedreno UNWIND=disabled EXTRA_OPTION="-D android-stub=true -D llvm=disabled" DRI_LOADERS="-D glx=disabled -D gbm=disabled -D egl=enabled -D platforms=android" CROSS=aarch64-linux-android ./.gitlab-ci/meson-build.sh
243
244 All you have left over from the build is its output, and a _build
245 directory.  You can hack on mesa and iterate testing the build with:
246
247 .. code-block:: console
248
249     sudo docker run --rm -v `pwd`:/mesa $IMAGE ninja -C /mesa/_build
250
251
252 Conformance Tests
253 -----------------
254
255 Some conformance tests require a special treatment to be maintained on GitLab CI.
256 This section lists their documentation pages.
257
258 .. toctree::
259   :maxdepth: 1
260
261   skqp
262
263
264 Updating GitLab CI Linux Kernel
265 -------------------------------
266
267 GitLab CI usually runs a bleeding-edge kernel. The following documentation has
268 instructions on how to uprev Linux Kernel in the GitLab CI ecosystem.
269
270 .. toctree::
271   :maxdepth: 1
272
273   kernel