diff --git a/.gitignore b/.gitignore index 06f78b4b..f130579c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ bin/ gopath/ *.sw[ponm] +.vagrant diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fc637b15..fbbcd3ab 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 index 00000000..93b2866a --- /dev/null +++ b/Vagrantfile @@ -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