Skip to content

Commit

Permalink
Adding vagrant setup for ycmd development
Browse files Browse the repository at this point in the history
  • Loading branch information
Valloric committed Feb 1, 2016
1 parent e4ba41a commit e514ab0
Show file tree
Hide file tree
Showing 5 changed files with 183 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ Creating good pull requests
sometimes what you want can be done in a different way if the reason for the
change is known. _What goal is your change trying to accomplish?_

You might also want to easily set up [an environment for ycmd
development][dev-setup].

[build-bots]: https://travis-ci.org/Valloric/ycmd
[ycmd-users]: https://groups.google.com/forum/?hl=en#!forum/ycmd-users
[ycmd-tests]: https://github.com/Valloric/ycmd/blob/master/TESTS.md
[dev-setup]: https://github.com/Valloric/ycmd/blob/master/DEV_SETUP.md
20 changes: 20 additions & 0 deletions DEV_SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Setting up for ycmd development

1. Install [Vagrant][].
2. `cd` into the folder where you checked out ycmd.
3. `$ vagrant up && vagrant ssh`. This will take a while because the VM is being
built and set up. Only needs to happen once though.
4. You are now in the VM. Run the tests with `$ ./run_tests.sh`.
5. Hack away. When done, exit the ssh connection with `exit`.
6. `$ vagrant suspend` so that you can quickly get back to hacking later.
7. Later on: `$ vagrant resume && vagrant ssh`. This will be _much_ faster.

That's it!

You can switch between Python versions with `pyenv global 2.6.6` and `pyenv
global 3.3.0`.

If you ever feel like you've screwed up the VM, just kill it with
`vagrant destroy` and then run `vagrant up` again to get to a clean state.

[vagrant]: https://www.vagrantup.com/
7 changes: 7 additions & 0 deletions TESTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

This readme documents instructions on running the test suite.

The easiest way to run the ycmd test suite locally is to [set up your ycmd dev
environment using Vagrant][dev-setup] which will have everything installed and
ready to go. Reading this file is still useful because you'll learn how to skip
the build or parts of the test suite.

An alternative (canonical) reference is the scripts used for running the tests
on Travis CI. These can be found in `.travis.yml` and `./travis` directory.

Expand Down Expand Up @@ -105,3 +110,5 @@ Likely to be a problem with the OmniSharpServer.
FAIL: ycmd.completers.general.tests.filename_completer_test.FilenameCompleter_test.SystemPathCompletion_test

Ensure that you have UTF-8 support in your environment (see above)

[dev-setup]: https://github.com/Valloric/ycmd/blob/master/DEV_SETUP.md
22 changes: 22 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|
# TODO: update to xenial64 when that comes out
config.vm.box = "ubuntu/trusty64"

# On startup, run our bootstrap script to setup the VM
config.vm.provision :shell, :path => "vagrant_bootstrap.sh"

config.vm.provider "virtualbox" do |v|
# MAGIC for faster guest networking
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
v.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
v.customize ["modifyvm", :id, "--nictype1", "virtio"]

# We need quite a bit of memory to compile more than one ycmd C++ file at a
# time.
v.memory = 2048
v.cpus = 2
end
end
130 changes: 130 additions & 0 deletions vagrant_bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
#!/usr/bin/env bash
#
# Don't forget, this file needs to be idempotent, i.e. running it multiple times
# in a row leaves the system in the same state as if it were run only once.

#######################
# ENV VAR SETUP
#######################

# Makes apt-get STFU about pointless nonsense
export DEBIAN_FRONTEND=noninteractive

# For pyenv Python building
export CFLAGS='-O2'


#######################
# APT-GET INSTALL
#######################

apt-get update
apt-get -yqq dist-upgrade
apt-get install -yqq python-dev
apt-get install -yqq python-setuptools
apt-get install -yqq python3
apt-get install -yqq python3-dev
apt-get install -yqq python3-setuptools
apt-get install -yqq build-essential
apt-get install -yqq cmake
apt-get install -yqq git
apt-get install -yqq golang
apt-get install -yqq mono-complete

# These two are for pyopenssl
apt-get install -yqq libffi-dev
apt-get install -yqq libssl-dev

# These are Python build deps (though it depends on Python version). We need
# them because pyenv builds Python.
apt-get install -yqq libssl-dev
apt-get install -yqq zlib1g-dev
apt-get install -yqq libbz2-dev
apt-get install -yqq libreadline-dev
apt-get install -yqq libsqlite3-dev
apt-get install -yqq wget
apt-get install -yqq curl
apt-get install -yqq llvm
apt-get install -yqq libncurses5-dev
apt-get install -yqq libncursesw5-dev


#######################
# PIP SETUP
#######################

curl -sOL https://bootstrap.pypa.io/get-pip.py
python get-pip.py


#######################
# PYTHON LIBS
#######################

# This is needed to prevent InsecurePlatformWarning from showing up AFTER this
# stuff is installed.
pip install --upgrade pyopenssl ndg-httpsclient pyasn1
pip install -r /vagrant/test_requirements.txt
pip install coveralls


#######################
# NODEJS SETUP & LIBS
#######################

apt-get install -yqq nodejs

# Needed so that the node binary is named 'node' and not 'nodejs'; necessary
# because of scripts that call 'node'.
apt-get install -yqq nodejs-legacy
apt-get install -yqq npm

npm install -g typescript


#######################
# RUST SETUP
#######################

# multirust installation
echo "Installing multirust"
curl -sf https://raw.githubusercontent.com/brson/multirust/master/blastoff.sh \
| sh -s -- --yes >/dev/null 2>&1

# Needs to run as vagrant user otherwise it only sets up a Rust toolchain for
# root, which doesn't do us any good.
su - vagrant -c "multirust default stable 2>/dev/null"


#######################
# PYENV SETUP
#######################

git clone https://github.com/yyuu/pyenv.git /home/vagrant/.pyenv
chown -R vagrant:vagrant /home/vagrant/.pyenv

# Sourcing .profile to determine has provisioning already been done. If it has,
# then we don't re-add setup code.
source /home/vagrant/.profile
if [ -z "$PROVISIONING_DONE" ]; then
echo 'export PROVISIONING_DONE=true' >> /home/vagrant/.profile
echo 'export PYENV_ROOT="/home/vagrant/.pyenv"' >> /home/vagrant/.profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> /home/vagrant/.profile
echo 'eval "$(pyenv init -)"' >> /home/vagrant/.profile
echo 'cd /vagrant' >> /home/vagrant/.profile

# In case we just created the file.
chown vagrant:vagrant /home/vagrant/.profile

# We need the newly-added commands from .profile in the current shell to run
# pyenv.
source /home/vagrant/.profile

pyenv install 2.6.6
pyenv install 3.3.0

# Avoid relying on the system python at all. Devs using some other
# python is perfectly fine, but let's use a supported version by default.
echo 'pyenv global 2.6.6' >> /home/vagrant/.profile
fi

0 comments on commit e514ab0

Please sign in to comment.