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 17, 2024
1 parent 00cbdd1 commit 7f80631
Show file tree
Hide file tree
Showing 13 changed files with 1,673 additions and 1,486 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
31 changes: 26 additions & 5 deletions .github/workflows/tests-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,40 @@ on: [push, pull_request]
jobs:
unit_tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ 3.8, 3.9, 3.10 ]

steps:
- uses: actions/checkout@v3

- name: install_requirements
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
run: |
echo "[INFO] Installing Poetry..."
curl -sSL https://install.python-poetry.org | POETRY_HOME=/usr/local POETRY_VERSION=1.8.2 python -
- name: Configure Poetry
run: |
echo "[INFO] Configuring Poetry..."
poetry config virtualenvs.create false # Avoid creating virtual environment
- name: Install dependencies using Poetry
run: |
echo "[INFO] Installing requirements..."
pip install -r dev-requirements.txt
echo "[INFO] Installing dependencies..."
poetry install
- name: run_unit_tests
- name: Run unit tests
run: |
echo "[INFO] Running unit tests and generate coverage report"
pytest --verbose
poetry run pytest --verbose
shell: bash

- name: Report Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
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.

Loading

0 comments on commit 7f80631

Please sign in to comment.