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

Add a diff summary above the Pulumi output in PR comments #865

Closed
wants to merge 6 commits into from
Closed

Add a diff summary above the Pulumi output in PR comments #865

wants to merge 6 commits into from

Conversation

JDTX0
Copy link

@JDTX0 JDTX0 commented Feb 9, 2023

This PR adds a brief summary to PR comment just before the Pulumi output. It includes a URL to view the preview, and a brief summary of all changes.

I think it's useful to see an overall view without having to expand the full output and scroll to the bottom.

With these changes, this is what the new output should look like:
Screenshot 2023-06-13 at 2 41 14 PM

My method of finding the diffs and URL involves grabbing the first & last 500 chars of the Pulumi output, then using simple regex to search for changes/additions/deletions among the last 500 chars. This approach should take minimal resources.

If there's a better way to accomplish this or if I've missed something in my changes, please let me know.

Thanks!

@justinvp
Copy link
Member

Sorry for the long delay @JDTX0! We missed this in our daily triage of incoming issues/PRs.

Definitely agree that it would be useful to have a summary here! Although, I think we'll want to iterate on the design a bit here, likely aligning it more closely with the output of the GitHub App. I've opened an issue to track the overall suggestions here: #969

Implementation wise, rather than using regex to extract the data from the raw output, we could use the automation API operation's result, which includes a map of operation types (e.g. delete/update/create/etc.) along with corresponding counts. We'd have to modify the code here to return that summary information:

actions/src/main.ts

Lines 87 to 101 in f9775fb

const actions: Record<Commands, () => Promise<string>> = {
up: () => stack.up({ onOutput, ...config.options }).then((r) => r.stdout),
update: () =>
stack.up({ onOutput, ...config.options }).then((r) => r.stdout),
refresh: () =>
stack.refresh({ onOutput, ...config.options }).then((r) => r.stdout),
destroy: () =>
stack.destroy({ onOutput, ...config.options }).then((r) => r.stdout),
preview: async () => {
const { stdout, stderr } = await stack.preview(config.options);
onOutput(stdout);
onOutput(stderr);
return stdout;
},
};

For getting the link, we do have an API in the Go Automation API for retrieving this, but haven't added it to the other languages yet. This is tracked by pulumi/pulumi#5533. We should add support to the Node.js automation API and make use of that to grab the permalink URL.

@JDTX0
Copy link
Author

JDTX0 commented Jun 26, 2023

@justinvp Good points, didn't realize there was an automation API to retrieve those.

I'll close this out and let the Pulumi team handle implementation. Or if I get enough time one of these days then I'll open a PR that utilizes the automation API.

Thank you for the response & opening the feature request. much appreciated!

@JDTX0 JDTX0 closed this Jun 26, 2023
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