From 7c05cc6a91d8b7bd14756540af14fb058ddb17e7 Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Thu, 26 Oct 2017 16:06:29 -0700 Subject: [PATCH 1/4] Call travis.ps1 for failure and success --- .travis.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ddbdf11f07a..888d5404f9a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,7 +35,7 @@ install: npm install -g markdown-spellcheck@0.11.0; fi - ulimit -n 4096 - - pwsh -File tools/travis.ps1 -Bootstrap + - pwsh -File tools/travis.ps1 -Stage Bootstrap script: - pwsh -File tools/travis.ps1 @@ -43,3 +43,9 @@ script: - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then mdspell '**/*.md' '!powershell/**/*.md' --ignore-numbers --ignore-acronyms --report; fi + +after_failure: + - pwsh -File tools/travis.ps1 -Stage Failure + +after_success: + - pwsh -File tools/travis.ps1 -Stage Success From 44842cbd655fc3c0f87873b2757911e42f0e6a8f Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Thu, 26 Oct 2017 16:07:14 -0700 Subject: [PATCH 2/4] move code to report success or failure to when travis-ci calls us for success or failure --- tools/travis.ps1 | 64 +++++++++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 25 deletions(-) diff --git a/tools/travis.ps1 b/tools/travis.ps1 index fe665737f62..59d55588cb1 100644 --- a/tools/travis.ps1 +++ b/tools/travis.ps1 @@ -1,6 +1,8 @@ param( - [switch]$Bootstrap + [ValidateSet('Bootstrap','Build','Failure','Success')] + [String]$Stage = 'Build' ) + Import-Module $PSScriptRoot/../build.psm1 -Force Import-Module $PSScriptRoot/packaging -Force @@ -158,14 +160,14 @@ $isDailyBuild = $env:TRAVIS_EVENT_TYPE -eq 'cron' -or $env:TRAVIS_EVENT_TYPE -eq $cronBuild = $env:TRAVIS_EVENT_TYPE -eq 'cron' $isFullBuild = $isDailyBuild -or $hasFeatureTag -if($Bootstrap.IsPresent) +if($Stage -eq 'Bootstrap') { Write-Host -Foreground Green "Executing travis.ps1 -BootStrap `$isPR='$isPr' - $commitMessage" # Make sure we have all the tags Sync-PSTags -AddRemoteIfMissing Start-PSBootstrap -Package:(-not $isPr) } -else +elseif($Stage -eq 'Build') { $BaseVersion = (Get-PSVersion -OmitCommitId) + '-' Write-Host -Foreground Green "Executing travis.ps1 `$isPR='$isPr' `$isFullBuild='$isFullBuild' - $commitMessage" @@ -270,32 +272,44 @@ else } } + # if the tests did not pass, throw the reason why + if ( $result -eq "FAIL" ) { + Throw $resultError + } +} +elseif($Stage -in 'Failure', 'Success') +{ + $result = 'PASS' + if($Stage -eq 'Failure') + { + $result = 'FAIL' + } + + if ((-not $isPr) -and $cronBuild) { # update the badge if you've done a cron build, these are not fatal issues - if ( $cronBuild ) { - try { - $svgData = Get-DailyBadge -result $result - if ( ! $svgData ) { - write-warning "Could not retrieve $result badge" - } - else { - log "Setting status badge to '$result'" - Set-DailyBuildBadge -content $svgData - } - } - catch { - Write-Warning "Could not update status badge: $_" + try { + $svgData = Get-DailyBadge -result $result + if ( ! $svgData ) { + write-warning "Could not retrieve $result badge" } - try { - Send-DailyWebHook -result $result - } - catch { - Write-Warning "Could not send webhook: $_" + else { + log "Setting status badge to '$result'" + Set-DailyBuildBadge -content $svgData } } - } + catch { + Write-Warning "Could not update status badge: $_" + } - # if the tests did not pass, throw the reason why - if ( $result -eq "FAIL" ) { - Throw $resultError + try { + Send-DailyWebHook -result $result + } + catch { + Write-Warning "Could not send webhook: $_" + } } + else { + log 'We only send bagde or webhook update for Cron builds' + } + } From d83870e9c7f3041f0cffdf9758ce280e34e6cfd2 Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Thu, 26 Oct 2017 16:37:47 -0700 Subject: [PATCH 3/4] address PR comments --- tools/travis.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/travis.ps1 b/tools/travis.ps1 index 59d55588cb1..6c84952310e 100644 --- a/tools/travis.ps1 +++ b/tools/travis.ps1 @@ -285,7 +285,7 @@ elseif($Stage -in 'Failure', 'Success') $result = 'FAIL' } - if ((-not $isPr) -and $cronBuild) { + if ($cronBuild) { # update the badge if you've done a cron build, these are not fatal issues try { $svgData = Get-DailyBadge -result $result From f4e7ae574039fb5f5b0a8bf5ccec7a5c2135f722 Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Thu, 26 Oct 2017 16:42:07 -0700 Subject: [PATCH 4/4] add missing bracket --- tools/travis.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/travis.ps1 b/tools/travis.ps1 index 6c84952310e..73c3a74808e 100644 --- a/tools/travis.ps1 +++ b/tools/travis.ps1 @@ -271,6 +271,7 @@ elseif($Stage -eq 'Build') Start-NativeExecution -sb {dotnet nuget push $package --api-key $env:NUGET_KEY --source "$env:NUGET_URL/api/v2/package"} -IgnoreExitcode } } + } # if the tests did not pass, throw the reason why if ( $result -eq "FAIL" ) {