diff --git a/tools/ci.psm1 b/tools/ci.psm1 index d1e10b2252..c02cefaa7f 100644 --- a/tools/ci.psm1 +++ b/tools/ci.psm1 @@ -33,36 +33,7 @@ Function Test-DailyBuild { return $true } - - # if [feature] is in the commit message, - # Run Daily tests - $commitMessage = Get-CommitMessage - Write-log -message "commitMessage: $commitMessage" - - if($commitMessage -match '\[feature\]' -or $env:FORCE_FEATURE -eq 'True') - { - Set-BuildVariable -Name PS_DAILY_BUILD -Value $trueString - return $true - } - else - { - return $false - } -} - -# Returns the commit message for the current build -function Get-CommitMessage -{ - 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] - return &git log --format=%B -n 1 $commitId - } - else - { - Write-Log "Unknown BUILD_SOURCEVERSIONMESSAGE format '$env:BUILD_SOURCEVERSIONMESSAGE'" -Verbose - } + return $false } # Sets a build variable @@ -127,7 +98,6 @@ function Invoke-CIBuild } Start-PSBuild -CrossGen -PSModuleRestore -Configuration 'Release' -CI -ReleaseTag $releaseTag - Save-PSOptions $options = (Get-PSOptions) @@ -152,7 +122,6 @@ function Invoke-CIInstall ) # Make sure we have all the tags Sync-PSTags -AddRemoteIfMissing - $releaseTag = Get-ReleaseTag if(Test-DailyBuild) { @@ -257,7 +226,7 @@ function Invoke-CITest $ExcludeTag = @('CI') } Default { - throw "Unknow TagSet: '$TagSet'" + throw "Unknown TagSet: '$TagSet'" } } @@ -398,7 +367,7 @@ function Invoke-CIAfterTest $testPackageFullName = Join-Path $destBasePath 'TestPackage.zip' Write-Verbose "Created TestPackage.zip" -Verbose Write-Host -ForegroundColor Green 'Upload test package' - Push-Artifact $testPackageFullName -Name 'artifacts' + Push-Artifact $testPackageFullName -Name 'CodeCoverage' } } @@ -536,29 +505,26 @@ function Invoke-CIFinish } # only publish assembly nuget packages if it is a daily build and tests passed - if((Test-DailyBuild) -and $env:TestPassed -eq 'True') + if(Test-DailyBuild) { - Publish-NuGetFeed -OutputPath .\nuget-artifacts -ReleaseTag $preReleaseVersion - $nugetArtifacts = Get-ChildItem .\nuget-artifacts -ErrorAction SilentlyContinue | ForEach-Object { $_.FullName } + $nugetArtifacts = Get-ChildItem $PSScriptRoot\packaging\nugetOutput -ErrorAction SilentlyContinue -Filter *.nupkg | Select-Object -ExpandProperty FullName if($nugetArtifacts) { - $artifacts.AddRange($nugetArtifacts) + $artifacts.AddRange(@($nugetArtifacts)) } } - if (Test-DailyBuild) - { - # produce win-arm and win-arm64 packages if it is a daily build - Start-PSBuild -Restore -Runtime win-arm -PSModuleRestore -Configuration 'Release' -ReleaseTag $releaseTag - $arm32Package = Start-PSPackage -Type zip -WindowsRuntime win-arm -ReleaseTag $releaseTag -SkipReleaseChecks - $artifacts.Add($arm32Package) + # produce win-arm and win-arm64 packages if it is a daily build + Start-PSBuild -Restore -Runtime win-arm -PSModuleRestore -Configuration 'Release' -ReleaseTag $releaseTag + $arm32Package = Start-PSPackage -Type zip -WindowsRuntime win-arm -ReleaseTag $releaseTag -SkipReleaseChecks + $artifacts.Add($arm32Package) - Start-PSBuild -Restore -Runtime win-arm64 -PSModuleRestore -Configuration 'Release' -ReleaseTag $releaseTag - $arm64Package = Start-PSPackage -Type zip -WindowsRuntime win-arm64 -ReleaseTag $releaseTag -SkipReleaseChecks - $artifacts.Add($arm64Package) - } + Start-PSBuild -Restore -Runtime win-arm64 -PSModuleRestore -Configuration 'Release' -ReleaseTag $releaseTag + $arm64Package = Start-PSPackage -Type zip -WindowsRuntime win-arm64 -ReleaseTag $releaseTag -SkipReleaseChecks + $artifacts.Add($arm64Package) $pushedAllArtifacts = $true + $artifacts | ForEach-Object { Write-Log -Message "Pushing $_ as CI artifact" if(Test-Path $_) @@ -624,14 +590,6 @@ function Invoke-LinuxTestsCore 'ExcludeTag' = $testExcludeTag 'OutputFile' = $testResultsNoSudo } - # create packages if it is a full build - $isFullBuild = Test-DailyBuild - if (!$isFullBuild) { - $noSudoPesterParam['ThrowOnFailure'] = $true - } - if ($hasRunFailingTestTag) { - $noSudoPesterParam['IncludeFailingTest'] = $true - } # Get the experimental feature names and the tests associated with them $ExperimentalFeatureTests = Get-ExperimentalFeatureTests @@ -704,7 +662,7 @@ function Invoke-LinuxTestsCore # Determine whether the build passed try { $allTestResultsWithNoExpFeature = @($pesterPassThruNoSudoObject, $pesterPassThruSudoObject) - $allTestResultsWithExpFeatures = $noSudoResultsWithExpFeatures + $sudoResultsWithExpFeatures + $allTestResultsWithExpFeatures = @($noSudoResultsWithExpFeatures, $sudoResultsWithExpFeatures) # This throws if there was an error: $allTestResultsWithNoExpFeature | ForEach-Object { Test-PSPesterResults -ResultObject $_ } $allTestResultsWithExpFeatures | ForEach-Object { Test-PSPesterResults -ResultObject $_ -CanHaveNoResult } @@ -714,53 +672,6 @@ function Invoke-LinuxTestsCore $resultError = $_ $result = "FAIL" } -} - -# Build and test script for Linux and macOS: -function Invoke-LinuxTests -{ - param( - [switch] - $SkipBuild - ) - - if(!$SkipBuild.IsPresent) - { - $releaseTag = Get-ReleaseTag - Write-Log -Message "Executing ci.psm1 build and test on a Linux based operating system." - $originalProgressPreference = $ProgressPreference - $ProgressPreference = 'SilentlyContinue' - try { - # We use CrossGen build to run tests only if it's the daily build. - Start-PSBuild -CrossGen -PSModuleRestore -CI -ReleaseTag $releaseTag -Configuration 'Release' - } - finally - { - $ProgressPreference = $originalProgressPreference - } - } - - Invoke-LinuxTestsCore - - try { - $xUnitTestResultsFile = "$pwd/xUnitTestResults.xml" - Start-PSxUnit -xUnitTestResultsFile $xUnitTestResultsFile - # If there are failures, Test-XUnitTestResults throws - Test-XUnitTestResults -TestResultsFile $xUnitTestResultsFile - } catch { - $result = "FAIL" - if (!$resultError) - { - $resultError = $_ - } - } - - $createPackages = $isFullBuild - - if ($createPackages) - { - New-LinuxPackage -NugetKey $env:NugetKey - } # If the tests did not pass, throw the reason why if ( $result -eq "FAIL" )