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 diff --git a/tools/travis.ps1 b/tools/travis.ps1 index fe665737f62..73c3a74808e 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" @@ -269,33 +271,46 @@ else 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" ) { + Throw $resultError + } +} +elseif($Stage -in 'Failure', 'Success') +{ + $result = 'PASS' + if($Stage -eq 'Failure') + { + $result = 'FAIL' + } + if ($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 - } + try { + $svgData = Get-DailyBadge -result $result + if ( ! $svgData ) { + write-warning "Could not retrieve $result badge" } - catch { - Write-Warning "Could not update status 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' + } + }