Makefile reforma vol.2 [WIP]
Už máme ty jednoduché targety (nebo byly smazány), zbývá dořešit několik složitých.
This commit is contained in:
parent
9f78963e7f
commit
8b36e79f04
13 changed files with 39 additions and 78 deletions
63
Makefile_old
63
Makefile_old
|
@ -1,44 +1,3 @@
|
||||||
.PHONY: all venv_check clean install install_web install_venv clean_venv clean_schema run test deploy_test deploy_prod sync_test_media sync_test_db sync_test sync_local_media sync_local_db sync_local
|
|
||||||
|
|
||||||
install: install_web
|
|
||||||
|
|
||||||
install_web: venv_check
|
|
||||||
@# venv může být příšerně starý, takže nejdříve upgradujeme venvové věci
|
|
||||||
pip install --upgrade pip
|
|
||||||
pip install --upgrade setuptools
|
|
||||||
# Instalace závislostí webu
|
|
||||||
pip install -r requirements.txt --upgrade
|
|
||||||
# Pro vygenerování tesdat spusť ./manage.py testdata
|
|
||||||
# Po vygenerování testdat spusť ./manage.py loaddata data/*, ať máš menu a další modely
|
|
||||||
# Pro synchronizaci flatpages spusť make sync_prod_flatpages
|
|
||||||
|
|
||||||
install_venv:
|
|
||||||
${VENV} ${VENV_PATH}
|
|
||||||
|
|
||||||
clean_venv:
|
|
||||||
# Možná není 100% foolproof...
|
|
||||||
@test ! ${VENV_PATH} = . || ! echo "Smaž si prosím venv sám, nebudu mazat celý web"
|
|
||||||
rm -rfv ${VENV_PATH}
|
|
||||||
rm -f pip-selfcheck.json
|
|
||||||
clean_schema:
|
|
||||||
rm -f schema_seminar.pdf schema_all.pdf
|
|
||||||
|
|
||||||
run: venv_check
|
|
||||||
./manage.py runserver
|
|
||||||
|
|
||||||
test: venv_check
|
|
||||||
./manage.py test -v2 seminar mamweb
|
|
||||||
|
|
||||||
# DB schemata
|
|
||||||
|
|
||||||
schema: schema_seminar.pdf schema_all.pdf
|
|
||||||
|
|
||||||
schema_seminar.pdf: venv_check
|
|
||||||
./manage.py graph_models seminar | dot -Tpdf > schema_seminar.pdf
|
|
||||||
|
|
||||||
schema_all.pdf: venv_check
|
|
||||||
./manage.py graph_models -a -g | dot -Tpdf > schema_all.pdf
|
|
||||||
|
|
||||||
# Deploy to current *mamweb-test* directory
|
# Deploy to current *mamweb-test* directory
|
||||||
deploy: venv_check
|
deploy: venv_check
|
||||||
@if [ ${USER} != "mam-web" ]; then echo "Only possible by user mam-web"; exit 1; fi
|
@if [ ${USER} != "mam-web" ]; then echo "Only possible by user mam-web"; exit 1; fi
|
||||||
|
@ -104,25 +63,3 @@ sync_test_db_aggressive:
|
||||||
# Sync test with production
|
# Sync test with production
|
||||||
# HACK ALERT: using aggressive variant, due to the schemas being too different.
|
# HACK ALERT: using aggressive variant, due to the schemas being too different.
|
||||||
sync_test: sync_test_media sync_test_db_aggressive
|
sync_test: sync_test_media sync_test_db_aggressive
|
||||||
|
|
||||||
|
|
||||||
# Sync media directory with atrey. Useful for local development with production database
|
|
||||||
# Does not sync Galerie and CACHE (too huge).
|
|
||||||
sync_local_media:
|
|
||||||
rsync -ave ssh --exclude Galerie --exclude CACHE\
|
|
||||||
mam-web@gimli.ms.mff.cuni.cz:/akce/mam/www/mamweb-prod/media/ ./media/
|
|
||||||
# Downloads and restores production database to local database. PostgreSQL only.
|
|
||||||
sync_local_db:
|
|
||||||
scp mam-web@gimli.ms.mff.cuni.cz:`ssh mam-web@gimli.ms.mff.cuni.cz 'ls -v /akce/mam/www/backups/mam_prod-*\.pgdump.xz | tail -n 1'` \
|
|
||||||
./last.pgdump.xz
|
|
||||||
xz -fd last.pgdump.xz
|
|
||||||
pg_restore -c -d mam-prod last.pgdump
|
|
||||||
|
|
||||||
# Sync database and media. See above lines
|
|
||||||
sync_local: sync_local_media sync_local_db
|
|
||||||
|
|
||||||
# Push local compiled Vue to gimli test site
|
|
||||||
push_compiled_vue_to_test:
|
|
||||||
scp vue_frontend/webpack-stats.json mam-web@gimli:/akce/mam/www/mamweb-test/vue_frontend/
|
|
||||||
rsync -ave ssh seminar/static/seminar/vue mam-web@gimli:/akce/mam/www/mamweb-test/seminar/static/seminar/
|
|
||||||
ssh mam-web@gimli.ms.mff.cuni.cz 'cd /akce/mam/www/mamweb-test/ && . env/bin/activate && ./manage.py collectstatic --noinput'
|
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -exuo pipefail
|
set -exuo pipefail
|
||||||
|
. make/lib.sh
|
||||||
|
|
||||||
|
${VENV} ${VENV_PATH}
|
||||||
|
|
|
@ -1,3 +1,16 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -exuo pipefail
|
set -exuo pipefail
|
||||||
|
. make/lib.sh
|
||||||
|
|
||||||
|
ensure_venv
|
||||||
|
|
||||||
|
# Aktualizace toolchainu
|
||||||
|
pip install --upgrade pip setuptools
|
||||||
|
# Instalace závislostí webu
|
||||||
|
pip install -r requirements.txt --upgrade
|
||||||
|
|
||||||
|
# XXX: Připomínka z původního Makefile:
|
||||||
|
echo 'Pro vygenerování tesdat spusť ./manage.py testdata
|
||||||
|
Po vygenerování testdat spusť ./manage.py loaddata data/*, ať máš menu a další modely
|
||||||
|
Pro synchronizaci flatpages spusť make/sync_prod_flatpages'
|
||||||
|
|
|
@ -18,6 +18,7 @@ function die {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Vždycky chceme zajistit, že běžíme z rootu repozitáře
|
# Vždycky chceme zajistit, že běžíme z rootu repozitáře
|
||||||
|
# TODO: chceme? Nechceme naopak umět to spouštět odkudkoliv, aspoň u většiny targetů?
|
||||||
test -d '.git' || die "Make skript spuštěn ve špatné složce, spusť ho z kořenového adresáře repozitáře."
|
test -d '.git' || die "Make skript spuštěn ve špatné složce, spusť ho z kořenového adresáře repozitáře."
|
||||||
|
|
||||||
function ensure_venv {
|
function ensure_venv {
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -exuo pipefail
|
set -exuo pipefail
|
||||||
|
. make/lib.sh
|
||||||
|
|
||||||
|
scp vue_frontend/webpack-stats.json "$GIMLI_LOGIN:$TESTWEB/vue_frontend/"
|
||||||
|
rsync -ave ssh seminar/static/seminar/vue "$GIMLI_LOGIN:$TESTWEB/seminar/static/seminar/"
|
||||||
|
# TODO: Je OK tady zapínat venv přímo takhle, nebo by to taky mělo být enkapsulováno do nějakého skriptu (e.g. make/deploy/collect_static)?
|
||||||
|
ssh "$GIMLI_LOGIN" "cd $TESTWEB && . env/bin/activate && ./manage.py collectstatic --noinput'
|
||||||
|
|
5
make/run
5
make/run
|
@ -1,3 +1,8 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -exuo pipefail
|
set -exuo pipefail
|
||||||
|
. make/lib.sh
|
||||||
|
|
||||||
|
ensure_venv
|
||||||
|
|
||||||
|
./manage.py runserver
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -exuo pipefail
|
set -exuo pipefail
|
||||||
|
. make/lib.sh
|
||||||
|
|
||||||
|
ensure_venv
|
||||||
|
|
||||||
|
./manage.py graph_models seminar | dot -Tpdf > schema_seminar.pdf
|
||||||
|
./manage.py graph_models -a -g | dot -Tpdf > schema_all.pdf
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -exuo pipefail
|
|
|
@ -1,3 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -exuo pipefail
|
|
|
@ -1,3 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -exuo pipefail
|
|
|
@ -1,3 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -exuo pipefail
|
|
|
@ -1,3 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -exuo pipefail
|
|
|
@ -1,3 +1,8 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -exuo pipefail
|
set -exuo pipefail
|
||||||
|
. make/lib.sh
|
||||||
|
|
||||||
|
ensure_venv
|
||||||
|
|
||||||
|
./manage.py test -v2
|
||||||
|
|
Loading…
Reference in a new issue