Skip to content

Commit ea1ba17

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

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

.github/workflows/test-installers.yml

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,15 @@ 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+
chmod a+rw ${{ github.workspace }}
95+
# Use a shell which switch to the non-root compass user first
96+
shell: bash -e -c "su - compass; source {0}"
8997
container:
9098
image: rockylinux:9
9199
volumes:
@@ -133,24 +141,25 @@ jobs:
133141

134142
runs-on: ${{ matrix.runs-on }}
135143
container: ${{ matrix.container }}
144+
defaults:
145+
run:
146+
shell: ${{ matrix.shell }}
136147
env:
137148
DEBUG: compass:smoketests:*
138149
steps:
150+
- name: Run pre-checkout command
151+
if: matrix.pre-checkout-command
152+
run: ${{ matrix.pre-checkout-command }}
153+
# Use bash shell for pre-checkout command as it might setup a user which is needed for subsequent steps
154+
shell: bash
155+
139156
- name: Checkout
140157
uses: actions/checkout@v2
141158
- name: Setup Node.js
142159
uses: actions/setup-node@v4
143160
with:
144161
node-version: 20
145162
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
154163

155164
- name: Cache downloads
156165
uses: actions/cache@v4
@@ -195,4 +204,4 @@ jobs:
195204
# Exposing token to prevent update server from being rate limited
196205
GITHUB_TOKEN: ${{ github.token }}
197206
working-directory: packages/compass-smoke-tests
198-
run: ${{ matrix.test-command-prefix }} npm start -- --package ${{ matrix.package }} --tests ${{ matrix.test }}
207+
run: npm start -- --package ${{ matrix.package }} --tests ${{ matrix.test }}

0 commit comments

Comments
 (0)