From cb05621d18caf100b617f233c364eadd4a784928 Mon Sep 17 00:00:00 2001 From: Samuel Grayson Date: Fri, 8 Mar 2024 09:03:46 -0600 Subject: [PATCH] Fix GitHub workflow --- .github/workflows/main.yml | 2 ++ ci.sh | 2 +- pre-commit.sh | 3 +++ tests/test_cli.py | 14 +++++++++----- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ec32f2b..ebe3c17 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,3 +10,5 @@ jobs: - uses: DeterminateSystems/nix-installer-action@main - uses: DeterminateSystems/magic-nix-cache-action@main - run: nix develop --command ./ci.sh + env: + CLEAN_VM: 1 diff --git a/ci.sh b/ci.sh index 1d0aa0f..77bfa88 100755 --- a/ci.sh +++ b/ci.sh @@ -7,7 +7,7 @@ mypy --package zilch mypy tests/*.py -pytest +pytest -v poetry build diff --git a/pre-commit.sh b/pre-commit.sh index 7d26d05..682fd77 100755 --- a/pre-commit.sh +++ b/pre-commit.sh @@ -2,6 +2,9 @@ set -ex ruff check --fix . + mypy --package zilch + mypy tests/*.py + poetry build diff --git a/tests/test_cli.py b/tests/test_cli.py index e243d1d..3697664 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -51,7 +51,10 @@ def test_zilch_project_uses_cwd() -> None: catch_exceptions=False, ) -@pytest.mark.skipif(not bool(int(os.environ.get("CLEAN_VM", "0"))), reason="Not running in CLEAN_VM") +@pytest.mark.skipif( + not bool(int(os.environ.get("CLEAN_VM", "0"))), + reason="Declining to run tests that modify $HOME because we are not running in CLEAN_VM", +) def test_zilch_project_uses_global() -> None: runner = CliRunner() with runner.isolated_filesystem(): @@ -74,11 +77,12 @@ def test_search() -> None: catch_exceptions=False, ) -package = "aria" -executable = "aria2c" +package = "hello" +executable = "hello" +which_executable = subprocess.run(["which", executable], check=False, capture_output=True) @pytest.mark.skipif( - subprocess.run(["which", package], check=False, capture_output=True).returncode == 0, - reason=f"You have {package}, so we can't test its installation/removal", + which_executable.returncode == 0, + reason=f"You already have {package}, so we can't test its installation/removal. Try choosing a different package/executable", ) def test_install_remove() -> None: runner = CliRunner()