#!/usr/bin/env bash
# @copyright Highly Confidential and Proprietary Zoox Information. Copyright (c) Zoox.

# -e Exit script on any error
# -o pipefail Do not propagate errors silently thru pipes
set -eo pipefail

echo "repo_info/$0::START pwd="`pwd`

# Clear any packages that may be present
rm -f dist/* 2> /dev/null

# Generate new Python package in dist/
echo "repo_info/$0::CREATE_SDIST"
python3.6 setup.py sdist 2> /dev/null

# Install the requirements
pip3.6 install -r requirements.txt

# Install test requirements (needed for CI)
pip3.6 install -r test_requirements.txt

# Install the package into the virtualenv
pip3.6 install --force-reinstall dist/*

# Navigate cwd to repo root to satisfy bazel_info runtime requirements
pushd ./../../../../

# Run the tests
echo "Running tests against Python"
pytest -v firmware/validation/py_packages/repo_info/tests/  --log-format="[PYTHON_%(levelname)s] %(module)s.%(funcName)s  %(message)s"

# Restore cwd
popd

echo "repo_info/$0::FINISH"
