Port automation scripts from JavaScript to Go - #3829
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Ankitsinghsisodya The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @Ankitsinghsisodya. Thanks for your PR. I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with Tip We noticed you've done this a few times! Consider joining the org to skip this step and gain Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR migrates several automation/update scripts from Node.js to Go and updates the GitHub Actions workflows/Makefile to use the new Go implementations.
Changes:
- Replaced JS-based platform/CA update scripts with Go commands under
hack/cmd/.... - Added shared Go helpers for HTTP + command execution used by the new tools.
- Updated GitHub Actions workflows and Makefile targets to run the Go commands and create PRs via
peter-evans/create-pull-request.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| hack/update-springboot-platform.js | Removed legacy Node.js automation script for Spring Boot platform updates. |
| hack/update-quarkus-platform.js | Removed legacy Node.js automation script for Quarkus platform updates. |
| hack/update-ca-bundle.js | Removed legacy Node.js automation script for CA bundle updates. |
| hack/cmd/update-springboot-platform/main.go | New Go implementation to fetch latest Spring Boot version + update POM(s). |
| hack/cmd/update-quarkus-platform/main.go | New Go implementation to fetch latest Quarkus version + update POM(s). |
| hack/cmd/update-ca-bundle/main.go | New Go implementation to update the CA bundle via make. |
| hack/cmd/shared/shared.go | Shared Go utilities (HTTP client, signal handling, command runner). |
| Makefile | Added make update-* targets to run the new Go tools. |
| .github/workflows/update-springboot-platform.yaml | Switched workflow from Node to Go + create-pull-request action, added generate/tests steps. |
| .github/workflows/update-quarkus-platform.yaml | Switched workflow from Node to Go + create-pull-request action, added generate/tests steps. |
| .github/workflows/update-ca-bundle.yaml | Switched workflow from Node to Go + create-pull-request action, added generate step. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if err != nil { | ||
| return err | ||
| } | ||
| updated := parentVersionRe.ReplaceAll(data, []byte("${1}"+newVersion+"${3}")) |
| if release.Draft { | ||
| return "", nil | ||
| } | ||
| return strings.TrimPrefix(release.TagName, "v"), nil |
| for _, m := range mappings { | ||
| r := m.CompatibilityRange | ||
|
|
||
| if strings.HasPrefix(r, "[") { |
| } else { | ||
| // open-ended lower bound | ||
| begin, err := semver.ParseTolerant(r) |
| data, err := os.ReadFile(path) | ||
| if err != nil { | ||
| return err | ||
| } |
|
This one will require a more in-depth review. @gauron99 did @Ankitsinghsisodya adress your concerns from the original, now-defunkt PR? |
| // Range format mirrors Maven version ranges: | ||
| // - "[begin,end)" — begin inclusive, end exclusive | ||
| // - "begin" — begin inclusive, no upper bound | ||
| func resolveSpringCloudVersion(springBootVersion string, mappings []springCloudMapping) (string, error) { |
There was a problem hiding this comment.
No tests in this PR. resolveSpringCloudVersion is a pure function and the POM read/update helpers are testable with t.TempDir() — please add table tests for both (see hack/cmd/components/main_test.go for the existing pattern).
| } | ||
|
|
||
| func run(ctx context.Context) error { | ||
| return shared.RunCmd(ctx, "make", caBundleMakeTarget) |
There was a problem hiding this comment.
This program only execs make templates/certs/ca-certificates.crt, and make certs already exists for exactly that. Please drop the Go wrapper: in update-ca-bundle.yaml replace the go run step with run: make certs (keep the make generate/zz_filesystem_generated.go step and setup-go as they are — generate needs Go), delete this file and shared.RunCmd (its only caller), and remove the update-ca-bundle Makefile target (or alias it to certs).
| return err | ||
| } | ||
| updated := parentVersionRe.ReplaceAll(data, []byte("${1}"+newVersion+"${3}")) | ||
| updated = springCloudVersionRe.ReplaceAll(updated, |
There was a problem hiding this comment.
nit: springCloudVersionRe is never checked for a match; if <spring-cloud.version> is absent the parent bumps and spring-cloud silently stays. Error if it doesn't match.
| return "", fmt.Errorf("cannot parse Spring Boot version %q: %w", springBootVersion, err) | ||
| } | ||
|
|
||
| for _, m := range mappings { |
There was a problem hiding this comment.
nit: continue on an unparsable compatibilityRange can fall through to a wrong later mapping; the JS threw. Return an error instead.
- Introduced new Makefile targets: `update-quarkus-platform`, `update-springboot-platform`, and `update-ca-bundle` to automate the process of updating respective platform versions in templates. - Updated GitHub Actions workflows for `update-ca-bundle`, `update-quarkus-platform`, and `update-springboot-platform` to utilize Go scripts instead of Node.js for executing updates. - Added new Go scripts for handling the update logic for CA bundle, Quarkus platform, and Spring Boot platform, including PR creation and version checks. - Implemented shared GitHub client functionality for PR management and version retrieval. This change enhances the automation of platform updates and streamlines the CI/CD process for dependency management.
…ment - Updated Makefile targets to streamline the execution of platform updates for Quarkus, Spring Boot, and CA bundle. - Replaced Node.js scripts with Go scripts for better performance and maintainability in GitHub Actions workflows. - Enhanced the update logic for CA bundle, Quarkus platform, and Spring Boot platform, including automated PR creation and version checks. - Removed outdated JavaScript files related to platform updates, consolidating functionality within Go. These changes improve the automation process for dependency management and enhance the CI/CD workflow.
- Pass GITHUB_TOKEN to the Spring Boot update step so GitHub API calls are authenticated (unauthenticated rate limit is 60 req/hr, shared across all Actions runners, causing intermittent 403s on the 4-hour cron) - Add a git-diff check after each Go tool + make generate step; skip smoke tests and the create-pull-request action when no files changed, restoring the early-exit behaviour the original JS scripts had
- Switch all `go run .../main.go` invocations to `go run ./pkg` in Makefile and the three CI workflows so additional files added to a command package are automatically included - Rename hack/cmd/shared/github.go → shared.go; the file contains a generic HTTP client and command runner, not GitHub-specific helpers
- Eliminated the change detection step from the GitHub Actions workflows for updating CA bundle, Quarkus platform, and Spring Boot platform. This simplifies the workflows by directly proceeding to create pull requests without checking for file changes, streamlining the automation process.
e36f175 to
3ecc3ef
Compare
- Updated the Makefile to simplify the `update-ca-bundle` target, making it an alias for the `certs` target. - Modified the GitHub Actions workflow to run `make certs` instead of the previous direct command for updating the CA bundle, enhancing consistency and maintainability. - Removed the now redundant Go script for updating the CA bundle, consolidating functionality within the Makefile and improving the overall automation process.
related to #2815
/kind cleanup
Changes
hack/update-ca-bundle.js,hack/update-quarkus-platform.js, andhack/update-springboot-platform.js, eliminating the Node.js runtime dependency from CIhack/cmd/for each removed script:update-ca-bundle,update-quarkus-platform,update-springboot-platformhack/cmd/sharedpackage with a shared HTTP client and command runner used across the new programsupdate-ca-bundle.yaml,update-quarkus-platform.yaml, andupdate-springboot-platform.yamlworkflows to use the new Go programs viago run, delegate PR creation topeter-evans/create-pull-request@v7, and gate smoke tests and PR creation on actual file changesupdate-quarkus-platform,update-springboot-platform, andupdate-ca-bundleMakefile targets for local invocation