Skip to content

Commit 2a21098

Browse files
pks-tgitster
authored andcommitted
github: adapt containerized jobs to be rootless
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 65f5861 commit 2a21098

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

.github/workflows/main.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,10 +371,12 @@ jobs:
371371
run: apt -q update && apt -q -y install libc6-amd64 lib64stdc++6
372372
- uses: actions/checkout@v4
373373
- run: ci/install-dependencies.sh
374-
- run: ci/run-build-and-tests.sh
374+
- run: useradd builder --create-home
375+
- run: chown -R builder .
376+
- run: sudo --preserve-env --set-home --user=builder ci/run-build-and-tests.sh
375377
- name: print test failures
376378
if: failure() && env.FAILED_TEST_ARTIFACTS != ''
377-
run: ci/print-test-failures.sh
379+
run: sudo --preserve-env --set-home --user=builder ci/print-test-failures.sh
378380
- name: Upload failed tests' directories
379381
if: failure() && env.FAILED_TEST_ARTIFACTS != ''
380382
uses: actions/upload-artifact@v4

ci/install-dependencies.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ alpine-*)
3131
;;
3232
fedora-*|almalinux-*)
3333
dnf -yq update >/dev/null &&
34-
dnf -yq install make gcc findutils diffutils perl python3 gettext zlib-devel expat-devel openssl-devel curl-devel pcre2-devel >/dev/null
34+
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
3535
;;
3636
ubuntu-*|ubuntu32-*|debian-*)
3737
# Required so that apt doesn't wait for user input on certain packages.

0 commit comments

Comments
 (0)