Skip to content

Latest commit

 

History

History
74 lines (46 loc) · 2.64 KB

CONTRIBUTING.md

File metadata and controls

74 lines (46 loc) · 2.64 KB

Hacking on Knitter

Local development

Knitter comes with a Makefile which defines following targets:

  • build - Build all knitter related binaries(e.g. knitter-manager,knitter-agent,knitter-plugin,knitter-mornitor)
  • test-ut - Test knitter with unit test
  • test-e2e - Test knitter with e2e test
  • clean - Clean all output artifacts
  • verify - Execute the source code verification tools(e.g. gofmt,lint,govet)
  • install-extra - Install tools used by verify(e.g. gometalinter)

Test Suites

Knitter uses two levels of testing - unit tests and e2e tests, both of them are run on each pull request, so make sure to run those before submitting one.

Unit tests

Unit tests follow standard Go conventions and are intended to test the behavior and output of a single package in isolation. All code is expected to be easily testable with mock interfaces and stubs, and when they are not it usually means that there's a missing interface or abstraction in the code. A unit test should focus on testing that branches and error conditions are properly returned and that the interface and code flows work as described. Unit tests can depend on other packages but should not depend on other components.

Run the unit tests with:

$ make test-ut

or an individual package unit test with:

$ hack/test-ut.sh pkg/adapter

To run only a certain regex of tests in a package, use:

$ hack/test-ut.sh  pkg/SpecificPackage -test.run=TestSpecificCase

To get verbose output add -v to the end:

$ hack/test-ut.sh pkg/SpecificPackage -test.run=TestSpecificCase -v

Integration tests

The second category are e2e tests which verify the whole Knitter flow.

Run the integration tests with:

$ hack/test-e2e.sh

Installing govendor

Knitter uses govendor for dependency package management. To install godep locally run:

$ go get github.com/kardianos/govendor

If you are not updating packages you should not need govendor installed.

Building a Release

To build a Knitter release you run make release, which will create a build environment image and then execute a cross platform Go build within it. The build output will be copied to _output/releases as a set of tars containing each version.

  1. Create a new git tag git tag vX.X.X -a -m "vX.X.X" HEAD
  2. Push the tag to GitHub git push origin --tags where origin is github.com/ZTE/knitter.git
  3. Run make release
  4. Upload the binary artifacts generated by that build to GitHub release page.
  5. Send an email to the dev list, including the important changes prior to the release.