#!/bin/bash

set -e

# defaults if not set
: "${SKIP_LINT:=0}"

# run linting of python files
if [ "$SKIP_LINT" -ne 1 ]; then
    echo 'Running linting...'
    flake8 main.py transcoding/ tests/
else
    echo 'Skipping linting...'
fi

# run pytest with args set
echo 'Running tests...'
export Environment=test
PYTHONDONTWRITEBYTECODE=1 COVERAGE_FILE=.coverage pytest $TEST_ARGS tests/ \
    -p no:cacheprovider \
    --cov transcoding \
    --cov-report xml:coverage.xml \
    --cov-report term \
    --junitxml=pyunit.xml

echo 'Done!'
