-
Notifications
You must be signed in to change notification settings - Fork 11
Changing to use the embedded copilot CLI #143
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
Merged
richardpark-msft
merged 9 commits into
microsoft:main
from
richardpark-msft:wz-copilot-bundle-or-install
Mar 19, 2026
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
0138000
Changing to use the embedded copilot CLI - this gives us greater cont…
b080275
make generate also gofmt the files.
514fc6b
Missed a couple of spots where I meant to make some of the mock setup…
b4caf09
- Changed Init() so it does stop the client if we see that _auth_ has…
d3c46aa
Adding a blurb about enabling and building the waza code.
35e9d22
We do support darwin/amd64
d242795
Using shutdown is better. These tests are isolated, but they do still…
8c59f46
Potential fix for pull request finding
richardpark-msft bf4771c
Adding in lfs support to the github actions.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| // Generates all the proper copilot CLI SDK bundles, so we can use them in waza. | ||
| // The .zst, .license and generated .go files should all be checked in. When waza is built | ||
| // only the relevant copilot CLI package will be added. | ||
|
|
||
| package main | ||
|
|
||
| import ( | ||
| "bytes" | ||
| "fmt" | ||
| "os" | ||
| "os/exec" | ||
| "path/filepath" | ||
| "strings" | ||
|
|
||
| "golang.org/x/sync/errgroup" | ||
| ) | ||
|
|
||
| //go:generate go run . windows/arm64 windows/amd64 linux/arm64 linux/amd64 darwin/arm64 darwin/amd64 | ||
|
|
||
| func main() { | ||
| g := errgroup.Group{} | ||
|
|
||
| platforms := os.Args[1:] | ||
|
|
||
| fmt.Printf("Generating the following platforms:\n") | ||
|
|
||
| for _, p := range platforms { | ||
| fmt.Println(p) | ||
| } | ||
|
|
||
| fmt.Println("Starting...") | ||
|
|
||
| outputDir := ".." | ||
|
|
||
| for _, arg := range platforms { | ||
richardpark-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| g.Go(func() error { | ||
| cmd := exec.Command("go", "tool", "bundler", "-platform", arg, "-output", outputDir) | ||
|
|
||
| fmt.Printf("Running %s\n", cmd.String()) | ||
|
|
||
| output, err := cmd.CombinedOutput() | ||
|
|
||
| if err != nil { | ||
| return fmt.Errorf("bundler failed (with output %s): %w", string(output), err) | ||
| } | ||
|
|
||
| // once it's finished we just need to slap the proper package name on it. | ||
| platformParts := strings.Split(arg, "/") | ||
|
|
||
| if len(platformParts) != 2 { | ||
| return fmt.Errorf("bad format for platform %q. Platforms should be <GOOS compatible OS>/<GOARCH compatible arch> (ex: windows/amd64 )", arg) | ||
| } | ||
|
|
||
| path := filepath.Join(outputDir, fmt.Sprintf("zcopilot_%s_%s.go", platformParts[0], platformParts[1])) | ||
|
|
||
| fmt.Printf("Patching %s's package directive\n", path) | ||
| return fixCopilotPackageInGoFile(path) | ||
| }) | ||
| } | ||
|
|
||
| if err := g.Wait(); err != nil { | ||
| fmt.Printf("Failed to generate bundles: %s\n", err) | ||
| os.Exit(1) | ||
| } else { | ||
| fmt.Println("Done, no errors") | ||
| fmt.Println("You must delete any older .zst or .license files, manually") | ||
| } | ||
| } | ||
|
|
||
| func fixCopilotPackageInGoFile(goFile string) error { | ||
| contents, err := os.ReadFile(goFile) | ||
|
|
||
| if err != nil { | ||
| return fmt.Errorf("failed to read %q to fix the package: %w", goFile, err) | ||
| } | ||
|
|
||
| contents = bytes.Replace(contents, []byte("package main"), []byte("package embedded"), 1) | ||
|
|
||
| err = os.WriteFile(goFile, contents, 0644) | ||
|
|
||
| if err != nil { | ||
| return fmt.Errorf("failed to rewrite %q to fix the package: %w", goFile, err) | ||
| } | ||
richardpark-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| cmd := exec.Command("gofmt", "-w", goFile) | ||
| stdout, err := cmd.CombinedOutput() | ||
|
|
||
| if err != nil { | ||
| return fmt.Errorf("failed to gofmt %q. output: %s: %w", goFile, stdout, err) | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.