From f8efb2d7ea33c2a4fe9eb5d04e79a781b77d8962 Mon Sep 17 00:00:00 2001 From: Ama Asare Date: Tue, 3 May 2016 16:15:29 -0500 Subject: [PATCH 1/3] Ama/Chris #7121 Added script to run or test redash vagrant server in one command. --- Vagrantfile | 7 +++++++ circle.yml | 4 +--- docs/dev/vagrant.rst | 28 +++++----------------------- install_requirements.sh | 5 +++++ run_redash_locally.sh | 7 +++++++ run_tests.sh | 7 +++++++ vagrant_provision.sh | 13 +++++++++++++ 7 files changed, 45 insertions(+), 26 deletions(-) create mode 100755 install_requirements.sh create mode 100755 run_redash_locally.sh create mode 100644 run_tests.sh create mode 100755 vagrant_provision.sh diff --git a/Vagrantfile b/Vagrantfile index 7af657f2ac..c24a14a229 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -8,4 +8,11 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = "redash/dev" config.vm.synced_folder "./", "/opt/redash/current" config.vm.network "forwarded_port", guest: 5000, host: 9001 + config.vm.provision "shell" do |s| + s.inline = "/opt/redash/current/install_requirements.sh" + end + config.vm.provision "shell" do |s| + s.inline = "/opt/redash/current/vagrant_provision.sh" + s.privileged = false + end end diff --git a/circle.yml b/circle.yml index e93e92d05c..5ab71e1e7c 100644 --- a/circle.yml +++ b/circle.yml @@ -9,9 +9,7 @@ machine: 2.7.3 dependencies: pre: - - pip install -r requirements_dev.txt - - pip install -r requirements.txt - - pip install pymongo==3.2.1 + - ./install_requirements.sh - if [ "$CIRCLE_BRANCH" = "master" ]; then make deps; fi cache_directories: - rd_ui/node_modules/ diff --git a/docs/dev/vagrant.rst b/docs/dev/vagrant.rst index 40fa8e2e18..2b2114c05f 100644 --- a/docs/dev/vagrant.rst +++ b/docs/dev/vagrant.rst @@ -14,28 +14,10 @@ To get started with this box: `Vagrant `__ installed. 2. Clone the Re:dash repository: ``git clone https://github.com/getredash/redash.git``. -3. Change dir into the repository (``cd redash``) and run run - ``vagrant up``. This might take some time the first time you run it, +3. Change dir into the repository (``cd redash``) +4a. To execute tests, run ``./run_tests.sh`` +4b. To run the app, run ``./run_redash_locally.sh``. + This might take some time the first time you run it, as it downloads the Vagrant virtual box. -4. Once Vagrant is ready, ssh into the instance (``vagrant ssh``), and - change dir to ``/opt/redash/current`` -- this is where your local - repository copy synced to. -5. Copy ``.env`` file into this directory (``cp ../.env ./``). -6. From ``/opt/redash/current/rd_ui`` run ``bower install`` to install - frontend packages. This can be done from your host machine as well, - if you have bower installed. -7. Go back to ``/opt/redash/current`` and install python dependencies - ``sudo pip install -r requirements.txt`` -8. Update database schema to the latest version: - - :: - - bin/run ./manage.py database drop_tables - bin/run ./manage.py database create_tables - bin/run ./manage.py users create --admin --password admin "Admin" "admin" -9. Purging the Redis cache - ``redis-cli -n 1 FLUSHALL`` -10. Start the server and background workers with - ``bin/run honcho start -f Procfile.dev``. -11. Now the server should be available on your host on port 9001 and you + Now the server should be available on your host on port 9001 and you can login with username admin and password admin. diff --git a/install_requirements.sh b/install_requirements.sh new file mode 100755 index 0000000000..7bd79c0169 --- /dev/null +++ b/install_requirements.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +pip install -r /opt/redash/current/requirements_dev.txt +pip install -r /opt/redash/current/requirements.txt +pip install pymongo==3.2.1 \ No newline at end of file diff --git a/run_redash_locally.sh b/run_redash_locally.sh new file mode 100755 index 0000000000..2fe0f1aaa0 --- /dev/null +++ b/run_redash_locally.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +#Provision VM +vagrant up + +#start server and background workers +vagrant ssh -c "cd /opt/redash/current; bin/run honcho start -f Procfile.dev" & \ No newline at end of file diff --git a/run_tests.sh b/run_tests.sh new file mode 100644 index 0000000000..40e8e07866 --- /dev/null +++ b/run_tests.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +#Provision VM +vagrant up + +#Run tests +vagrant ssh -c "cd /opt/redash/current; nosetests --with-coverage --cover-package=redash tests/" \ No newline at end of file diff --git a/vagrant_provision.sh b/vagrant_provision.sh new file mode 100755 index 0000000000..aa06b86668 --- /dev/null +++ b/vagrant_provision.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +cd /opt/redash/current +cp /opt/redash/.env /opt/redash/current +cd /opt/redash/current/rd_ui +bower install +cd /opt/redash/current + +#update database +bin/run ./manage.py database drop_tables +bin/run ./manage.py database create_tables +bin/run ./manage.py users create --admin --password admin "Admin" "admin" + From 90f0b3b49a4c9d1510cc3a3bb6085761ed6e2606 Mon Sep 17 00:00:00 2001 From: Ama Asare Date: Sun, 8 May 2016 19:44:22 -0500 Subject: [PATCH 2/3] Ama: Consolidate vagrant_provision script, move files to more intuitive locations, include command from #1021. Also reset circle.yml to be as in the main redash repo so our changes are not included in the changeset Check earlier PR https://github.com/getredash/redash/pull/1027 to follow conversation. --- Vagrantfile | 5 +---- bin/vagrant_ctl.sh | 21 +++++++++++++++++++ circle.yml | 6 ++++-- .../vagrant/provision.sh | 9 ++++++++ 4 files changed, 35 insertions(+), 6 deletions(-) create mode 100755 bin/vagrant_ctl.sh rename vagrant_provision.sh => setup/vagrant/provision.sh (56%) diff --git a/Vagrantfile b/Vagrantfile index c24a14a229..875cca8fa6 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -9,10 +9,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.synced_folder "./", "/opt/redash/current" config.vm.network "forwarded_port", guest: 5000, host: 9001 config.vm.provision "shell" do |s| - s.inline = "/opt/redash/current/install_requirements.sh" - end - config.vm.provision "shell" do |s| - s.inline = "/opt/redash/current/vagrant_provision.sh" + s.inline = "/opt/redash/current/setup/vagrant/provision.sh" s.privileged = false end end diff --git a/bin/vagrant_ctl.sh b/bin/vagrant_ctl.sh new file mode 100755 index 0000000000..da08abb236 --- /dev/null +++ b/bin/vagrant_ctl.sh @@ -0,0 +1,21 @@ +#!/bin/bash +set -e + +help() { + echo "Usage: " + echo "`basename "$0"` {start, test}" +} + +case "$1" in + start) + vagrant up + vagrant ssh -c "cd /opt/redash/current; bin/run honcho start -f Procfile.dev;" + ;; + test) + vagrant up + vagrant ssh -c "cd /opt/redash/current; make test" + ;; + *) + help + ;; +esac \ No newline at end of file diff --git a/circle.yml b/circle.yml index 5ab71e1e7c..1b5aab5c2d 100644 --- a/circle.yml +++ b/circle.yml @@ -9,7 +9,9 @@ machine: 2.7.3 dependencies: pre: - - ./install_requirements.sh + - pip install -r requirements_dev.txt + - pip install -r requirements.txt + - pip install pymongo==3.2.1 - if [ "$CIRCLE_BRANCH" = "master" ]; then make deps; fi cache_directories: - rd_ui/node_modules/ @@ -34,4 +36,4 @@ notify: general: branches: ignore: - - gh-pages + - gh-pages \ No newline at end of file diff --git a/vagrant_provision.sh b/setup/vagrant/provision.sh similarity index 56% rename from vagrant_provision.sh rename to setup/vagrant/provision.sh index aa06b86668..7c9f023d84 100755 --- a/vagrant_provision.sh +++ b/setup/vagrant/provision.sh @@ -1,13 +1,22 @@ #!/usr/bin/env bash + cd /opt/redash/current cp /opt/redash/.env /opt/redash/current cd /opt/redash/current/rd_ui bower install cd /opt/redash/current +#install requirements +sudo pip install -r /opt/redash/current/requirements_dev.txt +sudo pip install -r /opt/redash/current/requirements.txt +sudo pip install -r /opt/redash/current/requirements_all_ds.txt + #update database bin/run ./manage.py database drop_tables bin/run ./manage.py database create_tables bin/run ./manage.py users create --admin --password admin "Admin" "admin" +#Purge Redis cache +redis-cli -n 1 FLUSHALL + From d4ff7482adbb679ab9a54ab67e3c25857f2236da Mon Sep 17 00:00:00 2001 From: Ama Asare Date: Mon, 9 May 2016 10:37:50 -0500 Subject: [PATCH 3/3] Ama: Install just pymongo and not everything in requirements_all_ds.txt Because some dependencies were missing and we dont really need everything in the file...just pymongo Also removed unneeded files, reverted circle.yml to as it is on redash, so it doesnt show in the PR diff --- circle.yml | 2 +- docs/dev/vagrant.rst | 4 ++-- install_requirements.sh | 5 ----- run_redash_locally.sh | 7 ------- run_tests.sh | 7 ------- setup/vagrant/provision.sh | 2 +- 6 files changed, 4 insertions(+), 23 deletions(-) delete mode 100755 install_requirements.sh delete mode 100755 run_redash_locally.sh delete mode 100644 run_tests.sh diff --git a/circle.yml b/circle.yml index 1b5aab5c2d..e93e92d05c 100644 --- a/circle.yml +++ b/circle.yml @@ -36,4 +36,4 @@ notify: general: branches: ignore: - - gh-pages \ No newline at end of file + - gh-pages diff --git a/docs/dev/vagrant.rst b/docs/dev/vagrant.rst index 2b2114c05f..40b9171099 100644 --- a/docs/dev/vagrant.rst +++ b/docs/dev/vagrant.rst @@ -15,8 +15,8 @@ To get started with this box: 2. Clone the Re:dash repository: ``git clone https://github.com/getredash/redash.git``. 3. Change dir into the repository (``cd redash``) -4a. To execute tests, run ``./run_tests.sh`` -4b. To run the app, run ``./run_redash_locally.sh``. +4a. To execute tests, run ``./bin/vagrant_ctl.sh test`` +4b. To run the app, run ``./bin/vagrant_ctl.sh start``. This might take some time the first time you run it, as it downloads the Vagrant virtual box. Now the server should be available on your host on port 9001 and you diff --git a/install_requirements.sh b/install_requirements.sh deleted file mode 100755 index 7bd79c0169..0000000000 --- a/install_requirements.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -pip install -r /opt/redash/current/requirements_dev.txt -pip install -r /opt/redash/current/requirements.txt -pip install pymongo==3.2.1 \ No newline at end of file diff --git a/run_redash_locally.sh b/run_redash_locally.sh deleted file mode 100755 index 2fe0f1aaa0..0000000000 --- a/run_redash_locally.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -#Provision VM -vagrant up - -#start server and background workers -vagrant ssh -c "cd /opt/redash/current; bin/run honcho start -f Procfile.dev" & \ No newline at end of file diff --git a/run_tests.sh b/run_tests.sh deleted file mode 100644 index 40e8e07866..0000000000 --- a/run_tests.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -#Provision VM -vagrant up - -#Run tests -vagrant ssh -c "cd /opt/redash/current; nosetests --with-coverage --cover-package=redash tests/" \ No newline at end of file diff --git a/setup/vagrant/provision.sh b/setup/vagrant/provision.sh index 7c9f023d84..1de15f816b 100755 --- a/setup/vagrant/provision.sh +++ b/setup/vagrant/provision.sh @@ -10,7 +10,7 @@ cd /opt/redash/current #install requirements sudo pip install -r /opt/redash/current/requirements_dev.txt sudo pip install -r /opt/redash/current/requirements.txt -sudo pip install -r /opt/redash/current/requirements_all_ds.txt +sudo pip install pymongo==3.2.1 #update database bin/run ./manage.py database drop_tables