Skip to content

Commit

Permalink
Merge pull request #34 from capitalone/dev
Browse files Browse the repository at this point in the history
Release 2022.7.0
  • Loading branch information
Faisal authored Jul 15, 2022
2 parents e089337 + 02afd18 commit b11f6c5
Show file tree
Hide file tree
Showing 9 changed files with 312 additions and 89 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ repos:
files: ^edgetest_conda/
language_version: python3.9
- repo: https://github.com/jazzband/pip-tools
rev: 5.5.0
rev: 6.8.0
hooks:
- id: pip-compile
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down
12 changes: 0 additions & 12 deletions .whitesource

This file was deleted.

71 changes: 38 additions & 33 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@
import os
import sys

sys.path.insert(0, os.path.abspath('../..'))
sys.path.insert(0, os.path.abspath("../.."))


# -- Project information -----------------------------------------------------

project = 'Conda edgetest plugin'
copyright = '2021, Akshay Gupta'
author = 'Akshay Gupta'
project = "Conda edgetest plugin"
copyright = "2021, Akshay Gupta"
author = "Akshay Gupta"

# The short X.Y version
version = "2022.4.1"
version = "2022.7.0"
# The full version, including alpha/beta/rc tags
release = ''
release = ""


# -- General configuration ---------------------------------------------------
Expand All @@ -40,29 +40,29 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.doctest',
'sphinx.ext.todo',
'sphinx.ext.coverage',
'sphinx.ext.imgmath',
'sphinx.ext.viewcode',
'sphinx.ext.githubpages',
'sphinx.ext.napoleon',
"sphinx.ext.autodoc",
"sphinx.ext.doctest",
"sphinx.ext.todo",
"sphinx.ext.coverage",
"sphinx.ext.imgmath",
"sphinx.ext.viewcode",
"sphinx.ext.githubpages",
"sphinx.ext.napoleon",
"sphinx_tabs.tabs",
"sphinx_copybutton",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
source_suffix = ".rst"

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand All @@ -77,14 +77,14 @@
exclude_patterns = []

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"

# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'furo'
html_theme = "furo"

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand All @@ -95,7 +95,7 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
Expand All @@ -113,7 +113,7 @@
# -- Options for HTMLHelp output ---------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'edgetest_condadoc'
htmlhelp_basename = "edgetest_condadoc"


# -- Options for LaTeX output ------------------------------------------------
Expand All @@ -122,15 +122,12 @@
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
Expand All @@ -140,10 +137,13 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc,
'edgetest_conda.tex',
'Conda edgetest plugin Documentation',
'Akshay Gupta', 'manual'),
(
master_doc,
"edgetest_conda.tex",
"Conda edgetest plugin Documentation",
"Akshay Gupta",
"manual",
),
]


Expand All @@ -152,8 +152,7 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'edgetest_conda', 'Conda edgetest plugin Documentation',
[author], 1)
(master_doc, "edgetest_conda", "Conda edgetest plugin Documentation", [author], 1)
]


Expand All @@ -163,9 +162,15 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'edgetest_conda', 'Conda edgetest plugin Documentation',
author, 'Conda edgetest plugin', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
"edgetest_conda",
"Conda edgetest plugin Documentation",
author,
"Conda edgetest plugin",
"One line description of project.",
"Miscellaneous",
),
]


Expand Down
5 changes: 5 additions & 0 deletions docs/source/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,14 @@ you will need to modify the configuration file:
python_version = 3.8
upgrade =
myupgrade
update_with_conda = True
.. important::

If you have `mamba <https://github.com/mamba-org/mamba>`_ installed (via ``conda``) in your
execution environment, this plugin will use ``mamba`` to create your individual testing
environments.

``update_with_conda`` is optional. The default behaviour is ``False``. Accepted values are ``True`` or ``False`` if
provided. If ``True`` the update command will be executed using ``conda`` or ``mamba``. If ``False`` the update command
will be executed using the default behaviour using ``pip``.
2 changes: 1 addition & 1 deletion edgetest_conda/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Package initialization."""

__version__ = "2022.4.1"
__version__ = "2022.7.0"

__title__ = "edgetest-conda"
__description__ = "Conda edgetest plugin"
Expand Down
69 changes: 67 additions & 2 deletions edgetest_conda/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import json
from pathlib import Path
from typing import Dict
from typing import Dict, List

import pluggy
from edgetest.logger import get_logger
Expand All @@ -23,6 +23,10 @@ def addoption(schema: Schema):
schema : Schema
The schema class.
"""

def to_bool(x):
return x.lower() in ["true", "1"]

schema.add_envoption(
"conda_install",
{
Expand All @@ -36,6 +40,14 @@ def addoption(schema: Schema):
schema.add_envoption(
"python_version", {"type": "string", "default": "3.7", "coerce": str}
)
schema.add_envoption(
"update_with_conda",
{
"type": "boolean",
"coerce": to_bool,
"required": False,
},
)


def _check_mamba() -> bool:
Expand Down Expand Up @@ -65,7 +77,7 @@ def _check_mamba() -> bool:
status = False
except RuntimeError:
raise RuntimeError(
"Unable to run ``conda list``. Please check that you ``conda`` is available."
"Unable to run ``conda list``. Please check that ``conda`` is available."
)

return status
Expand All @@ -84,6 +96,13 @@ def create_environment(basedir: Path, envname: str, conf: Dict):
conf : dict
The configuration dictionary for the environment. We will look for ``conda_install``.
Returns
-------
bool
For ``firstresult`` mark compatability in Pluggy
https://pluggy.readthedocs.io/en/stable/index.html#first-result-only
Raises
------
RuntimeError
Expand Down Expand Up @@ -112,3 +131,49 @@ def create_environment(basedir: Path, envname: str, conf: Dict):
"--yes",
)
LOG.info(f"Successfully installed conda packages for {envname}")

return True


@hookimpl
def run_update(basedir: Path, envname: str, upgrade: List, conf: Dict):
"""Update packages from upgrade list.
Parameters
----------
basedir : Path
The base directory location for the environment.
envname : str
The name of the virtual environment.
upgrade : list
The list of packages to upgrade
conf : dict
The configuration dictionary for the environment. We will look for ``update_with_conda``.
Returns
-------
bool
For ``firstresult`` mark compatability in Pluggy
https://pluggy.readthedocs.io/en/stable/index.html#first-result-only
Raises
------
RuntimeError
Error raised if the packages cannot be updated.
"""
if conf["update_with_conda"] is False:
return None

env_manager = "mamba" if _check_mamba() else "conda"
try:
_run_command(
env_manager,
"update",
"-p",
str(basedir / envname),
*upgrade,
"--yes",
)
return True
except Exception:
raise RuntimeError(f"Unable to {env_manager} update: {upgrade}")
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
#
cerberus==1.3.4
# via edgetest
click==8.0.4
click==8.1.3
# via edgetest
edgetest==2022.3.1
edgetest==2022.7.0
# via edgetest-conda (setup.cfg)
packaging==21.3
# via edgetest
pluggy==1.0.0
# via edgetest
pyparsing==3.0.8
pyparsing==3.0.9
# via packaging
tabulate==0.8.9
# via edgetest
Expand Down
Loading

0 comments on commit b11f6c5

Please sign in to comment.