Skip to content

Commit e9d1467

Browse files
committed
ci: port setup_rootless from Cirrus, revert oracle-vm to cncf
Signed-off-by: Tim Zhou <tizhou@redhat.com>
1 parent 0b158f3 commit e9d1467

2 files changed

Lines changed: 44 additions & 7 deletions

File tree

.github/workflows/ci.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
name: smoke
2020
uses: ./.github/workflows/lima.yml
2121
with:
22-
runner: oracle-vm-16cpu-64gb-x86-64
22+
runner: cncf-ubuntu-4-16-x86
2323
test: smoke
2424
distro: fedora-current
2525
timeout: 20
@@ -28,7 +28,7 @@ jobs:
2828
name: vendor
2929
uses: ./.github/workflows/lima.yml
3030
with:
31-
runner: oracle-vm-16cpu-64gb-x86-64
31+
runner: cncf-ubuntu-4-16-x86
3232
test: vendor
3333
distro: fedora-current
3434
timeout: 20
@@ -59,7 +59,7 @@ jobs:
5959
storage: [vfs, overlay]
6060
uses: ./.github/workflows/lima.yml
6161
with:
62-
runner: oracle-vm-16cpu-64gb-x86-64
62+
runner: cncf-ubuntu-4-16-x86
6363
test: unit
6464
storage: ${{ matrix.storage }}
6565
priv: root
@@ -75,7 +75,7 @@ jobs:
7575
storage: [vfs, overlay]
7676
uses: ./.github/workflows/lima.yml
7777
with:
78-
runner: oracle-vm-16cpu-64gb-x86-64
78+
runner: cncf-ubuntu-8-32-x86
7979
test: conformance
8080
storage: ${{ matrix.storage }}
8181
priv: root
@@ -102,7 +102,7 @@ jobs:
102102
distro: fedora-rawhide
103103
uses: ./.github/workflows/lima.yml
104104
with:
105-
runner: oracle-vm-16cpu-64gb-x86-64
105+
runner: cncf-ubuntu-8-32-x86
106106
test: integration
107107
storage: ${{ matrix.storage }}
108108
priv: ${{ matrix.priv }}
@@ -114,7 +114,7 @@ jobs:
114114
name: in_podman
115115
uses: ./.github/workflows/lima.yml
116116
with:
117-
runner: oracle-vm-16cpu-64gb-x86-64
117+
runner: cncf-ubuntu-8-32-x86
118118
test: in_podman
119119
storage: vfs
120120
priv: root

contrib/ci/runner.sh

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,36 @@ for which in uid gid; do
3939
fi
4040
done
4141

42+
ROOTLESS_USER="rootlessuser"
43+
44+
# Mirror upstream Cirrus's setup_rootless(): create a dedicated user with subuid
45+
# mapping and 3 supplemental groups, then re-exec the rootless test as that user
46+
# (Cirrus uses ssh; we use sudo -u which is simpler and equivalent for our needs).
47+
function setup_rootless_user() {
48+
if id -u "$ROOTLESS_USER" &>/dev/null; then
49+
sudo chown -R "$ROOTLESS_USER:$ROOTLESS_USER" "$GOSRC" || true
50+
return 0
51+
fi
52+
local uid=$((RANDOM + 1000))
53+
local gid=$uid
54+
local sg1=$((gid + 1))
55+
local sg2=$((sg1 + 1))
56+
local sg3=$((sg2 + 1))
57+
sudo groupadd -g "$gid" "$ROOTLESS_USER"
58+
sudo groupadd -g "$sg1" "${ROOTLESS_USER}sg1"
59+
sudo groupadd -g "$sg2" "${ROOTLESS_USER}sg2"
60+
sudo groupadd -g "$sg3" "${ROOTLESS_USER}sg3"
61+
sudo useradd -g "$gid" \
62+
-G "${ROOTLESS_USER}sg1,${ROOTLESS_USER}sg2,${ROOTLESS_USER}sg3" \
63+
-u "$uid" --no-user-group --create-home "$ROOTLESS_USER"
64+
if ! grep -qE "^$ROOTLESS_USER:" /etc/subuid; then
65+
echo "$ROOTLESS_USER:200000:65536" | sudo tee -a /etc/subuid
66+
echo "$ROOTLESS_USER:200000:65536" | sudo tee -a /etc/subgid
67+
fi
68+
echo "$ROOTLESS_USER ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/rootlessuser
69+
sudo chown -R "$ROOTLESS_USER:$ROOTLESS_USER" "$GOSRC"
70+
}
71+
4272
if [[ "$TEST" == "conformance" ]]; then
4373
case "$OS_RELEASE_ID" in
4474
fedora)
@@ -99,7 +129,14 @@ function run_conformance() {
99129

100130
function run_integration() {
101131
make all
102-
$SUDO make test-integration
132+
if [[ "$PRIV" == "rootless" ]]; then
133+
setup_rootless_user
134+
sudo -u "$ROOTLESS_USER" --preserve-env="$PRESERVE_ENVS" \
135+
env "GOSRC=$GOSRC" "PATH=$PATH" \
136+
make test-integration
137+
else
138+
$SUDO make test-integration
139+
fi
103140
}
104141

105142
function run_in_podman() {

0 commit comments

Comments
 (0)