From e8a52d20bc8b3faa2c66b89dd98eb8100e8eed6e Mon Sep 17 00:00:00 2001 From: Jiaxin Shan Date: Sun, 22 Mar 2020 19:32:45 -0700 Subject: [PATCH] Update Contributing docs for recent go changes (#58) As we migrate to go modules and update linter configs, I add a new page to give contributor more guidance on basic setup and development flow. Signed-off-by: Jiaxin Shan --- CONTRIBUTING.md | 61 ++++++++++++++++++++++++++++++++++++++++++ README.md | 2 +- hack/update-codegen.sh | 4 ++- 3 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..bd1aa5ef --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,61 @@ +## Contributing + +mxnet-operator uses go modules and supports both v1beta1 and v1. We suggest to use golang 1.13.x for development. +Make sure you enable `GO111MODULE`. + +### Setup development environment + +```shell +mkdir -p ${GOPATH}/src/github.com/kubeflow +cd ${GOPATH}/src/github.com/kubeflow +git clone https://github.com/${GITHUB_USER}/mxnet-operator.git +``` + +### Download go mods + +Some utility modules like `code-generator` will be used in hack scripts, +it's better to download all dependencies for the first time. + +```shell +go mod download +``` + +### Build the operator locally + +```shell +go build -o mxnet-operator.v1beta1 github.com/kubeflow/mxnet-operator/cmd/mxnet-operator.v1beta1 +go build -o mxnet-operator.v1 github.com/kubeflow/mxnet-operator/cmd/mxnet-operator.v1 +``` + +### Build container image + +```shell +# It requires you to build binary locally first. +docker build -t ${your_dockerhub_username}/mxnet-operator:v1 . +``` + +### Test Binaries locally + +```shell +./mxnet-operator.v1beta1 --kubeconfig=$HOME/.kube/config +``` + +### Before code check-in + +There're several steps to follow before you submit PR. + +```shell +# Verify codegen in case you change api but for get to generate new packages. +./hack/verify-codegen.sh + +# Lint codes +golangci-lint run --config=linter_config.yaml ./... +``` + +### Regenerate clients and apis + +If you make changes under `/pkg/apis`, you probably need to regenerate clients and apis. + +```shell +./hack/update-codegen.sh +``` \ No newline at end of file diff --git a/README.md b/README.md index ff860fff..676a87a9 100644 --- a/README.md +++ b/README.md @@ -278,7 +278,7 @@ server-76no-1 ## Contributing -Please refer to the [developer_guide](https://github.com/kubeflow/tf-operator/blob/master/developer_guide.md) +Please refer to the [Contributing Document](./CONTRIBUTING.md) ## Community diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index ff97506e..204cd869 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -80,4 +80,6 @@ echo "Generating defaulters for v1" --output-package github.com/kubeflow/mxnet-operator/pkg/apis/mxnet/v1 # Copy everything back. -cp -a "${TEMP_DIR}/${ROOT_PKG}/." "${SCRIPT_ROOT}/" \ No newline at end of file +cp -a "${TEMP_DIR}/${ROOT_PKG}/." "${SCRIPT_ROOT}/" +# Clean up binaries we build for update codegen +rm ./defaulter-gen \ No newline at end of file