Skip to content

Commit

Permalink
Update Contributing doc
Browse files Browse the repository at this point in the history
  • Loading branch information
SoManyHs committed Feb 13, 2018
1 parent 35cf69d commit 6cb45c6
Showing 1 changed file with 14 additions and 21 deletions.
35 changes: 14 additions & 21 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,20 @@ From `$GOPATH/src/github.com/aws/amazon-ecs-cli`:
* Run `make` (This creates a standalone executable in the `bin/local` directory).

From `$GOPATH/src/github.com/aws/amazon-ecs-cli/ecs-cli`:
* Run `godep restore` (This will download and install dependencies specified in the `Godeps/Godeps.json` into your `$GOPATH`).
* **NOTE:** `godep restore` puts the dependencies in a detached HEAD state (see: [Updating an existing dependency](https://github.com/aws/amazon-ecs-cli/blob/master/README.md#updating-an-existing-dependency)).

### Adding new dependencies
* Make sure you have the latest [godep](https://github.com/tools/godep) (`go get -u github.com/tools/godep`) (version 79)
* `go get` the new dependency.
* Edit your application's source code to import the new dependency.
* From `$GOPATH/src/github.com/aws/amazon-ecs-cli/ecs-cli`, run `godep save ./...` (This will update `Godeps/Godeps.json` and copy the dependencies source to the `vendor/` directory).

### Updating an existing dependency
* While godep recommends using `godep update`, this command unfortunately has several known issues (See: https://github.com/tools/godep/issues/498). We recommend following their [suggestion](https://github.com/tools/godep/issues/498#issuecomment-238946586):
1. Delete any reference to the package in `Godeps/Godeps.json` (you can also delete the entire `Godeps` dir).
1. Delete the package from the `/vendor` dir: `rm -rf $GOPATH/src/github.com/aws/amazon-ecs-cli/ecs-cli/vendor/<package>`. (You can also delete the entire vendor dir)
1. Re-vendor the dependency by running `godep save ./...` from `$GOPATH/src/github.com/aws/amazon-ecs-cli/ecs-cli`.

* Inspect the changes with `git diff` (should show up in `vendor/` directory)
* Example: https://github.com/aws/amazon-ecs-cli/pull/315
* **NOTE:** Unfortunately, using `godep restore` means that `go get` will not work with dependencies. Until we move off `godep`, when we want to update a dependency we will have to go to the dependency in the `$GOPATH` and manually use `git pull` an update to that package.

### Generating mocks
* From `$GOPATH/src/github.com/aws/amazon-ecs-cli/`, run `make generate`. This will look for all files named `generate_mock.go` in the `ecs-cli/modules` directory and call the `mockgen.sh` script, which is a wrapper for the [mockgen](https://github.com/golang/mock#running-mockgen) command.
* run `dep ensure`. This will download dependencies specified in the `Gopkg.lock` by default in `$GOPATH/pkg/dep/sources`.
* **NOTE:** `dep ensure` puts the dependencies in a detached HEAD state.

### Adding/updating new dependencies
* We use [dep](https://github.com/golang/dep) to manage dependencies. Make sure you have the latest [dep](https://github.com/golang/dep) (installation instructions [here](https://golang.github.io/dep/docs/installation.html)).
* To [add a dependency](https://golang.github.io/dep/docs/daily-dep.html#adding-a-new-dependency), run `dep ensure -add <your_package>`.
* To [update a dependency](https://golang.github.io/dep/docs/daily-dep.html#updating-dependencies), run `dep ensure -update<your_package>`.

### Generating mocks/licenses
* From `$GOPATH/src/github.com/aws/amazon-ecs-cli/`, run `make generate`. This
will look for all files named `generate_mock.go` in the `ecs-cli/modules`
directory and call the `scripts/mockgen.sh` script, which is a wrapper for the
[mockgen](https://github.com/golang/mock#running-mockgen) command.
* **NOTE:** `make generate` will also regenerate the license via `scripts/license.sh`.

### Cross-compiling
The `make docker-build` target builds standalone amd64 executables for
Expand Down

0 comments on commit 6cb45c6

Please sign in to comment.