Add Vagrantfile, document how to run test suite in a vagrant VM
authorGabe Rosenhouse <rosenhouse@gmail.com>
Wed, 6 Jul 2016 06:07:55 +0000 (23:07 -0700)
committerGabe Rosenhouse <rosenhouse@gmail.com>
Wed, 6 Jul 2016 06:12:02 +0000 (23:12 -0700)
.gitignore
CONTRIBUTING.md
Vagrantfile [new file with mode: 0644]

index 06f78b4..f130579 100644 (file)
@@ -1,3 +1,4 @@
 bin/
 gopath/
 *.sw[ponm]
+.vagrant
index fc637b1..fbbcd3a 100644 (file)
@@ -37,10 +37,35 @@ This is a rough outline of how to prepare a contribution:
 - Make commits of logical units.
 - Make sure your commit messages are in the proper format (see below).
 - Push your changes to a topic branch in your fork of the repository.
-- If you changed code, make sure the tests pass, and add any new tests as appropriate.
-- Make sure any new code files have a license header.
+- If you changed code:
+   - add automated tests to cover your changes, using the [Ginkgo](http://onsi.github.io/ginkgo/) & [Gomega](http://onsi.github.io/gomega/) style
+   - if the package did not previously have any test coverage, add it to the list
+   of `TESTABLE` packages in the `test` script.
+   - run the full test script and ensure it passes
+- Make sure any new code files have a license header (this is now enforced by automated tests)
 - Submit a pull request to the original repository.
 
+## How to run the test suite
+We generally require test coverage of any new features or bug fixes.
+
+Here's how you can run the test suite on any system (even Mac or Windows) using
+ [Vagrant](https://www.vagrantup.com/) and a hypervisor of your choice:
+
+```bash
+vagrant up
+vagrant ssh
+# you're now in a shell in a virtual machine
+sudo su
+cd /go/src/github.com/containernetworking/cni
+
+# to run the full test suite
+./test
+
+# to focus on a particular test suite
+cd plugins/main/loopback
+go test
+```
+
 # Acceptance policy
 
 These things will make a PR more likely to be accepted:
@@ -48,7 +73,7 @@ These things will make a PR more likely to be accepted:
  * a well-described requirement
  * tests for new code
  * tests for old code!
- * new code follows the conventions in old code
+ * new code and tests follow the conventions in old code and tests
  * a good commit message (see below)
 
 In general, we will merge a PR once two maintainers have endorsed it.
diff --git a/Vagrantfile b/Vagrantfile
new file mode 100644 (file)
index 0000000..93b2866
--- /dev/null
@@ -0,0 +1,20 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+Vagrant.configure(2) do |config|
+  config.vm.box = "bento/ubuntu-16.04"
+
+  config.vm.synced_folder ".", "/go/src/github.com/containernetworking/cni"
+
+  config.vm.provision "shell", inline: <<-SHELL
+    set -e -x -u
+
+    apt-get update -y || (sleep 40 && apt-get update -y)
+    apt-get install -y golang git
+    echo "export GOPATH=/go" >> /root/.bashrc
+    export GOPATH=/go
+    go get github.com/tools/godep
+    cd /go/src/github.com/containernetworking/cni
+    /go/bin/godep restore
+  SHELL
+end