From a016b693f7830f3c8ae815851d3204b8b6e99821 Mon Sep 17 00:00:00 2001 From: "Yann E. MORIN" Date: Tue, 7 Feb 2023 22:33:12 +0100 Subject: [PATCH] gitlab-ci: fix pipelines 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. It is most probably impossible to change the ownership of the files: we run as non-root,and the files belong to root (in the container). So we're stuck. The alternative, is to do as git suggest, and tell it to ignore the situation. In a local setup, this would be very insecure, but in the pipelines, this is in a throw-away container, where a single user exists and is running, so we don't care much (if at all). Add a global before_script that registers the git config to ignore ownership issues in the buildroot repository; see [0] for the definition of the CI_PROJECT_DIR variable. Note: unlike what is said in there, and in [1], the value actually seen in CI_PROJECT_DIR is already prefixed with CI_BUILDS_DIR (the documentation is unclear about that point). [0] https://docs.gitlab.com/ee/ci/variables/predefined_variables.html [1] https://docs.gitlab.com/runner/configuration/advanced-configuration.html#the-runners-section Signed-off-by: Yann E. MORIN Cc: Arnout Vandecappelle (Essensium/Mind) Cc: Romain Naour Cc: Thomas Petazzoni Signed-off-by: Thomas Petazzoni --- support/misc/gitlab-ci.yml.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/support/misc/gitlab-ci.yml.in b/support/misc/gitlab-ci.yml.in index 9c1faf0d5f..38aca31fb5 100644 --- a/support/misc/gitlab-ci.yml.in +++ b/support/misc/gitlab-ci.yml.in @@ -1,3 +1,6 @@ +before_script: + - git config --global --add safe.directory ${CI_PROJECT_DIR} + .check-check-package_base: script: - python3 -m pytest -v utils/checkpackagelib/