Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Makefile and CI to run make build #11

Merged
merged 4 commits into from
Mar 2, 2021
Merged

Conversation

iamniting
Copy link
Member

Signed-off-by: Nitin Goyal [email protected]

This was referenced Feb 18, 2021
Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
.github/workflows/protoc.yaml Outdated Show resolved Hide resolved
@iamniting iamniting force-pushed the protoc branch 4 times, most recently from 996b147 to 6d5a608 Compare February 23, 2021 05:47
.gitignore Outdated Show resolved Hide resolved
Makefile Show resolved Hide resolved
.gitignore Outdated
@@ -0,0 +1,11 @@
# binary files
protoc
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are installed inside the folder name called google right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, they are directly inside our repo

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ew, better not do that

.gitignore Outdated Show resolved Hide resolved
Makefile Outdated
install-deps:
ifndef PROTOC
# download protoc
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.14.0/protoc-3.14.0-linux-x86_64.zip
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.14.0/protoc-3.14.0-linux-x86_64.zip
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/${PROTOC_VERSION}/protoc-3.14.0-linux-x86_64.zip

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for all the tools we installed the version should be defined as a variable above and we should use the same here.

Makefile Outdated

build: install-deps
# generate libs
./protoc --go_out=lib/go/replication --go_opt=paths=source_relative --plugin=./protoc-gen-go *.proto
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
./protoc --go_out=lib/go/replication --go_opt=paths=source_relative --plugin=./protoc-gen-go *.proto
./protoc --go_out=lib/go/replication --go_opt=paths=source_relative --plugin=./protoc-gen-go replication.proto

Copy link
Member Author

@iamniting iamniting Feb 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the file name but can not change the indentation. It gives an error

Makefile Outdated
Comment on lines 56 to 62
rm -rf protoc \
protoc-gen-go \
protoc-gen-go-grpc \
protoc-3.14.0-linux-x86_64.zip \
protoc-gen-go.v1.25.0.linux.386.tar.gz \
protoc-gen-go-grpc.v1.1.0.linux.386.tar.gz \
google/protobuf/*.proto
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation? and also its good to install these packages to a folder and remove the folder

Copy link
Contributor

@nixpanic nixpanic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just some nits to consider for improvement

Makefile Outdated
install-deps:
ifndef PROTOC
# download protoc
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.14.0/protoc-3.14.0-linux-x86_64.zip
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better download in a sub-directory and not clutter the root of the project with unneeded files.
Same counts for the extraction, run it from a different directory.

Makefile Outdated
endif

clean:
rm -rf protoc \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why pass -r for recursive? I do not think any directories are removed here?

It probably is not a good idea to remove the downloaded dependencies with make clean. A next make will need to download them again, that does not seem very useful. make clean should remove compiled/generated files, I recommend to introduce a different target for cleaning up everything, maybe make dep-clean or something like it.

Makefile Outdated
PROTOC_GEN_GO_REQ := "protoc-gen-go v1.25.0"
PROTOC_GEN_GO_GRPC_REQ := "protoc-gen-go-grpc 1.1.0"

PROTOC := $(shell ([ "`$(PWD)/protoc --version 2> /dev/null`" == $(PROTOC_REQ) ] && echo true))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

passing && echo true is a little strange to read, you could rewrite it to something easier to understand like:

PROTOC_VERSION := $(shell ./protoc --version 2>/dev/null)
ifeq($(PROTOC_VERSION),$(PROTOC_REQ)
    HAVE_PROTOC := "yes"
endif

After that, you can use ifdef HAVE_PROTOC to check if it is available. This reads more similar to how other projects use detection of features/settings/...

Makefile Outdated
protoc-gen-go \
protoc-gen-go-grpc \
protoc-3.14.0-linux-x86_64.zip \
protoc-gen-go.v1.25.0.linux.386.tar.gz \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really, it would be so much cleaner to place downloaded files in ./dist/ and executables in ./bin/

.gitignore Outdated
@@ -0,0 +1,11 @@
# binary files
protoc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ew, better not do that

@@ -1,20 +1,16 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explain in the commit how these files are generated. You added a make target, so the command in the commit should be make ....

@iamniting
Copy link
Member Author

@nixpanic Can you pls take a look again at fresh as the whole structure is changed now?

Copy link
Contributor

@nixpanic nixpanic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks much cleaner to me, way easier to understand what is done and where non-repository files are located.

Thanks!

Makefile Outdated
PROTOC_GEN_GO_GRPC_FOUND := $(shell ./bin/protoc-gen-go-grpc --version 2> /dev/null)


ifeq ("$(PROTOC_FOUND)","libprotoc ${PROTOC_VERSION}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you tested this? there is a mix of $(...) (make) and ${...} (bash) notation

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I did both are working similarly for me. Anyway, I have changed it to curly.

Copy link
Member

@Madhu-1 Madhu-1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. one minor comment to check *.go files after make build in CI


- name: generate go libs using protoc
run: |
make build
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we check that pushed*.go files are not having any changes once we do make the build here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Signed-off-by: Nitin Goyal <[email protected]>
Signed-off-by: Nitin Goyal <[email protected]>
Signed-off-by: Nitin Goyal <[email protected]>
@Madhu-1 Madhu-1 merged commit ad3b144 into csi-addons:main Mar 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants