Skip to content

build: Ensure clean go build environment for goreleaser and ko #824

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

Merged
merged 1 commit into from
Jul 26, 2024

Conversation

jimmidyson
Copy link
Member

Previous builds were overriding the GOOS and GOARCH enviroment
variables, which is fine to do when using ko directly, but appears to be
broken when building via ko using goreleaser.

This commit ensures that GOOS and GOARCH are always unset when
running builds by undefining them via make undefine. The override
keyword ensures that the env vars are always undefined regardless of the
source (e.g. enviroment, make variables, etc) to ensure a clean build
environment.

Instead of using GOARCH env var for building for the local build
architecure, this commit uses goreleaser's {{ .Runtime.Goarch }}
variable available via templating which contains the architecture of the
build machine.

This commit also removes the ldflags config from the ko
configuration in goreleaser config as this is automatically inherited
from the build config referenced in the ko config.

Previous builds were overriding the `GOOS` and `GOARCH` enviroment
variables, which is fine to do when using `ko` directly, but appears to be
broken when building via ko using `goreleaser`.

This commit ensures that `GOOS` and `GOARCH` are always unset when
running builds by undefining them via `make` `undefine`. The `override`
keyword ensures that the env vars are always undefined regardless of the
source (e.g. enviroment, make variables, etc) to ensure a clean build
environment.

Instead of using `GOARCH` env var for building for the local build
architecure, this commit uses `goreleaser`'s `{{ .Runtime.Goarch }}`
variable available via templating which contains the architecture of the
build machine.

This commit also removes the `ldflags` config from the `ko`
configuration in `goreleaser` config as this is automatically inherited
from the `build` config referenced in the `ko` config.
@jimmidyson jimmidyson force-pushed the jimmi/fix-goreleaser-ko branch from 4a9defd to 300fa61 Compare July 26, 2024 10:28
@jimmidyson
Copy link
Member Author

The error on Nutanix is to do with reserving the IPs for the CP endpoint:

failed to wait for task completion: failed to wait for task ZXJnb24=:2c4527f5-30b4-4562-98d7-c99345cb9410 to complete: context deadline exceeded

I think we may have a leak but this is blocking PR merges so we need to fix this ASAP.

Copy link
Contributor

@dkoshkin dkoshkin left a comment

Choose a reason for hiding this comment

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

Tested locally on my arm Mac. The e2e tests are running on an amd64 Linux.

@jimmidyson jimmidyson enabled auto-merge (squash) July 26, 2024 13:27
@jimmidyson jimmidyson requested a review from mhrabovcin July 26, 2024 13:27
@jimmidyson jimmidyson merged commit 3ac7bf0 into main Jul 26, 2024
15 checks passed
@jimmidyson jimmidyson deleted the jimmi/fix-goreleaser-ko branch July 26, 2024 13:27
jimmidyson added a commit that referenced this pull request Jul 26, 2024
🤖 I have created a release *beep* *boop*
---


## 0.13.3 (2024-07-26)

<!-- Release notes generated using configuration in .github/release.yaml
at main -->

## What's Changed
### Fixes 🔧
* fix: add cluster domain with final dot to no proxy list by @mhrabovcin
in
#821
### Other Changes
* build: Ensure clean go build environment for goreleaser and ko by
@jimmidyson in
#824


**Full Changelog**:
v0.13.2...v0.13.3

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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.

3 participants