From 50169c11eba013c6715199be7707a3149df854a8 Mon Sep 17 00:00:00 2001 From: LoveIsGrief Date: Sat, 15 Nov 2014 22:22:27 +0100 Subject: [PATCH 1/5] Introduce vagrant for testing [Vagrant](https://www.vagrantup.com/) allows us to test all changes in a virtual machine. We can "vagrant up" into a clean environment and "vagrant destroy" whenever --- Vagrantfile | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++ provision.sh | 10 ++++ 2 files changed, 137 insertions(+) create mode 100644 Vagrantfile create mode 100644 provision.sh diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000000..a6b3c56a78 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,127 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! +VAGRANTFILE_API_VERSION = "2" + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + # All Vagrant configuration is done here. The most common configuration + # options are documented and commented below. For a complete reference, + # please see the online documentation at vagrantup.com. + + # Every Vagrant virtual environment requires a box to build off of. + config.vm.box = "hashicorp/precise64" + + config.vm.provision "shell", + path: "provision.sh", + privileged: false + + # Disable automatic box update checking. If you disable this, then + # boxes will only be checked for updates when the user runs + # `vagrant box outdated`. This is not recommended. + # config.vm.box_check_update = false + + # Create a forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine. In the example below, + # accessing "localhost:8080" will access port 80 on the guest machine. + # config.vm.network "forwarded_port", guest: 80, host: 8080 + + # Create a private network, which allows host-only access to the machine + # using a specific IP. + # config.vm.network "private_network", ip: "192.168.33.10" + + # Create a public network, which generally matched to bridged network. + # Bridged networks make the machine appear as another physical device on + # your network. + # config.vm.network "public_network" + + # If true, then any SSH connections made will enable agent forwarding. + # Default value: false + # config.ssh.forward_agent = true + + # Share an additional folder to the guest VM. The first argument is + # the path on the host to the actual folder. The second argument is + # the path on the guest to mount the folder. And the optional third + # argument is a set of non-required options. + # config.vm.synced_folder "../data", "/vagrant_data" + + # Provider-specific configuration so you can fine-tune various + # backing providers for Vagrant. These expose provider-specific options. + # Example for VirtualBox: + # + # config.vm.provider "virtualbox" do |vb| + # # Don't boot with headless mode + # vb.gui = true + # + # # Use VBoxManage to customize the VM. For example to change memory: + # vb.customize ["modifyvm", :id, "--memory", "1024"] + # end + # + # View the documentation for the provider you're using for more + # information on available options. + + # Enable provisioning with CFEngine. CFEngine Community packages are + # automatically installed. For example, configure the host as a + # policy server and optionally a policy file to run: + # + # config.vm.provision "cfengine" do |cf| + # cf.am_policy_hub = true + # # cf.run_file = "motd.cf" + # end + # + # You can also configure and bootstrap a client to an existing + # policy server: + # + # config.vm.provision "cfengine" do |cf| + # cf.policy_server_address = "10.0.2.15" + # end + + # Enable provisioning with Puppet stand alone. Puppet manifests + # are contained in a directory path relative to this Vagrantfile. + # You will need to create the manifests directory and a manifest in + # the file default.pp in the manifests_path directory. + # + # config.vm.provision "puppet" do |puppet| + # puppet.manifests_path = "manifests" + # puppet.manifest_file = "default.pp" + # end + + # Enable provisioning with chef solo, specifying a cookbooks path, roles + # path, and data_bags path (all relative to this Vagrantfile), and adding + # some recipes and/or roles. + # + # config.vm.provision "chef_solo" do |chef| + # chef.cookbooks_path = "../my-recipes/cookbooks" + # chef.roles_path = "../my-recipes/roles" + # chef.data_bags_path = "../my-recipes/data_bags" + # chef.add_recipe "mysql" + # chef.add_role "web" + # + # # You may also specify custom JSON attributes: + # chef.json = { mysql_password: "foo" } + # end + + # Enable provisioning with chef server, specifying the chef server URL, + # and the path to the validation key (relative to this Vagrantfile). + # + # The Opscode Platform uses HTTPS. Substitute your organization for + # ORGNAME in the URL and validation key. + # + # If you have your own Chef Server, use the appropriate URL, which may be + # HTTP instead of HTTPS depending on your configuration. Also change the + # validation key to validation.pem. + # + # config.vm.provision "chef_client" do |chef| + # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME" + # chef.validation_key_path = "ORGNAME-validator.pem" + # end + # + # If you're using the Opscode platform, your validator client is + # ORGNAME-validator, replacing ORGNAME with your organization name. + # + # If you have your own Chef Server, the default validation client name is + # chef-validator, unless you changed the configuration. + # + # chef.validation_client_name = "ORGNAME-validator" + +end diff --git a/provision.sh b/provision.sh new file mode 100644 index 0000000000..9f577c9d31 --- /dev/null +++ b/provision.sh @@ -0,0 +1,10 @@ +#!/bin/bash +sudo apt-get update -qq +sudo apt-get install -y git fish + +# Switch to fish as a default shell +sudo chsh -s `which fish` vagrant + +# Install nvm +export METHOD=copy +/vagrant/install.sh From 6acce5246ac226f3537bcecb84dbb25b31e7cbda Mon Sep 17 00:00:00 2001 From: LoveIsGrief Date: Sat, 15 Nov 2014 22:47:35 +0100 Subject: [PATCH 2/5] Introduce "copy" METHOD for installation This method copies the folder containing install.sh (normally also containing the repo) to $NVM_DIR - unless of course the install.sh being executed is in $NVM_DIR (where nvm was installed) This is useful for vagrant to test local changes instead of pulling them from git and thus testing what's on the server and not local changes --- install.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/install.sh b/install.sh index 897459317a..adb7bf59f5 100755 --- a/install.sh +++ b/install.sh @@ -109,6 +109,18 @@ nvm_do_install() { exit 1 fi install_nvm_as_script + elif [ "~$METHOD" = "~copy" ]; then + local COPY=true + if [ $DIR = $NVM_DIR ]; then + echo "=> install.sh is already in $NVM_DIR" + COPY=false + elif [ -d $NVM_DIR ]; then + echo "=> $NVM_DIR already exists and its contents will be replaced" + fi + mkdir -p $NVM_DIR + if $COPY; then + cp -R $DIR/* $NVM_DIR + fi fi echo From 4770f43ae4f68c5e72d0a0d4f86b7221112dab21 Mon Sep 17 00:00:00 2001 From: LoveIsGrief Date: Sun, 16 Nov 2014 15:38:50 +0100 Subject: [PATCH 3/5] Revert "Introduce "copy" METHOD for installation" This reverts commit 6acce5246ac226f3537bcecb84dbb25b31e7cbda. --- install.sh | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/install.sh b/install.sh index adb7bf59f5..897459317a 100755 --- a/install.sh +++ b/install.sh @@ -109,18 +109,6 @@ nvm_do_install() { exit 1 fi install_nvm_as_script - elif [ "~$METHOD" = "~copy" ]; then - local COPY=true - if [ $DIR = $NVM_DIR ]; then - echo "=> install.sh is already in $NVM_DIR" - COPY=false - elif [ -d $NVM_DIR ]; then - echo "=> $NVM_DIR already exists and its contents will be replaced" - fi - mkdir -p $NVM_DIR - if $COPY; then - cp -R $DIR/* $NVM_DIR - fi fi echo From 771e89ee42818ddbf2239d0ec1885d2899ad9c2e Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 16 Nov 2014 15:52:26 +0100 Subject: [PATCH 4/5] Oops, forgot to remove copy installation method When vagrant is provisioned it will choose an automatic method from now (which means git or script with the newest version of nvm from the web) --- provision.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/provision.sh b/provision.sh index 9f577c9d31..433ba099f8 100644 --- a/provision.sh +++ b/provision.sh @@ -6,5 +6,4 @@ sudo apt-get install -y git fish sudo chsh -s `which fish` vagrant # Install nvm -export METHOD=copy /vagrant/install.sh From e47a04b130a2be150ddd9796fb0fdd2bdf4b4e41 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 16 Nov 2014 18:42:22 +0100 Subject: [PATCH 5/5] Add make to provision.sh and remove fish as default shell Make is needed for the tests to run The tests don't run with with either as `npm test` uses the "shell" package which tries to execute shell commands in its parent shell. If the shell is fish..well, it doesn't work. --- provision.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/provision.sh b/provision.sh index 433ba099f8..4382437609 100644 --- a/provision.sh +++ b/provision.sh @@ -1,9 +1,9 @@ #!/bin/bash sudo apt-get update -qq -sudo apt-get install -y git fish +sudo apt-get install -y git fish make # Switch to fish as a default shell -sudo chsh -s `which fish` vagrant +# sudo chsh -s `which fish` vagrant # Install nvm /vagrant/install.sh