pulumi / pulumi-az-pipelines-task

Azure Pipelines task extension for running Pulumi apps.
https://marketplace.visualstudio.com/publishers/pulumi
Apache License 2.0
27 stars 19 forks source link

Add support for PR comments for AzDO-hosted git repos #113

Closed praneetloke closed 1 year ago

praneetloke commented 1 year ago

Related to #110.

This PR adds support for adding the Pulumi command log output as a PR comment to pull requests created in Azure Repositories. In order to make this work, the extension now requires the the vso.code_write OAuth2 scope explicitly. With the new scope builds will get an access token that has that specific permission.

As for the approach I took, I started out implementing this as a "post-execution" step which is why I am writing the logs to a temp file and reading that back again. I eventually backtracked on that since there could be a delay between when the Pulumi step is actually completed vs. when the whole job completes, which is when the post-execution steps run. A job can contain many steps. I favored creating the PR comment asap rather than at the end. Anyway, I kept the part that was stream the logs to a file rather than keeping it in memory. I can change that if you'd like, but I sort of liked dealing with a stable file, though it's temporary. The file gets removed after the PR comment is added successfully.

Screenshots Example of the permissions users have to review for the new version ![image](https://user-images.githubusercontent.com/1466314/189231758-9c18704a-8689-4434-907a-d60ef626fb15.png) Example of the PR comment ![Screenshot 2022-09-08 at 12-13-01 Pull request 22 Export the random string value - Repos](https://user-images.githubusercontent.com/1466314/189231560-5ee7fd3c-155f-4786-bcfe-01bb7aea465d.png)
t0yv0 commented 1 year ago

Hi @praneetloke this looks awesome at a glance, unfortunately a few things came up and I'm slipping with reviewing this on time, likely will review on Monday.

praneetloke commented 1 year ago

@RobbieMcKinstry thank you for the review! Just wanted to post a quick note that I am looking into them.

praneetloke commented 1 year ago

@RobbieMcKinstry I've added inline replies to your comments. Can you please have another look at this?

RobbieMcKinstry commented 1 year ago

Any idea why the status check is still pending?

praneetloke commented 1 year ago

Any idea why the status check is still pending?

For PR from forks, you'll need to explicitly run /azp run to run the PR build in this repo.

RobbieMcKinstry commented 1 year ago

/azp run

azure-pipelines[bot] commented 1 year ago
Azure Pipelines successfully started running 1 pipeline(s).
RobbieMcKinstry commented 1 year ago

/azp run

azure-pipelines[bot] commented 1 year ago
Azure Pipelines successfully started running 1 pipeline(s).
praneetloke commented 1 year ago

Yeah not sure what's going on with the test failures. They were (and still are) passing on my machine. We'll have to look at the build logs to see what's going. We could run a build manually with the variable TASK_TEST_TRACE=1 to get debug logs.

RobbieMcKinstry commented 1 year ago

/azp run

azure-pipelines[bot] commented 1 year ago
Azure Pipelines successfully started running 1 pipeline(s).
RobbieMcKinstry commented 1 year ago

/azp run

azure-pipelines[bot] commented 1 year ago
Azure Pipelines successfully started running 1 pipeline(s).
RobbieMcKinstry commented 1 year ago

/azp run

azure-pipelines[bot] commented 1 year ago
Azure Pipelines successfully started running 1 pipeline(s).
RobbieMcKinstry commented 1 year ago

/azp run

azure-pipelines[bot] commented 1 year ago
Azure Pipelines successfully started running 1 pipeline(s).