Debian Codegraph @

devel-docs/building_deps_in_ci.rst

raw
1 Building dependencies in CI
2 ===========================
3
4 **Status as of 2024/Sep/11:** implemented in :pr:`896`.
5 Non-Rust dependencies are built from git tags and installed in the CI
6 container image. See the ``ci/build-dependencies.sh`` script that
7 does this.
8
9 Preamble
10 --------
11
12 Until Sep/2023, librsvg's CI has worked by building a container image
13 out of a snapshot of openSUSE Tumbleweed, a rolling release, that has
14 all of librsvg's dependencies in it. What this means for runtime
15 dependencies like Cairo, Pango, etc. is that they come in a
16 "reasonably recent" version, but they are not pinned, and can change
17 any time that the rolling release decides to update them.
18
19 This is not entirely terrible: librsvg's run-time dependencies are all
20 stable, mature libraries that don't change very much. From librsvg's
21 viewpoint, the only trouble comes in situations like these:
22
23 * A library involved in text rendering changes something, and text
24 output changes slightly. The test suite breaks as a result, since
25 it assumes exact rendering based on reference images.
26
27 * Less often, a library involved in Bézier path rendering changes
28 something, and parts of the test suite break because antialiasing is
29 not the same as before.
30
31 * Someone runs librsvg's test suite with a different set of dependency
32 versions than the test suite assumes; a bunch of tests fail for
33 them, and they file bugs that are not very useful. In the best
34 case, they are using newer libraries and the bug reports let me (the
35 maintainer) know that I'll need to re-generate the test suite's
36 images soon. In the worst case, I just close those bugs since they
37 don't provide useful information.
38
39 And probably the biggest problem of all: I am never sure of exactly
40 what set of versions are okay for the test suite to work; I just
41 regenerate test reference files when they break after a CI update.
42
43 Pinning dependency versions
44 ---------------------------
45
46 Librsvg's CI needs to be able to build the library's dependencies in a
47 custom fashion, without necessarily assuming that the dependencies
48 come from system libraries. If we have that ability, then we can do a
49 few interesting things:
50
51 * Pin the versions of dependencies to a particular set, for example,
52 one that corresponds to a certain GNOME release. This is important
53 to keep CI working for old branches, so security patches are easy to
54 build.
55
56 * Compile the dependencies with a particular set of compiler options.
57 For example, for fuzzing, dependencies should be built with
58 sanitizers like asan/ubsan. For deep debugging, it would be nice to
59 have all the dependencies built in debug mode. For performance
60 testing, compile all the dependencies in release mode, etc.
61
62 Which dependencies? These ones; this list is already sorted in the
63 correct build order:
64
65 * glib
66 * gobject-introspection
67 * freetype2
68 * fontconfig
69 * cairo
70 * harfbuzz
71 * pango
72 * libxml2
73 * gdk-pixbuf
74
75 How do we achieve that?
76 -----------------------
77
78 **Option 1:** There is a script ``ci/build-dependencies.sh`` that can
79 already build librsvg's dependencies pinned to particular git tags.
80 In theory one can pass environment variables to change compiler
81 options; the script may need some tweaks to change the meson or
82 autotools invocations. The script builds and installs the
83 dependencies to a given prefix, and assumes that
84 ``PATH/LD_LIBRARY_PATH/PKG_CONFIG_PATH`` are tweaked to use things
85 from that prefix.
86
87 **Option 2:** Alternatively, we can outsource the problem and use
88 GNOME's BuildStream images. These correspond to specific releases of
89 the GNOME platform libraries, including librsvg's dependencies... and
90 librsvg itself, as it *is* a platform library. One must be a little
91 careful to keep the test suite from using the "system's" librsvg in
92 that case, but this is not a huge problem.
93
94 Implementation notes - building dependencies explicitly
95 -------------------------------------------------------
96
97 As of Sep/2023 the CI builds three main images:
98
99 * An image with the MSRV, just used to test the promise that the MSRV
100 can still build the library and its Rust dependencies.
101
102 * An image with a recent, stable Rust compiler - the main image used
103 for most jobs, and what I use for local development.
104
105 * An image with the nightly compiler. This is not updated frequently
106 since the whole CI doesn't regenerate its images nightly.
107
108 * (Other images for other architectures or distros, not in scope for
109 this discussion.)
110
111 All images have whatever RPM versions are available in openSUSE for
112 librsvg's runtime dependencies.
113
114 Proposed change:
115
116 * Keep a single image, pre-populated with ``rustup toolchain install
117 <version>`` for the MSRV, the stable compiler, and nightly. Select
118 the compiler version on a per-job basis; hopefully this will be fast
119 since ``toolchain`` should cache them.
120
121 * In that single image, keep pre-built sets of runtime dependencies
122 (e.g. libraries built from git tags) in at least two configurations:
123 the minimum supported versions, and the latest stable ones. These
124 configurations can live in different prefixes,
125 e.g. ``/usr/local/librsvg-minimum`` and
126 ``/usr/local/librsvg-stable``.
127
128 The idea is to ensure that the minimum-supported everything (rustc and
129 dependencies) actually works, in addition to testing the recent-stable
130 stuff.
131
132 Keeping everything in a single container image (versions of the Rust
133 toolchain, and sets of dependencies installed to different prefixes)
134 is just an optimization to build and maintain a single image, instead
135 of the three we have right now. If we determine that selecting
136 rustc/deps makes jobs too slow, we can go back to producing multiple
137 images.
138
139 Implementation note - BuildStream to test nightly dependencies
140 --------------------------------------------------------------
141
142 FIXME: alatiera's work goes here.
143
144 Other architectures, other distros
145 ----------------------------------
146
147 I'd like to keep an ``aarch64`` image; it has let us notice
148 peculiarities like the different signedness of ``libc::c_char``. It
149 doesn't need the minimum/stable/nightly distinction; we can keep it
150 stable-only as currently.
151
152 I think we can drop the Fedora image. It still runs Fedora 36, is
153 seldom updated, and I don't pay attention to it. I'd rather make it
154 possible to have explicit git versions of dependencies.
155