[gnome-software] ci: Relax the requirement about running run-tests.sh as root
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] ci: Relax the requirement about running run-tests.sh as root
- Date: Wed, 8 Jul 2020 17:09:54 +0000 (UTC)
commit 11b7cca72fd25965798293e28635d4af289f32ae
Author: Philip Withnall <withnall endlessm com>
Date: Tue Jul 7 14:43:48 2020 +0100
ci: Relax the requirement about running run-tests.sh as root
We can use `sudo` inside the script instead, which means the following
commit can introduce a non-root user to run the build under, which means
we get to cache things in an existent home directory.
Signed-off-by: Philip Withnall <withnall endlessm com>
.gitlab-ci/debian-stable.Dockerfile | 6 +++++-
.gitlab-ci/fedora.Dockerfile | 5 ++++-
.gitlab-ci/run-tests.sh | 23 ++++++++++-------------
3 files changed, 19 insertions(+), 15 deletions(-)
---
diff --git a/.gitlab-ci/debian-stable.Dockerfile b/.gitlab-ci/debian-stable.Dockerfile
index 1e512eac..1b34f065 100644
--- a/.gitlab-ci/debian-stable.Dockerfile
+++ b/.gitlab-ci/debian-stable.Dockerfile
@@ -45,6 +45,7 @@ RUN apt-get update -qq && apt-get install --no-install-recommends -qq -y \
python3-setuptools \
python3-wheel \
shared-mime-info \
+ sudo \
unzip \
valgrind \
wget \
@@ -54,8 +55,11 @@ RUN apt-get update -qq && apt-get install --no-install-recommends -qq -y \
RUN pip3 install meson==0.47.0
+# Enable passwordless sudo for sudo users
+RUN sed -i -e '/%sudo/s/ALL$/NOPASSWD: ALL/' /etc/sudoers
+
ARG HOST_USER_ID=5555
ENV HOST_USER_ID ${HOST_USER_ID}
-RUN useradd -u $HOST_USER_ID -ms /bin/bash user
+RUN useradd -u $HOST_USER_ID -G sudo -ms /bin/bash user
ENV LANG=C.UTF-8 LANGUAGE=C.UTF-8 LC_ALL=C.UTF-8
diff --git a/.gitlab-ci/fedora.Dockerfile b/.gitlab-ci/fedora.Dockerfile
index 0044a823..058bbc37 100644
--- a/.gitlab-ci/fedora.Dockerfile
+++ b/.gitlab-ci/fedora.Dockerfile
@@ -58,8 +58,11 @@ RUN dnf -y install \
RUN pip3 install meson==0.47.0
+# Enable sudo for wheel users
+RUN sed -i -e 's/# %wheel/%wheel/' -e '0,/%wheel/{s/%wheel/# %wheel/}' /etc/sudoers
+
ARG HOST_USER_ID=5555
ENV HOST_USER_ID ${HOST_USER_ID}
-RUN useradd -u $HOST_USER_ID -ms /bin/bash user
+RUN useradd -u $HOST_USER_ID -G wheel -ms /bin/bash user
ENV LANG C.UTF-8
diff --git a/.gitlab-ci/run-tests.sh b/.gitlab-ci/run-tests.sh
index 8813828c..c2b38c42 100755
--- a/.gitlab-ci/run-tests.sh
+++ b/.gitlab-ci/run-tests.sh
@@ -12,21 +12,18 @@ case "$1" in
log_file="_build/meson-logs/testlog.json"
esac
-# FIXME: The tests need to be run as root
-if ! [ $(id -u) = 0 ]; then
- echo "Tests need to be run as root"
- exit 1
-fi
-
# FIXME: The tests should be isolated and use mock services so they do not
# require a functioning system bus. This will have to do for now though.
-mkdir -p /run/dbus
-mkdir -p /var
-ln -s /var/run /run
-dbus-daemon --system --fork
-/usr/lib/polkit-1/polkitd --no-debug &
-/usr/libexec/fwupd/fwupd --verbose &
-
+sudo mkdir -p /run/dbus
+sudo mkdir -p /var
+sudo ln -s /var/run /run
+sudo dbus-daemon --system --fork
+sudo /usr/lib/polkit-1/polkitd --no-debug &
+sudo /usr/libexec/fwupd/fwupd --verbose &
+
+# FIXME: Running the flatpak tests as root means the system helper doesn’t
+# need to be used, which makes them run a lot faster.
+sudo \
meson test \
-C _build \
--timeout-multiplier ${MESON_TEST_TIMEOUT_MULTIPLIER} \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]