From e92bb8f1c9523227413500380df16bfc64053fad Mon Sep 17 00:00:00 2001 From: "Yann E. MORIN" Date: Tue, 7 Feb 2023 22:33:11 +0100 Subject: [PATCH] gitlab-ci: don't use before_script in job templates When gitlab prepares a job to run, it checks out the repository with a non-root user, and spawns a container that runs as root, with some UID mapping that makes the files be owned by root in the container. However, our pipelines run as a nont-root user. Commit bde165f7ad (.gitlab-ci.yml: update Docker image to use) updated the docker image that is used to run in our pipelines. That new image includes a git version that is stricter about the ownership of the git tree it is acting in: git aborts in error when the user running it does not own the repository. We use `git ls-tree` quite a lot in our check-{flake8,package,symbols} rules, so they all fail (in various ways). To fix this, we either need to fix the ownership or tell git to ignore the situation. In either case, we'll need to run a scriptlet before all our jobs. Gitlab-ci allows to provide a global before_script, that is inherited by all jobs. However, some of our jobs already declare a before_script, and that would shadow the global before_script. There is no technical reason to do our before_script separately from the actual script, so we move the code from the before_scripts to the corresponding scripts. Signed-off-by: Yann E. MORIN Cc: Arnout Vandecappelle (Essensium/Mind) Cc: Romain Naour Cc: Thomas Petazzoni Reviewed-by: Romain Naour Signed-off-by: Thomas Petazzoni --- support/misc/gitlab-ci.yml.in | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/support/misc/gitlab-ci.yml.in b/support/misc/gitlab-ci.yml.in index 0ccf36665e..9c1faf0d5f 100644 --- a/support/misc/gitlab-ci.yml.in +++ b/support/misc/gitlab-ci.yml.in @@ -23,9 +23,8 @@ - utils/check-symbols .defconfig_check: - before_script: - - DEFCONFIG_NAME=$(echo ${CI_JOB_NAME} | sed -e 's,_check$,,g') script: + - DEFCONFIG_NAME=$(echo ${CI_JOB_NAME} | sed -e 's,_check$,,g') - echo "Configure Buildroot for ${DEFCONFIG_NAME}" - make ${DEFCONFIG_NAME} - support/scripts/check-dotconfig.py .config configs/${DEFCONFIG_NAME} @@ -44,10 +43,9 @@ } .defconfig_base: - before_script: + script: - DEFCONFIG_NAME=${CI_JOB_NAME} - OUTPUT_DIR=output - script: - echo "Configure Buildroot for ${DEFCONFIG_NAME}" - make ${DEFCONFIG_NAME} - ./support/scripts/check-dotconfig.py .config ./configs/${DEFCONFIG_NAME} @@ -72,13 +70,12 @@ - runtime-test.log .runtime_test_base: - before_script: - - TEST_CASE_NAME=${CI_JOB_NAME} # Keep build directories so the rootfs can be an artifact of the job. The # runner will clean up those files for us. # Multiply every emulator timeout by 10 to avoid sporadic failures in # elastic runners. script: + - TEST_CASE_NAME=${CI_JOB_NAME} - echo "Starting runtime test ${TEST_CASE_NAME}" - ./support/testing/run-tests -o test-output/ -d test-dl/ -k --timeout-multiplier 10 ${TEST_CASE_NAME} artifacts: @@ -91,9 +88,8 @@ .test_pkg: stage: build - before_script: - - OUTPUT_DIR=${CI_JOB_NAME} script: + - OUTPUT_DIR=${CI_JOB_NAME} - echo "Configure Buildroot for ${OUTPUT_DIR}" - make O=${OUTPUT_DIR} syncconfig - make O=${OUTPUT_DIR} savedefconfig