Skip to content

Commit

Permalink
Update CI and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
goanpeca committed Mar 15, 2023
1 parent be091e9 commit 1e905c4
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 142 deletions.
43 changes: 27 additions & 16 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ on:
- main
paths:
- 'constructor-manager/**'
- 'constructor-manager-cli/**'
- 'constructor-manager-api/**'
- 'constructor-manager-ui/**'
workflow_dispatch:

jobs:
Expand All @@ -30,29 +31,39 @@ jobs:
- name: Set up Python ${{ matrix.python-version }}
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: ""
activate-environment: "constructor-manager"
auto-activate-base: true

- name: Install dependencies constructor-manager-cli
- name: Install dependencies on base environment
run: |
python -m pip install --upgrade pip
python -m pip install setuptools tox tox-gh-actions
cd constructor-manager-cli
pip install -e ".[testing]"
pip list
conda install -n base conda-lock mamba -c conda-forge --quiet
conda list
- name: Test constructor-manager-cli
- name: Install constructor-manager-environment dependencies
run: |
cd constructor-manager-cli
pytest -v --color=yes --cov=constructor_manager_cli
conda install -n constructor-manager conda packaging requests pyyaml -c conda-forge --quiet
- name: Install dependencies constructor-manager
# List installed packages
conda list
- name: Install constructor-manager
run: |
cd constructor-manager
pip install -e ".[testing]"
pip list
pip install -e . --no-deps
# List installed packages
conda list
- name: Install test dependencies
run: |
conda install -n constructor-manager pytest pytest-cov -c conda-forge --quiet
# List installed packages
conda list
- name: Test constructor-manager
run: |
cd constructor-manager
pytest -v --color=yes --cov=constructor_manager
cd constructor-manager/src
# Run Tests
pytest constructor_manager --cov=constructor_manager
50 changes: 0 additions & 50 deletions .github/workflows/tests_ui.yml

This file was deleted.

8 changes: 4 additions & 4 deletions .github/workflows/typing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- main
paths:
- 'constructor-manager/**'
- 'constructor-manager-cli/**'
- 'constructor-manager-api/**'
- 'constructor-manager-ui/**'
workflow_dispatch:

Expand All @@ -30,16 +30,16 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies cli
- name: Install dependencies
run: |
cd constructor-manager-cli
cd constructor-manager
python -m pip install --upgrade pip
python -m pip install mypy typing-extensions types-requests types-urllib3 typing-inspect mypy-extensions types-PyYAML
pip list
- name: Typing
run: |
cd constructor-manager-cli
cd constructor-manager
mypy src
- name: Install dependencies
Expand Down
4 changes: 2 additions & 2 deletions constructor-manager/src/constructor_manager/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Constructor manager."""

__version__ = "0.0.1"
VERSION_INFO = (0, 0, 1)
__version__ = "0.1.0"
VERSION_INFO = (0, 1, 0)
21 changes: 3 additions & 18 deletions constructor-manager/src/constructor_manager/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def _remove_shortcuts(self, version: str):
prefix = get_prefix_by_name(f"{self._application_name}-{version}")
menu_spec = f"{self._application_name}-menu={version}"
rc = self._installer.uninstall(
pkg_list=[menu_spec], prefix=str(prefix), shortcuts=True, block=True
pkg_list=[menu_spec], prefix=str(prefix), block=True
)
return rc, paths

Expand Down Expand Up @@ -807,25 +807,10 @@ def clean_all(
# Add actions taken by the clean all command
return {}

def uninstall(
self,
lock_created: Optional[bool] = None,
) -> Dict:
"""Uninstall the bundle application."""
# Remove all shortcuts

# Remove all the application environments

# Remove the constructor environment

# Remove the base environment

# Remove everything else with rm rf $CONDA_PREFIX

def open(
self,
version: str = None,
target_prefix: str = None,
version: Optional[str] = None,
target_prefix: Optional[str] = None,
lock_created: Optional[bool] = None,
) -> Dict:
"""Open the application with package name and version."""
Expand Down
14 changes: 6 additions & 8 deletions constructor-manager/src/constructor_manager/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ def __init__(self) -> None:
# -------------------------- Public API ------------------------------
def install(
self,
prefix: str,
pkg_list: Sequence[str],
*,
prefix: Optional[str] = None,
block: bool = False,
) -> job_id:
"""Install packages in `pkg_list` into `prefix`.
Expand All @@ -71,7 +70,9 @@ def install(
return self._queue_args(self._get_install_args(pkg_list, prefix))

def uninstall(
self, pkg_list: Sequence[str], *, prefix: Optional[str] = None
self,
prefix: str,
pkg_list: Sequence[str],
) -> job_id:
"""Uninstall packages in `pkg_list` from `prefix`.
Expand Down Expand Up @@ -370,9 +371,8 @@ def remove(self, prefix: str, block: bool = False) -> job_id:

def install(
self,
prefix: Optional[str],
prefix: str,
pkg_list: Sequence[str],
shortcuts: bool = False,
block: bool = False,
) -> job_id:
"""Install packages in `pkg_list` into `prefix`.
Expand All @@ -393,10 +393,8 @@ def install(

def uninstall(
self,
prefix: str,
pkg_list: Sequence[str],
*,
prefix: Optional[str] = None,
shortcuts: bool = False,
block: bool = False,
) -> job_id:
"""Uninstall packages in `pkg_list` from `prefix`.
Expand Down
2 changes: 1 addition & 1 deletion constructor-manager/src/constructor_manager/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def _configure_logging(log_level: str = "WARNING"):
log_level : str, optional
Log level, by default ``"WARNING"``.
"""
log_level = getattr(logging, log_level.upper(), logging.WARNING)
log_level = getattr(logging, log_level.upper(), logging.WARNING) # type: ignore
log_format = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
logging.basicConfig(format=log_format, level=log_level)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ def test_conda_installer_install_uninstall(use_mamba):
installer = CondaInstaller(use_mamba=use_mamba)

# Install
_ = installer.install([pkg], prefix=prefix, block=True)
_ = installer.install(prefix, [pkg], block=True)

pkgs = installer.list(prefix=prefix, block=True)
print("HELLO", pkgs)
pkg_names = [pkg["name"] for pkg in pkgs]
assert pkg in pkg_names

# Uninstall
_ = installer.uninstall([pkg], prefix=prefix, block=True)
_ = installer.uninstall(prefix, [pkg], block=True)
pkgs = installer.list(prefix=prefix, block=True)
print("HELLO 2", pkgs)
pkg_names = [pkg["name"] for pkg in pkgs]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import platform

from constructor_manager.utils.conda import get_base_prefix, get_prefix_by_name
from menuinst.api import _load, install, remove
from menuinst.api import _load, install, remove # type: ignore

TEMPLATE = {
"$schema": "https://json-schema.org/draft-07/schema",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@


def test_get_base_prefix():
assert str(get_base_prefix()) == sys.prefix
assert str(get_base_prefix()) != sys.prefix


def test_get_prefix_by_name():
assert get_prefix_by_name() == get_base_prefix()
assert get_prefix_by_name() == get_base_prefix() / "envs" / "constructor-manager"
assert get_prefix_by_name("base") == get_base_prefix()
assert get_prefix_by_name("foo") == get_base_prefix() / "envs" / "foo"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


def test_user_agent():
from constructor_manager_cli import __version__
from constructor_manager import __version__

assert _user_agent() == f"constructor-manager-{__version__}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
("0.4.15", True),
("0.4.15rc1", False),
("0.4.15dev0", False),
("0.4.15beta", False),
("0.4.15alfa", False),
("0.4.15b0", False),
("0.4.15a0", False),
(("0", "4"), True),
(("0", "4", "15"), True),
(("0", "4", "15", "rc1"), False),
(("0", "4", "15", "beta"), False),
(("0", "4", "15", "b"), False),
],
)
def test_is_stable_version(test_input, expected):
Expand All @@ -32,9 +32,8 @@ def test_is_stable_version(test_input, expected):
"0.4.15",
"0.4.15rc1",
"0.4.15dev0",
"0.4.15beta",
"0.4.15alfa",
"whatever",
"0.4.15b0",
"0.4.15a0",
],
)
def test_parse_version(test_input):
Expand Down
31 changes: 0 additions & 31 deletions constructor-manager/tox.ini

This file was deleted.

0 comments on commit 1e905c4

Please sign in to comment.