Skip to content

Commit 0f15ce0

Browse files
committed
github: Setup tests for both rootful and rootless modes
Currently tests are only executed in rootful mode. This commit sets up a new user in the container for rootless tests as well. Signed-off-by: Povilas Kanapickas <[email protected]>
1 parent 406596e commit 0f15ce0

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

.github/workflows/test.yml

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
python-version: [ '3.9', '3.10', '3.11', '3.12', '3.13' ]
13+
mode: [ 'root', 'rootless' ]
1314

1415
runs-on: ubuntu-latest
1516
container:
@@ -19,22 +20,50 @@ jobs:
1920
options: --privileged --cgroupns=host
2021
steps:
2122
- uses: actions/checkout@v4
22-
- name: Install dependencies
23+
- name: Setup root/rootless
2324
run: |
2425
set -e
26+
if [ "${{ matrix.mode }}" = "rootless" ]; then
27+
useradd -m myuser
28+
echo "USER_EXEC_CMD=su myuser" >> $GITHUB_ENV
29+
chown myuser:myuser .
30+
else
31+
echo USER_EXEC_CMD="/bin/bash" >> $GITHUB_ENV
32+
fi
33+
- name: Install dependencies
34+
run: |
2535
apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y podman
26-
python -m pip install --upgrade pip
36+
- name: Setup virtualenv
37+
run: |
38+
$USER_EXEC_CMD -c "
39+
set -e
40+
python3 -m venv .venv
41+
source .venv/bin/activate
42+
pip install --upgrade pip
2743
pip install -r requirements.txt
2844
pip install -r test-requirements.txt
45+
"
2946
- name: Run integration tests
3047
run: |
48+
$USER_EXEC_CMD -c "
49+
set -e
50+
source .venv/bin/activate
3151
python -m unittest discover -v tests/integration
52+
"
3253
env:
3354
TESTS_DEBUG: 1
3455
- name: Run unit tests
3556
run: |
57+
$USER_EXEC_CMD -c "
58+
set -e
59+
source .venv/bin/activate
3660
coverage run --source podman_compose -m unittest discover tests/unit
61+
"
3762
- name: Report coverage
3863
run: |
64+
$USER_EXEC_CMD -c "
65+
set -e
66+
source .venv/bin/activate
3967
coverage combine
4068
coverage report --format=markdown | tee -a $GITHUB_STEP_SUMMARY
69+
"

0 commit comments

Comments
 (0)