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

# CI Entry point for BMU Smoke Tests

# Export vehicle architecture variable
export VEHICLE_ARCHITECTURE=vh6a/a

# 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

# Build Docker containers
cd firmware/validation/docker/net_man
./build.sh bmu
cd $origin

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

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

# DBC files are generated by the make_dbcs fixture defined in the dbc_builder.py plugin.

# Run Smoke Test
python -m pytest firmware/validation/bmu/test_deploy.py \
                 --verbose

# Run everything else
python -m pytest firmware/validation/bmu/ \
                 --ignore=firmware/validation/bmu/test_deploy.py \
                 --verbose

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