github.com/jingweno/gh@v2.1.1-0.20221007190738-04a7985fa9a1+incompatible/Vagrantfile (about) 1 # -*- mode: ruby -*- 2 # vi: set ft=ruby : 3 4 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 5 # 6 # Place this Vagrantfile in your src folder and run: 7 # 8 # vagrant up 9 # 10 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 11 12 # Vagrantfile API/syntax version. 13 VAGRANTFILE_API_VERSION = "2" 14 15 GO_ARCHIVES = { 16 "linux" => "go1.2.linux-amd64.tar.gz", 17 } 18 19 INSTALL = { 20 "linux" => "apt-get update -qq; apt-get install -qq -y git mercurial bzr curl", 21 } 22 23 # location of the Vagrantfile 24 def src_path 25 ENV["GOPATH"] 26 end 27 28 # shell script to bootstrap Go 29 def bootstrap(box) 30 install = INSTALL[box] 31 archive = GO_ARCHIVES[box] 32 vagrant_home = "/home/vagrant" 33 34 profile = <<-PROFILE 35 export GOROOT=#{vagrant_home}/go 36 export GOPATH=#{vagrant_home}/gocode 37 export PATH=$PATH:$GOROOT/bin:$GOPATH/bin 38 export CDPATH=.:$GOPATH/src/github.com:$GOPATH/src/code.google.com/p:$GOPATH/src/bitbucket.org:$GOPATH/src/launchpad.net 39 PROFILE 40 41 <<-SCRIPT 42 #{install} 43 44 if ! [ -f /home/vagrant/#{archive} ]; then 45 curl -O# https://go.googlecode.com/files/#{archive} 46 fi 47 tar -C /home/vagrant -xzf #{archive} 48 chown -R vagrant:vagrant #{vagrant_home}/go 49 50 if ! grep -q GOPATH #{vagrant_home}/.profile; then 51 echo '#{profile}' >> #{vagrant_home}/.profile 52 fi 53 source #{vagrant_home}/.profile 54 55 chown -R vagrant:vagrant #{vagrant_home}/gocode 56 go get github.com/jingweno/gotask 57 58 echo "\nRun: vagrant ssh #{box} -c 'cd project/path; go test ./...'" 59 SCRIPT 60 end 61 62 Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 63 64 config.vm.define "linux" do |linux| 65 linux.vm.box = "precise64" 66 linux.vm.box_url = "http://files.vagrantup.com/precise64.box" 67 linux.vm.synced_folder "#{src_path}/src/github.com/jingweno/gh", "/home/vagrant/gocode/src/github.com/jingweno/gh" 68 linux.vm.provision :shell, :inline => bootstrap("linux") 69 end 70 71 end