git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 03/10] github: adapt containerized jobs to be rootless

From
Patrick Steinhardt <ps@pks.im>
Date
Jan 7, 2025, 12:30 UTC
Message-ID
<20250107-b4-pks-ci-fixes-v3-3-546a0ebc8481@pks.im>
In-Reply-To
<20250107-b4-pks-ci-fixes-v3-0-546a0ebc8481@pks.im>

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>
---
 .github/workflows/main.yml | 6 ++++--
 ci/install-dependencies.sh | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 900be9957a23fcaa64e1aefd0c8638c5f84b7997..b02f5873a540b458d38e7951b4ee3d5ca598ae23 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -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
diff --git a/ci/install-dependencies.sh b/ci/install-dependencies.sh
index d1cb9fa8785388b3674fcea4dd682abc0725c968..ecb5b9d36c20d3e7e96148ac628a96c62642c308 100755
--- a/ci/install-dependencies.sh
+++ b/ci/install-dependencies.sh
@@ -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.
-- 
2.48.0.rc1.245.gb3e6e7acbc.dirty
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 5 of 12 in “A couple of CI improvements”
  1. 00/10 A couple of CI improvementsPatrick Steinhardt, Jan 7, 2025
  2. 02/10 t7422: fix flaky test caused by buffered stdoutPatrick Steinhardt, Jan 7, 2025
  3. Jeff KingJan 9, 2025
  4. 01/10 t0060: fix EBUSY in MinGW when setting up runtime prefixPatrick Steinhardt, Jan 7, 2025
  5. 03/10 github: adapt containerized jobs to be rootlessPatrick Steinhardt, Jan 7, 2025
  6. 04/10 github: convert all Linux jobs to be containerizedPatrick Steinhardt, Jan 7, 2025
  7. 06/10 gitlab-ci: remove the "linux-old" jobPatrick Steinhardt, Jan 7, 2025
  8. 05/10 github: simplify computation of the job's distroPatrick Steinhardt, Jan 7, 2025
  9. 07/10 gitlab-ci: add linux32 job testing against i386Patrick Steinhardt, Jan 7, 2025
  10. 08/10 ci: stop special-casing for Ubuntu 16.04Patrick Steinhardt, Jan 7, 2025
  11. 09/10 ci: use latest Ubuntu releasePatrick Steinhardt, Jan 7, 2025
  12. 10/10 ci: remove stale code for Azure PipelinesPatrick Steinhardt, Jan 7, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.