]> Kevux Git Server - rit/commitdiff
github: adapt containerized jobs to be rootless
authorPatrick Steinhardt <ps@pks.im>
Fri, 10 Jan 2025 11:31:59 +0000 (12:31 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 10 Jan 2025 17:15:37 +0000 (09:15 -0800)
The containerized jobs in GitHub Actions run as root, giving them
special permissions to for example delete files even when the user
shouldn't be able to due to file permissions. This limitation keeps us
from using containerized jobs for most of our Ubuntu-based jobs as it
causes a number of tests to fail.

Adapt the jobs to create a separate user that executes the test suite.
This follows similar infrastructure that we already have in GitLab CI.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
.github/workflows/main.yml
ci/install-dependencies.sh

index 900be99..b02f587 100644 (file)
@@ -371,10 +371,12 @@ jobs:
       run: apt -q update && apt -q -y install libc6-amd64 lib64stdc++6
     - uses: actions/checkout@v4
     - run: ci/install-dependencies.sh
-    - run: ci/run-build-and-tests.sh
+    - run: useradd builder --create-home
+    - run: chown -R builder .
+    - run: sudo --preserve-env --set-home --user=builder ci/run-build-and-tests.sh
     - name: print test failures
       if: failure() && env.FAILED_TEST_ARTIFACTS != ''
-      run: ci/print-test-failures.sh
+      run: sudo --preserve-env --set-home --user=builder ci/print-test-failures.sh
     - name: Upload failed tests' directories
       if: failure() && env.FAILED_TEST_ARTIFACTS != ''
       uses: actions/upload-artifact@v4
index d1cb9fa..ecb5b9d 100755 (executable)
@@ -31,7 +31,7 @@ alpine-*)
        ;;
 fedora-*|almalinux-*)
        dnf -yq update >/dev/null &&
-       dnf -yq install make gcc findutils diffutils perl python3 gettext zlib-devel expat-devel openssl-devel curl-devel pcre2-devel >/dev/null
+       dnf -yq install shadow-utils sudo make gcc findutils diffutils perl python3 gettext zlib-devel expat-devel openssl-devel curl-devel pcre2-devel >/dev/null
        ;;
 ubuntu-*|ubuntu32-*|debian-*)
        # Required so that apt doesn't wait for user input on certain packages.