Skip to content

Commit b3b69bf

Browse files
Merge pull request #237 from openebs/dev
- docs: enhance contributors development setup guide - fix: don't wait forever if the launch pod failed - test: speed up with graceful termination - test: add nixos shell - test: add ci helper script - refactor: shellcheck on build script - build: add bootstrap tools - build(nix-shell): enhance local shell environment
2 parents 64cca24 + d340df7 commit b3b69bf

File tree

31 files changed

+1039
-345
lines changed

31 files changed

+1039
-345
lines changed

.github/workflows/build_and_push.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
uses: actions/checkout@v4
2222
with:
2323
fetch-depth: 0
24-
24+
2525
- uses: cachix/install-nix-action@v22
2626
- uses: rrbutani/[email protected]
2727
with:
@@ -78,7 +78,7 @@ jobs:
7878
uses: actions/checkout@v4
7979

8080
- name: Build images locally
81-
run: make provisioner-localpv-image || exit 1;
81+
run: make provisioner-localpv-image
8282

8383
- name: Setup Minikube-Kubernetes
8484
uses: medyagh/setup-minikube@latest
@@ -91,14 +91,12 @@ jobs:
9191
start-args: '--install-addons=false'
9292

9393
- name: Set up infra for integration test
94-
run: |
95-
sudo apt-get update && sudo apt-get install -y xfsprogs quota linux-modules-extra-`uname -r`
96-
go install -mod=mod github.com/onsi/ginkgo/v2/[email protected]
97-
helm install localpv-provisioner ./deploy/helm/charts -n openebs --create-namespace --set localpv.image.pullPolicy=Never --set analytics.enabled=false
98-
kubectl get pods -A
94+
run: sudo apt-get update && sudo apt-get install -y xfsprogs quota linux-modules-extra-`uname -r`
9995

10096
- name: Integration test
10197
run: |
98+
make bootstrap
99+
make helm-install
102100
make integration-test
103101
104102
- name: Upload Integration Test Coverage Report
@@ -120,7 +118,7 @@ jobs:
120118
uses: actions/setup-go@v5
121119
with:
122120
go-version: 1.19.13
123-
121+
124122
- name: Set Image Org
125123
# sets the default IMAGE_ORG to openebs
126124
run: |

.github/workflows/pull_request.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ jobs:
9393
uses: actions/checkout@v4
9494

9595
- name: Build images locally
96-
run: make provisioner-localpv-image || exit 1;
96+
run: make provisioner-localpv-image
9797

9898
- name: Setup Minikube-Kubernetes
9999
uses: medyagh/setup-minikube@latest
@@ -106,14 +106,12 @@ jobs:
106106
start-args: '--install-addons=false'
107107

108108
- name: Set up infra for integration test
109-
run: |
110-
sudo apt-get update && sudo apt-get install -y xfsprogs quota linux-modules-extra-`uname -r`
111-
go install -mod=mod github.com/onsi/ginkgo/v2/[email protected]
112-
helm install localpv-provisioner ./deploy/helm/charts -n openebs --create-namespace --set localpv.image.pullPolicy=Never --set analytics.enabled=false
113-
kubectl get pods -A
109+
run: sudo apt-get update && sudo apt-get install -y xfsprogs quota linux-modules-extra-`uname -r`
114110

115111
- name: Integration test
116112
run: |
113+
make bootstrap
114+
make helm-install
117115
make integration-test
118116
119117
- name: Upload Integration Test Coverage Report

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,12 @@ cmd/provisioner-localpv/start.sh
88

99
# Ginkgo test
1010
tests/tests.test
11+
12+
# Nix-Shell Go
13+
/nix/.go/
14+
/nix/.tmp/
15+
16+
/tests/integration_coverage.txt
17+
18+
/nixos.qcow2
19+

CODE_OF_CONDUCT.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Code of Conduct
2+
23
<BR>
34

45
## Umbrella Project
6+
57
OpenEBS is an "umbrella project". Every project, repository and file in the OpenEBS organization adopts and follows the policies found in the Community repo umbrella project files.
68
<BR>
79

8-
This project follows the [OpenEBS Code of Conduct](https://github.com/openebs/community/blob/HEAD/CODE_OF_CONDUCT.md)
10+
This project follows the [OpenEBS Code of Conduct](https://github.com/openebs/community/blob/HEAD/CODE_OF_CONDUCT.md)

CONTRIBUTING.md

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,55 @@
11
# Contributing Guidelines
2-
<BR>
2+
3+
<br>
34

45
## Umbrella Project
6+
57
OpenEBS is an "umbrella project". Every project, repository and file in the OpenEBS organization adopts and follows the policies found in the Community repo umbrella project files.
6-
<BR>
8+
<br>
79

810
This project follows the [OpenEBS Contributor Guidelines](https://github.com/openebs/community/blob/HEAD/CONTRIBUTING.md)
911

10-
# Contributing to OpenEBS Dynamic Local PV Provisioner
12+
## Contributing to OpenEBS Dynamic Local PV Provisioner
1113

1214
OpenEBS uses the standard GitHub pull requests process to review and accept contributions. There are several areas that could use your help. For starters, you could help in improving the sections in this document by either creating a new issue describing the improvement or submitting a pull request to this repository. The issues for the various OpenEBS components (including this repository) are maintained in [openebs/openebs](https://github.com/openebs/openebs/issues) repository.
1315

1416
* If you are a first-time contributor, please see [Steps to Contribute](#steps-to-contribute).
1517
* If you have documentation improvement ideas, go ahead and create a pull request. See [Pull Request checklist](#pull-request-checklist).
1618
* If you would like to make code contributions, please start with [Setting up the Development Environment](#setting-up-your-development-environment).
17-
* If you would like to work on something more involved, please connect with the OpenEBS Contributors. See [OpenEBS Community](https://github.com/openebs/openebs/tree/master/community).
19+
* If you would like to work on something more involved, please connect with the OpenEBS Contributors. See [OpenEBS Community](https://github.com/openebs/openebs/tree/HEAD/community).
1820

19-
## Steps to Contribute
21+
### Steps to Contribute
2022

2123
OpenEBS is an Apache 2.0 Licensed project and all your commits should be signed with Developer Certificate of Origin. See [Sign your work](#sign-your-work).
2224

2325
* Find an issue to work on or create a new issue. The issues are maintained at [openebs/openebs](https://github.com/openebs/openebs/issues). You can pick up from a list of [good-first-issues](https://github.com/openebs/openebs/labels/good%20first%20issue).
2426
* Claim your issue by commenting your intent to work on it to avoid duplication of efforts.
2527
* Fork the repository on GitHub.
26-
* Create a branch from where you want to base your work (usually master).
28+
* Create a branch from where you want to base your work (usually `develop`).
2729
* Make your changes. If you are working on code contributions, please see [Setting up the Development Environment](#setting-up-your-development-environment).
2830
* Relevant coding style guidelines are the [Go Code Review Comments](https://code.google.com/p/go-wiki/wiki/CodeReviewComments) and the _Formatting and style_ section of Peter Bourgon's [Go: Best Practices for Production Environments](http://peter.bourgon.org/go-in-production/#formatting-and-style).
2931
* Commit your changes by making sure the commit messages convey the need and notes about the commit.
3032
* Push your changes to the branch in your fork of the repository.
3133
* Submit a pull request to the original repository. See [Pull Request checklist](#pull-request-checklist).
3234

33-
## Pull Request Checklist
35+
### Pull Request Checklist
3436

35-
* Rebase to the current master branch before submitting your pull request.
37+
* Rebase to the current `develop` branch before submitting your pull request.
3638
* Commits should be as small as possible. Each commit should follow the checklist below:
37-
- For code changes, add tests relevant to the fixed bug or new feature.
38-
- Pass the compile and tests - includes spell checks, formatting, etc.
39-
- Commit header (first line) should convey what changed.
40-
- Commit body should include details such as why the changes are required and how the proposed changes.
41-
- DCO Signed.
42-
* If your PR is not getting reviewed or you need a specific person to review it, please reach out to the OpenEBS Contributors. See [OpenEBS Community](https://github.com/openebs/openebs/tree/master/community).
39+
* For code changes, add tests relevant to the fixed bug or new feature.
40+
* Pass the compile and tests - includes spell checks, formatting, etc.
41+
* Commit header (first line) should convey what changed.
42+
* Commit body should include details such as why the changes are required and how the proposed changes.
43+
* DCO Signed.
44+
* If your PR is not getting reviewed or you need a specific person to review it, please reach out to the OpenEBS Contributors. See [OpenEBS Community](https://github.com/openebs/openebs/tree/HEAD/community).
4345

44-
## Sign your work
46+
### Sign your work
4547

46-
We use the Developer Certificate of Origin (DCO) as an additional safeguard for the OpenEBS project. This is a well established and widely used mechanism to assure that contributors have confirmed their right to license their contribution under the project's license. Please read [dcofile](https://github.com/openebs/openebs/blob/master/contribute/developer-certificate-of-origin). If you can certify it, then just add a line to every git commit message:
48+
We use the Developer Certificate of Origin (DCO) as an additional safeguard for the OpenEBS project. This is a well established and widely used mechanism to assure that contributors have confirmed their right to license their contribution under the project's license. Please read [dcofile](https://github.com/openebs/openebs/blob/HEAD/contribute/developer-certificate-of-origin). If you can certify it, then just add a line to every git commit message:
4749

4850
Please certify it by just adding a line to every git commit message. Any PR with Commits which does not have DCO Signoff will not be accepted:
4951

50-
```
52+
```text
5153
Signed-off-by: Random J Developer <[email protected]>
5254
```
5355

@@ -56,38 +58,45 @@ If you set your `user.name` and `user.email` in git config, you can sign your co
5658

5759
You can also use git [aliases](https://git-scm.com/book/tr/v2/Git-Basics-Git-Aliases) like `git config --global alias.ci 'commit -s'`. Now you can commit with `git ci` and the commit will be signed.
5860

59-
## Setting up your Development Environment
61+
### Setting up your Development Environment
6062

6163
This project is implemented using Go and uses the standard golang tools for development and build. In addition, this project heavily relies on Docker and Kubernetes. It is expected that the contributors:
62-
- are familiar with working with Go;
63-
- are familiar with Docker containers;
64-
- are familiar with Kubernetes and have access to a Kubernetes cluster or Minikube to test the changes.
64+
65+
* are familiar with working with Go;
66+
* are familiar with Docker containers;
67+
* are familiar with Kubernetes and have access to a Kubernetes cluster or Minikube to test the changes.
6568

6669
For setting up a Development environment on your local host, see the detailed instructions [here](./docs/developer.md).
6770

68-
## Reviews against Pull Requests
71+
### Reviews against Pull Requests
6972

7073
A PR can be reviewed by both core as well as external contributors. Below can be referred to during reviews:
71-
- contributor should fix all the linting issues raised by the lint tools integrated with CI (`make test`)
72-
- contributor should try to implement relevant golang based unit tests for the fix/enhancement (`make test`)
73-
- contributor should try to rework on the review comments as much as possible
74-
- a review comment can be taken up later if it falls under any of the following categories
75-
- if the review comment talks about a new idiom or code pattern that is not currently in use by this repo
76-
- if the review comment talks about the need to implement integration test corresponding to the fix/enhancement
77-
- if contributor as well as reviewer agree that it can be addressed in a different PR
78-
- contributor should follow below pattern in code comments when some rework needs to be done at a later point:
74+
75+
* contributor should fix all the linting issues raised by the lint tools integrated with CI (`make test`)
76+
* contributor should try to implement relevant golang based unit tests for the fix/enhancement (`make test`)
77+
* contributor should try to rework on the review comments as much as possible
78+
* a review comment can be taken up later if it falls under any of the following categories
79+
* if the review comment talks about a new idiom or code pattern that is not currently in use by this repo
80+
* if the review comment talks about the need to implement integration test corresponding to the fix/enhancement
81+
* if contributor as well as reviewer agree that it can be addressed in a different PR
82+
* contributor should follow below pattern in code comments when some rework needs to be done at a later point:
83+
7984
```go
8085
// TD: -- indicates technical debt
8186
```
87+
8288
```go
8389
// NBDD: -- indicates needs integration tests in BDD format _(i.e. ginkgo tests)_
8490
```
91+
8592
```go
8693
// TD: SMALL -- indicates few/similar code changes & hence less impact
8794
```
95+
8896
```go
8997
// TD: MEDIUM -- indicates code changes at multiple files & may impact certain feature
9098
```
99+
91100
```go
92101
// TD: LARGE -- indicates code changes at multiple files & has impact on more than one features
93102
```

GOVERNANCE.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Governance
2+
23
<BR>
34

45
## Umbrella Project
6+
57
OpenEBS is an "umbrella project". Every project, repository and file in the OpenEBS organization adopts and follows the policies found in the Community repo umbrella project files.
68
<BR>
79

8-
This project follows the [OpenEBS Governance](https://github.com/openebs/community/blob/HEAD/GOVERNANCE.md)
10+
This project follows the [OpenEBS Governance](https://github.com/openebs/community/blob/HEAD/GOVERNANCE.md)

Makefile

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,21 @@ PACKAGES = $(shell go list ./... | grep -v '/pkg/version\|tests')
2323
PACKAGES_IT = $(shell go list ./... | grep -v 'pkg/client/generated' | grep 'tests')
2424

2525
# The images can be pushed to any docker/image registeries
26-
# like docker hub, quay. The registries are specified in
26+
# like docker hub, quay. The registries are specified in
2727
# the `buildscripts/push` script.
2828
#
2929
# The images of a project or company can then be grouped
3030
# or hosted under a unique organization key like `openebs`
3131
#
32-
# Each component (container) will be pushed to a unique
33-
# repository under an organization.
34-
# Putting all this together, an unique uri for a given
32+
# Each component (container) will be pushed to a unique
33+
# repository under an organization.
34+
# Putting all this together, an unique uri for a given
3535
# image comprises of:
3636
# <registry url>/<image org>/<image repo>:<image-tag>
3737
#
38-
# IMAGE_ORG can be used to customize the organization
39-
# under which images should be pushed.
40-
# By default the organization name is `openebs`.
38+
# IMAGE_ORG can be used to customize the organization
39+
# under which images should be pushed.
40+
# By default the organization name is `openebs`.
4141

4242
ifeq (${IMAGE_ORG}, )
4343
IMAGE_ORG = openebs
@@ -84,13 +84,16 @@ ifeq (${DBUILD_SITE_URL}, )
8484
export DBUILD_SITE_URL
8585
endif
8686

87-
# Specify the kubeconfig path to a Kubernetes cluster
87+
# Specify the kubeconfig path to a Kubernetes cluster
8888
# to run Hostpath integration tests
8989
ifeq (${KUBECONFIG}, )
9090
KUBECONFIG=${HOME}/.kube/config
9191
export KUBECONFIG
9292
endif
9393

94+
EXTERNAL_TOOLS=\
95+
github.com/onsi/ginkgo/v2/[email protected]
96+
9497
export DBUILD_ARGS=--build-arg DBUILD_DATE=${DBUILD_DATE} --build-arg DBUILD_REPO_URL=${DBUILD_REPO_URL} --build-arg DBUILD_SITE_URL=${DBUILD_SITE_URL} --build-arg BRANCH=${BRANCH} --build-arg RELEASE_TAG=${RELEASE_TAG}
9598

9699
.PHONY: all
@@ -100,7 +103,7 @@ all: test provisioner-localpv-image
100103
deps:
101104
@echo "--> Tidying up submodules"
102105
@go mod tidy
103-
@echo "--> Veryfying submodules"
106+
@echo "--> Verifying submodules"
104107
@go mod verify
105108

106109

@@ -110,25 +113,40 @@ verify-deps: deps
110113
echo "go module files are out of date, please commit the changes to go.mod and go.sum"; exit 1; \
111114
fi
112115

116+
.PHONY: bootstrap
117+
bootstrap:
118+
@for tool in $(EXTERNAL_TOOLS) ; do \
119+
echo "+ Installing $$tool" ; \
120+
GO111MODULE=on go install -mod=mod $$tool; \
121+
done
122+
113123
.PHONY: clean
114-
clean:
124+
clean:
115125
go clean -testcache
116126
rm -rf bin
127+
./ci/ci-test.sh clean
128+
chmod -R u+w ${GOPATH}/bin/${PROVISIONER_LOCALPV} 2>/dev/null || true
129+
chmod -R u+w ${GOPATH}/pkg/* 2>/dev/null || true
130+
rm -rf ${GOPATH}/bin/${PROVISIONER_LOCALPV}
131+
rm -rf ${GOPATH}/pkg/*
117132

118133
.PHONY: test
119134
test: format vet
120135
@echo "--> Running go test";
121-
$(PWD)/buildscripts/test.sh ${XC_ARCH}
136+
./buildscripts/test.sh ${XC_ARCH}
122137

123138
.PHONY: testv
124139
testv: format
125140
@echo "--> Running go test verbose" ;
126141
@go test -v $(PACKAGES)
127142

128-
# Requires KUBECONFIG env and Ginkgo binary
143+
.PHONY: helm-install
144+
helm-install:
145+
./ci/ci-test.sh install
146+
129147
.PHONY: integration-test
130148
integration-test:
131-
@cd tests && sudo -E env "PATH=${PATH}" ginkgo -v --fail-fast -coverprofile="integration_coverage.txt" -covermode=atomic;
149+
./ci/ci-test.sh run -t
132150

133151
.PHONY: format
134152
format:
@@ -142,9 +160,9 @@ vet:
142160
@go list ./... | xargs go vet -composites
143161

144162
.PHONY: verify-src
145-
verify-src:
163+
verify-src:
146164
@echo "--> Checking for git changes post running tests";
147-
$(PWD)/buildscripts/check-diff.sh "format"
165+
./buildscripts/check-diff.sh "format"
148166

149167

150168
#Use this to build provisioner-localpv
@@ -153,7 +171,7 @@ provisioner-localpv:
153171
@echo "----------------------------"
154172
@echo "--> provisioner-localpv "
155173
@echo "----------------------------"
156-
@PNAME=${PROVISIONER_LOCALPV} CTLNAME=${PROVISIONER_LOCALPV} sh -c "'$(PWD)/buildscripts/build.sh'"
174+
@PNAME=${PROVISIONER_LOCALPV} CTLNAME=${PROVISIONER_LOCALPV} sh -c "'./buildscripts/build.sh'"
157175

158176
.PHONY: provisioner-localpv-image
159177
provisioner-localpv-image: provisioner-localpv
@@ -164,6 +182,17 @@ provisioner-localpv-image: provisioner-localpv
164182
@cd buildscripts/provisioner-localpv && docker build -t ${PROVISIONER_LOCALPV_IMAGE_TAG} ${DBUILD_ARGS} . --no-cache
165183
@rm buildscripts/provisioner-localpv/${PROVISIONER_LOCALPV}
166184

185+
.PHONY: image-tag
186+
image-tag:
187+
@echo ${TAG}
188+
189+
.PHONY: image-repo
190+
image-repo:
191+
@echo ${IMAGE_ORG}/${PROVISIONER_LOCALPV_IMAGE}
192+
193+
.PHONY: image-ref
194+
image-ref:
195+
@echo ${IMAGE_ORG}/${PROVISIONER_LOCALPV_IMAGE}:${TAG}
167196

168197
.PHONY: push
169198
push:

0 commit comments

Comments
 (0)