diff --git a/.github/workflows/spread-manual.yaml b/.github/workflows/spread-manual.yaml index cd7860e0b..438fe99da 100644 --- a/.github/workflows/spread-manual.yaml +++ b/.github/workflows/spread-manual.yaml @@ -43,7 +43,13 @@ jobs: with: name: snap path: tests - - name: Run spread (large/flaky) + + - name: Run remote-build tests + env: + LAUNCHPAD_TOKEN: "${{ secrets.LAUNCHPAD_TOKEN }}" + run: spread tests/spread/rockcraft/remote-build + - name: Run large/flaky tests + id: flaky run: spread tests/spread/manual/ - name: Discard spread workers diff --git a/requirements-dev.txt b/requirements-dev.txt index 88a6b3a2f..ace4c971c 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -62,13 +62,13 @@ colorama==0.4.6 # via sphinx-autobuild coverage==7.6.8 # via rockcraft (pyproject.toml) -craft-application==4.5.0 +craft-application==4.6.0 # via rockcraft (pyproject.toml) craft-archives==2.0.1 # via # craft-application # rockcraft (pyproject.toml) -craft-cli==2.10.1 +craft-cli==2.12.0 # via # craft-application # rockcraft (pyproject.toml) diff --git a/requirements-doc.txt b/requirements-doc.txt index 06dd848dd..95994c810 100644 --- a/requirements-doc.txt +++ b/requirements-doc.txt @@ -50,13 +50,13 @@ click==8.1.7 # via uvicorn colorama==0.4.6 # via sphinx-autobuild -craft-application==4.5.0 +craft-application==4.6.0 # via rockcraft (pyproject.toml) craft-archives==2.0.1 # via # craft-application # rockcraft (pyproject.toml) -craft-cli==2.10.1 +craft-cli==2.12.0 # via # craft-application # rockcraft (pyproject.toml) diff --git a/requirements.txt b/requirements.txt index fc16544d0..dc4f1cdce 100644 --- a/requirements.txt +++ b/requirements.txt @@ -18,13 +18,13 @@ chardet==5.2.0 # via python-debian charset-normalizer==3.4.0 # via requests -craft-application==4.5.0 +craft-application==4.6.0 # via rockcraft (pyproject.toml) craft-archives==2.0.1 # via # craft-application # rockcraft (pyproject.toml) -craft-cli==2.10.1 +craft-cli==2.12.0 # via # craft-application # rockcraft (pyproject.toml) diff --git a/rockcraft/cli.py b/rockcraft/cli.py index abd10d638..7a5221e61 100644 --- a/rockcraft/cli.py +++ b/rockcraft/cli.py @@ -18,6 +18,8 @@ from typing import TYPE_CHECKING +from craft_application import commands as appcommands + from . import commands from .services import RockcraftServiceFactory @@ -54,4 +56,6 @@ def _create_app() -> "Rockcraft": ], ) + app.add_command_group("Lifecycle", [appcommands.RemoteBuild]) + return app diff --git a/rockcraft/services/__init__.py b/rockcraft/services/__init__.py index f41dde237..251cb77ee 100644 --- a/rockcraft/services/__init__.py +++ b/rockcraft/services/__init__.py @@ -21,6 +21,7 @@ from rockcraft.services.lifecycle import RockcraftLifecycleService from rockcraft.services.package import RockcraftPackageService from rockcraft.services.provider import RockcraftProviderService +from rockcraft.services.remotebuild import RockcraftRemoteBuildService from rockcraft.services.service_factory import RockcraftServiceFactory __all__ = [ @@ -30,4 +31,5 @@ "RockcraftPackageService", "RockcraftProviderService", "RockcraftServiceFactory", + "RockcraftRemoteBuildService", ] diff --git a/rockcraft/services/remotebuild.py b/rockcraft/services/remotebuild.py new file mode 100644 index 000000000..3c6d965e7 --- /dev/null +++ b/rockcraft/services/remotebuild.py @@ -0,0 +1,25 @@ +# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- +# +# Copyright 2023 Canonical Ltd. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 3 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +"""Rockcraft Remote Build service.""" +from craft_application.launchpad import RockRecipe +from craft_application.services import RemoteBuildService + + +class RockcraftRemoteBuildService(RemoteBuildService): + """Rockcraft Remote Build service.""" + + RecipeClass = RockRecipe diff --git a/rockcraft/services/service_factory.py b/rockcraft/services/service_factory.py index 4f4b47866..b1da4ab88 100644 --- a/rockcraft/services/service_factory.py +++ b/rockcraft/services/service_factory.py @@ -45,6 +45,9 @@ class RockcraftServiceFactory(ServiceFactory): InitClass: type[ # type: ignore[reportIncompatibleVariableOverride] services.RockcraftInitService ] = services.RockcraftInitService + RemoteBuildClass: type[ # type: ignore[reportIncompatibleVariableOverride] + services.RockcraftRemoteBuildService + ] = services.RockcraftRemoteBuildService if TYPE_CHECKING: image: services.RockcraftImageService = None # type: ignore[assignment] diff --git a/tests/spread/rockcraft/remote-build/task.yaml b/tests/spread/rockcraft/remote-build/task.yaml new file mode 100644 index 000000000..daea15d8a --- /dev/null +++ b/tests/spread/rockcraft/remote-build/task.yaml @@ -0,0 +1,39 @@ +summary: Test the remote builder +manual: true +kill-timeout: 30m + +environment: + LAUNCHPAD_TOKEN: '$(HOST: echo "${LAUNCHPAD_TOKEN}")' + +prepare: | + if [[ -z "$LAUNCHPAD_TOKEN" ]]; then + echo "No credentials set in env LAUNCHPAD_TOKEN" + exit 1 + fi + + mkdir work + cd work + rockcraft init --name="remote-build" + + # commit the project + git init + git add rockcraft.yaml + git commit -m "Initial Commit" + + # set up launchpad token + CREDENTIALS_FILE="$HOME/.local/share/rockcraft/launchpad-credentials" + mkdir -p "$(dirname "$CREDENTIALS_FILE")" + echo -e "$LAUNCHPAD_TOKEN" >> "$CREDENTIALS_FILE" + +execute: | + cd work + + rockcraft remote-build --launchpad-accept-public-upload + + # The rock + test -f remote-build_0.1_amd64.rock + # The build log + test -f rockcraft-remote-build-*_amd64_*.txt + +restore: | + rm -f ./work/*.rock ./work/*.txt