Skip to content

Commit

Permalink
Merge branch 'main' into work/1461/CRAFT-2371/ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
lengau authored Oct 16, 2024
2 parents 425237c + f3b7108 commit 0dc20bf
Show file tree
Hide file tree
Showing 140 changed files with 2,464 additions and 682 deletions.
1 change: 1 addition & 0 deletions .github/workflows/spread.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ jobs:
name: Run spread
env:
CHARMCRAFT_AUTH: ${{ secrets.CHARMCRAFT_AUTH }}
CHARMCRAFT_SINGLE_CHARM_AUTH: ${{ secrets.CHARMCRAFT_SINGLE_CHARM_AUTH }}
CHARM_DEFAULT_NAME: gh-ci-charmcraft-charm
BUNDLE_DEFAULT_NAME: gh-ci-charmcraft-bundle
run: |
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ jobs:
if [[ $(lsb_release --codename --short) == 'jammy' ]]; then
python3 -m pip install -U pip
fi
- name: Setup LXD
uses: canonical/[email protected]
if: ${{ runner.os == 'Linux' }}
- name: Install skopeo (mac)
# This is only necessary for Linux until skopeo >= 1.11 is in repos.
# Once we're running on Noble, we can get skopeo from apt.
Expand Down
4 changes: 3 additions & 1 deletion charmcraft/application/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#
# For further info, check https://github.com/canonical/charmcraft
"""Charmcraft commands."""

import craft_application

from charmcraft.application.commands.analyse import Analyse, Analyze
Expand Down Expand Up @@ -109,7 +110,8 @@ def fill_command_groups(app: craft_application.Application) -> None:
],
)
app.add_command_group(
"Extensions", [ExpandExtensionsCommand, ExtensionsCommand, ListExtensionsCommand]
"Extensions",
[ExpandExtensionsCommand, ExtensionsCommand, ListExtensionsCommand],
)
app.add_command_group(
"Other",
Expand Down
1 change: 1 addition & 0 deletions charmcraft/application/commands/analyse.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#
# For further info, check https://github.com/canonical/charmcraft
"""Command for analysing a charm."""

import argparse
import json
import pathlib
Expand Down
1 change: 1 addition & 0 deletions charmcraft/application/commands/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#
# For further info, check https://github.com/canonical/charmcraft
"""Base command for Charmcraft commands."""

from __future__ import annotations

import craft_application.commands
Expand Down
1 change: 1 addition & 0 deletions charmcraft/application/commands/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# For further info, check https://github.com/canonical/charmcraft

"""Infrastructure for the 'extensions' command."""

import argparse
from textwrap import dedent

Expand Down
5 changes: 4 additions & 1 deletion charmcraft/application/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# For further info, check https://github.com/canonical/charmcraft

"""Infrastructure for the 'init' command."""

import argparse
import os
import pathlib
Expand Down Expand Up @@ -130,7 +131,9 @@ class InitCommand(base.CharmcraftCommand):

def fill_parser(self, parser):
"""Specify command's specific parameters."""
parser.add_argument("--name", help="The name of the charm; defaults to the directory name")
parser.add_argument(
"--name", help="The name of the charm; defaults to the directory name"
)
parser.add_argument(
"--author",
help="The charm author; defaults to the current user name per GECOS",
Expand Down
11 changes: 9 additions & 2 deletions charmcraft/application/commands/lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#
# For further info, check https://github.com/canonical/charmcraft
"""craft-application based lifecycle commands."""

from __future__ import annotations

import pathlib
Expand Down Expand Up @@ -171,14 +172,20 @@ def run_managed(self, parsed_args: argparse.Namespace) -> bool:
# Always use a runner on non-Linux platforms.
# Craft-parts is not designed to work on non-posix platforms, and most
# notably here, the bundle plugin doesn't work on Windows.
if sys.platform == "linux" and charmcraft_yaml and charmcraft_yaml.get("type") == "bundle":
if (
sys.platform == "linux"
and charmcraft_yaml
and charmcraft_yaml.get("type") == "bundle"
):
return False

return super().run_managed(parsed_args)

def _update_charm_libs(self) -> None:
"""Update charm libs attached to the project."""
craft_cli.emit.progress("Checking that charmlibs match 'charmcraft.yaml' values")
craft_cli.emit.progress(
"Checking that charmlibs match 'charmcraft.yaml' values"
)
project = cast(models.CharmcraftProject, self._services.project)
libs_svc = cast(services.CharmLibsService, self._services.charm_libs)
installable_libs: list[models.CharmLib] = []
Expand Down
21 changes: 16 additions & 5 deletions charmcraft/application/commands/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#
# For further info, check https://github.com/canonical/charmcraft
"""Build a charm remotely on Launchpad."""

import argparse
import os
import pathlib
Expand Down Expand Up @@ -63,7 +64,9 @@ class RemoteBuild(ExtensibleCommand):

@override
def _fill_parser(self, parser: argparse.ArgumentParser) -> None:
parser.add_argument("--recover", action="store_true", help="recover an interrupted build")
parser.add_argument(
"--recover", action="store_true", help="recover an interrupted build"
)
parser.add_argument(
"--launchpad-accept-public-upload",
action="store_true",
Expand Down Expand Up @@ -121,7 +124,9 @@ def _run(self, parsed_args: argparse.Namespace, **kwargs: Any) -> int | None: #
emit.progress(f"Recovering build {build_id}")
builds = builder.resume_builds(build_id)
else:
emit.progress("Starting new build. It may take a while to upload large projects.")
emit.progress(
"Starting new build. It may take a while to upload large projects."
)
builds = builder.start_builds(project_dir)

try:
Expand All @@ -138,7 +143,9 @@ def _run(self, parsed_args: argparse.Namespace, **kwargs: Any) -> int | None: #
builder.cleanup()
return returncode

def _monitor_and_complete(self, build_id: str | None, builds: Collection[Build]) -> int:
def _monitor_and_complete(
self, build_id: str | None, builds: Collection[Build]
) -> int:
builder = self._services.remote_build
emit.progress("Monitoring build")
try:
Expand Down Expand Up @@ -168,10 +175,14 @@ def _monitor_and_complete(self, build_id: str | None, builds: Collection[Build])
emit.progress("; ".join(progress_parts))
except TimeoutError:
if build_id:
resume_command = f"{self._app.name} remote-build --recover --build-id={build_id}"
resume_command = (
f"{self._app.name} remote-build --recover --build-id={build_id}"
)
else:
resume_command = f"{self._app.name} remote-build --recover"
emit.message(f"Timed out waiting for build.\nTo resume, run {resume_command!r}")
emit.message(
f"Timed out waiting for build.\nTo resume, run {resume_command!r}"
)
return 75 # Temporary failure

emit.progress(f"Fetching {len(builds)} build logs...")
Expand Down
Loading

0 comments on commit 0dc20bf

Please sign in to comment.