forked from procrastinate-org/procrastinate
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev-env
More file actions
90 lines (76 loc) · 2.85 KB
/
dev-env
File metadata and controls
90 lines (76 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# This file is meant to be sourced, not executed:
# source ./dev-env
# We're doing our best to keep it compatible with bash and zsh.
if [ -z "$VIRTUAL_ENV" ]; then
if [ ! -d ".venv" ]; then
echo "Creating virtual environment at .venv"
if which virtualenv; then
virtualenv .venv
else
python3 -m venv .venv
fi
fi
echo "Activating virtual environment at .venv"
source .venv/bin/activate
fi
echo ""
echo "Virtualenv is present and active!"
echo ""
if ! ls .venv/lib/python*/site-packages/procrastinate.egg-link 1>/dev/null 2>&1; then
echo "Installing package for development"
pip install -r requirements.txt
fi
echo ""
echo "Procrastinate is installed!"
echo ""
if ! which pg_isready; then
# When installing libpq from Homebrew, it's not added to the path automatically.
if [ -e /usr/local/opt/libpq/bin/psql ]; then
export PATH="$PATH:usr/local/opt/libpq/bin:"
else
# It's not a good idea not to install system-wide stuff without asking.
echo "Please install psql and libpq utils on your machine:"
echo "Ubuntu:"
echo " sudo apt install postgresql-client"
echo "MacOS (using Homebrew):"
echo " brew install libpq"
return
fi
fi
if ! pg_isready ; then
echo "Starting database"
export PGDATABASE=procrastinate PGHOST=localhost PGUSER=postgres PGPASSWORD=password
docker-compose up -d postgres
sleep 3
fi
echo ""
echo "Database is ready!"
echo ""
if ! pg_dump --schema-only --table=procrastinate_jobs 1>/dev/null 2>&1; then
echo "Applying migrations"
procrastinate schema --apply
fi
echo "Migrations applied!"
export PROCRASTINATE_APP=procrastinate_demo.app.app
alias htmlcov='python -m webbrowser file://$(pwd)/htmlcov/index.html'
alias htmldoc='python -m webbrowser file://$(pwd)/docs/_build/html/index.html'
alias check-lint='tox -e check-lint'
alias format='tox -e format'
alias docs='tox -e docs'
echo ""
echo "Welcome to the Procrastinate development environment interactive shell!"
echo ""
echo "You'll find the detailed instructions in the contributing documentation:"
echo " https://procrastinate.readthedocs.io/en/latest/contributing.html"
echo ""
echo "TL;DR: important commands:"
echo "- pytest: Launch the tests"
echo "- tox: Entrypoint for testing multiple python versions as well as docs, linters & formatters"
echo "- procrastinate: Test procrastinate locally."
echo ""
echo "We've gone ahead and set up a few additional commands for you:"
echo "- htmlcov: Opens the test coverage results in your browser"
echo "- htmldoc: Opens the locally built sphinx documentation in your browser"
echo "- check-lint: shorthand for tox -e check-lint (validates code style)"
echo "- format: shorthand for tox -e format (rewrites files according to code style)"
echo "- docs: shorthand for tox -e docs (builds the doc)"