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 suppression label script #31672

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

JackTn
Copy link
Member

@JackTn JackTn commented Nov 26, 2024

This tool is designed to identify suppression changes in the specification pull requests and manage suppression labels by adding or removing them as needed

Copy link

openapi-pipeline-app bot commented Nov 26, 2024

Next Steps to Merge

⌛ Please wait. Next steps to merge this PR are being evaluated by automation. ⌛

Copy link

openapi-pipeline-app bot commented Nov 26, 2024

PR validation pipeline restarted successfully. If there is ApiView generated, it will be updated in this comment.

on:
pull_request:
branches:
- jacktn/suppression-label-script
Copy link
Member

Choose a reason for hiding this comment

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

Add main and remove the test branch before merge.

Authorization = "bearer $token"
}
return $headers
$headers = @{
Copy link
Member

Choose a reason for hiding this comment

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

Remove the indentation changes and this file change must be made on azure-sdk-tools repo.

-Headers (Get-GitHubApiHeaders -token $AuthToken) `
-MaximumRetryCount 3
}
function Remove-GitHubIssueLabels {
Copy link
Member

Choose a reason for hiding this comment

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

Let's hold off adding this functions as we are planning to use a common GitHub action to process label addition and deletion. CC: @mikeharder

GITHUB_EVENT_PULL_REQUEST_HEAD_REPO_NAME: ${{ github.event.pull_request.head.repo.name }}
GITHUB_EVENT_PULL_REQUEST_HEAD_REF: ${{ github.event.pull_request.head.ref }}
GITHUB_EVENT_PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}
GITHUB_TOKEN: ${{ secrets.TOKEN }}
Copy link
Member

Choose a reason for hiding this comment

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

Can the name of TOKEN be more descriptive? How about Spec_Repo_Token if the name doesn't support prefix of 'GitHub'?

exit 1
}

function Get-GitHubFileContent {
Copy link
Member

Choose a reason for hiding this comment

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

How about adding this function to common script Invoke-GitHubAPI.ps1?

$BaseSDKSuppressionYaml = Get-GitHubFileContent -Token $AuthToken -RepoOwner $BaseRepoOwner -RepoName $BaseRepoName -FilePath $SuppressionFile -Branch $BaseRepoBranch

if (!$HeadSDKSuppressionYaml -or !$BaseSDKSuppressionYaml) {
Write-Host "Unable to retrieve file content."
Copy link
Member

Choose a reason for hiding this comment

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

Can you use the logger functions from the logging.ps1 under common script folder?

Copy link
Member

Choose a reason for hiding this comment

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

Is this new code, or porting existing powershell code from another place? If new code, we should probably port this to JavaScript, which we are planning to use as the standard for code in GitHub Actions.

Copy link
Member Author

@JackTn JackTn Nov 27, 2024

Choose a reason for hiding this comment

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

This code was from existing ts project @raych1 Should we continue to use PowerShell or only standard change to Javascript ?

}
if ($addSdkSuppressionsLabels.length -gt 0) {
try {
Add-GithubIssueLabels -RepoOwner $RepoOwner -RepoName $RepoName `
Copy link
Member

Choose a reason for hiding this comment

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

If this code needs permissions to write to the repo, it will need a thorough security review, and it will likely need to be split into two actions. One part that runs on trigger pull_request with read-only access to process the business logic, and another part that runs on trigger workflow_completed with write access to modify labels.

Copy link
Member

@mikeharder mikeharder Nov 27, 2024

Choose a reason for hiding this comment

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

For an example of a work-in-progress, see mikeharder#5

Copy link
Member Author

Choose a reason for hiding this comment

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

I saw the example and it was an operation for github label action. If i want to do another script like validate something by Javascript which use 3th-part package. Does the package.json place in eng/scripts/ folder ?

- name: Checkout code
uses: actions/checkout@v2

- name: Run Manage-SDKSuppression-Label script from file
Copy link
Member

Choose a reason for hiding this comment

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

We should probably change this from PowerShell to JavaScript, and use the github-script action which handles the GitHub Token for us.

Copy link
Member

@mikeharder mikeharder left a comment

Choose a reason for hiding this comment

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

This should probably be converted to a two-part github-script action

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.

3 participants