#!/bin/ash

set -euo pipefail

APK="apk -q --no-cache"
BUILDDEPS="gcc python3-dev musl-dev parallel yaml-dev g++"
TESTDEPS="bitstring pytest wheel virtualenv pip"
PIP3="pip3 -q install --upgrade"
FROOT="/faucet-src"

dir=$(dirname "$0")

${APK} add -U git ${BUILDDEPS}
"${dir}/retrycmd.sh" "${PIP3} ${TESTDEPS}"
"${dir}/retrycmd.sh" "${PIP3} -r ${FROOT}/requirements.txt"
${PIP3} ${FROOT}

if [ "$(uname -m)" = "x86_64" ]; then
  (
  echo "Running unit tests"
  cd "${FROOT}"
  python3 -m unittest discover "tests/unit/faucet/"
  python3 -m unittest discover "tests/unit/gauge/"
  )
else
  echo "Skipping tests on $(uname -m) platform"
fi

pip3 uninstall -y ${TESTDEPS} || exit 1
for i in ${BUILDDEPS} ; do
  ${APK} del "$i" || exit 1
done

# Clean up
rm -r "${HOME}/.cache"
rm -r "${FROOT}"
rm -r /usr/local/lib/python3*/site-packages/os_ken/tests/

# Smoke test
faucet -V || exit 1

find / -name \*pyc -delete || exit 1

#!/bin/ash

set -euo pipefail

APK="apk --no-cache"
BUILDDEPS="gcc python3-dev musl-dev parallel yaml-dev g++"
TESTDEPS="bitstring pytest wheel virtualenv pip"
PIP3="pip3 install --upgrade"
FROOT="/faucet-src"

dir=$(dirname "$0")

${APK} add -U git ${BUILDDEPS}
"${dir}/retrycmd.sh" "${PIP3} ${TESTDEPS}"
"${dir}/retrycmd.sh" "${PIP3} -r ${FROOT}/requirements.txt"
${PIP3} ${FROOT}

if [ "$(uname -m)" = "x86_64" ]; then
  (
  echo "Running unit tests"
  cd "${FROOT}"
  python3 -m unittest discover "tests/unit/faucet/"
  python3 -m unittest discover "tests/unit/gauge/"
  )
else
  echo "Skipping tests on $(uname -m) platform"
fi

pip3 uninstall -y ${TESTDEPS} || exit 1
for i in ${BUILDDEPS} ; do
  ${APK} del "$i" || exit 1
done

# Clean up
rm -r "${HOME}/.cache"
rm -r "${FROOT}"
rm -r /usr/local/lib/python3*/site-packages/os_ken/tests/

# Smoke test
faucet -V || exit 1

find / -name \*pyc -delete || exit 1

Make docker builds less quiet to make debugging issues easier.
Make docker builds less quiet to make debugging issues easier.
