diff --git a/build/yaml/botbuilder-dotnet-ci.yml b/build/yaml/botbuilder-dotnet-ci.yml index 8f5fa8ba81..2268bd3df4 100644 --- a/build/yaml/botbuilder-dotnet-ci.yml +++ b/build/yaml/botbuilder-dotnet-ci.yml @@ -104,10 +104,11 @@ stages: } } $multiconfig = $multiconfig.TrimEnd(' ').TrimEnd(',') + "}"; + echo 'Matrix variable:' echo $multiconfig "##vso[task.setVariable variable=MULTICONFIG;isOutput=true]$multiconfig" name: generate_var - - script: echo $(generate_var.MULTICONFIG) + displayName: Generate matrix variable - job: check_api_for dependsOn: generate_multiconfig_var diff --git a/build/yaml/ci-post-to-github-steps.yml b/build/yaml/ci-post-to-github-steps.yml index 06c927abe1..b1378f0702 100644 --- a/build/yaml/ci-post-to-github-steps.yml +++ b/build/yaml/ci-post-to-github-steps.yml @@ -1,14 +1,14 @@ steps: - task: DownloadBuildArtifacts@0 - displayName: 'Download Compat Results artifact' + displayName: 'Download compat results artifact' inputs: downloadType: specific itemPattern: '**\*.txt' downloadPath: '$(System.ArtifactsDirectory)\ApiCompat' - condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest')) + condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest'), ne(variables['System.PullRequest.IsFork'], 'True')) - task: SOUTHWORKS.github-pr-comment.custom-publish-comment-task.github-pr-comment@0 - displayName: 'Publish Compat Results to Github' + displayName: 'Publish compat results to Github' inputs: userToken: '$(GitHubCommentApiKey)' bodyFilePath: '$(System.ArtifactsDirectory)\ApiCompat' @@ -17,61 +17,73 @@ steps: condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest'), ne(variables['System.PullRequest.IsFork'], 'True')) - powershell: | - # Check for string in the logs in the current DevOps pipeline run. - # - # Note: The task immediately before this one may not get checked because its log may not yet be available. - # Calls the Azure DevOps REST API. - # Enable OAuth token access in the pipeline agent job for $(System.Accesstoken) to populate. + Start-Sleep -Seconds 30 + displayName: 'Wait for last task log to finish writing' + condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest'), ne(variables['System.PullRequest.IsFork'], 'True')) - $stringToCheckFor = '201 Created'; - - Start-Sleep -Milliseconds 1000 # Give time for the last log to become available - - $collectionUri = "$env:SYSTEM_COLLECTIONURI"; # e.g. 'https://fuselabs.visualstudio.com' - $teamProjectId = "$env:SYSTEM_TEAMPROJECTID"; # e.g. '86659c66-c9df-418a-a371-7de7aed35064' = SDK_v4 - - # Get the current build ID. - $buildId = "$env:BUILD_BUILDID"; - Write-Host 'Build ID = ' $buildId; - - # Get the log containers for the run. - $uri = "$collectionUri/$teamProjectId/_apis/build/builds/$buildId/logs"; - - $token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$(System.AccessToken)")); - $header = @{authorization = "Basic $token"}; - - $runLogContainers = Invoke-RestMethod "$uri" -Method Get -ContentType "application/json" -Headers $header; - - # Get the log from each log container. - Write-Host 'Checking the logs:'; - $found = $false; - foreach ($container in $runLogContainers.value) { - $container.id; - $uri = $container.url; - $uri; - $log = Invoke-RestMethod "$uri" -Method Get -ContentType "application/json" -Headers $header; - - # Search for our string. - if (!$found -and $log.Contains($stringToCheckFor)) { - $found = $true; - $log; - $mess = 'String "' + $stringToCheckFor + '" found in log #' + $container.id; - Write-Host $mess; - } else { - ($log -split '\r?\n')[0] + '...'; # Print first line - } - } - - # If not found, throw an error. - if (!$found) { - Write-Host; - $mess = 'Publish Compat Results failed. Is there a PR associated with this build? String "' + $stringToCheckFor + '" not found in the logs'; - throw $mess; - } +- powershell: | + # This task compensates for the 'Publish compat results...' task above which can fail silently. + # Check task log for a "success" string in the current pipeline run. + # If not succeeded, fail this task. + # + # Note: The target task needs time to finish writing its log. Hence the wait task above. + # Calls the Azure DevOps REST API. + # Enable OAuth token access in the pipeline agent job for $(System.Accesstoken) to populate. + + $taskToCheck = 'Publish compat results to Github'; + $successStringToCheckFor = 'status: 201'; + + $collectionUri = "$env:SYSTEM_COLLECTIONURI"; # e.g. 'https://fuselabs.visualstudio.com' + $teamProjectId = "$env:SYSTEM_TEAMPROJECTID"; # e.g. '86659c66-c9df-418a-a371-7de7aed35064' = SDK_v4 + + # Get the current build ID. + $buildId = "$env:BUILD_BUILDID"; + Write-Host 'Build ID = ' $buildId; + + # Get the log containers for the run. + $uri = "$collectionUri/$teamProjectId/_apis/build/builds/$buildId/logs"; + + $token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$(System.AccessToken)")); + $header = @{authorization = "Basic $token"}; + + $runLogContainers = Invoke-RestMethod "$uri" -Method Get -ContentType "application/json" -Headers $header; + $containersCount = $runLogContainers.count; + + # Get the log from each log container. + Write-Host 'Checking the logs:'; + $found = $false; + foreach ($container in $runLogContainers.value) { + # Search only the last 3 task logs. + if ($container.id -gt $containersCount - 3) { + $container.id; + $uri = $container.url; + $uri; + $log = Invoke-RestMethod "$uri" -Method Get -ContentType "application/json" -Headers $header; + + # Search for the success string. + if ($log.Contains($taskToCheck)) { + $log; + if ($log.Contains($successStringToCheckFor)) { + $found = $true; + $mess = 'String "' + $successStringToCheckFor + '" found in log #' + $container.id; + Write-Host $mess; + } + } else { + ($log -split '\r?\n')[0] + '...'; # Print first line + } + } + } - displayName: 'Verify Publish Compat Results success' + # If not found, throw an error. + if (!$found) { + Write-Host; + $mess = "$taskToCheck failed. Is there a PR associated with this build? String '" + $successStringToCheckFor + "' not found in the log."; + throw $mess; + } + displayName: 'Verify publish compat results success' + ignoreLASTEXITCODE: true continueOnError: true - condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest')) + condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest'), ne(variables['System.PullRequest.IsFork'], 'True')) - script: | cd ..