Skip to content

Latest commit

 

History

History
91 lines (57 loc) · 3.28 KB

CONTRIBUTING.md

File metadata and controls

91 lines (57 loc) · 3.28 KB

Contributing

Development is set up for Unix/Linux/Mac systems. Some of the instructions below may not work properly on Windows.

Preparing an environment

  • Install Go.
  • Install Godep: go get github.com/tools/godep.
  • Install go vet: go get code.google.com/p/go.tools/cmd/vet.
  • Fork the clc-go-cli repo
  • Setup your forked repo according to this guide
  • Ensure your $GOPATH is set correctly. Working in a clean environment without any other packages on $GOPATH is highly encouraged to avoid conflicts with the dependencies of the tool. Using a gvm tool is a good choice for setting up a clean environment. Also, gvm is a convenient tool for installing cross-compilation prerequisites.

Developing

  • Create a new branch for your change

  • The TDD approach is recommended - write a failing test first, then fix it.

  • Use a dev script to run commands as you change the code:

    ./dev <resource> <command>
    

    This way you do not need to rebuild the tool every time you alter something.

  • Before making a pull request check that gofmt -d=true ./.. and go vet ./... do not produce any output (except for that coming from Godeps/_workspace - ignore it).

  • Push your branch to your fork and then make a pull request from your branch to master on https://github.com/CenturyLinkCloud/clc-go-cli

  • Do not commit until the unit tests have passed (./run_tests).

  • If you want to make an executable, simply run ./scripts/build. The binary will appear in the ./out folder.

  • The integration tests can be running ./run_integration_tests.

  • The API file can be regenerated by running ./scripts/generate_api.

Building the releases

Generally, any Linux/Darwin machine should work for building the releases. A Darwin machine is required though if you want to build a MacOS .pkg.

  • Install gvm

  • Install the cross-compilation prerequisites:

./scripts/install_platform_commands
  • Build the releases:
./scripts/build_releases <version>

At first, the script updates base/constants.go with the given version. This is needed for the tool to use the relevant user agent information. After that, the script builds a binary for each of the following OS/arch flavors:

  • Linux/amd4
  • Windows/amd64
  • MacOS/amd64

The binaries are packaged along with utility scripts as described in the Install section. The folders are then archived - a .tar.gz file is made for Linux and Mac; a .zip file is made for Windows.

Here is a full list of the created artifacts:

  • clc-$version-linux-amd64/
  • clc-$version-linux-amd64.tar.gz
  • clc-$version-darwin-amd64
  • clc-$version-darwin-amd64.tar.gz
  • clc-$version-windows-amd64/
  • clc-$version-windows-amd64.zip

Building a .pkg for MacOS

  • Build a regular MacOS release using the command from the previous section

  • Execute the following script to build a .pkg file:

./scripts/build_darwin_pkg <version>

Note: the version has to match the version you specified in the previous section.

You should see 2 artifacts after executing this script:

  • clc-$version-pkg
  • clc-$version.pkg