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

Usability improvements to build steps #2890

Merged
merged 1 commit into from
Aug 3, 2018
Merged

Usability improvements to build steps #2890

merged 1 commit into from
Aug 3, 2018

Conversation

antoineco
Copy link
Contributor

@antoineco antoineco commented Aug 2, 2018

What this PR does / why we need it:

Suggestions of tiny improvements for things I run often. I though some may make sense for the rest of us as well:

  • Make the compiler actually use the Go cache (Go 1.10+) by avoiding full rebuilds (remove -a flag). Speeds up builds quite a lot on modest hardware.
  • Make build flags parameterizable: GOBUILD_FLAGS variable, defaults to -v to show the build progress. Also makes the wait more meaningful than a long blank on modest hardware.
  • Print main build steps ("+ Building bin/amd64/...", "+ Copying to temp dir...")
  • Move build of ingress-nginx:build image to a build-image make target, mainly to be able to log that step in the right order.
  • Rename make clean target to clean-container, because it's really what it does.

Which issue this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged):

Does not introduce any feature or fix any bug.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 2, 2018
@aledbf
Copy link
Member

aledbf commented Aug 2, 2018

@antoineco we removed the local build in #2868
Besides that, this LGTM

@@ -41,7 +41,8 @@ fi

export CGO_ENABLED=0

go build -a -installsuffix cgo \
go build \
${GOBUILD_FLAGS} \
Copy link
Member

Choose a reason for hiding this comment

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

you need to set a default in case this env value is not set (that's why this is failing CI)

@antoineco
Copy link
Contributor Author

I was working on an older master and the rebase didn't pick that up, thanks for the pointer ;)

@antoineco
Copy link
Contributor Author

@aledbf I addressed your comments and added some more minor fixes/improvements. Each commit should be self-documented.

Putting this on hold for now because I want to squash these commits.
/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 3, 2018
Makefile Outdated
@@ -48,7 +48,7 @@ ARCH ?= $(shell go env GOARCH)
GOARCH = ${ARCH}
DUMB_ARCH = ${ARCH}

GOBUILD_FLAGS ?= -v
GOBUILD_FLAGS :=
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tested with both make build and make build GOBUILD_FLAGS='-v -a'.
Does what's expected in both scenarios using a pretty old make version (3.81, mac OS).

Makefile Outdated
@@ -161,7 +161,7 @@ endif
build: build-image
@echo "+ Building bin/$(ARCH)/nginx-ingress-controller"
@$(DEF_VARS) \
GOBUILD_FLAGS=$(GOBUILD_FLAGS) \
GOBUILD_FLAGS="$(GOBUILD_FLAGS)" \
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Quotes needed to avoid /bin/sh: -a: command not found when passing custom flags.

Makefile Outdated
@@ -164,9 +168,6 @@ build:
GOBUILD_FLAGS="$(GOBUILD_FLAGS)" \
build/go-in-docker.sh build/build.sh

@echo "+ Copying artifact to temporary directory"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I figured this didn't make sense here, in isolation, because make build and make container could not be invoked separately.

Makefile

* Make Go build flags parameterizable
  * Verbose by default
  * Do not force complete rebuild
  * Remove unnecessary '-installsuffix' flag
    https://plus.google.com/117192131596509381660/posts/eNnNePihYnK
* Log build steps
* Rename 'clean' target to 'clean-container'
* Move artifact copy to '.container' target
* Add 'clean' target

Shell script

* Fix shellcheck SC2068
  https://github.com/koalaman/shellcheck/wiki/SC2068
* Reject mandatory vars with empty values
@codecov-io
Copy link

codecov-io commented Aug 3, 2018

Codecov Report

Merging #2890 into master will decrease coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2890      +/-   ##
==========================================
- Coverage   47.56%   47.54%   -0.02%     
==========================================
  Files          76       76              
  Lines        5483     5483              
==========================================
- Hits         2608     2607       -1     
- Misses       2540     2542       +2     
+ Partials      335      334       -1
Impacted Files Coverage Δ
internal/watch/file_watcher.go 80.76% <0%> (-3.85%) ⬇️
internal/ingress/controller/config/config.go 98.26% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update af7fe6b...446641e. Read the comment docs.

@antoineco
Copy link
Contributor Author

Squashed (I hope the thumb up reaction meant 'ok' 😉).
/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 3, 2018
@aledbf
Copy link
Member

aledbf commented Aug 3, 2018

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 3, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aledbf, antoineco

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit 7b67794 into kubernetes:master Aug 3, 2018
@antoineco antoineco deleted the build-improv branch August 6, 2018 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants