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

Feat: Build manifest on every backend build #1191

Merged
merged 2 commits into from
Jan 13, 2025

Conversation

oshirohugo
Copy link
Contributor

What this PR does / why we need it:

This PR is adding the build manifest step after every backend build. This would simplify the build process for specific architecture and make selecting specific architectures in the plugin-actions easier

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

The drawback is that in the buildAll target the manifest will be built multiple times

@oshirohugo oshirohugo self-assigned this Jan 10, 2025
@oshirohugo oshirohugo requested a review from a team as a code owner January 10, 2025 11:30
@oshirohugo oshirohugo requested review from wbrowne, andresmgot and xnyo and removed request for a team January 10, 2025 11:30
Copy link
Member

@xnyo xnyo left a comment

Choose a reason for hiding this comment

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

Great work! 🙌 Just a couple of small comments

build/common.go Show resolved Hide resolved
build/common.go Outdated
Comment on lines 101 to 102
// TODO: Change to sh.RunWithV once available.
return sh.RunWith(cfg.Env, "go", args...)
err = sh.RunWith(cfg.Env, "go", args...)
Copy link
Member

Choose a reason for hiding this comment

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

Nit, unrelated: the comment above specifies "TODO: Change to sh.RunWithV once available.", it is now available, maybe we can kill two birds with one stone? 🙂

Suggested change
// TODO: Change to sh.RunWithV once available.
return sh.RunWith(cfg.Env, "go", args...)
err = sh.RunWith(cfg.Env, "go", args...)
err = sh.RunWithV(cfg.Env, "go", args...)

@xnyo
Copy link
Member

xnyo commented Jan 10, 2025

Another comment: if we're worried about performance and we want to make sure that the manifest is generated only once, we can wrap GenerateManifestFile into a sync.OnceValue to ensure it's called only once, like so:

diff --git a/build/common.go b/build/common.go
index c104d30..40d0972 100644
--- a/build/common.go
+++ b/build/common.go
@@ -252,8 +252,7 @@ func (Build) DarwinARM64() error {
        return buildBackend(newBuildConfig("darwin", "arm64"))
 }
 
-// GenerateManifestFile generates a manifest file for plugin submissions
-func (Build) GenerateManifestFile() error {
+var generateManifestOnce = sync.OnceValue(func() error {
        config := Config{}
        config, err := beforeBuild(config)
        if err != nil {
@@ -279,6 +278,11 @@ func (Build) GenerateManifestFile() error {
                return err
        }
        return nil
+})
+
+// GenerateManifestFile generates a manifest file for plugin submissions
+func (Build) GenerateManifestFile() error {
+       return generateManifestOnce()
 }
 
 // Debug builds the debug version for the current platform.

However what we have right now is more readable and not a concern, so unless there are other issues down the line I'd keep it like this

@oshirohugo oshirohugo requested a review from xnyo January 10, 2025 16:04
Copy link
Member

@xnyo xnyo left a comment

Choose a reason for hiding this comment

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

LGTM! 🚀

@oshirohugo oshirohugo merged commit f932e55 into main Jan 13, 2025
3 checks passed
@oshirohugo oshirohugo deleted the generate-manifest-on-every-backend-build branch January 13, 2025 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

2 participants