Skip to content

Commit 0b6c9b7

Browse files
authored
Merge pull request #1432 from camilamacedo86/contribute-guide
improvements for contributors
2 parents 7a259a3 + b70e9ca commit 0b6c9b7

File tree

8 files changed

+59
-33
lines changed

8 files changed

+59
-33
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ bin/*
2424
# skip testdata go.mod, since it may have
2525
# different result depending on go version
2626
/testdata/project-v2/go.sum
27+
/testdata/project-v2-addon/go.sum
2728
/testdata/project-v2-multigroup/go.sum

.travis.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,16 @@ jobs:
3030
include:
3131
- stage: linting
3232
before_script: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.23.3
33-
script: ./scripts/verify.sh
33+
script: make lint
34+
after_success: echo "Linting check succeeded"
35+
after_failure: echo "Linting check failed. Run make lint to check it locally"
3436

35-
- stage: golden
36-
# The golden_test.sh check if the the testdata is updated according to the current changes
37-
# To update the testdata use the Makefile targets `make generate-setup` then `make generate-testdata`
38-
script: ./golden_test.sh
37+
- stage: testdata
38+
# Check if the the testdata is updated according to the current changes
39+
# To update the testdata use the Makefile target `make generate`
40+
script: make check-testdata
41+
after_success: echo "Generate check succeeded."
42+
after_failure: echo "Generate check failed. Run make test-gen to check it locally and use make generate to fix it"
3943

4044
- stage: coverage
4145
# The following module is used to integrate the project with coveralls.io. It allow us to easily sent the data.
@@ -44,10 +48,11 @@ jobs:
4448
script:
4549
- make test-coverage
4650
- $GOPATH/bin/goveralls -service=travis-ci -coverprofile=coverage-all.out -repotoken=$COVERALLS_TOKEN
47-
51+
after_success: echo "Coverage check succeeded. See in goveralls if the % of code covered with tests decreased."
52+
after_failure: echo "Coverage step failed. Run make test-coverage to check it locally"
4853
stages:
4954
- linting
50-
- golden
55+
- testdata
5156
- test
5257
- coverage
5358

CONTRIBUTING.md

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
# Contributing guidelines
22

3+
This document describes how to contribute to the project.
4+
35
## Sign the CLA
46

57
Kubernetes projects require that you sign a Contributor License Agreement (CLA) before we can accept your pull requests.
68

79
Please see https://git.k8s.io/community/CLA.md for more info.
810

911
## Prerequisites
12+
1013
- [go](https://golang.org/dl/) version v1.13+.
1114
- [dep](https://github.com/golang/dep) dep v0.5+
1215
- [docker](https://docs.docker.com/install/) version 17.03+.
@@ -15,6 +18,7 @@ Please see https://git.k8s.io/community/CLA.md for more info.
1518
- Access to a Kubernetes v1.11.3+ cluster.
1619

1720
## Contributing steps
21+
1822
1. Submit an issue describing your proposed change to the repo in question.
1923
1. The [repo owners](OWNERS) will respond to your issue promptly.
2024
1. If your proposed change is accepted, and you haven't already done so, sign a Contributor License Agreement (see details above).
@@ -23,26 +27,38 @@ Please see https://git.k8s.io/community/CLA.md for more info.
2327

2428
## How to build kubebuilder locally
2529

30+
Note that, by building the kubebuilder from the source code we are allowed to test the changes made locally.
31+
2632
1. Run the following command to clone your fork of the project locally in the dir /src/sigs.k8s.io/kubebuilder
2733

2834
```
2935
$ git clone [email protected]:<user>/kubebuilder.git $GOPATH/src/sigs.k8s.io/kubebuilder
3036
```
3137

3238
1. Ensure you activate module support before continue (`$ export GO111MODULE=on`)
33-
1. Build the project by using the command `make build`
3439
1. Run the command `make install` to create a bin with the source code
3540

36-
## How to test kubebuilder locally
41+
**NOTE** In order to check the local environment run `make go-test`.
42+
43+
## What to do before submitting a pull request
3744

38-
1. Run the tests by using the command `make test`. It will execute unit tests.
39-
1. Run the script `make generate` to update/generate the mock data used in the e2e test in `$GOPATH/src/sigs.k8s.io/kubebuilder/testdata/`
45+
1. Run the script `make generate` to update/generate the mock data used in the e2e test in `$GOPATH/src/sigs.k8s.io/kubebuilder/testdata/`
4046

4147
**IMPORTANT:** The `make generate` is very helpful. By using it, you can check if good part of the commands still working successfully after the changes. Also, note that its usage is a pre-requirement to submit a PR.
4248

43-
**NOTE** To run `make lint` is required to install `golangci-lint` locally it. More info: https://github.com/golangci/golangci-lint#install
44-
45-
## Where the CI Tests are configured?
49+
Following the targets that can be used to test your changes locally.
50+
51+
| Command | Description | Is called in the CI? |
52+
|--- |--- |--- |
53+
| make go-test | Runs go tests | no |
54+
| make test| Runs tests in shell (`./test.sh`) | yes |
55+
| make lint | Check the code implementation | yes |
56+
| make test-coverage | Run coveralls to check the % of code covered by tests | yes |
57+
| make check-testdata | Checks if the testdata dir is updated with the latest changes | yes |
58+
59+
**NOTE** To use the `make lint` is required to install `golangci-lint` locally. More info: https://github.com/golangci/golangci-lint#install
60+
61+
## Where the CI Tests are configured
4662

4763
1. See the [Travis](.travis.yml) file to check its tests and the scripts used on it.
4864
1. Note that the prow tests used in the CI are configured in [kubernetes-sigs/kubebuilder/kubebuilder-presubmits.yaml](https://github.com/kubernetes/test-infra/blob/master/config/jobs/kubernetes-sigs/kubebuilder/kubebuilder-presubmits.yaml).
@@ -62,7 +78,7 @@ If adding doc for an unreleased feature, the PR should target `master` branch.
6278
If updating existing docs, the PR should target `master` branch and then
6379
cherry-picked into `book-v2` branch.
6480

65-
### How to preview the changes performed in the docs?
81+
### How to preview the changes performed in the docs
6682

6783
Check the CI job after to do the Pull Request and then, click on in the `Details` of `netlify/kubebuilder/deploy-preview`
6884

@@ -71,7 +87,6 @@ Check the CI job after to do the Pull Request and then, click on in the `Details
7187
Learn how to engage with the Kubernetes community on the [community page](http://kubernetes.io/community/).
7288

7389
You can reach the maintainers of this project at:
74-
7590
- [Slack](http://slack.k8s.io/)
7691
- [Mailing List](https://groups.google.com/forum/#!forum/kubebuilder)
7792

@@ -84,3 +99,4 @@ KubeBuilder and the related repositories. See
8499
## Code of conduct
85100

86101
Participation in the Kubernetes community is governed by the [Kubernetes Code of Conduct](code-of-conduct.md).
102+

Makefile

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ generate: ## Update/generate all mock data. You should run this commands to upda
5151

5252
.PHONY: generate-testdata
5353
generate-testdata: ## Update/generate the testdata in $GOPATH/src/sigs.k8s.io/kubebuilder
54-
GO111MODULE=on ./generate_golden.sh
54+
GO111MODULE=on ./generate_testdata.sh
5555

5656
.PHONY: generate-vendor
5757
generate-vendor: ## (Deprecated) Update/generate the vendor by using the path $GOPATH/src/sigs.k8s.io/kubebuilder-test
@@ -68,22 +68,21 @@ lint: ## Run code lint checks
6868

6969
##@ Tests
7070

71-
.PHONY: test
72-
test: ## Run the go tests ($ go test -v ./cmd/... ./pkg/...)
71+
.PHONY: go-test
72+
go-test: ## Run the go tests ($ go test -v ./cmd/... ./pkg/...)
7373
go test -v ./cmd/... ./pkg/...
7474

75-
.PHONY: test-ci
76-
test-ci: ## Run the unit tests (used in the CI)
77-
./setup.sh
75+
.PHONY: test
76+
test: ## Run the unit tests (used in the CI)
7877
./test.sh
7978

80-
.PHONY: test-e2e
81-
test-e2e: ## Run the integration tests (used in the CI)
82-
./test_e2e.sh
83-
8479
.PHONY: test-coverage
8580
test-coverage: ## Run coveralls
8681
# remove all coverage files if exists
8782
- rm -rf *.out
8883
# run the go tests and gen the file coverage-all used to do the integration with coverrals.io
8984
go test -failfast -tags=integration -coverprofile=coverage-all.out -covermode=count ./pkg/... ./cmd/...
85+
86+
.PHONY: check-testdata
87+
check-testdata: ## Run the script to ensure that the testdata is updated
88+
./check_testdata.sh

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ Before you file an issue, please search existing issues to see if your issue is
8686
For realtime discussion, you can join the [#kubebuilder](https://slack.k8s.io/#kubebuilder) slack channel. Slack requires registration, but the Kubernetes team is open invitation to anyone to register here. Feel free to come and ask any questions.
8787

8888
## Contributing
89+
8990
Contributions are greatly appreciated. The maintainers actively manage the issues list, and try to highlight issues suitable for newcomers.
9091
The project follows the typical GitHub pull request model. See [CONTRIBUTING.md](CONTRIBUTING.md) for more details.
9192
Before starting any work, please either comment on an existing issue, or file a new one.
93+
94+
## Supportability
95+
96+
Currently, Kubebuilder officially supports OSX and Linux platforms. So, if you are using a Windows OS you may find issues. Contributions towards supporting Windows are welcome.

golden_test.sh renamed to check_testdata.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,22 @@ check_directory=testdata
3232

3333
# Check testdata directory first. If there are any uncommitted change, fail the test.
3434
if [[ `git status ${check_directory} --porcelain` ]]; then
35-
header_text "Golden test precondition failed!"
36-
header_text "Please commit the change under testdata directory before running the golden test"
35+
header_text "Generate Testdata test precondition failed!"
36+
header_text "Please commit the change under testdata directory before running the Generate Testdata test"
3737
exit 1
3838
fi
3939

40-
./generate_golden.sh
40+
./generate_testdata.sh
4141

4242
# Check if there are any changes to files under testdata directory.
4343
if [[ `git status ${check_directory} --porcelain` ]]; then
4444
header_text "git status ${check_directory} --porcelain"
4545
git status ${check_directory} --porcelain
4646
header_text "git diff ${check_directory}"
4747
git diff ${check_directory}
48-
header_text "Golden test failed!"
49-
header_text "Please make sure you have run ./generate_golden.sh if you have changed the scaffolding"
48+
header_text "Generate Testdata failed!"
49+
header_text "Please, if you have changed the scaffolding make sure you have run: make generate"
5050
exit 1
5151
else
52-
header_text "Golden test passed!"
52+
header_text "Generate Testdata passed!"
5353
fi
File renamed without changes.

testdata/project-v2-addon/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ require (
99
k8s.io/apimachinery v0.17.2
1010
k8s.io/client-go v0.17.2
1111
sigs.k8s.io/controller-runtime v0.5.0
12-
sigs.k8s.io/kubebuilder-declarative-pattern v0.0.0-20200226054827-748a6481b2a4
12+
sigs.k8s.io/kubebuilder-declarative-pattern v0.0.0-20200317144824-bbf1fb2a4a9a
1313
)

0 commit comments

Comments
 (0)