Skip to content

Commit 3175a61

Browse files
committed
Fix CI handling for root-required live package tests
1 parent 80ba9bb commit 3175a61

2 files changed

Lines changed: 33 additions & 3 deletions

File tree

.github/workflows/tests.yml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ permissions:
1313
jobs:
1414
build:
1515
runs-on: ${{ matrix.os }}
16-
env:
17-
ABX_PKG_LIVE_PKG_TESTS: "1"
1816
strategy:
1917
fail-fast: true
2018
matrix:
@@ -42,7 +40,33 @@ jobs:
4240
&& uv pip install pip \
4341
&& echo "/home/linuxbrew/.linuxbrew/bin" >> "$GITHUB_PATH"
4442
45-
- name: Run tests
43+
- name: Run standard test suite
4644
run: |
4745
source .venv/bin/activate \
4846
&& python tests.py
47+
48+
- name: Run live package lifecycle tests on macOS
49+
if: runner.os == 'macOS'
50+
env:
51+
ABX_PKG_LIVE_PKG_TESTS: "1"
52+
run: |
53+
source .venv/bin/activate \
54+
&& python -m unittest tests.LiveUpdateAndUninstallTest
55+
56+
- name: Run non-root live package lifecycle tests on Linux
57+
if: runner.os == 'Linux'
58+
env:
59+
ABX_PKG_LIVE_PKG_TESTS: "1"
60+
run: |
61+
source .venv/bin/activate \
62+
&& python -m unittest \
63+
tests.LiveUpdateAndUninstallTest.test_npm_provider_live_update_and_uninstall \
64+
tests.LiveUpdateAndUninstallTest.test_pip_provider_live_update_and_uninstall
65+
66+
- name: Run root-required live package lifecycle tests on Linux
67+
if: runner.os == 'Linux'
68+
run: |
69+
sudo env "PATH=$PATH" "ABX_PKG_LIVE_PKG_TESTS=1" ./.venv/bin/python -m unittest \
70+
tests.LiveUpdateAndUninstallTest.test_apt_provider_live_update_and_uninstall \
71+
tests.LiveUpdateAndUninstallTest.test_pyinfra_provider_live_update_and_uninstall \
72+
tests.LiveUpdateAndUninstallTest.test_ansible_provider_live_update_and_uninstall

tests.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,8 @@ def test_pyinfra_provider_live_update_and_uninstall(self):
638638
raise unittest.SkipTest('pyinfra is not available on this host')
639639

640640
if 'linux' in sys.platform and shutil.which('apt-get'):
641+
if os.geteuid() != 0:
642+
raise unittest.SkipTest('pyinfra apt lifecycle tests require root on Linux')
641643
provider = PyinfraProvider(pyinfra_installer_module='operations.apt.packages')
642644
binary = Binary(name=self.pick_missing_apt_package(), binproviders=[provider])
643645
elif shutil.which('brew'):
@@ -653,6 +655,8 @@ def test_ansible_provider_live_update_and_uninstall(self):
653655
raise unittest.SkipTest('ansible is not available on this host')
654656

655657
if 'linux' in sys.platform and shutil.which('apt-get'):
658+
if os.geteuid() != 0:
659+
raise unittest.SkipTest('ansible apt lifecycle tests require root on Linux')
656660
provider = AnsibleProvider(ansible_installer_module='ansible.builtin.apt')
657661
binary = Binary(name=self.pick_missing_apt_package(), binproviders=[provider])
658662
elif shutil.which('brew'):
@@ -668,6 +672,8 @@ def test_apt_provider_live_update_and_uninstall(self):
668672
raise unittest.SkipTest('apt live lifecycle tests only run on Linux hosts')
669673
if not shutil.which('apt-get'):
670674
raise unittest.SkipTest('apt-get is not available on this host')
675+
if os.geteuid() != 0:
676+
raise unittest.SkipTest('apt lifecycle tests require root on Linux')
671677

672678
provider = AptProvider()
673679
binary = Binary(name=self.pick_missing_apt_package(), binproviders=[provider])

0 commit comments

Comments
 (0)