Skip to content

Commit

Permalink
1-12 Update.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengillie committed Jan 13, 2024
1 parent e132cd5 commit 75c4821
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 33 deletions.
1 change: 1 addition & 0 deletions Tools/Auth.csv
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ PackageIdentifier,Account,strictness
2BrightSparks.SyncBackPro,2BrightSparks,should
2BrightSparks.SyncBackSE,2BrightSparks,should
AlexanderPro.SmartSystemMenu,AlexanderPro,should
ApeCloud.kbcli,apecloud-bot,should
amrdeveloper.gitql,AmrDeveloper,should
blacktop.ipsw,blacktop,should
blacktop.ipswd,blacktop,should
Expand Down
88 changes: 68 additions & 20 deletions Tools/ManualValidationPipeline.ps1
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
#Copyright 2022-2024 Microsoft Corporation
#Author: Stephen Gillie
#Title: Manual Validation Pipeline v3.6.3
#Title: Manual Validation Pipeline v3.7.0
#Created: 10/19/2022
#Updated: 1/11/2024
#Updated: 1/12/2024
#Notes: Utilities to streamline evaluating 3rd party PRs.
#Update log:
#3.7.0 Add Get-PRReportFromRecord to simplify reporting.
#3.6.9 Add ValidationSet to Get-PRFromRecord and Add-PRLabel.
#3.6.8 Remove unnecessary Get-CommitFile code.
#3.6.7 Bugfix to AutoValLog DefenderFail auto-commenting.
#3.6.6 Bugfix to Invoke-GitHubPRRequest.
#3.6.5 Add several new GitHub Presets.
#3.6.4 Bugfix to IEDS approval - to work off the Retry-1 label instead of the IEDS label.
#3.6.3 Numerous quality of life and speed improvements.
#3.6.2 Add Installer checking automation.
#3.6.1 Add Add-PRToRecord and Get-PRTitle to automate reporting.
#3.6.0 Add numerous functions to get text from PR and add suggestions on specific lines.
#3.5.5 Rename Get-AutoValBuild to Get-BuildFromPR.
#3.5.4 Rearrange commonly-developed functions to be near the top.


$build = 561
$build = 567
$appName = "Manual Validation"
Write-Host "$appName build: $build"
$MainFolder = "C:\ManVal"
Expand Down Expand Up @@ -108,9 +110,10 @@ Function Add-Waiver {
Foreach ($Label in $Labels) {
$Waiver = ""
Switch ($Label) {
"Internal-Error-Dynamic-Scan" {
"Retry-1" {
Add-PRLabel -PR $PR -Label "Validation-Completed" -Method PUT
Add-PRToRecord $PR "Manually-Validated-IEDS"
Add-PRLabel -PR $PR -Label "Retry-1" -Method POST
Add-PRToRecord $PR "Manual"
}
"Validation-Completed" {
Approve-PR $PR
Expand Down Expand Up @@ -158,27 +161,46 @@ Function Add-Waiver {
Function Get-GitHubPreset {
param(
[int]$PR,
[ValidateSet("DefenderFail","InstallerNotSilent","PackageUrl")][string]$Preset,
[ValidateSet("Approved","BadPR","DefenderFail","Feedback","InstallerNotSilent","PackageUrl","Waiver")][string]$Preset,
[string]$UserName = (Invoke-GitHubPRRequest $PR -Type "" -Output content -JSON).user.login,
$CannedResponse = $Preset,
$Label
)
Switch ($Preset) {
"Approved" {
Approve-PR $PR;
Add-PRToRecord $PR $Preset
}
"BadPR" {
Reply-ToPR $PR -Body "Bad PR." ;
Add-PRToRecord $PR Closed
}
"DefenderFail" {
$Label = "Needs-Attention"
Add-PRToRecord $PR "Blocking"
Reply-ToPR -PR $PR -CannedResponse $CannedResponse -UserInput $UserName
Add-PRLabel -PR $PR -Label $Label
}
"Feedback" {
Add-PRLabel $PR
Add-PRToRecord $PR $Preset
}
"InstallerNotSilent" {
$Label = "Needs-Author-Feedback"
Add-PRToRecord $PR "Feedback"
Add-PRToRecord $PR Feedback
Reply-ToPR -PR $PR -CannedResponse $CannedResponse -UserInput $UserName
Add-PRLabel -PR $PR -Label $Label
}
"PackageUrl" {
$Label = "Changes-Requested"
Reply-ToPR -PR $PR -CannedResponse $CannedResponse -UserInput $UserName
Add-PRLabel -PR $PR -Label $Label
}
"Waiver" {
Add-Waiver $PR;
Add-PRToRecord $PR $Preset
}
}

Reply-ToPR -PR $PR -CannedResponse $CannedResponse -UserInput $UserName
Add-PRLabel -PR $PR -Label $Label
}

#PR tools
Expand Down Expand Up @@ -221,9 +243,11 @@ Function Invoke-GitHubPRRequest {
)
$Response = @{}
$ResponseType = $Type
$uri = "https://api.github.com/repos/microsoft/winget-pkgs/$Path/$pr/$Type"

if (($Type -eq "") -OR ($Type -eq "files")){
$Path = "pulls"
$uri = "https://api.github.com/repos/microsoft/winget-pkgs/$Path/$pr/$Type"
} elseif ($Type -eq "comments") {
$Response.body += $Data
} elseif ($Type -eq "commits") {
Expand All @@ -245,7 +269,6 @@ Function Invoke-GitHubPRRequest {
$Response.$ResponseType += $Data
}

$uri = "https://api.github.com/repos/microsoft/winget-pkgs/$Path/$pr/$Type"
$uri = $uri -replace "/$",""

if ($Method -eq "GET") {
Expand Down Expand Up @@ -304,7 +327,8 @@ Function Get-AutoValLog {

$UserInput = $UserInput -replace "Standard error: ",""
if ($UserInput -ne "") {
if ($clip -match "\[FAIL\] Installer failed security check.") {Get-GitHubPreset $PR DefenderFail}
#Start-Process "https://github.com/microsoft/winGet-pkgs/pull/$PR"
if ($UserInput -match "\[FAIL\] Installer failed security check.") {Get-GitHubPreset $PR DefenderFail}

$UserInput = ($UserInput -split "`n") -notmatch ' success or error status`: 0'
$UserInput = ($UserInput -split "`n") -notmatch 'api-ms-win-core-errorhandling'
Expand Down Expand Up @@ -356,9 +380,8 @@ Function Get-CommitFile {
param(
$PR
)
$File = 0
$Commit = Invoke-GitHubPRRequest -PR $PR -Type commits -Output content -JSON
$CommitFile = Invoke-GitHubRequest -Uri $Commit.files[$File].contents_url
$CommitFile = Invoke-GitHubRequest -Uri $Commit.files.contents_url
$EncodedFile = $CommitFile.Content | ConvertFrom-Json
Get-DecodeGitHubFile $EncodedFile.content

Expand Down Expand Up @@ -437,11 +460,34 @@ Function Add-PRToRecord {

Function Get-PRFromRecord {
param(
[ValidateSet("Approved","Blocking","Feedback","Retry","Manual","Closed","Project","Squash","Waiver")]
$Action
)
("PR,Action`n" + (Get-Content $LogFile)) -split " " | ConvertFrom-Csv | Where-Object {$_.Action -match $Action}
}

Function Get-PRReportFromRecord {
param(
[ValidateSet("Approved","Blocking","Feedback","Retry","Manual","Closed","Project","Squash","Waiver")]
$Action,
$out = "",
$n = 0,
$Record = ((Get-PRFromRecord $Action).PR | Select-Object -Unique),
$length = $Record.length
)

(Get-Content $LogFile) | ConvertFrom-Csv | Where-Object {$_.Action -notmatch $Action} | ConvertTo-Csv|Out-File $LogFile

Foreach ($PR in $Record) {
$Title = Get-PRTitle $PR
$out += "$Title #$PR`n";
$n++;
$pct = $n / $length
Write-Progress -Activity "Get-PRTitle" -Status "$PR - $n / $length = " -PercentComplete ($pct*100)
}
return $out
}

Function Approve-PR {
param(
$PR,
Expand Down Expand Up @@ -588,8 +634,10 @@ Function Get-PRApproval {
Function Add-PRLabel {
param(
$PR,
[ValidateSet("Changes-Requested","Needs-Author-Feedback","Retry-1","Needs-Attention","Validation-Completed")]
[string]$Label = "Needs-Author-Feedback",
[ValidateSet("GET","DELETE","POST","PUT")][string]$Method = "POST"
[ValidateSet("GET","DELETE","POST","PUT")]
[string]$Method = "POST"
)
Invoke-GitHubPRRequest -PR $PR -Method $Method -Type "labels" -Data $Label
}
Expand Down
17 changes: 4 additions & 13 deletions Tools/PRWatcher.ps1
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#Copyright 2023-2024 Microsoft Corporation
#Author: Stephen Gillie
#Title: PRWatcher v1.2.7
#Title: PRWatcher v1.2.8
#Created: 2/15/2023
#Updated: 1/11/2024
#Updated: 1/12/2024
#Notes: Streamlines WinGet-pkgs manifest PR moderator approval by watching the clipboard - copy a PR's FIles tab to your clipboard, and Get-PRWatch parse the PR, start a VM to review if new, and approve the PR if it passes all checks. Also outputs valid titles to a logging file. Freeing moderators to focus on approving and helping.
#Update log:
#1.2.8 Clean up approved PR recording, and remove unnecessary code.
#1.2.7 Add PR Record system to gather PR numbers at decision points.
#1.2.6 Bugfix to WordFilter.
#1.2.5 Capitalize "Invoke" in Cmdlet names.



Expand Down Expand Up @@ -1445,22 +1445,13 @@ Function Get-PRWatch {
if ($Approve -eq "+") {
$Approve = Approve-PR $PR
Add-PRToRecord $PR "Approved"
Add-PRToRecord $PR Approved
}
Write-Host -nonewline -f $matchColor "$Approve | "
Write-Host -f $matchColor ""
$oldclip = $PRtitle
if ($noRecord -eq $false) {
if ($PRtitle.length -le 128) {
$PRtitle = $PRtitle -join "" | Where-Object {$_ -match $hashPRRegex}
#Write-Debug "Output $PRtitle to $LogFile"
Add-PRToRecord $PR "Approved"
} else {
Write-Host -f $cautionColor "Item length greater than 128 characters."
} ; #end if clip
}; #end if noRecord
}; #end if Compare-Object
}; #end if clip
Start-Sleep 1
Expand Down

0 comments on commit 75c4821

Please sign in to comment.