Skip to content

Commit ae6df3a

Browse files
committed
test: Run script with sudo instead of adding sudo in script
Signed-off-by: Xiaofeng Wang <[email protected]>
1 parent 3067f33 commit ae6df3a

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

.github/workflows/integration.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@ jobs:
2424
- name: Build bootc and bootc image
2525
env:
2626
TEST_OS: ${{ matrix.test_os }}
27-
run: tests/build.sh
27+
run: sudo -E TEST_OS=$TEST_OS tests/build.sh
28+
29+
- name: Grant sudo user permission for archived files
30+
run: |
31+
sudo chown "${SUDO_UID}" /tmp/tmp-bootc-build/disk.raw
32+
sudo chown "${SUDO_UID}" /tmp/tmp-bootc-build/id_rsa
2833
2934
- name: Archive bootc disk image - disk.raw
3035
uses: actions/upload-artifact@v4
@@ -76,7 +81,7 @@ jobs:
7681
- name: Run test
7782
env:
7883
TMT_PLAN_NAME: ${{ matrix.tmt_plan }}
79-
run: chmod 600 /tmp/tmp-bootc-build/id_rsa && tests/test.sh
84+
run: chmod 600 /tmp/tmp-bootc-build/id_rsa && sudo -E TMT_PLAN_NAME=$TMT_PLAN_NAME tests/test.sh
8085

8186
- name: Archive TMT logs
8287
if: always()

tests/build.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ EORUN
8282
CONTAINERFILEOF
8383

8484
LOCAL_IMAGE="localhost/bootc:test"
85-
sudo podman build \
85+
podman build \
8686
--retry 5 \
8787
--retry-delay 5s \
8888
-v "$(pwd)":/code:z \
@@ -93,14 +93,14 @@ sudo podman build \
9393
SSH_KEY=${BOOTC_TEMPDIR}/id_rsa
9494
ssh-keygen -f "${SSH_KEY}" -N "" -q -t rsa-sha2-256 -b 2048
9595

96-
sudo truncate -s 10G "${BOOTC_TEMPDIR}/disk.raw"
96+
truncate -s 10G "${BOOTC_TEMPDIR}/disk.raw"
9797

9898
# For test-22-logically-bound-install
99-
sudo podman pull --retry 5 --retry-delay 5s quay.io/curl/curl:latest
100-
sudo podman pull --retry 5 --retry-delay 5s quay.io/curl/curl-base:latest
101-
sudo podman pull --retry 5 --retry-delay 5s registry.access.redhat.com/ubi9/podman:latest
99+
podman pull --retry 5 --retry-delay 5s quay.io/curl/curl:latest
100+
podman pull --retry 5 --retry-delay 5s quay.io/curl/curl-base:latest
101+
podman pull --retry 5 --retry-delay 5s registry.access.redhat.com/ubi9/podman:latest
102102

103-
sudo podman run \
103+
podman run \
104104
--rm \
105105
--privileged \
106106
--pid=host \

tests/test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ SSH_KEY=${BOOTC_TEMPDIR}/id_rsa
1010
ARCH=$(uname -m)
1111
case "$ARCH" in
1212
"aarch64")
13-
sudo qemu-system-aarch64 \
13+
qemu-system-aarch64 \
1414
-name bootc-vm \
1515
-enable-kvm \
1616
-machine virt \
@@ -24,7 +24,7 @@ case "$ARCH" in
2424
-daemonize
2525
;;
2626
"x86_64")
27-
sudo qemu-system-x86_64 \
27+
qemu-system-x86_64 \
2828
-name bootc-vm \
2929
-enable-kvm \
3030
-cpu host \

0 commit comments

Comments
 (0)