Skip to content

Commit

Permalink
Add daily build non-windows platforms (PowerShell#7683)
Browse files Browse the repository at this point in the history
Add daily build non-windows platforms
  - Also, make the [Feature] tag work in VSTS for non-windows
  - Also, add a way to force feature tests to run
  - Also, fix an issue where `-workingdirectory` didn't work when running async
  • Loading branch information
TravisEz13 committed Sep 6, 2018
1 parent 70d6015 commit 2141c2a
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 29 deletions.
22 changes: 9 additions & 13 deletions .vsts-ci/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@ phases:
- phase: Linux_CI

queue:
name: Hosted Linux Preview
name: Hosted Ubuntu 1604
steps:
- powershell: Write-Host "##vso[build.updatebuildnumber]$env:BUILD_SOURCEBRANCHNAME-$env:BUILD_SOURCEVERSION-$((get-date).ToString("yyyyMMddhhss"))"
- powershell: |
Get-ChildItem -Path env:
displayName: Capture environment
condition: succeededOrFailed()
- powershell: Write-Host "##vso[build.updatebuildnumber]$env:BUILD_SOURCEBRANCHNAME-$env:BUILD_SOURCEVERSION-$((get-date).ToString("yyyyMMddhhmmss"))"
displayName: Set Build Name for Non-PR
condition: ne(variables['Build.Reason'], 'PullRequest')

Expand All @@ -33,8 +38,8 @@ phases:
condition: succeededOrFailed()
- powershell: |
apt-get update
apt-get install -y --no-install-recommends less
sudo apt-get update
sudo apt-get install -y --no-install-recommends less
displayName: Install less
condition: succeededOrFailed()
Expand Down Expand Up @@ -65,14 +70,5 @@ phases:
Write-Host "##vso[artifact.upload containerfolder=artifacts;artifactname=artifacts]$_"
}
displayName: Publish Artifacts
condition: succeededOrFailed()
continueOnError: true
# Uploads any Test results as an artifact
- powershell: |
Get-ChildItem -Path Test*.xml, *XUnitTestResults.xml -Recurse | Select-Object -ExpandProperty FullName | ForEach-Object {
Write-Host "##vso[artifact.upload containerfolder=testResults;artifactname=testResults]$_"
}
displayName: Publish Test Results
condition: ne(variables['Build.Reason'], 'PullRequest')
continueOnError: true
9 changes: 7 additions & 2 deletions .vsts-ci/mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@ phases:
- phase: macOS_CI

queue:
name: Hosted macOS Preview
name: Hosted macOS
steps:
- powershell: Write-Host "##vso[build.updatebuildnumber]$env:BUILD_SOURCEBRANCHNAME-$env:BUILD_SOURCEVERSION-$((get-date).ToString("yyyyMMddhhss"))"
- powershell: |
Get-ChildItem -Path env:
displayName: Capture environment
condition: succeededOrFailed()
- powershell: Write-Host "##vso[build.updatebuildnumber]$env:BUILD_SOURCEBRANCHNAME-$env:BUILD_SOURCEVERSION-$((get-date).ToString("yyyyMMddhhmmss"))"
displayName: Set Build Name for Non-PR
condition: ne(variables['Build.Reason'], 'PullRequest')

Expand Down
7 changes: 6 additions & 1 deletion .vsts-ci/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ resources:
clean: true

steps:
- powershell: Write-Host "##vso[build.updatebuildnumber]$env:BUILD_SOURCEBRANCHNAME-$env:BUILD_SOURCEVERSION-$((get-date).ToString("yyyyMMddhhss"))"
- powershell: |
Get-ChildItem -Path env:
displayName: Capture environment
condition: succeededOrFailed()
- powershell: Write-Host "##vso[build.updatebuildnumber]$env:BUILD_SOURCEBRANCHNAME-$env:BUILD_SOURCEVERSION-$((get-date).ToString("yyyyMMddhhmmss"))"
displayName: Set Build Name for Non-PR
condition: ne(variables['Build.Reason'], 'PullRequest')

Expand Down
2 changes: 1 addition & 1 deletion build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1825,7 +1825,7 @@ function Start-PSBootstrap {
# We cannot guess if the user wants to run gem install as root on linux and windows,
# but macOs usually requires sudo
$gemsudo = ''
if($Environment.IsMacOS) {
if($Environment.IsMacOS -or $env:TF_BUILD) {
$gemsudo = $sudo
}
Start-NativeExecution ([ScriptBlock]::Create("$gemsudo gem install fpm -v 1.10.0"))
Expand Down
23 changes: 21 additions & 2 deletions src/Microsoft.PowerShell.ConsoleHost/host/msh/Executor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,18 @@ internal void ExecuteCommandAsync(string command, out Exception exceptionThrown,
ExecuteCommandAsyncHelper(tempPipeline, out exceptionThrown, options);
}

/// <summary>
/// Executes a pipeline in the console when we are running asnyc.
/// </summary>
/// <param name="tempPipeline">
/// The pipeline to execute.
/// </param>
/// <param name="exceptionThrown">
/// Any exception thrown trying to run the pipeline.
/// </param>
/// <param name="options">
/// The options to use to execute the pipeline.
/// </param>
internal void ExecuteCommandAsyncHelper(Pipeline tempPipeline, out Exception exceptionThrown, ExecutionOptions options)
{
Dbg.Assert(!_isPromptFunctionExecutor, "should not async invoke the prompt");
Expand Down Expand Up @@ -192,7 +204,14 @@ internal void ExecuteCommandAsyncHelper(Pipeline tempPipeline, out Exception exc

tempPipeline.Output.DataReady += new EventHandler(OutputObjectStreamHandler);
tempPipeline.Error.DataReady += new EventHandler(ErrorObjectStreamHandler);
PipelineFinishedWaitHandle waiterThereIsAFlyInMySoup = new PipelineFinishedWaitHandle(tempPipeline);
PipelineFinishedWaitHandle pipelineWaiter = new PipelineFinishedWaitHandle(tempPipeline);

// close the input pipeline so the command will do something
// if we are not reading input
if ((options & Executor.ExecutionOptions.ReadInputObjects) == 0)
{
tempPipeline.Input.Close();
}

tempPipeline.InvokeAsync();
if ((options & ExecutionOptions.ReadInputObjects) > 0 && Console.IsInputRedirected)
Expand Down Expand Up @@ -224,7 +243,7 @@ internal void ExecuteCommandAsyncHelper(Pipeline tempPipeline, out Exception exc
}
tempPipeline.Input.Close();

waiterThereIsAFlyInMySoup.Wait();
pipelineWaiter.Wait();

//report error if pipeline failed
if (tempPipeline.PipelineStateInfo.State == PipelineState.Failed && tempPipeline.PipelineStateInfo.Reason != null)
Expand Down
4 changes: 2 additions & 2 deletions test/powershell/Host/ConsoleHost.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ foo
@{ value = "~\$folderName"; expectedPath = $((Get-Item ~\$folderName).FullName) }
) {
param($value, $expectedPath)
$output = & $powershell -WorkingDirectory "$value" -Command "`$pwd.Path"
$output = & $powershell -NoProfile -WorkingDirectory "$value" -Command '(Get-Location).Path'
$output | Should -BeExactly $expectedPath
}

Expand All @@ -558,7 +558,7 @@ foo
@{ parameter = '-wo' }
) {
param($parameter)
$output = & $powershell $parameter ~ -Command "`$pwd.Path"
$output = & $powershell -NoProfile $parameter ~ -Command "`$pwd.Path"
$output | Should -BeExactly $((Get-Item ~).FullName)
}

Expand Down
48 changes: 40 additions & 8 deletions tools/travis.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -154,30 +154,62 @@ function Set-DailyBuildBadge
# One of push, pull_request, api, cron.
$isPR = $env:TRAVIS_EVENT_TYPE -eq 'pull_request'

$commitMessage = [string]::Empty

# For PRs, Travis-ci strips out [ and ] so read the message directly from git
if($env:TRAVIS_EVENT_TYPE -eq 'pull_request')
if($env:TRAVIS_EVENT_TYPE -eq 'pull_request' -or $env:BUILD_REASON)
{
# If the current job is a pull request, the env variable 'TRAVIS_PULL_REQUEST_SHA' contains
# the commit SHA of the HEAD commit of the PR.
$commitMessage = git log --format=%B -n 1 $env:TRAVIS_PULL_REQUEST_SHA
$commitId = $null
if ($env:TRAVIS_EVENT_TYPE)
{
# We are in Travis-CI
$commitId = $env:TRAVIS_PULL_REQUEST_SHA

# If the current job is a pull request, the env variable 'TRAVIS_PULL_REQUEST_SHA' contains
# the commit SHA of the HEAD commit of the PR.
$commitMessage = git log --format=%B -n 1 $commitId
Write-Log -message "commitMessage: $commitMessage"
}
elseif($env:TF_BUILD)
{
if($env:BUILD_SOURCEVERSIONMESSAGE -match 'Merge\s*([0-9A-F]*)')
{
# We are in VSTS and have a commit ID in the Source Version Message
$commitId = $Matches[1]
$commitMessage = git log --format=%B -n 1 $commitId
}
else
{
Write-Log "Unknown BUILD_SOURCEVERSIONMESSAGE format '$env:BUILD_SOURCEVERSIONMESSAGE'" -Verbose
}
}
}
else
{
$commitMessage = $env:TRAVIS_COMMIT_MESSAGE
}

# Run a full build if the build was trigger via cron, api or the commit message contains `[Feature]`
$hasFeatureTag = $commitMessage -match '\[feature\]'
$hasPackageTag = $commitMessage -match '\[package\]'
# or the environment variable `FORCE_FEATURE` equals `True`
$hasFeatureTag = $commitMessage -match '\[feature\]' -or $env:FORCE_FEATURE -eq 'True'

# Run a packaging if the commit message contains `[Package]`
# or the environment variable `FORCE_PACKAGE` equals `True`
$hasPackageTag = $commitMessage -match '\[package\]' -or $env:FORCE_PACKAGE -eq 'True'
$createPackages = -not $isPr -or $hasPackageTag
$hasRunFailingTestTag = $commitMessage -match '\[includeFailingTest\]'
$isDailyBuild = $env:TRAVIS_EVENT_TYPE -eq 'cron' -or $env:TRAVIS_EVENT_TYPE -eq 'api'
$isDailyBuild = $env:TRAVIS_EVENT_TYPE -eq 'cron' -or $env:TRAVIS_EVENT_TYPE -eq 'api' -or $env:BUILD_REASON -eq 'Schedule'
# only update the build badge for the cron job
$cronBuild = $env:TRAVIS_EVENT_TYPE -eq 'cron'
$cronBuild = $env:TRAVIS_EVENT_TYPE -eq 'cron' -or $env:BUILD_REASON -eq 'Schedule'
$isFullBuild = $isDailyBuild -or $hasFeatureTag

if($Stage -eq 'Bootstrap')
{
if($cronBuild -and $env:TF_BUILD)
{
Write-Host "##vso[build.updatebuildnumber]Daily-$env:BUILD_SOURCEBRANCHNAME-$env:BUILD_SOURCEVERSION-$((get-date).ToString("yyyyMMddhhmmss"))"
}

Write-Host -Foreground Green "Executing travis.ps1 -BootStrap `$isPR='$isPr' - $commitMessage"
# Make sure we have all the tags
Sync-PSTags -AddRemoteIfMissing
Expand Down

0 comments on commit 2141c2a

Please sign in to comment.