[Tarantool-patches] [PATCH 1/2] ci: use sudo to install packages if not root

Alexander Turenko alexander.turenko at tarantool.org
Thu Oct 1 04:06:05 MSK 2026


The setup-linux and setup-debuggers actions call `apt` without `sudo`,
which works on our self-hosted runners: the jobs run there as root. The
next commit moves the ARM64 jobs to GitHub-hosted runners, where the
steps run as the runner's regular user, so we have to call `sudo` there.

If the current user is already `root`, `sudo` is not called: this way we
don't depend on its presence when we don't need it.

Drafted by an LLM, conducted and corrected by the commit author.
---
 .github/actions/setup-debuggers/action.yml | 6 ++++--
 .github/actions/setup-linux/action.yml     | 6 ++++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/.github/actions/setup-debuggers/action.yml b/.github/actions/setup-debuggers/action.yml
index c34d4502..e2ac09db 100644
--- a/.github/actions/setup-debuggers/action.yml
+++ b/.github/actions/setup-debuggers/action.yml
@@ -7,6 +7,8 @@ runs:
       uses: ./.github/actions/setup-linux
     - name: Install dependencies for the tests
       run: |
-        apt -y update
-        apt install -y python3 gdb lldb
+        # GitHub-hosted runners run the steps as a regular user.
+        SUDO=$([ "$(id -u)" = 0 ] || echo sudo)
+        ${SUDO} apt -y update
+        ${SUDO} apt install -y python3 gdb lldb
       shell: bash
diff --git a/.github/actions/setup-linux/action.yml b/.github/actions/setup-linux/action.yml
index f0171b83..8f13940a 100644
--- a/.github/actions/setup-linux/action.yml
+++ b/.github/actions/setup-linux/action.yml
@@ -14,6 +14,8 @@ runs:
       shell: bash
     - name: Install build and test dependencies
       run: |
-        apt -y update
-        apt -y install cmake gcc make ninja-build perl
+        # GitHub-hosted runners run the steps as a regular user.
+        SUDO=$([ "$(id -u)" = 0 ] || echo sudo)
+        ${SUDO} apt -y update
+        ${SUDO} apt -y install cmake gcc make ninja-build perl
       shell: bash
-- 
2.55.0



More information about the Tarantool-patches mailing list