From 11211f6db70c2586a323265e2a62a2fcb7df5bde Mon Sep 17 00:00:00 2001
From: Emanuele Aina <emanuele.aina@collabora.com>
Date: Thu, 9 Dec 2021 11:56:14 +0100
Subject: [PATCH] Do not chdir to the parent directory in the CI

In the past, using the parent directory as the working directory has been
a source of troubles in the CI: since it does not get cleaned up on
runners that process multiple jobs (as the lightweight one does) stale
files from other jobs have been a source of failures.

The previous commits have switched the update script to use `$TMPDIR` as
the working directory anyway, but to be extra sure let's not `cd ..`
before invoking the script.

Signed-off-by: Emanuele Aina <emanuele.aina@collabora.com>
---
 .gitlab-ci.yml                      | 6 +++---
 gitlab-ci/update-test-binaries.yaml | 9 +++------
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 78af599..b1e4d4e 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -13,8 +13,8 @@ test-glib-gio-fs:
     - .update-test-binaries
   variables:
     GIT_PUSH_URL: ""
-    REPOSITORY: glib-gio-fs
+    TESTCASE: glib-gio-fs
   before_script:
-    - git clone "${CI_SERVER_URL}/tests/$REPOSITORY.git/" "$REPOSITORY"
-    - cd "$REPOSITORY"
+    - git clone "${CI_SERVER_URL}/tests/$TESTCASE.git/" "$TESTCASE"
+    - cd "$TESTCASE"
     - git checkout f86085845450
diff --git a/gitlab-ci/update-test-binaries.yaml b/gitlab-ci/update-test-binaries.yaml
index e1b2a12..b399c4f 100644
--- a/gitlab-ci/update-test-binaries.yaml
+++ b/gitlab-ci/update-test-binaries.yaml
@@ -5,12 +5,9 @@
   variables:
     BRANCH: $CI_COMMIT_BRANCH
     GIT_PUSH_URL: https://${GITLAB_CI_USER}:${GITLAB_CI_PASSWORD}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git/
-    REPOSITORY: $CI_PROJECT_NAME
   script:
     - env --null | sort -z | tr '\0' '\n'
-    - cd ..
-    - test -d $REPOSITORY
     - wget ${CI_SERVER_URL}/tests/helper-tools/-/raw/${osname}/${release}/update_test_binaries.sh -O /tmp/update_test_binaries.sh
-    - bash /tmp/update_test_binaries.sh --release "${release}" --branch "$BRANCH" --repository "$REPOSITORY" --dry-run
-    - git -C "$REPOSITORY" show
-    - if [ -n "$GIT_PUSH_URL" ]; then git -C "$REPOSITORY" push "${GIT_PUSH_URL}" "HEAD:${BRANCH}"; fi
+    - bash /tmp/update_test_binaries.sh --release "${release}" --branch "$BRANCH" --repository . --dry-run
+    - git show
+    - if [ -n "$GIT_PUSH_URL" ]; then git push "${GIT_PUSH_URL}" "HEAD:${BRANCH}"; fi
-- 
GitLab