diff --git a/.dockerignore b/.dockerignore index 1269488..b4d8935 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,106 @@ data +/build_venv/ +/.venv/ +/misc/ +/incl/image_service/test/ +/scratch/ +/bamboo-specs/ +README.md +Dockerfile +*idea +*misc +*egg-innfo +*pycache* + +# Git +.git +.gitignore + +# CI +.codeclimate.yml +.travis.yml +.taskcluster.yml + +# Docker +.docker + +# Byte-compiled / optimized / DLL files +__pycache__/ +*/__pycache__/ +*/*/__pycache__/ +*/*/*/__pycache__/ +*.py[cod] +*/*.py[cod] +*/*/*.py[cod] +*/*/*/*.py[cod] + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/** +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.cache +nosetests.xml +coverage.xml + +# Translations +*.mo +*.pot + +# Django stuff: +*.log + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Virtual environment +.env/ +.venv/ +#venv/ + +# PyCharm +.idea + +# Python mode for VIM +.ropeproject +*/.ropeproject +*/*/.ropeproject +*/*/*/.ropeproject + +# Vim swap files +*.swp +*/*.swp +*/*/*.swp +*/*/*/*.swp \ No newline at end of file diff --git a/Dockerfile_tests b/Dockerfile_tests new file mode 100755 index 0000000..d6eb732 --- /dev/null +++ b/Dockerfile_tests @@ -0,0 +1,19 @@ +ARG BASE_ROOT="nexus.iqser.com:5001/red/" +ARG VERSION_TAG="latest" + +FROM ${BASE_ROOT}pyinfra:${VERSION_TAG} + +EXPOSE 5000 +EXPOSE 8080 + +RUN python3 -m pip install coverage + +# Make a directory for the service files and copy the service repo into the container. +WORKDIR /app/service +COPY . . + +# Install module & dependencies +RUN python3 -m pip install -e . +RUN python3 -m pip install -r requirements.txt + +CMD coverage run -m pytest pyinfra/test/ -x && coverage report -m && coverage xml diff --git a/bamboo-specs/src/main/resources/scripts/sonar-scan.sh b/bamboo-specs/src/main/resources/scripts/sonar-scan.sh index 632f69f..8747145 100755 --- a/bamboo-specs/src/main/resources/scripts/sonar-scan.sh +++ b/bamboo-specs/src/main/resources/scripts/sonar-scan.sh @@ -7,8 +7,8 @@ python3 -m venv build_venv source build_venv/bin/activate python3 -m pip install --upgrade pip -pip install -e . -pip install -r requirements.txt +echo "coverage report generation" +bash run_tests.sh SERVICE_NAME=$1 diff --git a/pyinfra/storage/adapters/azure.py b/pyinfra/storage/adapters/azure.py index 532da38..aa28279 100644 --- a/pyinfra/storage/adapters/azure.py +++ b/pyinfra/storage/adapters/azure.py @@ -13,18 +13,6 @@ logging.getLogger("azure").setLevel(logging.WARNING) logging.getLogger("urllib3").setLevel(logging.WARNING) -def _retry(exceptions=Exception): - def inner(func): - @retry(exceptions=exceptions, delay=5, jitter=(0, 3), max_delay=60) - @wraps(func) - def inner(*args, **kwargs): - return func(*args, **kwargs) - - return inner - - return inner - - class AzureStorageAdapter(StorageAdapter): def __init__(self, client): super().__init__(client=client) diff --git a/run_tests.sh b/run_tests.sh new file mode 100755 index 0000000..4e958bc --- /dev/null +++ b/run_tests.sh @@ -0,0 +1,8 @@ +docker build -f Dockerfile_tests -t pyinfra-tests . + +docker-compose -remove-orphans up -d +echo "Sleeping for 30 seconds to wait for dependency containers to finish startup..." +sleep 30s +docker rm /pyinfra-tests +docker run --net=host --name pyinfra-tests pyinfra-tests +docker cp pyinfra-tests:/app/service/reports/coverage.xml reports/coverage.xml