Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow aicoe-ci to do only tox and precommit checks #145

Merged
merged 1 commit into from
Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .aicoe-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
check:
- thoth-tox
harshad16 marked this conversation as resolved.
Show resolved Hide resolved
- thoth-precommit
release:
- upload-pypi-sesheta
harshad16 marked this conversation as resolved.
Show resolved Hide resolved
24 changes: 0 additions & 24 deletions .coafile

This file was deleted.

2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @goern @harshad16 @fridex @frenzymadness
* @goern @harshad16 @fridex @frenzymadness
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@

## Description

<!--- Describe your changes in detail -->
<!--- Describe your changes in detail -->
54 changes: 54 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
repos:
- repo: git://github.com/Lucas-C/pre-commit-hooks
rev: v1.1.9
hooks:
- id: remove-tabs

- repo: git://github.com/pre-commit/pre-commit-hooks
rev: v3.3.0
hooks:
- id: trailing-whitespace
- id: check-merge-conflict
- id: end-of-file-fixer
- id: check-added-large-files
- id: check-byte-order-marker
- id: check-case-conflict
- id: check-docstring-first
- id: check-json
- id: detect-private-key
- id: check-ast
- id: debug-statements

- repo: git://github.com/pycqa/pydocstyle.git
rev: 5.1.1
hooks:
- id: pydocstyle

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.3.0
hooks:
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.790
hooks:
- id: mypy
exclude: '^(docs|tasks|tests)|setup\.py'
args: [--ignore-missing-imports]

- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
- id: black

- repo: https://gitlab.com/PyCQA/flake8
rev: '3.8.4'
hooks:
- id: flake8
additional_dependencies: ['pep8-naming']
# Ignore all format-related checks as Black takes care of those.
args: ['--ignore', 'E2,W5', '--select', 'E,W,F,N', '--max-line-length=150']
11 changes: 0 additions & 11 deletions .zuul.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ lock files or converting them to `pip-tools
<https://pypi.org/project/pip-tools/>`_ compatible output. Designed for
containerized Python applications but not limited to them.

For a brief video preview, `check this demo
For a brief video preview, `check this demo
<https://www.youtube.com/watch?v=I-QC83BcLuo&t=8m58s>`_ (the micropipenv
part starts at 9:00) or this
`blog post <https://medium.com/swlh/a-bridge-to-two-python-dependency-pinning-worlds-micropipenv-5da674f38e89>`_.
Expand Down Expand Up @@ -348,7 +348,7 @@ dependencies managed by Poetry:
$ micropipenv requirements --no-default > dev-requirements.txt
$ micropipenv requirements --no-default --only-direct > dev-requirements.in

For OpenShift's s2i integration,
For OpenShift's s2i integration,
`check this repo with a demo <https://github.com/fridex/s2i-example-micropipenv>`_.

Installation
Expand Down
47 changes: 26 additions & 21 deletions micropipenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,13 @@
_DEBUG = int(os.getenv("MICROPIPENV_DEBUG", 0))
_NO_LOCKFILE_PRINT = int(os.getenv("MICROPIPENV_NO_LOCKFILE_PRINT", 0))
_NO_LOCKFILE_WRITE = int(os.getenv("MICROPIPENV_NO_LOCKFILE_WRITE", 0))
_FILE_METHOD_MAP = OrderedDict([ # The order here defines priorities
("Pipfile.lock", "pipenv"),
("poetry.lock", "poetry"),
("requirements.txt", "requirements"),
])
_FILE_METHOD_MAP = OrderedDict(
[ # The order here defines priorities
("Pipfile.lock", "pipenv"),
("poetry.lock", "poetry"),
("requirements.txt", "requirements"),
]
)


class MicropipenvException(Exception):
Expand Down Expand Up @@ -304,7 +306,10 @@ def install_pipenv(
cmd = [pip_bin, "install", "--no-deps", "--disable-pip-version-check", "-r", tmp_file.name, *(pip_args or [])]
_LOGGER.debug("Requirements will be installed using %r", cmd)

packages = chain(sections.get("default", {}).items(), sections.get("develop", {}).items() if dev else [],)
packages = chain(
sections.get("default", {}).items(),
sections.get("develop", {}).items() if dev else [],
)

# We maintain an integer assigned to each package - this integer holds a value - how
# many times the given package failed to install. If a package fails to install, it is
Expand Down Expand Up @@ -360,7 +365,9 @@ def _instantiate_package_finder(pip_session): # type: (PipSession) -> PackageFi
from pip._internal.models.search_scope import SearchScope
from pip._internal.models.selection_prefs import SelectionPreferences

selection_prefs = SelectionPreferences(allow_yanked=True,)
selection_prefs = SelectionPreferences(
allow_yanked=True,
)
search_scope = SearchScope([], [])

try:
Expand All @@ -370,13 +377,14 @@ def _instantiate_package_finder(pip_session): # type: (PipSession) -> PackageFi
from pip._internal.collector import LinkCollector
except ModuleNotFoundError: # pip>=19.2<20
return PackageFinder.create(
session=pip_session,
selection_prefs=selection_prefs,
search_scope=search_scope
session=pip_session, selection_prefs=selection_prefs, search_scope=search_scope
)

link_collector = LinkCollector(session=pip_session, search_scope=search_scope)
return PackageFinder.create(link_collector=link_collector, selection_prefs=selection_prefs,)
return PackageFinder.create(
link_collector=link_collector,
selection_prefs=selection_prefs,
)


def _get_requirement_info(requirement): # type: (ParsedRequirement) -> Dict[str, Any]
Expand All @@ -391,9 +399,7 @@ def _get_requirement_info(requirement): # type: (ParsedRequirement) -> Dict[str
# Check for unsupported VCS.
link_url = getattr(requirement, "requirement", None) or getattr(requirement, "link", None)
if link_url and str(link_url).startswith(("hg+", "svn+", "bzr+")):
raise NotSupportedError(
"Non-Git VCS requirement {!r} is not supported yet".format(str(link_url))
)
raise NotSupportedError("Non-Git VCS requirement {!r} is not supported yet".format(str(link_url)))

is_url = False
req = None
Expand Down Expand Up @@ -679,9 +685,7 @@ def _poetry2pipfile_lock(

if "source" in entry:
if entry["source"]["type"] != "git":
raise NotSupportedError(
"micropipenv supports Git VCS, got {} instead".format(entry["source"]["type"])
)
raise NotSupportedError("micropipenv supports Git VCS, got {} instead".format(entry["source"]["type"]))

requirement["git"] = entry["source"]["url"]
requirement["ref"] = entry["source"]["reference"]
Expand Down Expand Up @@ -792,7 +796,8 @@ def install(
if not paths:
raise FileNotFound(
"Failed to find Pipfile.lock, poetry.lock or requirements.txt "
"in the current directory or any of its parent: {}".format(os.getcwd()))
"in the current directory or any of its parent: {}".format(os.getcwd())
)

_LOGGER.debug("Dependencies definitions found: %s", paths)
# The longest path means that we are as close to CWD as possible.
Expand Down Expand Up @@ -909,8 +914,8 @@ def _get_package_entry_str(
result = "--editable {}".format(info.get("path", "."))
else:
result = package_name
if info.get('file'):

if info.get("file"):
result = "{}#egg{}".format(info.get("file"), package_name)

if info.get("extras"):
Expand Down Expand Up @@ -1052,7 +1057,7 @@ def requirements(


def main(argv=None): # type: (Optional[List[str]]) -> int
"""Main for micropipenv."""
"""Micropipenv Main Function."""
argv = argv or sys.argv[1:]

parser = argparse.ArgumentParser(prog=__title__, description=__doc__)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
-i https://pypi.org/simple
-i https://pypi.org/simple
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Setup file for micropipenv python package."""
from setuptools import setup
import os

Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# type: ignore
"""Configure tests for micropipenv."""

import pytest
import os
Expand Down
2 changes: 1 addition & 1 deletion tests/data/install/pip-tools/_Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/data/install/pipenv/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/data/install/pipenv_editable/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/data/install/pipenv_file/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/data/install/pipenv_iter_index/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/data/install/pipenv_vcs_editable/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/data/install/poetry/_Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/data/install/poetry_vcs/_Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/data/parse/pip-tools/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/data/parse/poetry/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions tests/generate_test_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
# A simple script to generate data to be reviewed for the test suite.

for i in default dev extras marker source extras_marker; do
pushd "data/requirements/${i}/"
pushd "data/requirements/${i}/"

python3 ../../../../micropipenv.py requirements --no-hashes > requirements_no_hashes.txt
python3 ../../../../micropipenv.py requirements --no-indexes > requirements_no_indexes.txt
python3 ../../../../micropipenv.py requirements --no-versions > requirements_no_versions.txt
python3 ../../../../micropipenv.py requirements --only-direct > requirements_only_direct.txt
python3 ../../../../micropipenv.py requirements --no-comments > requirements_no_comments.txt
python3 ../../../../micropipenv.py requirements --no-default > requirements_no_default.txt
python3 ../../../../micropipenv.py requirements --no-dev > requirements_no_dev.txt
python3 ../../../../micropipenv.py requirements --no-hashes > requirements_no_hashes.txt
python3 ../../../../micropipenv.py requirements --no-indexes > requirements_no_indexes.txt
python3 ../../../../micropipenv.py requirements --no-versions > requirements_no_versions.txt
python3 ../../../../micropipenv.py requirements --only-direct > requirements_only_direct.txt
python3 ../../../../micropipenv.py requirements --no-comments > requirements_no_comments.txt
python3 ../../../../micropipenv.py requirements --no-default > requirements_no_default.txt
python3 ../../../../micropipenv.py requirements --no-dev > requirements_no_dev.txt

popd
popd
done
Loading