From 780cf8d621ace5a11bf5a726bc3200507fe3bf2a Mon Sep 17 00:00:00 2001 From: Dan Miller Date: Sat, 4 Jan 2025 21:40:39 +0000 Subject: [PATCH] Bring back other test jobs --- .github/workflows/build.yml | 14 +++++++------- README.md | 3 ++- ptah/cli/__init__.py | 6 +++++- pyproject.toml | 2 +- tests/cli/test_cli_end_to_end.py | 16 ++++++++++------ 5 files changed, 25 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c0b2467..bdfc9ea 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,13 +21,13 @@ jobs: strategy: matrix: os: - # - macos-latest + - macos-latest - ubuntu-latest - # - windows-latest + - windows-latest python-version: - # - 3.11 + - 3.11 - 3.12 - # - 3.13 + - 3.13 runs-on: ${{ matrix.os }} @@ -59,9 +59,6 @@ jobs: cond: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12' && github.actor != 'dependabot[bot]' }} if_true: true - - if: ${{ steps.singleton.outputs.value }} - run: pytest -m e2e - - if: ${{ steps.singleton.outputs.value }} uses: EnricoMi/publish-unit-test-result-action@v2 with: @@ -73,6 +70,9 @@ jobs: with: use_oidc: true + - if: ${{ steps.singleton.outputs.value }} + run: pytest -m e2e + - uses: actions/upload-artifact@v4 with: name: release-dists diff --git a/README.md b/README.md index 0d95f0f..ce61bb5 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,8 @@ Try to add documentation for any new feature you build. When possible it should mkdocs serve ``` -TODO: run end-to-end tests. +The lengthy series of tests in [test_cli_end_to_end.py](./tests/cli/test_cli_end_to_end.py) are +skipped by default. To force them to run, use the command: ```bash pytest -m e2e diff --git a/ptah/cli/__init__.py b/ptah/cli/__init__.py index e815de8..fb2fbc3 100644 --- a/ptah/cli/__init__.py +++ b/ptah/cli/__init__.py @@ -14,6 +14,7 @@ Kind, Kubernetes, Project, + PtahPanic, Version, Yaml, get, @@ -126,7 +127,10 @@ def nuke(docker: bool = True, kind: bool = True): """ Forcibly delete the Kind cluster, all related resources, and prune dangling Docker images. """ - _forward(kill=True) + try: + _forward(kill=True) + except SystemExit: + pass if docker: get(Docker).prune() diff --git a/pyproject.toml b/pyproject.toml index b1ada25..80eaf60 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -62,7 +62,7 @@ filterwarnings = [ ] # https://stackoverflow.com/a/60813297 markers = [ - "e2e: marks tests as end-to-end (TODO)", + "e2e: marks tests as end-to-end (these will be skipped by default)", ] [tool.ruff.lint.per-file-ignores] diff --git a/tests/cli/test_cli_end_to_end.py b/tests/cli/test_cli_end_to_end.py index c4f13f0..295de42 100644 --- a/tests/cli/test_cli_end_to_end.py +++ b/tests/cli/test_cli_end_to_end.py @@ -1,11 +1,16 @@ +import logging +import time + import httpx import pytest from typer.testing import CliRunner from ptah.cli import app -from ptah.clients import get +from ptah.clients import Shell, get from ptah.models import OperatingSystem +log = logging.getLogger(__name__) + # https://stackoverflow.com/a/71264963 if get(OperatingSystem) != OperatingSystem.LINUX: pytest.skip(reason="unsupported", allow_module_level=True) @@ -29,7 +34,7 @@ def test_build(in_project): def test_deploy(in_project): runner = CliRunner() result = runner.invoke(app, ["deploy"]) - assert result.exit_code == 0, f"STDOUT: {result.stdout} + STDERR: {result.stderr}" + assert result.exit_code == 0, result.stdout @pytest.mark.e2e @@ -43,8 +48,7 @@ def test_deployed_service_is_functional(): assert "headers" in response.json() success = True except Exception as e: - print(e) - import time + log.warning(e) time.sleep(1) @@ -55,6 +59,6 @@ def test_deployed_service_is_functional(): def test_nuke(in_project): runner = CliRunner() result = runner.invoke(app, ["nuke"]) - assert result.exit_code == 0, f"STDOUT: {result.stdout} + STDERR: {result.stderr}" + assert result.exit_code == 0, result.stdout - # TODO: assert no running Kind clusters. + assert not get(Shell).run(["kind", "get", "clusters"])