Skip to content

Instantly share code, notes, and snippets.

@RikkiGibson
Created December 22, 2020 00:14
Show Gist options
  • Save RikkiGibson/1510ca398611f0047a061bb449675730 to your computer and use it in GitHub Desktop.
Save RikkiGibson/1510ca398611f0047a061bb449675730 to your computer and use it in GitHub Desktop.
# This script scrapes AzDo data and writes out a CSV of build runtimes
$roslynPipelineId = "15"
$baseURL = "https://dev.azure.com/dnceng/public/_apis/"
$runsURL = "$baseURL/pipelines/$roslynPipelineId/runs?api-version=6.0-preview.1"
$buildsURL = "$baseURL/build/builds/"
$runs = (Invoke-WebRequest -uri $runsURL | ConvertFrom-Json)
$wantedRecords = @(
"Build_Windows_Debug",
"Build_Windows_Release",
"Build_Unix_Debug",
"Correctness_Determinism",
"Correctness_Build",
"Correctness_SourceBuild",
"Test_Windows_Desktop_Debug_32",
"Test_Windows_Desktop_Spanish_Debug_32",
"Test_Windows_Desktop_Debug_64",
"Test_Windows_CoreClr_Debug",
"Test_Windows_Desktop_Release_32",
"Test_Windows_Desktop_Release_64",
"Test_Windows_CoreClr_Release",
"Test_Linux_Debug",
"Test_macOS_Debug")
[System.Collections.ArrayList]$allRuns = @()
foreach ($run in $runs.value[0..10]) {
if ($run.result -eq "succeeded") {
$timelineURL = "$buildsURL/$($run.id)/timeline"
$timeline = (Invoke-WebRequest -uri $timelineURL | ConvertFrom-Json)
foreach ($record in $timeline.records) {
if ($wantedRecords.Contains($record.name)) {
$allRuns.Add([PSCustomObject]@{
startTime = $record.startTime;
endTime = $record.endTime;
})
}
}
}
}
Export-Csv -InputObject $allRuns -Path "ci-times.csv" -NoTypeInformation
@jschneidereit
Copy link

$roslynPipelineId = "15"
$baseURL = "https://dev.azure.com/dnceng/public/_apis/"
$runsURL = "$baseURL/pipelines/$roslynPipelineId/runs?api-version=6.0-preview.1"
$buildsURL = "$baseURL/build/builds/"

class Record {
    [Nullable[DateTime]] $StartTime
    [Nullable[DateTime]] $EndTime
}

$runs = (Invoke-WebRequest -uri $runsURL | ConvertFrom-Json)

$wantedRecords = @(
    "Build_Windows_Debug",
    "Build_Windows_Release",
    "Build_Unix_Debug",
    "Correctness_Determinism",
    "Correctness_Build",
    "Correctness_SourceBuild",
    "Test_Windows_Desktop_Debug_32",
    "Test_Windows_Desktop_Spanish_Debug_32",
    "Test_Windows_Desktop_Debug_64",
    "Test_Windows_CoreClr_Debug",
    "Test_Windows_Desktop_Release_32",
    "Test_Windows_Desktop_Release_64",
    "Test_Windows_CoreClr_Release",
    "Test_Linux_Debug",
    "Test_macOS_Debug"
)

$allRuns = New-Object -TypeName 'Collections.Generic.List[Record]'

# [System.Collections.ArrayList]$allRuns = @()
foreach ($run in $runs.value[0..10]) {
    if ($run.result -eq "succeeded") {
        $timelineURL = "$buildsURL/$($run.id)/timeline"
        $timeline = (Invoke-WebRequest -uri $timelineURL | ConvertFrom-Json)

        foreach ($record in $timeline.records) {
            if ($wantedRecords.Contains($record.name)) {
                $r = [Record]::new()
                $r.StartTime = $record.startTime
                $r.EndTime = $record.endTime
                $allRuns.Add($r)

                # $allRuns.Add([PSCustomObject]@{
                #     startTime = $record.startTime;
                #     endTime = $record.endTime;
                # })
            }
        }
    }
}

$allRuns | Select-Object | Export-Csv -Path "ci-times.csv" -NoTypeInformation -Force

#Export-Csv -InputObject $allRuns -Path "ci-times.csv" -NoTypeInformation -Force
Get-Content -Path "ci-times.csv"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment