-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
base: main
Are you sure you want to change the base?
add suppression label script #31672
Conversation
Next Steps to Merge⌛ Please wait. Next steps to merge this PR are being evaluated by automation. ⌛ |
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 |
There was a problem hiding this comment.
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 = @{ |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 }} |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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." |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ` |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this 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
This tool is designed to identify suppression changes in the specification pull requests and manage suppression labels by adding or removing them as needed