#! /bin/sh
set -xe
origin="$PWD"

# CI Entry point for CCC Smoke Tests

# Clean out anything that might be lurking around...
git clean -fdx

# Run the bazel precheck steps (shutdown, remove cache)
firmware/validation/common/ci/bazel_precheck.sh

# Clear out bazel cache
rm -rf ~/.cache/bazel/


# Set up virtualenv
if [ -d ccc_smoke_env ]; then
    rm -rf ccc_smoke_env
fi

virtualenv -p python3.6 ccc_smoke_env
. ccc_smoke_env/bin/activate
python -m pip install -r firmware/validation/ccc_smoke/requirements.txt

# Deploy First!
python -m pytest firmware/validation/ccc_smoke/test_deploy.py \
                 --exitfirst \
                 --verbose

# Now run some smoke tests
python -m pytest firmware/validation/ccc_smoke/ \
                 --ignore=firmware/validation/ccc_smoke/test_deploy.py \
                 --charger_type=CCS \
                 --verbose

# Cleanup bazel job
cd $(bazel info workspace)
firmware/validation/common/ci/bazel_postcheck.sh
