build-unit-test-docker.sh: Bake heavily-used repos into Docker image
Introduce a handful of core OpenBMC packages and a new file into the
docker image, /root/.depcache, which contains a comma-separated list of
${PACKAGE}:${COMMIT_ID} pairs. The commit ID represents the HEAD of
https://github.com/openbmc/${PACKAGE} master. The way the Dockerfile
change is structured means that we will rebuild the image to use updated
packages whenever the upstream master changes.
This improves build times by allowing us to avoid building the core
dependencies for every CI run whilst still keeping the environment
up-to-date.
Tested: Ran run-unit-test-docker.sh, confirmed no regressions
Change-Id: I4e0e1a86ffc0a26107d328a3418d6afa27b8f375
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
diff --git a/build-unit-test-docker.sh b/build-unit-test-docker.sh
index b0cc4a3..ad7084b 100755
--- a/build-unit-test-docker.sh
+++ b/build-unit-test-docker.sh
@@ -32,6 +32,16 @@
exit 1
esac
+PKGS="phosphor-objmgr sdbusplus phosphor-logging phosphor-dbus-interfaces"
+PKGS+=" openpower-dbus-interfaces"
+DEPCACHE=
+for package in $PKGS
+do
+ tip=$(git ls-remote https://github.com/openbmc/${package} |
+ grep 'refs/heads/master' | awk '{ print $1 }')
+ DEPCACHE+=${package}:${tip},
+done
+
################################# docker img # #################################
# Create docker image that can run package unit tests
if [[ "${DISTRO}" == "ubuntu"* ]]; then
@@ -100,6 +110,47 @@
RUN echo '${AUTOM4TE}' > ${AUTOM4TE_CFG}
+# Sneaky use of Dockerfile semantics! Force a rebuild of the image if master
+# has been updated in any of the repositories in $PKGS: This happens as a
+# consequence of the ls-remotes above, which will change the value of
+# ${DEPCACHE} and therefore trigger rebuilds of all of the following layers.
+RUN echo '${DEPCACHE}' > /root/.depcache
+
+RUN git clone https://github.com/openbmc/sdbusplus && \
+cd sdbusplus && \
+./bootstrap.sh && \
+./configure --enable-transaction && \
+make -j$(nproc) && \
+make install
+
+RUN git clone https://github.com/openbmc/phosphor-dbus-interfaces && \
+cd phosphor-dbus-interfaces && \
+./bootstrap.sh && \
+./configure && \
+make -j$(nproc) && \
+make install
+
+RUN git clone https://github.com/openbmc/openpower-dbus-interfaces && \
+cd openpower-dbus-interfaces && \
+./bootstrap.sh && \
+./configure && \
+make -j$(nproc) && \
+make install
+
+RUN git clone https://github.com/openbmc/phosphor-logging && \
+cd phosphor-logging && \
+./bootstrap.sh && \
+./configure --enable-metadata-processing YAML_DIR=/usr/local/share/phosphor-dbus-yaml/yaml && \
+make -j$(nproc) && \
+make install
+
+RUN git clone https://github.com/openbmc/phosphor-objmgr && \
+cd phosphor-objmgr && \
+./bootstrap.sh && \
+./configure --enable-unpatched-systemd && \
+make -j$(nproc) && \
+make install
+
RUN /bin/bash
EOF
)