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

[chore] Refactor goreleaser config generation for distributions #797

Open
wants to merge 46 commits into
base: main
Choose a base branch
from

Conversation

douglascamata
Copy link
Contributor

This PR will split off of #795.

This moves the code for generating the goreleaser configuration for the distros into a more declarative and easy-to-extend form.

Why so many changes? 😱

I am completely aware that it represents a big rewrite of this part of code. I tried a few different approaches with the intent of having a minimum change that would allow me to support Windows, but the amount of changes needed always ended up snowballing quickly. Some examples of the reasons for this "snowballing" of code are (non-exhaustive list):

  • Handling arm vs arm/v7.
  • "Build-only" distro for core distro.

This might not the best code for this job too, but at least I believe it sets up a good structure that we can build upon and iterate on to improve.

I'm very open to hear your feedback and see how we can move this forward!

I can join the Collector SIG call on 2025-01-15 to talk about this if any maintainer finds it more productive.

Questions ⍰

If anyone, please, could help me out in testing that release process works fine with the update goreleaser configuration, it would be aaaaamazing! I don't feel super confident without testing this, of course.

@douglascamata
Copy link
Contributor Author

FYI I'm working on fixing the failing deb/rpm package tests, but this will be mostly some small details on configuration rather than something that changes the structure of the PR.

@douglascamata douglascamata changed the title Refactor goreleaser config generation for distributions [chore] Refactor goreleaser config generation for distributions Jan 20, 2025
@mowies
Copy link
Member

mowies commented Jan 21, 2025

i'm reviewing this but it takes some time 😅 maybe you could squash the commits into groups of commits that make sense to review separately?
anyways, for testing, I think the collector maintainers can provide you with a key for goreleaser-pro that you can use in your fork to test the whole release process (cc @jpkrohling )

@douglascamata
Copy link
Contributor Author

@mowies I'm well aware it takes some time, no worries. Let me know if there's anything I can do to help out with the review, besides the squashing you already mentioned. 👍

I'll try to squash some commits in the next hours and see wether I can group them in a way that will make reviewing easier. It's a bit difficult because it's a "one thing lead to the other" situation all the way down. So the commits ended up organized in the way that I was developing, trying things, figuring out what the path forward, etc.

@mowies
Copy link
Member

mowies commented Jan 21, 2025

another option would be to add annotate the code with some PR comments where you feel like an explanation would help make it easier for the reviewer

Copy link
Member

@mowies mowies left a comment

Choose a reason for hiding this comment

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

LGTM overall, I like how the code looks now, it's pretty easy to read for the amount of stuff that's going on here with goreleaser.

Some other general things:

  • i would move all structs and interfaces to the top

cmd/goreleaser/internal/configure.go Show resolved Hide resolved
cmd/goreleaser/internal/configure.go Outdated Show resolved Hide resolved
cmd/goreleaser/internal/configure.go Outdated Show resolved Hide resolved
distributions/otelcol-k8s/.goreleaser.yaml Outdated Show resolved Hide resolved
distributions/otelcol-contrib/.goreleaser-build.yaml Outdated Show resolved Hide resolved
distributions/otelcol-contrib/.goreleaser.yaml Outdated Show resolved Hide resolved
distributions/otelcol-otlp/.goreleaser.yaml Outdated Show resolved Hide resolved
distributions/otelcol-otlp/.goreleaser.yaml Outdated Show resolved Hide resolved
distributions/otelcol/.goreleaser.yaml Outdated Show resolved Hide resolved
distributions/otelcol/.goreleaser.yaml Outdated Show resolved Hide resolved
@douglascamata
Copy link
Contributor Author

@mowies I think I handled all the feedback you gave so far. I will refrain from anything that would require a forced-push from now on so that reviews become easier as you can use the "commits since your last review" feature. Thank you very much for your time and review. 🙇

By the way, I was about to unexport everything that is unnecessarily exported (that's everything except the BuildDist function). But I thought that this is not super important and the PR is already big enough. There might be other additional improvements/refactors to the remaining code that can be done at a later time.

@mowies
Copy link
Member

mowies commented Jan 23, 2025

@mowies I think I handled all the feedback you gave so far. I will refrain from anything that would require a forced-push from now on so that reviews become easier as you can use the "commits since your last review" feature. Thank you very much for your time and review. 🙇

cool, i'll take another look now

By the way, I was about to unexport everything that is unnecessarily exported (that's everything except the BuildDist function). But I thought that this is not super important and the PR is already big enough. There might be other additional improvements/refactors to the remaining code that can be done at a later time.

that's good, let's rather have a few follow up PRs :)

Copy link
Member

@mowies mowies left a comment

Choose a reason for hiding this comment

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

LGTM! I still think you could move all/most interfaces and structs to the top of the file but that's mostly just my taste.
Additional follow ups that I see:

  • moving things into separate files where it makes sense

A full test release in your fork would be good to verify that everything works and that the same amount of release assets is produced in the end

}).Build()

// k8s distro
k8sArchs = []string{"amd64", "arm64", "ppc64le", "s390x"}
Copy link
Member

Choose a reason for hiding this comment

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

[nitpick] this could be moved to the other hardcoded vars at the top

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.

2 participants