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
Build improvements #443
Build improvements #443
Conversation
f720a38
to
ad8e887
Compare
Makefile
Outdated
@@ -17,25 +22,34 @@ STACKER_BUILD_UBUNTU_IMAGE?=$(STACKER_DOCKER_BASE)ubuntu:latest | |||
LXC_CLONE_URL?=https://github.com/lxc/lxc | |||
LXC_BRANCH?=stable-5.0 | |||
|
|||
stacker: stacker-dynamic | |||
./stacker-dynamic --debug $(STACKER_OPTS) build \ | |||
LEVEL1_STACKER ?= ./stacker-dynamic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe call this BOOTSTRAP_STACKER
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't love the name LEVEL1_STACKER either, but BOOTSTRAP_STACKER felt like it would be a boolean, ie: Should I bootstrap?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
STACKER_BOOTSTRAP
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
huh. i +1'd to the STAGE1_STACKER and then it changed to STACKER_BOOTSTRAP. i like the STAGE1_STACKER, just pushed that.
I looked a bit deeper into the failure that c-i is showing. It reproduces locally with a simple 'make test' from this branch.
So the solutions we have
For reference, the error from c-i is:
|
I think it makes sense to just change the default 'BUILD_D' (and thus GOPATH which is derived from it) to be outside of the source directory. |
workflow: * add Setup Environment section that defines GOPATH and set GOPATH to <checkoutdir>/.build/gopath and GOCACHE to <checkoutdir>/.build/gocache/gocache. This means that all 'go' operations in subsequent sections will have that variable set. The go toolchain will then correctly re-use anything it can throughout the build. Note these are the same values that use of Make will set both inside and outside the stacker build. (stacker build dir is bind'd into the build environment and Make will set the variable correctly inside also, so the static build will benefit from a cache that the dynamic build did) Note comment in PR project-stacker#443 indicating issues with 'go test ./...' if GOPATH is under the current working directory. * Separate out 'go mod download' from the build. This makes better information available on how long operations things took. Because GOMODPATH is shared, these will used both by the stacker-dynamic and stacker binary builds. Makefile: * Allow caller to use a already-built "level 1 stacker" to build the current source. By setting LEVEL1_STACKER as below, you can avoid building (and re-building) the stacker that is used to build the static stacker. make LEVEL1_STACKER=/usr/local/bin/stacker * export GOPATH and GOCACHE (above) * change GO_SRC to only look under pkg/ and cmd/ directories for go source files. Previously it would search the .build directory which is at best a waste of time and often produced errors to stderr about not being able to read directories. * change stacker's dependency from cmd/stacker/lxc-wrapper/lxc-wrapper to cmd/stacker/lxc-wrapper/lxc-wrapper.c . stacker is built inside the stacker environment and the build.yaml file removes the existing lxc-wrapper, so the internal build will never use lxc-wrapper from the external environment. At some point we could use the caching in github actions to re-use a .build/gopath directory to get caching across actions. Signed-off-by: Scott Moser <smoser@brickies.net>
ad8e887
to
ece2499
Compare
workflow: * add Setup Environment section that defines GOPATH and set GOPATH to <checkoutdir>/../stacker-build/gopath and GOCACHE to <checkoutdir>-build/gopath/gocache. This means that all 'go' operations in subsequent sections will have that variable set. The go toolchain will then correctly re-use anything it can throughout the build. Note these are the same values that use of Make will set both inside and outside the stacker build. (stacker build dir is bind'd into the build environment and Make will set the variable correctly inside also, so the static build will benefit from a cache that the dynamic build did) Note comment in PR project-stacker#443 indicating issues with 'go test ./...' if GOPATH is under the current working directory. * Separate out 'go mod download' from the build. This makes better information available on how long operations things took. Because GOMODPATH is shared, these will used both by the stacker-dynamic and stacker binary builds. Makefile: * Allow caller to use a already-built "level 1 stacker" to build the current source. By setting LEVEL1_STACKER as below, you can avoid building (and re-building) the stacker that is used to build the static stacker. make LEVEL1_STACKER=/usr/local/bin/stacker * export GOPATH and GOCACHE (above) * change GO_SRC to only look under pkg/ and cmd/ directories for go source files. Previously it would search the .build directory which is at best a waste of time and often produced errors to stderr about not being able to read directories. * change stacker's dependency from cmd/stacker/lxc-wrapper/lxc-wrapper to cmd/stacker/lxc-wrapper/lxc-wrapper.c . stacker is built inside the stacker environment and the build.yaml file removes the existing lxc-wrapper, so the internal build will never use lxc-wrapper from the external environment. At some point we could use the caching in github actions to re-use a .build/gopath directory to get caching across actions. Signed-off-by: Scott Moser <smoser@brickies.net>
ece2499
to
73c8e02
Compare
workflow: * add Setup Environment section that defines GOPATH and set GOPATH to <checkoutdir>/../stacker-build/gopath and GOCACHE to <checkoutdir>-build/gopath/gocache. This means that all 'go' operations in subsequent sections will have that variable set. The go toolchain will then correctly re-use anything it can throughout the build. Note these are the same values that use of Make will set both inside and outside the stacker build. (stacker build dir is bind'd into the build environment and Make will set the variable correctly inside also, so the static build will benefit from a cache that the dynamic build did) Note comment in PR project-stacker#443 indicating issues with 'go test ./...' if GOPATH is under the current working directory. * Separate out 'go mod download' from the build. This makes better information available on how long operations things took. Because GOMODPATH is shared, these will used both by the stacker-dynamic and stacker binary builds. Makefile: * Allow caller to use a already-built "level 1 stacker" to build the current source. By setting LEVEL1_STACKER as below, you can avoid building (and re-building) the stacker that is used to build the static stacker. make LEVEL1_STACKER=/usr/local/bin/stacker * export GOPATH and GOCACHE (above) * change GO_SRC to only look under pkg/ and cmd/ directories for go source files. Previously it would search the .build directory which is at best a waste of time and often produced errors to stderr about not being able to read directories. * change stacker's dependency from cmd/stacker/lxc-wrapper/lxc-wrapper to cmd/stacker/lxc-wrapper/lxc-wrapper.c . stacker is built inside the stacker environment and the build.yaml file removes the existing lxc-wrapper, so the internal build will never use lxc-wrapper from the external environment. At some point we could use the caching in github actions to re-use a .build/gopath directory to get caching across actions. Signed-off-by: Scott Moser <smoser@brickies.net>
73c8e02
to
7cf4d97
Compare
workflow: * add Setup Environment section that defines GOPATH and set GOPATH to <checkoutdir>/../stacker-build/gopath and GOCACHE to <checkoutdir>-build/gopath/gocache. This means that all 'go' operations in subsequent sections will have that variable set. The go toolchain will then correctly re-use anything it can throughout the build. Note these are the same values that use of Make will set both inside and outside the stacker build. (stacker build dir is bind'd into the build environment and Make will set the variable correctly inside also, so the static build will benefit from a cache that the dynamic build did) Note comment in PR project-stacker#443 indicating issues with 'go test ./...' if GOPATH is under the current working directory. * Separate out 'go mod download' from the build. This makes better information available on how long operations things took. Because GOMODPATH is shared, these will used both by the stacker-dynamic and stacker binary builds. Makefile: * Allow caller to use a already-built "level 1 stacker" to build the current source. By setting LEVEL1_STACKER as below, you can avoid building (and re-building) the stacker that is used to build the static stacker. make LEVEL1_STACKER=/usr/local/bin/stacker * change 'go test' invocation to explicitly list the stacker package rather than using ./... which can cause problems if GOPATH is under the current working dir. * export GOPATH and GOCACHE (above) * change GO_SRC to only look under pkg/ and cmd/ directories for go source files. Previously it would search the .build directory which is at best a waste of time and often produced errors to stderr about not being able to read directories. * change stacker's dependency from cmd/stacker/lxc-wrapper/lxc-wrapper to cmd/stacker/lxc-wrapper/lxc-wrapper.c . stacker is built inside the stacker environment and the build.yaml file removes the existing lxc-wrapper, so the internal build will never use lxc-wrapper from the external environment. At some point we could use the caching in github actions to re-use a .build/gopath directory to get caching across actions. Signed-off-by: Scott Moser <smoser@brickies.net>
7cf4d97
to
12b3f9c
Compare
workflow: * add Setup Environment section that defines GOPATH and set GOPATH to <checkoutdir>/../stacker-build/gopath and GOCACHE to <checkoutdir>-build/gopath/gocache. This means that all 'go' operations in subsequent sections will have that variable set. The go toolchain will then correctly re-use anything it can throughout the build. Note these are the same values that use of Make will set both inside and outside the stacker build. (stacker build dir is bind'd into the build environment and Make will set the variable correctly inside also, so the static build will benefit from a cache that the dynamic build did) Note comment in PR project-stacker#443 indicating issues with 'go test ./...' if GOPATH is under the current working directory. * Separate out 'go mod download' from the build. This makes better information available on how long operations things took. Because GOMODPATH is shared, these will used both by the stacker-dynamic and stacker binary builds. Makefile: * Allow caller to use a already-built "level 1 stacker" to build the current source. By setting LEVEL1_STACKER as below, you can avoid building (and re-building) the stacker that is used to build the static stacker. make LEVEL1_STACKER=/usr/local/bin/stacker * change 'go test' invocation to explicitly list the stacker package rather than using ./... which can cause problems if GOPATH is under the current working dir. * export GOPATH and GOCACHE (above) * change GO_SRC to only look under pkg/ and cmd/ directories for go source files. Previously it would search the .build directory which is at best a waste of time and often produced errors to stderr about not being able to read directories. * change stacker's dependency from cmd/stacker/lxc-wrapper/lxc-wrapper to cmd/stacker/lxc-wrapper/lxc-wrapper.c . stacker is built inside the stacker environment and the build.yaml file removes the existing lxc-wrapper, so the internal build will never use lxc-wrapper from the external environment. At some point we could use the caching in github actions to re-use a .build/gopath directory to get caching across actions. Signed-off-by: Scott Moser <smoser@brickies.net>
12b3f9c
to
474bf1a
Compare
Codecov Report
@@ Coverage Diff @@
## main #443 +/- ##
=======================================
Coverage 11.87% 11.87%
=======================================
Files 45 45
Lines 5551 5551
=======================================
Hits 659 659
Misses 4775 4775
Partials 117 117 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
The solution I went with is not one of the two mentioned above, but a third. The change that made this work was to pass the package into go test that it should test rather than testing ./.... The package is |
workflow: * add Setup Environment section that defines GOPATH and set GOPATH to <checkoutdir>/../stacker-build/gopath and GOCACHE to <checkoutdir>-build/gopath/gocache. This means that all 'go' operations in subsequent sections will have that variable set. The go toolchain will then correctly re-use anything it can throughout the build. Note these are the same values that use of Make will set both inside and outside the stacker build. (stacker build dir is bind'd into the build environment and Make will set the variable correctly inside also, so the static build will benefit from a cache that the dynamic build did) Note comment in PR project-stacker#443 indicating issues with 'go test ./...' if GOPATH is under the current working directory. * Separate out 'go mod download' from the build. This makes better information available on how long operations things took. Because GOMODPATH is shared, these will used both by the stacker-dynamic and stacker binary builds. Makefile: * Allow caller to use a already-built "level 1 stacker" to build the current source. By setting LEVEL1_STACKER as below, you can avoid building (and re-building) the stacker that is used to build the static stacker. make STAGE1_STACKER=/usr/local/bin/stacker * change 'go test' invocation to explicitly list the stacker package rather than using ./... which can cause problems if GOPATH is under the current working dir. * export GOPATH and GOCACHE (above) * change GO_SRC to only look under pkg/ and cmd/ directories for go source files. Previously it would search the .build directory which is at best a waste of time and often produced errors to stderr about not being able to read directories. * change stacker's dependency from cmd/stacker/lxc-wrapper/lxc-wrapper to cmd/stacker/lxc-wrapper/lxc-wrapper.c . stacker is built inside the stacker environment and the build.yaml file removes the existing lxc-wrapper, so the internal build will never use lxc-wrapper from the external environment. At some point we could use the caching in github actions to re-use a .build/gopath directory to get caching across actions. Signed-off-by: Scott Moser <smoser@brickies.net>
474bf1a
to
61d6699
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
workflow:
add Setup Environment section that defines GOPATH and set GOPATH to /.build/gopath and GOCACHE to /.build/gocache/gocache.
This means that all 'go' operations in subsequent sections will have that variable set. The go toolchain will then correctly re-use anything it can throughout the build.
Note these are the same values that use of Make will set both inside and outside the stacker build.
(stacker build dir is bind'd into the build environment and Make will set the variable correctly inside also, so the static build will benefit from a cache that the dynamic build did)
Separate out 'go mod download' from the build. This makes better information available on how long operations things took.
Because GOMODPATH is shared, these will used both by the stacker-dynamic and stacker binary builds.
Makefile:
Allow caller to use a already-built "level 1 stacker" to build the current source. By setting LEVEL1_STACKER as below, you can avoid building (and re-building) the stacker that is used to build the static stacker.
make LEVEL1_STACKER=/usr/local/bin/stacker
export GOPATH and GOCACHE (above)
change GO_SRC to only look under pkg/ and cmd/ directories for go source files. Previously it would search the .build directory which is at best a waste of time and often produced errors to stderr about not being able to read directories.
change stacker's dependency from cmd/stacker/lxc-wrapper/lxc-wrapper to cmd/stacker/lxc-wrapper/lxc-wrapper.c . stacker is built inside the stacker environment and the build.yaml file removes the existing lxc-wrapper, so the internal build will never use lxc-wrapper from the external environment.
At some point we could use the caching in github actions to re-use a .build/gopath directory to get caching across actions.
What type of PR is this?
Which issue does this PR fix:
What does this PR do / Why do we need it:
If an issue # is not available please add repro steps and logs showing the issue:
Testing done on this change:
Automation added to e2e:
Will this break upgrades or downgrades?
Does this PR introduce any user-facing change?:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.