Skip to content

Commit

Permalink
chore: testing ci
Browse files Browse the repository at this point in the history
  • Loading branch information
aorumbayev committed Jun 3, 2024
1 parent 4699bee commit 9f2af80
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 70 deletions.
50 changes: 0 additions & 50 deletions .github/workflows/podman-test.yaml

This file was deleted.

12 changes: 5 additions & 7 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Pull Request validation
name: Codebase validation

on: [pull_request]
on:
pull_request:
schedule:
- cron: "0 8 * * 1" # Each monday 8 AM UTC

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
Expand All @@ -16,11 +19,6 @@ jobs:
needs: pr-check
uses: ./.github/workflows/build-python.yaml

pr-test-podman:
name: Test LocalNet with Podman
needs: pr-check
uses: ./.github/workflows/podman-test.yaml

pr-binaries-build:
name: Build & Test Binaries
needs: pr-check
Expand Down
2 changes: 2 additions & 0 deletions docs/features/localnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ The AlgoKit LocalNet feature also supports running the LocalNet in a GitHub Code
To run the LocalNet in a GitHub Codespace, you can use the `algokit localnet codespace` command.
By default without `--force` flag it will prompt you to delete stale codespaces created earlier (if any). Upon termination it will also prompt the user to delete the codespace that was used prior to termination.

Running an interactive session ensures that you have control over the lifecycle of your Codespace, preventing unnecessary usage and potential costs. GitHub Codespaces offers a free tier with certain limits, which you can review in the [GitHub Codespaces documentation](https://docs.github.com/en/codespaces/overview#pricing).

### Options

- `-m`, `--machine`: Specifies the GitHub Codespace machine type to use. Defaults to `basicLinux32gb`. Available options are `basicLinux32gb`, `standardLinux32gb`, `premiumLinux`, and `largePremiumLinux`. Refer to [GitHub Codespaces documentation](https://docs.github.com/en/codespaces/overview/machine-types) for more details.
Expand Down
7 changes: 4 additions & 3 deletions src/algokit/cli/doctor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
from algokit.core.conf import get_current_package_version
from algokit.core.doctor import DoctorResult, check_dependency
from algokit.core.sandbox import (
COMPOSE_MINIMUM_VERSION,
COMPOSE_VERSION_COMMAND,
get_container_engine,
get_min_compose_version,
)
from algokit.core.utils import is_windows as get_is_windows
from algokit.core.version_prompt import get_latest_github_version
Expand Down Expand Up @@ -45,6 +45,7 @@ def doctor_command(*, copy_to_clipboard: bool) -> None:
is_windows = get_is_windows()
container_engine = get_container_engine()
docs_url = f"https://{container_engine}.io"
compose_minimum_version = get_min_compose_version()
service_outputs = {
"timestamp": DoctorResult(ok=True, output=dt.datetime.now(dt.timezone.utc).replace(microsecond=0).isoformat()),
"AlgoKit": _get_algokit_version_output(),
Expand All @@ -56,9 +57,9 @@ def doctor_command(*, copy_to_clipboard: bool) -> None:
),
f"{container_engine} compose": check_dependency(
COMPOSE_VERSION_COMMAND,
minimum_version=COMPOSE_MINIMUM_VERSION,
minimum_version=compose_minimum_version,
minimum_version_help=[
f"{container_engine.capitalize()} Compose {COMPOSE_MINIMUM_VERSION} required to",
f"{container_engine.capitalize()} Compose {compose_minimum_version} required to",
"run `algokit localnet` command;",
f"install via {docs_url}",
],
Expand Down
20 changes: 12 additions & 8 deletions src/algokit/cli/localnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from algokit.cli.goal import goal_command
from algokit.core import proc
from algokit.core.sandbox import (
COMPOSE_MINIMUM_VERSION,
COMPOSE_VERSION_COMMAND,
SANDBOX_BASE_NAME,
ComposeFileStatus,
Expand All @@ -17,6 +16,7 @@
fetch_algod_status_data,
fetch_indexer_status_data,
get_container_engine,
get_min_compose_version,
save_container_engine,
)
from algokit.core.utils import extract_version_triple, is_minimum_version
Expand All @@ -43,20 +43,21 @@ def localnet_group(ctx: click.Context) -> None:
"Container engine compose not found; please install Docker Compose or Podman Compose and add to path."
)

compose_minimum_version = get_min_compose_version()
try:
compose_version_str = extract_version_triple(compose_version_result.output)
compose_version_ok = is_minimum_version(compose_version_str, COMPOSE_MINIMUM_VERSION)
compose_version_ok = is_minimum_version(compose_version_str, compose_minimum_version)
except Exception:
logger.warning(
"Unable to extract compose version from output: \n"
+ compose_version_result.output
+ f"\nPlease ensure a minimum of compose v{COMPOSE_MINIMUM_VERSION} is used",
+ f"\nPlease ensure a minimum of compose v{compose_minimum_version} is used",
exc_info=True,
)
else:
if not compose_version_ok:
raise click.ClickException(
f"Minimum compose version supported: v{COMPOSE_MINIMUM_VERSION}, "
f"Minimum compose version supported: v{compose_minimum_version}, "
f"installed = v{compose_version_str}\n"
"Please update your compose install"
)
Expand Down Expand Up @@ -95,11 +96,14 @@ def config_command(*, engine: str | None, force: bool) -> None:
engine = engine.split()[0].lower()

sandbox = ComposeSandbox.from_environment()
has_active_instance = sandbox is not None and click.confirm(
f"Detected active localnet instance, would you like to restart it with '{engine}'?",
default=True,
has_active_instance = sandbox is not None and (
force
or click.confirm(
f"Detected active localnet instance, would you like to restart it with '{engine}'?",
default=True,
)
)
if sandbox and (has_active_instance or force):
if sandbox and has_active_instance:
sandbox.down()
save_container_engine(engine)
sandbox.write_compose_file()
Expand Down
15 changes: 13 additions & 2 deletions src/algokit/core/sandbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@

logger = logging.getLogger(__name__)

COMPOSE_MINIMUM_VERSION = "2.5.0"
DOCKER_COMPOSE_MINIMUM_VERSION = "2.5.0"
PODMAN_COMPOSE_MINIMUM_VERSION = "1.0.6"


SANDBOX_BASE_NAME = "sandbox"
CONTAINER_ENGINE_CONFIG_FILE = get_app_config_dir() / "active-container-engine"

Expand All @@ -34,6 +37,13 @@ class ComposeFileStatus(enum.Enum):
OUT_OF_DATE = enum.auto()


def get_min_compose_version() -> str:
container_engine = get_container_engine()
return (
DOCKER_COMPOSE_MINIMUM_VERSION if container_engine == ContainerEngine.DOCKER else PODMAN_COMPOSE_MINIMUM_VERSION
)


class ComposeSandbox:
def __init__(self, name: str = SANDBOX_BASE_NAME) -> None:
self.name = SANDBOX_BASE_NAME if name == SANDBOX_BASE_NAME else f"{SANDBOX_BASE_NAME}_{name}"
Expand Down Expand Up @@ -155,7 +165,8 @@ def _run_compose_command(
def up(self) -> None:
logger.info("Starting AlgoKit LocalNet now...")
self._run_compose_command(
"up --detach --quiet-pull --wait", bad_return_code_error_message="Failed to start LocalNet"
f"up --detach --quiet-pull{' --wait' if get_container_engine() == ContainerEngine.DOCKER else ''}",
bad_return_code_error_message="Failed to start LocalNet",
)
logger.debug("AlgoKit LocalNet started, waiting for health check")
if _wait_for_algod():
Expand Down

0 comments on commit 9f2af80

Please sign in to comment.