Skip to content

Commit

Permalink
feat: add the remote-build command (#769)
Browse files Browse the repository at this point in the history
Fixes #766
  • Loading branch information
tigarmo authored Dec 13, 2024
1 parent ee528bb commit 8e74936
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 7 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/spread-manual.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions requirements-doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions rockcraft/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

from typing import TYPE_CHECKING

from craft_application import commands as appcommands

from . import commands
from .services import RockcraftServiceFactory

Expand Down Expand Up @@ -54,4 +56,6 @@ def _create_app() -> "Rockcraft":
],
)

app.add_command_group("Lifecycle", [appcommands.RemoteBuild])

return app
2 changes: 2 additions & 0 deletions rockcraft/services/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__ = [
Expand All @@ -30,4 +31,5 @@
"RockcraftPackageService",
"RockcraftProviderService",
"RockcraftServiceFactory",
"RockcraftRemoteBuildService",
]
25 changes: 25 additions & 0 deletions rockcraft/services/remotebuild.py
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.

"""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
3 changes: 3 additions & 0 deletions rockcraft/services/service_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
39 changes: 39 additions & 0 deletions tests/spread/rockcraft/remote-build/task.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 8e74936

Please sign in to comment.