Skip to content

Commit

Permalink
[157] Update package manager to poetry
Browse files Browse the repository at this point in the history
  • Loading branch information
borland667 authored and Osvaldo Demo committed Apr 16, 2024
1 parent 00cbdd1 commit 2d93f3b
Show file tree
Hide file tree
Showing 12 changed files with 1,647 additions and 1,481 deletions.
6 changes: 6 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[run]
branch = True

[report]
show_missing = True
skip_covered = True
26 changes: 13 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ LABEL vendor="Binbash Leverage ([email protected])"
RUN apk update &&\
apk add --no-cache bash bash-completion ncurses git curl gcc musl-dev python3 python3-dev py3-pip

ENV POETRY_VIRTUALENVS_CREATE=false
ENV PATH="${PATH}:/root/.poetry/bin"

# Install bats from source
RUN git clone https://github.com/bats-core/bats-core.git && ./bats-core/install.sh /usr/local
# Install other bats modules
Expand All @@ -16,19 +19,16 @@ RUN mkdir /root/.ssh
# Needed for git to run propertly
RUN touch /root/.gitconfig

WORKDIR /leverage
RUN git config --global --add safe.directory /leverage
# Install requirements for running unit tests
COPY ./dev-requirements.txt .
RUN pip install -r dev-requirements.txt
RUN curl -sSL https://install.python-poetry.org | POETRY_HOME=/usr/local POETRY_VERSION=1.8.2 python3 -

RUN git config --global --add safe.directory /workdir

# Copying all necessary files to /workdir directory
COPY . /workdir
WORKDIR /workdir

RUN poetry install --with=dev --with=main

COPY entrypoint.sh /
# Make script to configure and start docker daemon the default entrypoint
RUN echo $'#!/bin/bash \n\
# Configure docker daemon to listen through socket \n\
mkdir /etc/docker \n\
echo \'{"tls": false, "hosts": ["unix:///var/run/docker.sock"]}\' > /etc/docker/daemon.json\n\
# Start daemon silently \n\
dockerd > /dev/null 2>&1 & \n\
exec "$@" \n' >> /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT [ "/entrypoint.sh" ]
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ test-unit-no-cov: ## Run unit tests with no coverage report
docker run --rm --privileged --mount type=bind,src=$(shell pwd),dst=/leverage -t ${LEVERAGE_TESTING_IMAGE}:${LEVERAGE_TESTING_TAG} pytest --verbose --no-cov

test-int: ## Run integration tests
docker run --rm --privileged --mount type=bind,src=$(shell pwd),dst=/leverage --env LEVERAGE_IMAGE_TAG=${LEVERAGE_IMAGE_TAG} -t ${LEVERAGE_TESTING_IMAGE}:${LEVERAGE_TESTING_TAG} bash -c "pip3 install -e . > /dev/null && bats --verbose-run --show-output-of-passing-tests -p -r tests/bats"
docker run --rm --privileged --mount type=bind,src=$(shell pwd),dst=/leverage --env LEVERAGE_IMAGE_TAG=${LEVERAGE_IMAGE_TAG} -t ${LEVERAGE_TESTING_IMAGE}:${LEVERAGE_TESTING_TAG} bash -c "bats --verbose-run --show-output-of-passing-tests --print-output-on-failure -T -t -p -r tests/bats"

tests: test-unit-no-cov test-int ## Run full set of tests

setup: ## Set up requirements
python3 -m pip3 install --user --upgrade pipenv && pipenv install --dev
poetry install --with=dev --with=main

clean: ## Clean build files
rm -rf ./build/
Expand Down
30 changes: 0 additions & 30 deletions Pipfile

This file was deleted.

1,405 changes: 0 additions & 1,405 deletions Pipfile.lock

This file was deleted.

15 changes: 0 additions & 15 deletions dev-requirements.txt

This file was deleted.

7 changes: 7 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
# Configure docker daemon to listen through socket
mkdir /etc/docker
echo '{"tls": false, "hosts": ["unix:///var/run/docker.sock"]}' > /etc/docker/daemon.json
# Start daemon silently
dockerd > /dev/null 2>&1 &
exec "$@"
1,561 changes: 1,561 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

58 changes: 56 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,63 @@
[tool.poetry]
name = "leverage"
version = "0.0.0"
description = "Binbash Leverage Command-Line tool."
authors = ["BinBash Inc <[email protected]>"]
license = "MIT"
readme = "README.md"
homepage = "https://github.com/binbashar/leverage"
repository = "https://github.com/binbashar/leverage"
documentation = "https://leverage.binbash.co/"
keywords = ["leverage", "binbash"]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Topic :: Software Development :: Build Tools",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10"
]
packages = [
{ include = "leverage" },
{ include = "leverage/modules" },
{ include = "leverage/containers" }
]

[tool.poetry.dependencies]
python = "^3.8"
click = "8.0.1"
yaenv = "1.4.1"
"ruamel.yaml" = "0.17.10"
jinja2 = "3.0.1"
docker = "6.1.0"
dockerpty = "0.4.1"
questionary = "1.10.0"
python-hcl2 = "3.0.1"
boto3 = "1.33.2"
configupdater = "3.2"
docutils = "0.17.1"
rich = "10.4.0"

[tool.poetry.group.dev.dependencies]
pylint = "2.8.3"
pytest = "6.2.4"
pytest-cov = "2.12.1"
twine = "3.4.1"
black = "23.3.0"


[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.poetry.scripts]
leverage = "leverage:leverage"

[tool.black]
line-length = 120
extend-exclude = """
simple_build_bad_syntax.py
"""

12 changes: 0 additions & 12 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,6 @@ packages =
leverage/modules
leverage/containers
python_requires = >= 3.8
install_requires =
yaenv == 1.4.1
ruamel.yaml == 0.17.10
click == 8.0.1
rich == 10.4.0
jinja2 == 3.0.1
docker == 6.1.0
dockerpty == 0.4.1
questionary == 1.10.0
python-hcl2 == 3.0.1
boto3 == 1.33.2
configupdater == 3.2
include_package_data = True

[options.entry_points]
Expand Down
2 changes: 1 addition & 1 deletion tests/bats/leverage_terraform.bats
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ teardown(){
# Create required build.env in root directory and go there
cd "$ROOT_DIR"

run leverage terraform version
run leverage -vvv terraform version

assert_output --regexp "[\S\s]*Terraform v[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}[\s\S]*"
}
2 changes: 1 addition & 1 deletion tests/bats/utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ _create_directory_structure(){

_create_leverage_directory_structure(){
: " Create a temporary directory structure, initialize
a git repository in the root of such structrue and
a git repository in the root of such structure and
print its path
"
ROOT_DIR="$(_create_directory_structure)"
Expand Down

0 comments on commit 2d93f3b

Please sign in to comment.