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

Builder: add option to skip generate #7541

Open
hypnoce opened this issue Apr 18, 2023 · 6 comments
Open

Builder: add option to skip generate #7541

hypnoce opened this issue Apr 18, 2023 · 6 comments

Comments

@hypnoce
Copy link
Contributor

hypnoce commented Apr 18, 2023

Is your feature request related to a problem? Please describe.
The builder currently offers skipping building and resolving modules. We have a case where we would like to skip generated sources as we need to version it but then resolve modules and build in the CI.

Describe the solution you'd like
Add an option to skip generate.

Describe alternatives you've considered
I did not find any alternative as I cannot hook into the builder lifecycle.

@bogdandrutu
Copy link
Member

To build and resolve modules you don't need this binary, you can use a simple go build ... command.

@hypnoce
Copy link
Contributor Author

hypnoce commented Apr 19, 2023

I agree, but some flags (linking for instance) can be defined in the builder config file which has different owner in my case. The builder provides also out of the box default build configuration that we would like to inherit and follow based on builder evolution.

@jpkrohling
Copy link
Member

I'm also a bit confused: if you don't have the sources, what do you have? Only the manifest?

@hypnoce
Copy link
Contributor Author

hypnoce commented May 12, 2023

As I understood, there are 3 steps in the builder: code generation, module resolution, build

In my scenario, the 2 first steps are executed in a 'generate source' step and committed to a git repo (skipping compilation).
Then a CI syncs the code and execute the 3rd step (skipping code generation and mod resolution).

It's today possible to skip compilation and module resolution, but not code generation.

@jpkrohling
Copy link
Member

I see, thank you for the clarification. While I enjoy seeing this tool being used in different manners than what I originally planned, I wouldn't use it this way myself. Besides, I think the value the tool would provide without its main purpose (generating code) would be too low to justify having this option.

On the other hand, I believe it should be relatively easy to implement this solution, as you proved with your PR.

@jmacd
Copy link
Contributor

jmacd commented Jun 13, 2023

I came looking for a similar issue and found this one. I would like to support use of the builder within an existing monorepo, meaning to support updating an existing go.mod instead somewhere outside the generated code.

See this branch main...jmacd:opentelemetry-collector:jmacd/skip_generate_builder

I added one commit on top of the one in #7542 with a second new option related to skipping. The new option SkipNewGoMod and command-line flag --skip-new-go-mod causes two behaviors:

  1. The go.mod file will not be generated.
  2. The go mod tidy step is replaced instead with go get for each module except those with v0.0.0 (indicating they are part of the main module)

This commit also checks a few invalid configurations. When SkipNewGoMod is set, the Excludes and Replaces must be empty, and no module can use a Path replacement.

This allows the builder to generate a build without unnecessarily starting with a fresh set of Go dependencies. Whereas generating a new go.mod every time will result in using the newest version of all unspecified dependencies, using --skip-new-go-mod will only update necessary dependencies.

(However, I think this change is somewhat unfinished. There are core collector components that should also have go get called, which are not included in the list of modules, I think.) @hypnoce would these changes help with your workflow, possibly?

codeboten pushed a commit that referenced this issue Jun 22, 2023
This option makes the builder skip generating sources.

**Link to tracking Issue:** #7541

**Testing:** Unit tests

**Documentation:** as part of the CLI help menu

Signed-off-by: Francois JACQUES <[email protected]>
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

No branches or pull requests

4 participants