diff mbox series

[v3,07/13] ci: fix setup of custom path for GitLab CI

Message ID ef61b578da84dbd8087bf22c43029acf6983e547.1712825204.git.ps@pks.im (mailing list archive)
State Superseded
Headers show
Series t: exercise Git/JGit reftable compatibility | expand

Commit Message

Patrick Steinhardt April 11, 2024, 9:10 a.m. UTC
Part of "install-dependencies.sh" is to install some binaries required
for tests into a custom directory that gets added to the PATH. This
directory is located at "$HOME/path" and thus depends on the current
user that the script executes as.

This creates problems for GitLab CI, which installs dependencies as the
root user, but runs tests as a separate, unprivileged user. As their
respective home directories are different, we will end up using two
different custom path directories. Consequently, the unprivileged user
will not be able eto find the binaries that were setu up as root user.

Fix this issue by allowing CI to override the custom path, which allows
GitLab to set up a constant value that isn't derived from "$HOME".
---
 .gitlab-ci.yml | 2 ++
 ci/lib.sh      | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

Comments

Eric Sunshine April 11, 2024, 10:06 a.m. UTC | #1
On Thu, Apr 11, 2024 at 5:10 AM Patrick Steinhardt <ps@pks.im> wrote:
> Part of "install-dependencies.sh" is to install some binaries required
> for tests into a custom directory that gets added to the PATH. This
> directory is located at "$HOME/path" and thus depends on the current
> user that the script executes as.
>
> This creates problems for GitLab CI, which installs dependencies as the
> root user, but runs tests as a separate, unprivileged user. As their
> respective home directories are different, we will end up using two
> different custom path directories. Consequently, the unprivileged user
> will not be able eto find the binaries that were setu up as root user.

s/eto/to/
s/setu/setup/

> Fix this issue by allowing CI to override the custom path, which allows
> GitLab to set up a constant value that isn't derived from "$HOME".
> ---

Missing sign-off.
Patrick Steinhardt April 11, 2024, 10:26 a.m. UTC | #2
On Thu, Apr 11, 2024 at 06:06:05AM -0400, Eric Sunshine wrote:
> On Thu, Apr 11, 2024 at 5:10 AM Patrick Steinhardt <ps@pks.im> wrote:
> > Part of "install-dependencies.sh" is to install some binaries required
> > for tests into a custom directory that gets added to the PATH. This
> > directory is located at "$HOME/path" and thus depends on the current
> > user that the script executes as.
> >
> > This creates problems for GitLab CI, which installs dependencies as the
> > root user, but runs tests as a separate, unprivileged user. As their
> > respective home directories are different, we will end up using two
> > different custom path directories. Consequently, the unprivileged user
> > will not be able eto find the binaries that were setu up as root user.
> 
> s/eto/to/
> s/setu/setup/

Ugh. Well, to my excuse, my keyboard is a bit wonky recently.

> > Fix this issue by allowing CI to override the custom path, which allows
> > GitLab to set up a constant value that isn't derived from "$HOME".
> > ---
> 
> Missing sign-off.

Indeed. Sorry, I'm somewhat distracted today.

Patrick
diff mbox series

Patch

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index c0fa2fe90b..3a0ef4d4d4 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -9,6 +9,8 @@  workflow:
 
 test:linux:
   image: $image
+  variables:
+    CUSTOM_PATH: "/custom"
   before_script:
     - ./ci/install-docker-dependencies.sh
   script:
diff --git a/ci/lib.sh b/ci/lib.sh
index 4cce854bad..473a2d0348 100755
--- a/ci/lib.sh
+++ b/ci/lib.sh
@@ -350,7 +350,7 @@  macos-*)
 	;;
 esac
 
-CUSTOM_PATH="$HOME/path"
+CUSTOM_PATH="${CUSTOM_PATH:-$HOME/path}"
 export PATH="$CUSTOM_PATH:$PATH"
 
 case "$jobname" in