|
| 1 | +Package pipeline: multi configuration |
| 2 | +===================================== |
| 3 | + |
| 4 | +In the previous section we were building just 1 configuration. This section will cover the case in which we need to build more |
| 5 | +than 1 configuration. We will use the ``Release`` and ``Debug`` configurations here for convenience, as it is easier to |
| 6 | +follow, but in real case these configurations will be more like Windows, Linux, OSX, building for different architectures, |
| 7 | +cross building, etc. |
| 8 | + |
| 9 | +Let's begin cleaning our cache: |
| 10 | + |
| 11 | +.. code-block:: bash |
| 12 | +
|
| 13 | + $ conan remove "*" -c # Make sure no packages from last run |
| 14 | +
|
| 15 | +We will create the packages for the 2 configurations sequentially in our computer, but note these will typically run |
| 16 | +in different computers, so it is typical for CI systems to launch the builds of different configurations in parallel. |
| 17 | + |
| 18 | +.. code-block:: bash |
| 19 | + :caption: Release build |
| 20 | +
|
| 21 | + $ cd ai # If you were not inside "ai" folder already |
| 22 | + $ conan create . --build="missing:ai/*" -s build_type=Release --format=json > graph.json |
| 23 | + $ conan list --graph=graph.json --graph-binaries=build --format=json > built.json |
| 24 | +
|
| 25 | + $ conan remote enable packages |
| 26 | + $ conan upload -l=built.json -r=packages -c --format=json > uploaded_release.json |
| 27 | + $ conan remote disable packages |
| 28 | +
|
| 29 | +We have done a few changes and extra steps: |
| 30 | + |
| 31 | +- First step is similar to the one in the previous section, a ``conan create``, just making it explicit our configuration |
| 32 | + ``-s build_type=Release`` for clarity, and capturing the output of the ``conan create`` in a ``graph.json`` file. |
| 33 | +- The second step is create from the ``graph.json`` a ``built.json`` **package list** file, with the packages that needs to be uploaded, |
| 34 | + in this case, only the packages that have been built from source (``--graph-binaries=build``) will be uploaded. This is |
| 35 | + done for efficiency and faster uploads. |
| 36 | +- Third step is to enable the ``packages`` repository. It was not enabled to guarantee that al possible dependencies came from ``develop`` |
| 37 | + repo only. |
| 38 | +- Then, we will upload the ``built.json`` package list to the ``packages`` repository, creating the ``uploaded_release.json`` |
| 39 | + package list with the new location of the packages (the server repository). |
| 40 | +- Finally, we will disable again the ``packages`` repository |
| 41 | + |
| 42 | +Likewise, the Debug build will do the same steps: |
| 43 | + |
| 44 | + |
| 45 | +.. code-block:: bash |
| 46 | + :caption: Debug build |
| 47 | +
|
| 48 | + $ conan create . --build="missing:ai/*" -s build_type=Debug --format=json > graph.json |
| 49 | + $ conan list --graph=graph.json --graph-binaries=build --format=json > built.json |
| 50 | +
|
| 51 | + $ conan remote enable packages |
| 52 | + $ conan upload -l=built.json -r=packages -c --format=json > uploaded_debug.json |
| 53 | + $ conan remote disable packages |
| 54 | +
|
| 55 | +
|
| 56 | +When both Release and Debug configuration finish successfully, we would have these packages in the repositories: |
| 57 | + |
| 58 | +.. graphviz:: |
| 59 | + :align: center |
| 60 | + |
| 61 | + digraph repositories { |
| 62 | + node [fillcolor="lightskyblue", style=filled, shape=box] |
| 63 | + rankdir="LR"; |
| 64 | + subgraph cluster_0 { |
| 65 | + label="Packages server"; |
| 66 | + style=filled; |
| 67 | + color=lightgrey; |
| 68 | + subgraph cluster_1 { |
| 69 | + label = "packages\n repository" |
| 70 | + shape = "box"; |
| 71 | + style=filled; |
| 72 | + color=lightblue; |
| 73 | + "packages" [style=invis]; |
| 74 | + "ai/1.1.0\n (Release)"; |
| 75 | + "ai/1.1.0\n (Debug)"; |
| 76 | + } |
| 77 | + subgraph cluster_2 { |
| 78 | + label = "products\n repository" |
| 79 | + shape = "box"; |
| 80 | + style=filled; |
| 81 | + color=lightblue; |
| 82 | + "products" [style=invis]; |
| 83 | + } |
| 84 | + subgraph cluster_3 { |
| 85 | + rankdir="BT"; |
| 86 | + shape = "box"; |
| 87 | + label = "develop repository"; |
| 88 | + color=lightblue; |
| 89 | + rankdir="BT"; |
| 90 | + |
| 91 | + node [fillcolor="lightskyblue", style=filled, shape=box] |
| 92 | + "game/1.0" -> "engine/1.0" -> "ai/1.0" -> "mathlib/1.0"; |
| 93 | + "engine/1.0" -> "graphics/1.0" -> "mathlib/1.0"; |
| 94 | + "mapviewer/1.0" -> "graphics/1.0"; |
| 95 | + "game/1.0" [fillcolor="lightgreen"]; |
| 96 | + "mapviewer/1.0" [fillcolor="lightgreen"]; |
| 97 | + } |
| 98 | + { |
| 99 | + edge[style=invis]; |
| 100 | + "packages" -> "products" -> "game/1.0" ; |
| 101 | + rankdir="BT"; |
| 102 | + } |
| 103 | + } |
| 104 | + } |
| 105 | + |
| 106 | + |
| 107 | +When all the different binaries for ``ai/1.1.0`` have been built correctly, the ``package pipeline`` can consider its job succesfull and decide |
| 108 | +to promote those binaries. But further package builds and checks are necessary, so instead of promoting them to the ``develop`` repository, |
| 109 | +the ``package pipeline`` can promote them to the ``products`` binary repository. As all other developers and CI use the ``develop`` repository, |
| 110 | +no one will be broken at this stage either: |
| 111 | + |
| 112 | +.. code-block:: bash |
| 113 | + :caption: Promoting from packages->product |
| 114 | +
|
| 115 | + # aggregate the package list |
| 116 | + $ conan pkglist merge -l uploaded_release.json -l uploaded_debug.json --format=json > uploaded.json |
| 117 | +
|
| 118 | + $ conan remote enable packages |
| 119 | + $ conan remote enable products |
| 120 | + # Promotion using Conan download/upload commands |
| 121 | + # (slow, can be improved with art:promote custom command) |
| 122 | + $ conan download --list=uploaded.json -r=packages --format=json > promote.json |
| 123 | + $ conan upload --list=promote.json -r=products -c |
| 124 | + $ conan remote disable packages |
| 125 | + $ conan remote disable products |
| 126 | +
|
| 127 | +
|
| 128 | +The first step uses the ``conan pkglist merge`` command to merge the package lists from the "Release" and "Debug" configurations and |
| 129 | +merge it into a single ``uploaded.json`` package list. |
| 130 | +This list is the one that will be used to run the promotion. |
| 131 | + |
| 132 | +In this example we are using a slow ``conan download`` + ``conan upload`` promotion. This can be way more efficient with |
| 133 | +the ``conan art:promote`` extension command. |
| 134 | + |
| 135 | +After running the promotion we will have the following packages in the server: |
| 136 | + |
| 137 | +.. graphviz:: |
| 138 | + :align: center |
| 139 | + |
| 140 | + digraph repositories { |
| 141 | + node [fillcolor="lightskyblue", style=filled, shape=box] |
| 142 | + rankdir="LR"; |
| 143 | + subgraph cluster_0 { |
| 144 | + label="Packages server"; |
| 145 | + style=filled; |
| 146 | + color=lightgrey; |
| 147 | + subgraph cluster_1 { |
| 148 | + label = "packages\n repository" |
| 149 | + shape = "box"; |
| 150 | + style=filled; |
| 151 | + color=lightblue; |
| 152 | + "packages" [style=invis]; |
| 153 | + "ai/1.1.0\n (Release)"; |
| 154 | + "ai/1.1.0\n (Debug)"; |
| 155 | + } |
| 156 | + subgraph cluster_2 { |
| 157 | + label = "products\n repository" |
| 158 | + shape = "box"; |
| 159 | + style=filled; |
| 160 | + color=lightblue; |
| 161 | + "products" [style=invis]; |
| 162 | + "ai/promoted release" [label="ai/1.1.0\n (Release)"]; |
| 163 | + "ai/promoted debug" [label="ai/1.1.0\n (Debug)"]; |
| 164 | + } |
| 165 | + subgraph cluster_3 { |
| 166 | + rankdir="BT"; |
| 167 | + shape = "box"; |
| 168 | + label = "develop repository"; |
| 169 | + color=lightblue; |
| 170 | + rankdir="BT"; |
| 171 | + |
| 172 | + node [fillcolor="lightskyblue", style=filled, shape=box] |
| 173 | + "game/1.0" -> "engine/1.0" -> "ai/1.0" -> "mathlib/1.0"; |
| 174 | + "engine/1.0" -> "graphics/1.0" -> "mathlib/1.0"; |
| 175 | + "mapviewer/1.0" -> "graphics/1.0"; |
| 176 | + "game/1.0" [fillcolor="lightgreen"]; |
| 177 | + "mapviewer/1.0" [fillcolor="lightgreen"]; |
| 178 | + } |
| 179 | + { |
| 180 | + edge[style=invis]; |
| 181 | + "packages" -> "products" -> "game/1.0" ; |
| 182 | + rankdir="BT"; |
| 183 | + } |
| 184 | + } |
| 185 | + } |
| 186 | + |
| 187 | + |
| 188 | +To summarize: |
| 189 | + |
| 190 | +- We built 2 different configurations, ``Release`` and ``Debug`` (could have been Windows/Linux or others), and uploaded them |
| 191 | + to the ``packages`` repository. |
| 192 | +- When all package binaries for all configurations were successfully built, we promoted them from the ``packages`` to the |
| 193 | + ``products`` repository, to make them available for the ``products pipeline``. |
| 194 | +- **Package lists** were captured in the package creation process and merged into a single one to run the promotion. |
| 195 | + |
| 196 | + |
| 197 | +There is still an aspect that we haven't considered yet, the possibility that the dependencies of ``ai/1.1.0`` change |
| 198 | +during the build. Move to the next section to see how to use lockfiles to achieve more consistent multi-configuration builds. |
0 commit comments