Skip to content

Instantly share code, notes, and snippets.

@matthewdeanmartin
Created September 14, 2016 12:32
Show Gist options
  • Save matthewdeanmartin/94f4da45eb1c3d3ae5fa5e03d626fa05 to your computer and use it in GitHub Desktop.
Save matthewdeanmartin/94f4da45eb1c3d3ae5fa5e03d626fa05 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
#ex
# !/usr/bin/env bash -ex
clear
# guarantee expected environment
pyenv local miniconda3-4.0.5
# fails inside .sh script!
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
pyenv activate mc-twitter-folk
pyenv virtualenvs | grep '*'
# SEPARATE FILE FOR PIP/CONDA stuff
# Generate docs
#cd docs
#make html
#cd ..
# Should pick up stray dead code
python -m compileall -q .
echo Running nose tests...
nosetests --with-doctest --doctest-tests
if [[ $? -eq 0 ]] ; then
echo "Tests OK "
else
echo "At Least 1 test failed"
echo "FAILED"
exit -1
fi
#find . -name "*.py" -exec pylint -E '{}' +
echo Running lint...
rm lint.txt
pylint --rcfile=pylintrc twitter_folk>lint.txt
echo Too many lines or not...
lines=$(cat lint.txt | wc -l)
echo Currently $lines of lint
if [[ $lines -lt 5 ]] ; then
echo "Lint is okay " $lines
else
cat lint.txt
echo "Lint is out of control!"
echo "FAILED"
exit -1
fi
# conda install pytest-cov
PYTHONPATH=.
# --junitxml
echo Running py-test-coverage...
# https://coverage.readthedocs.io/en/latest/config.html related?
py.test --cov=twitter_folk tests --cov-report html
if [[ $? -eq 0 ]] ; then
echo "Test Coverage OK "
else
echo "Test coverage is too low"
echo "FAILED"
exit -1
fi
cd web
python manage.py collectstatic --link
# TODO: grunt tasks for CSS, and JS.
if [[ $? -eq 0 ]] ; then
echo "Collect static okay"
else
echo "Collect static failed"
echo "FAILED"
exit -1
fi
python manage.py test
if [[ $? -eq 0 ]] ; then
echo "Django Tests OK"
else
echo "Django Tests failed"
echo "FAILED"
exit -1
fi
cd ..
# package
echo Creating a setup.py build distribution
python setup.py build>setup_build_trace.txt
if [[ $? -eq 0 ]] ; then
echo "setup.py build OK"
else
echo "setup.py failed"
echo "FAILED"
exit -1
fi
echo Creating a source distribution
python setup.py sdist --formats=gztar,zip>sdist_trace.txt
if [[ $? -eq 0 ]] ; then
echo "Sdist OK"
else
echo "Sdist failed"
echo "FAILED"
exit -1
fi
# run it.
#python main.py
# Send to vagrant!
# Send to AWS test!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment