Skip to content

feat(internal/librariangen): implement the configure container command (and run go mod tidy)#13221

Merged
quartzmo merged 4 commits intomainfrom
run-go-mod-tidy
Oct 24, 2025
Merged

feat(internal/librariangen): implement the configure container command (and run go mod tidy)#13221
quartzmo merged 4 commits intomainfrom
run-go-mod-tidy

Conversation

@jskeet
Copy link
Copy Markdown
Contributor

@jskeet jskeet commented Oct 24, 2025

This is an alternative to #13214 - it's the same code but with one more commit, which:

  • Moves go mod init from configure to the generate postprocessor, conditional on the library being new
  • Adds go mod tidy in the generate postprocessor

This avoids go mod tidy having to be run by hand.

This is completely lacking in tests, which should be provided before
merging.

The implementation will currently require a playbook along the lines of:

1. Run `librarian generate -api=google/cloud/abc/v1 -library=abc`
1. Run `(cd abc && go mod tidy)`
1. Run `go work use ./abc`
1. Commit changes and push

Steps 2 and 3 are only needed for whole new libraries (as opposed to
new APIs within existing libraries)

It would be nice to be able to get rid of steps 2 and 3 entirely, but
they're difficult.

We can't run `go mod tidy` without source code,
which either means running the generator during configure (which is
ugly and somewhat against the spirit of configure) or do so in
`generate`, but *only* on the very first run.

We can't run `go work use` without copying *all* of the `go.mod` files
referenced in there into the output directory (and then removing
them again). We could modify `go.work` directly, but that's ugly too.

These can be addressed in the longer term as we attempt to get to
fully automated onboarding, but having the steps in the playbook
introduces *relatively* little toil, while saving a *lot* of work in the
container.
@quartzmo quartzmo marked this pull request as ready for review October 24, 2025 14:59
@quartzmo quartzmo requested a review from a team October 24, 2025 14:59
Copy link
Copy Markdown
Member

@quartzmo quartzmo left a comment

Choose a reason for hiding this comment

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

Merging without tests. Test coverage must be added prior to deployment.

@quartzmo quartzmo merged commit 8cbc328 into main Oct 24, 2025
9 checks passed
@quartzmo quartzmo deleted the run-go-mod-tidy branch October 24, 2025 15:09
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