This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Add Travis-CI integration.

The only way to test travis is to deploy to master with a `.travis.yml` file and wait for travis-ci to pick up the change.  To do some pre-testing here, the `Vagrantfile` has been split into two distinct machines:

 * `default` is, as before, the full reddit build (we have an opportunity to rename this)
 * `travis` is a minimal install with only the packages and services required to run `nosetests` against the codebase.  It tries to mimic what will happen when we try to build this on travis-ci's workers.

As part of this addition, I've moved `install-reddit.sh` to `install/reddit.sh` and populated that `install` folder with common scripts used for both `default` and `travis` builds.
  • Loading branch information...
KeyserSosa committed Jan 14, 2016
1 parent 817c1c6 commit 69698a9d12e8cafe21e3be3fd3a02cbb906bd744
View
@@ -0,0 +1,26 @@
sudo: required
dist: trusty
language: python
python:
- "2.7"
virtualenv:
system_site_packages: true
services:
- postgres
- memcached
- rabbitmq
install:
- sudo install/travis.sh travis .
before_script:
- install/setup_rabbitmq.sh
- install/setup_postgres.sh
- install/setup_cassandra.sh
script:
- cd r2 && nosetests
View
@@ -25,6 +25,14 @@
# each plugin directory is that "reddit-plugin-NAME" should be in the directory
# {ROOTDIR}/NAME.
#
# This VagrantFile allows for the creation of two VMs:
# * default: the primary VM, with all services necessary to run reddit
# locally against the local codebase.
# * travis: Testing-only VM suitable for running `nosetests` and debugging
# issues encountered without having to wait for travis-ci to pick
# up the build. This will *not* be the same environment as
# travis, but it should be useful for repairing broken tests.
#
# To start your vagrant box simply enter `vagrant up` from {ROOTDIR}/reddit.
# You can then ssh into it with `vagrant ssh`.
#
@@ -49,7 +57,7 @@ overlay_mount = "/home/#{vagrant_user}/src"
overlay_lower = code_share_guest_path
overlay_upper = "/home/#{vagrant_user}/.overlay"
# vm config
# "default" vm config
guest_ip = "192.168.56.111"
guest_mem = "4096"
guest_swap = "4096"
@@ -62,11 +70,6 @@ Vagrant.configure(2) do |config|
config.vm.box_download_checksum = "0975e1a73226563ec7791c9b2fd114a57e918e401f82f4778a44e43040e39609"
config.vm.box_download_checksum_type = "sha256"
config.vm.hostname = hostname
# host-only network interface
config.vm.network "private_network", ip: guest_ip
# mount the host shared folder
config.vm.synced_folder code_share_host_path, code_share_guest_path, mount_options: ["ro"]
@@ -88,7 +91,7 @@ Vagrant.configure(2) do |config|
fi
SCRIPT
# setup the overlay filesystem
# set up the overlay filesystem
config.vm.provision "shell", inline: <<-SCRIPT
if [ ! -d #{overlay_mount} ]; then
echo "creating overlay mount directory #{overlay_mount}"
@@ -104,49 +107,90 @@ Vagrant.configure(2) do |config|
mount -t overlayfs overlayfs -o lowerdir=#{overlay_lower},upperdir=#{overlay_upper} #{overlay_mount}
SCRIPT
# run install script
plugin_string = plugins.join(" ")
config.vm.provision "shell", inline: <<-SCRIPT
if [ ! -f /var/local/reddit_installed ]; then
echo "running install script"
cd /home/#{vagrant_user}/src/reddit
REDDIT_PLUGINS="#{plugin_string}" REDDIT_DOMAIN="#{hostname}" ./install-reddit.sh
touch /var/local/reddit_installed
else
echo "install script already run"
fi
SCRIPT
# setup private code
if File.exist?("#{code_share_host_path}/private/vagrant_setup.sh")
config.vm.provision "shell",
path: "#{code_share_host_path}/private/vagrant_setup.sh",
args: [vagrant_user]
# NOTE: This VM exists solely to assist in writing tests. It does not actually
# install travis but rather builds a minimal vm with only the services
# available under a travis build to aid in test debugging (via `nosetests`)
# To use:
# $ vagrant up travis
# $ vagrant ssh travis
# vagrant@travis$ cd src/reddit/r2 && nosetests
config.vm.define "travis", autostart: false do |travis|
travis.vm.hostname = "travis"
# run install script
plugin_string = plugins.join(" ")
travis.vm.provision "shell", inline: <<-SCRIPT
if [ ! -f /var/local/reddit_installed ]; then
echo "running install script"
cd /home/#{vagrant_user}/src/reddit
./install/travis.sh vagrant
touch /var/local/reddit_installed
else
echo "install script already run"
fi
SCRIPT
end
# inject test data
config.vm.provision "shell", inline: <<-SCRIPT
if [ ! -f /var/local/test_data_injected ]; then
cd /home/#{vagrant_user}/src/reddit
sudo -u #{vagrant_user} reddit-run scripts/inject_test_data.py -c 'inject_test_data()'
touch /var/local/test_data_injected
else
echo "inject test data already run"
fi
# HACK: stop and start everything (otherwise sometimes there's an issue with
# ports being in use?)
reddit-stop
reddit-start
SCRIPT
# additional setup
config.vm.provision "shell", inline: <<-SCRIPT
if [ ! -f /var/local/additional_setup ]; then
apt-get install -y ipython avahi-daemon
touch /var/local/additional_setup
else
echo "additional setup already run"
fi
SCRIPT
# NB: this is the primary VM. To build run
# $ vagrant up
# [though 'vagrant up default' will also work, the 'default' is redudnant]
# Once built, avahi-daemon should guarantee the instance will be accessible
# from https://reddit.local/
config.vm.define "default", primary: true do |redditlocal|
redditlocal.vm.hostname = hostname
# host-only network interface
redditlocal.vm.network "private_network", ip: guest_ip
# run install script
plugin_string = plugins.join(" ")
redditlocal.vm.provision "shell", inline: <<-SCRIPT
if [ ! -f /var/local/reddit_installed ]; then
echo "running install script"
cd /home/#{vagrant_user}/src/reddit
REDDIT_PLUGINS="#{plugin_string}" REDDIT_DOMAIN="#{hostname}" ./install/reddit.sh
touch /var/local/reddit_installed
else
echo "install script already run"
fi
SCRIPT
# set up private code
if File.exist?("#{code_share_host_path}/private/vagrant_setup.sh")
redditlocal.vm.provision "shell",
path: "#{code_share_host_path}/private/vagrant_setup.sh",
args: [vagrant_user]
end
# inject test data
redditlocal.vm.provision "shell", inline: <<-SCRIPT
if [ ! -f /var/local/test_data_injected ]; then
cd /home/#{vagrant_user}/src/reddit
sudo -u #{vagrant_user} reddit-run scripts/inject_test_data.py -c 'inject_test_data()'
touch /var/local/test_data_injected
else
echo "inject test data already run"
fi
# HACK: stop and start everything (otherwise sometimes there's an issue with
# ports being in use?)
reddit-stop
reddit-start
SCRIPT
# additional setup
redditlocal.vm.provision "shell", inline: <<-SCRIPT
if [ ! -f /var/local/additional_setup ]; then
apt-get install -y ipython avahi-daemon
touch /var/local/additional_setup
else
echo "additional setup already run"
fi
SCRIPT
# DONE: let this run whenever provision is run so that the user can see
# how to proceed.
redditlocal.vm.provision "shell", inline: <<-SCRIPT
cd /home/#{vagrant_user}/src/reddit
REDDIT_DOMAIN="#{hostname}" ./install/done.sh
SCRIPT
end
end
Oops, something went wrong.

0 comments on commit 69698a9

Please sign in to comment.