Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions serve/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ func (s *PluginServe) build(pluginDirectory, goos, goarch, distPath, pluginVersi
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Env = os.Environ()
cmd.Env = append(cmd.Env, fmt.Sprintf("GOOS=%s", goos))
cmd.Env = append(cmd.Env, fmt.Sprintf("GOARCH=%s", goarch))
cmd.Env = append(cmd.Env, fmt.Sprintf("CGO_ENABLED=%v", getEnvOrDefault("CGO_ENABLED", "0"))) // default to CGO_ENABLED=0
if err := cmd.Run(); err != nil {
return nil, fmt.Errorf("failed to build plugin with `go %v`: %w", args, err)
}
Expand Down
14 changes: 14 additions & 0 deletions serve/package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ with multiple lines and **markdown**`
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
t.Setenv("CGO_ENABLED", "0") // disable CGO to ensure we environmental differences don't interfere with the test
srv := Plugin(p)
cmd := srv.newCmdPluginRoot()
distDir := t.TempDir()
Expand All @@ -74,6 +75,12 @@ with multiple lines and **markdown**`
if diff := cmp.Diff(expect, fileNames(files)); diff != "" {
t.Fatalf("unexpected files in dist directory (-want +got):\n%s", diff)
}
// expect SHA-256 for the zip files to differ
sha1 := sha256sum(filepath.Join(distDir, "plugin-testPlugin-v1.2.3-linux-amd64.zip"))
sha2 := sha256sum(filepath.Join(distDir, "plugin-testPlugin-v1.2.3-windows-amd64.zip"))
if sha1 == sha2 {
t.Fatalf("expected SHA-256 for linux and windows zip files to differ, but they are the same: %s", sha1)
}

expectPackage := PackageJSON{
SchemaVersion: 1,
Expand Down Expand Up @@ -135,6 +142,7 @@ with multiple lines and **markdown**`
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
t.Setenv("CGO_ENABLED", "0") // disable CGO to ensure we environmental differences don't interfere with the test
srv := Plugin(p)
cmd := srv.newCmdPluginRoot()
distDir := t.TempDir()
Expand All @@ -158,6 +166,12 @@ with multiple lines and **markdown**`
if diff := cmp.Diff(expect, fileNames(files)); diff != "" {
t.Fatalf("unexpected files in dist directory (-want +got):\n%s", diff)
}
// expect SHA-256 for the zip files to differ
sha1 := sha256sum(filepath.Join(distDir, "plugin-testPlugin-v1.2.3-windows-amd64.zip"))
sha2 := sha256sum(filepath.Join(distDir, "plugin-testPlugin-v1.2.3-darwin-amd64.zip"))
if sha1 == sha2 {
t.Fatalf("expected SHA-256 for windows and darwin zip files to differ, but they are the same: %s", sha1)
}

expectPackage := PackageJSON{
SchemaVersion: 1,
Expand Down