Skip to content

Commit 7ca66b6

Browse files
committed
Switch user earlier and via shell
1 parent d9b9881 commit 7ca66b6

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

.github/workflows/test-installers.yml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,14 @@ jobs:
8585
runs-on: ubuntu-latest
8686
arch: x64
8787
hadron-platform: linux
88-
test-command-prefix: sudo --user compass
88+
pre-checkout-command: |
89+
# Install dependencies
90+
dnf install -y sudo gcc gcc-c++ make git nss dbus xorg-x11-server-Xvfb
91+
# Add a non-admin sudoer user and switch to it
92+
adduser compass
93+
echo "compass ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
94+
# Use a shell which switch to the non-root compass user first
95+
shell: bash -c "su --login compass"
8996
container:
9097
image: rockylinux:9
9198
volumes:
@@ -133,24 +140,25 @@ jobs:
133140

134141
runs-on: ${{ matrix.runs-on }}
135142
container: ${{ matrix.container }}
143+
defaults:
144+
run:
145+
shell: ${{ matrix.shell }}
136146
env:
137147
DEBUG: compass:smoketests:*
138148
steps:
149+
- name: Run pre-checkout command
150+
if: matrix.pre-checkout-command
151+
run: ${{ matrix.pre-checkout-command }}
152+
# Use bash shell for pre-checkout command as it might setup a user which is needed for subsequent steps
153+
shell: bash
154+
139155
- name: Checkout
140156
uses: actions/checkout@v2
141157
- name: Setup Node.js
142158
uses: actions/setup-node@v4
143159
with:
144160
node-version: 20
145161
cache: "npm"
146-
- name: Configure Rocky linux
147-
if: matrix.container.image == 'rockylinux:9'
148-
run: |
149-
# Install dependencies
150-
dnf install -y sudo gcc gcc-c++ make git nss dbus xorg-x11-server-Xvfb
151-
# Add a non-admin sudoer user
152-
adduser compass
153-
echo "compass ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
154162

155163
- name: Cache downloads
156164
uses: actions/cache@v4
@@ -195,4 +203,4 @@ jobs:
195203
# Exposing token to prevent update server from being rate limited
196204
GITHUB_TOKEN: ${{ github.token }}
197205
working-directory: packages/compass-smoke-tests
198-
run: ${{ matrix.test-command-prefix }} npm start -- --package ${{ matrix.package }} --tests ${{ matrix.test }}
206+
run: npm start -- --package ${{ matrix.package }} --tests ${{ matrix.test }}

0 commit comments

Comments
 (0)