diff --git a/.github/workflows/integration_delivery.yml b/.github/workflows/integration_delivery.yml index 672cfa30..239a4d3f 100644 --- a/.github/workflows/integration_delivery.yml +++ b/.github/workflows/integration_delivery.yml @@ -61,7 +61,7 @@ jobs: ubo-pod-dependencies: name: Install Ubo Pod Dependencies - runs-on: ubo-pod + runs-on: ubo-pod-pi5 outputs: python-version: ${{ steps.get-python-version.outputs.PYTHON_VERSION }} steps: @@ -111,7 +111,7 @@ jobs: name: Type Check needs: - ubo-pod-dependencies - runs-on: ubo-pod + runs-on: ubo-pod-pi5 steps: - uses: actions/checkout@v4 name: Checkout @@ -125,7 +125,7 @@ jobs: ~/.local key: poetry-ubo-pod-python${{ - steps.get-python-version.outputs.PYTHON_VERSION }}-${{ + needs.ubo-pod-dependencies.outputs.python-version }}-${{ hashFiles('poetry.lock') }} - name: Create stub files @@ -172,14 +172,14 @@ jobs: - ubo-pod-dependencies strategy: matrix: - runner: ['ubo-pod', 'ubuntu-latest'] + runner: ['ubo-pod', 'ubo-pod-pi5', 'ubuntu-latest'] runs-on: ${{ matrix.runner }} environment: name: test url: https://app.codecov.io/gh/${{ github.repository }}/ steps: - name: System Dependencies - if: matrix.runner != 'ubo-pod' + if: matrix.runner == 'ubuntu-latest' run: | sudo apt-get update -y sudo apt-get install -y libegl1 libgl1 libmtdev1 libzbar0 @@ -188,7 +188,7 @@ jobs: name: Checkout - name: Setup Python - if: matrix.runner != 'ubo-pod' + if: matrix.runner == 'ubuntu-latest' uses: actions/setup-python@v5 with: python-version: ${{ env.PYTHON_VERSION }} @@ -202,13 +202,13 @@ jobs: ~/.cache ~/.local key: - poetry-${{ matrix.runner }}-python${{ matrix.runner == 'ubo-pod' && - needs.dependencies.outputs.python-version || env.PYTHON_VERSION - }}-${{hashFiles('poetry.lock') }} + poetry-${{ matrix.runner }}-python${{ startsWith(matrix.runner, + 'ubo-pod') && needs.dependencies.outputs.python-version || + env.PYTHON_VERSION }}-${{hashFiles('poetry.lock') }} - name: Run Tests run: | - poetry run poe test --verbosity=2 --capture=no --make-screenshots --cov-report=xml --cov-report=html --log-level=DEBUG -n ${{ matrix.runner == 'ubo-pod' && '1' || 'auto' }} + poetry run poe test --verbosity=2 --capture=no --make-screenshots --cov-report=xml --cov-report=html --log-level=DEBUG -n ${{ startsWith(matrix.runner, 'ubo-pod') && '1' || 'auto' }} - name: Collect Window Screenshots uses: actions/upload-artifact@v4 @@ -377,7 +377,7 @@ jobs: echo "image_url=$IMAGE_URL" >> "$GITHUB_OUTPUT" echo "image_name=$IMAGE_NAME" >> "$GITHUB_OUTPUT" echo "image_checksum_url=$CHECKSUM_URL" >> "$GITHUB_OUTPUT" - IMAGE_SIZE_GB=${{ matrix.suffix == 'lite' && '4.25' || matrix.suffix == '' && '6.5' || '13' }} + IMAGE_SIZE_GB=${{ matrix.suffix == 'lite' && '4.5' || matrix.suffix == '' && '6.75' || '13' }} IMAGE_SIZE=$(awk -v IMAGE_SIZE_GB=$IMAGE_SIZE_GB 'BEGIN {printf "%.0f", IMAGE_SIZE_GB * 1024 ^ 3}') echo "image_size=$IMAGE_SIZE" >> "$GITHUB_OUTPUT" diff --git a/CHANGELOG.md b/CHANGELOG.md index 8dc13732..0c807cbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - refactor(housekeeping): improve store imports - feat(store): add `DispatchItem` and `NotificationDispatchItem` as convenience `ActionItem` subclasses to dispatch actions and events - feat(users): add `users` service to create, list, delete and change password of system users +- feat(ci): add `ubo-pod-pi5` to the list of github runners for `test`, also use it for `dependencies` and `type-check` jobs ## Version 0.15.11 diff --git a/pyproject.toml b/pyproject.toml index f5667870..01fb95cf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -93,11 +93,15 @@ typecheck = "pyright -p pyproject.toml ." test = "pytest --cov=ubo_app" sanity = ["typecheck", "lint", "test"] build-docker-images = "sh -c 'docker buildx build . -f scripts/Dockerfile.dev -t ubo-app-dev && docker buildx build . -f scripts/Dockerfile.test -t ubo-app-test'" +"device:test:deps" = "poe test-on-device --deps" +"device:test:copy" = "poe test-on-device --copy" +"device:test:run" = "poe test-on-device --run" +"device:test:results" = "poe test-on-device --results" [tool.poe.tasks.test-on-device] args = [ - { name = "copy", type = "boolean" }, { name = "deps", type = "boolean" }, + { name = "copy", type = "boolean" }, { name = "run", type = "boolean" }, { name = "results", type = "boolean" }, ] diff --git a/tests/fixtures/mock_environment.py b/tests/fixtures/mock_environment.py index 7b4e2b4f..301163b5 100644 --- a/tests/fixtures/mock_environment.py +++ b/tests/fixtures/mock_environment.py @@ -216,6 +216,7 @@ async def communicate(self: FakeAsyncProcess) -> tuple[bytes, bytes]: _ = kwargs command, *args = _args + expected = False if command == '/usr/bin/env': command, *args = args @@ -224,28 +225,29 @@ async def communicate(self: FakeAsyncProcess) -> tuple[bytes, bytes]: if args[0] == '--user': args = args[1:] - if args[0] == 'is-enabled': - return FakeAsyncProcess(output=b'enabled') - if args[0] == 'is-active': - return FakeAsyncProcess(output=b'active') + if args[0] in ('is-active', 'is-enabled'): + expected = True + if command == 'dpkg-query' and args[-1] in ( 'docker', 'raspberrypi-ui-mods', 'rpi-connect', ): - return FakeAsyncProcess(output=b'install ok installed') + expected = True + if command == 'pulseaudio': return FakeAsyncProcess() import logging - logging.info( - 'Unexpected `async_create_subprocess_exec` command in test environment:', - extra={ - 'args_': args, - 'kwargs': kwargs, - }, - ) + if not expected: + logging.info( + 'Unexpected `async_create_subprocess_exec` command in test environment:', + extra={ + 'args_': _args, + 'kwargs': kwargs, + }, + ) return await originals['async_create_subprocess_exec'](*_args, **kwargs) diff --git a/tests/integration/results/test_services/all_services_register/store-desktop-000.jsonc b/tests/integration/results/test_services/all_services_register/store-desktop-000.jsonc index 2b92d280..d63fd55f 100644 --- a/tests/integration/results/test_services/all_services_register/store-desktop-000.jsonc +++ b/tests/integration/results/test_services/all_services_register/store-desktop-000.jsonc @@ -940,7 +940,7 @@ }, "rpi_connect": { "_type": "RPiConnectState", - "is_active": true, + "is_active": false, "is_downloading": false, "is_installed": null, "is_signed_in": null, diff --git a/tests/integration/results/test_services/all_services_register/store-rpi-000.jsonc b/tests/integration/results/test_services/all_services_register/store-rpi-000.jsonc index 70975066..bcde50a3 100644 --- a/tests/integration/results/test_services/all_services_register/store-rpi-000.jsonc +++ b/tests/integration/results/test_services/all_services_register/store-rpi-000.jsonc @@ -76,7 +76,7 @@ }, "service": { "_type": "DockerServiceState", - "status": "not_running", + "status": "not_installed", "usernames": {} } }, @@ -96,8 +96,8 @@ "lightdm": { "_type": "LightDMState", "is_active": false, - "is_enabled": true, - "is_installed": true, + "is_enabled": false, + "is_installed": false, "is_installing": false }, "main": { @@ -1005,7 +1005,7 @@ }, "rpi_connect": { "_type": "RPiConnectState", - "is_active": true, + "is_active": false, "is_downloading": false, "is_installed": null, "is_signed_in": null, diff --git a/ubo_app/services/050-lightdm/setup.py b/ubo_app/services/050-lightdm/setup.py index 1b8597e3..dc6279a8 100644 --- a/ubo_app/services/050-lightdm/setup.py +++ b/ubo_app/services/050-lightdm/setup.py @@ -22,7 +22,7 @@ ) from ubo_app.utils.apt import is_package_installed from ubo_app.utils.async_ import create_task -from ubo_app.utils.monitor_unit import is_unit_active, is_unit_enabled, monitor_unit +from ubo_app.utils.monitor_unit import is_unit_enabled, monitor_unit from ubo_app.utils.server import send_command if TYPE_CHECKING: @@ -162,15 +162,13 @@ def lightdm_title(_: LightDMState) -> str: async def check_lightdm() -> None: """Check if the LightDM service is enabled.""" - is_active, is_enabled, is_installed = await asyncio.gather( - is_unit_active('lightdm'), + is_enabled, is_installed = await asyncio.gather( is_unit_enabled('lightdm'), is_package_installed('raspberrypi-ui-mods'), ) store.dispatch( LightDMUpdateStateAction( - is_active=is_installed and is_active, is_enabled=is_installed and is_enabled, is_installed=is_installed, ), diff --git a/ubo_app/setup.py b/ubo_app/setup.py index 23d8c5fb..87a0320c 100644 --- a/ubo_app/setup.py +++ b/ubo_app/setup.py @@ -47,7 +47,20 @@ async def _fake_create_subprocess_exec( return Fake() if command in {'curl', 'tar'} or command.endswith('/code'): return original_asyncio_create_subprocess_exec(*args, **kwargs) - if command == 'dpkg-query': + if command == 'systemctl': + if args[0] in 'is-enabled': + return Fake( + _Fake__return_value=Fake(_Fake__await_value=(b'enabled', b'')), + ) + if args[0] == 'is-active': + return Fake( + _Fake__return_value=Fake(_Fake__await_value=(b'active', b'')), + ) + if command == 'dpkg-query' and args[-1] in ( + 'docker', + 'raspberrypi-ui-mods', + 'rpi-connect', + ): return Fake( _Fake__return_value=Fake(_Fake__await_value=(b'install ok installed', b'')), ) @@ -102,7 +115,9 @@ def setup() -> None: from ubo_app.utils import monitor_unit async def fake_monitor_unit(unit: str, callback: Callable[[str], None]) -> None: - callback('inactive' if unit == 'ubo-update.service' else 'active') + callback( + 'inactive' if unit in ('ubo-update.service') else 'active', + ) monitor_unit.monitor_unit = fake_monitor_unit