Skip to content
This repository was archived by the owner on Oct 8, 2025. It is now read-only.

Commit 8032ce3

Browse files
committed
Test with root access in GitHub workflows
To enable tests that require privileged root access, this commit tests with `sudo`. The Java and Python jobs have additional permissions issues, so they are also configured and made with `sudo`. A small permissions fix is required before running tests to allow non-root users to execute within the `/home/runner` directory. This change also removes the custom directories that were required without root access. Reviewed-by: Andrew Clayton <a.clayton@nginx.com> Signed-off-by: Dylan Arbour <d.arbour@f5.com>
1 parent c2f7f29 commit 8032ce3

File tree

1 file changed

+13
-31
lines changed

1 file changed

+13
-31
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,6 @@ jobs:
5353
steps:
5454
- uses: actions/checkout@v4
5555

56-
# Creates and outputs directories used by tests (/usr/local is unfriendly)
57-
- name: Configure directories
58-
id: dir
59-
run: |
60-
PREFIX=${HOME}/.unit
61-
BIN=${PREFIX}/bin
62-
VAR=${PREFIX}/var
63-
mkdir -p $BIN
64-
mkdir -p $VAR
65-
66-
echo "prefix=${PREFIX}" >> "$GITHUB_OUTPUT"
67-
echo "bin=${BIN}" >> "$GITHUB_OUTPUT"
68-
echo "bin=${BIN}" >> "$GITHUB_PATH"
69-
echo "var=${VAR}" >> "$GITHUB_OUTPUT"
70-
cat "$GITHUB_OUTPUT"
71-
7256
# Provides module, language version and testpath from build name
7357
- name: Output build metadata
7458
id: metadata
@@ -127,15 +111,6 @@ jobs:
127111
- name: Configure unit
128112
run: |
129113
./configure \
130-
--prefix=${{ steps.dir.outputs.prefix }} \
131-
--sbindir=${{ steps.dir.outputs.bin }} \
132-
--logdir=${{ steps.dir.outputs.var }}/log \
133-
--log=${{ steps.dir.outputs.var }}/log/unit/unit.log \
134-
--runstatedir=${{ steps.dir.outputs.var }}/run \
135-
--pid=${{ steps.dir.outputs.var }}/run/unit/unit.pid \
136-
--control=unix:${{ steps.dir.outputs.var }}/run/unit/control.sock \
137-
--modules=${{ steps.dir.outputs.prefix }}/lib/unit/modules \
138-
--statedir=${{ steps.dir.outputs.var }}/state/unit \
139114
--tests \
140115
--openssl \
141116
--njs \
@@ -179,12 +154,12 @@ jobs:
179154

180155
- name: Configure java
181156
run: |
182-
./configure java
157+
sudo ./configure java
183158
if: steps.metadata.outputs.module == 'java'
184159

185160
- name: Make java
186161
run: |
187-
make java
162+
sudo make java
188163
if: steps.metadata.outputs.module == 'java'
189164

190165
##
@@ -266,12 +241,12 @@ jobs:
266241

267242
- name: Configure python3
268243
run: |
269-
./configure python --config=python3-config
244+
sudo ./configure python --config=python3-config
270245
if: steps.metadata.outputs.module == 'python'
271246

272247
- name: Make python3
273248
run: |
274-
make python3
249+
sudo make python3
275250
if: steps.metadata.outputs.module == 'python'
276251

277252
##
@@ -321,6 +296,13 @@ jobs:
321296
## Tests
322297
##
323298

299+
# /home/runner will be root only after calling sudo above
300+
# Ensure all users and processes can execute
301+
- name: Fix permissions
302+
run: |
303+
sudo chmod -R +x /home/runner
304+
namei -l ${{ github.workspace }}
305+
324306
# Install python3 if not present
325307
- uses: actions/setup-python@v5
326308
with:
@@ -329,11 +311,11 @@ jobs:
329311

330312
- name: Install pytest
331313
run: |
332-
pip install pytest
314+
sudo -H pip install pytest
333315
if: steps.metadata.outputs.module != 'wasm'
334316

335317
- name: Run ${{ steps.metadata.outputs.module }} tests
336318
run: |
337-
pytest --print-log ${{ steps.metadata.outputs.testpath }}
319+
sudo -E pytest --print-log ${{ steps.metadata.outputs.testpath }}
338320
# Skip pytest if wasm build, as there are no tests yet
339321
if: steps.metadata.outputs.module != 'wasm'

0 commit comments

Comments
 (0)