Skip to content

Commit

Permalink
Update appveyor scripts to use new build script
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesWTruher committed Oct 18, 2018
1 parent 2978f78 commit 5c01978
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 59 deletions.
43 changes: 21 additions & 22 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
environment:
PSVersion: 5
BuildConfiguration: Release
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
PowerShellEdition: PowerShellCore
BuildConfiguration: Release
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
PowerShellEdition: WindowsPowerShell
BuildConfiguration: Release
- APPVEYOR_BUILD_WORKER_IMAGE: WMF 4
PowerShellEdition: WindowsPowerShell
BuildConfiguration: PSv4Release
PSVersion: 4
- APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu
PowerShellEdition: PowerShellCore
BuildConfiguration: Release

# cache Nuget packages and dotnet CLI cache
cache:
Expand All @@ -33,29 +32,29 @@ install:
build_script:
- ps: |
if ($env:PowerShellEdition -eq 'WindowsPowerShell') {
if ($env:BuildConfiguration -eq 'PSv4Release') {
# On WMF$: Also build for v3 to check it builds at least since we do not have a WMF3 image
Invoke-AppveyorBuild -CheckoutPath $env:APPVEYOR_BUILD_FOLDER -BuildConfiguration PSv3Release -BuildType 'FullCLR'
}
Invoke-AppveyorBuild -CheckoutPath $env:APPVEYOR_BUILD_FOLDER -BuildConfiguration $env:BuildConfiguration -BuildType 'FullCLR'
}
Set-Location $env:APPVEYOR_BUILD_FOLDER
./build.ps1 -Documentation
if ( $env:PSVersion -eq "4" ) { # On WMF4: Also build for v3 to check it builds at least since we do not have a WMF3 image
./build.ps1 -Configuration "$env:BuildConfiguration" -PSVersion 3 -Framework full
}
./build.ps1 -Configuration "$env:BuildConfiguration" -PSVersion "$env:PSVersion" -Framework full
- pwsh: |
if ($env:PowerShellEdition -eq 'PowerShellCore') {
Import-Module .\tools\appveyor.psm1 # Appveyor does not persist pwsh sessions like it does for ps
Invoke-AppveyorBuild -CheckoutPath $env:APPVEYOR_BUILD_FOLDER -BuildConfiguration $env:BuildConfiguration -BuildType 'NetStandard'
}
if ($env:PowerShellEdition -eq 'PowerShellCore') {
Set-Location $env:APPVEYOR_BUILD_FOLDER
./build.ps1 -Documentation
./build.ps1 -Configuration "$env:BuildConfiguration" -PSVersion 5 -Framework core
}
test_script:
- ps: |
if ($env:PowerShellEdition -eq 'WindowsPowerShell') {
Invoke-AppveyorTest -CheckoutPath $env:APPVEYOR_BUILD_FOLDER
}
if ($env:PowerShellEdition -eq 'WindowsPowerShell') {
Invoke-AppveyorTest -CheckoutPath $env:APPVEYOR_BUILD_FOLDER
}
- pwsh: |
if ($env:PowerShellEdition -eq 'PowerShellCore') {
Import-Module .\tools\appveyor.psm1 # Appveyor does not persist pwsh sessions like it does for ps
Invoke-AppveyorTest -CheckoutPath $env:APPVEYOR_BUILD_FOLDER
}
if ($env:PowerShellEdition -eq 'PowerShellCore') {
Import-Module .\tools\appveyor.psm1 # Appveyor does not persist pwsh sessions like it does for ps
Invoke-AppveyorTest -CheckoutPath $env:APPVEYOR_BUILD_FOLDER
}
# Upload the project along with test results as a zip archive
on_finish:
Expand Down
6 changes: 3 additions & 3 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,16 @@ function Remove-Build
}
}


# Build documentation using platyPS
function Build-Documentation
{
$docsPath = Join-Path $projectRoot docs
$markdownDocsPath = Join-Path $docsPath markdown
$outputDocsPath = Join-Path $destinationDir en-US
$requiredVersionOfplatyPS = 0.9
$modInfo = new-object Microsoft.PowerShell.Commands.ModuleSpecification -ArgumentList @{ ModuleName = "platyps"; ModuleVersion = $requiredVersionOfplatyPS}
if ( $null -eq (Get-Module -ListAvailable -FullyQualifiedName $modInfo))
#$modInfo = new-object Microsoft.PowerShell.Commands.ModuleSpecification -ArgumentList @{ ModuleName = "platyps"; ModuleVersion = $requiredVersionOfplatyPS}
#if ( $null -eq (Get-Module -ListAvailable -FullyQualifiedName $modInfo))
if ( $null -eq (Get-Module -ListAvailable platyPS))
{
throw "Cannot find required minimum version $requiredVersionOfplatyPS of platyPS. Install via 'Install-Module platyPS'"
}
Expand Down
42 changes: 8 additions & 34 deletions tools/appveyor.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -5,69 +5,43 @@ $ErrorActionPreference = 'Stop'

# Implements the AppVeyor 'install' step and installs the required versions of Pester, platyPS and the .Net Core SDK if needed.
function Invoke-AppVeyorInstall {
$requiredPesterVersion = '4.3.1'
$requiredPesterVersion = '4.4.1'
$pester = Get-Module Pester -ListAvailable | Where-Object { $_.Version -eq $requiredPesterVersion }
if ($null -eq $pester) {
if ($null -eq (Get-Module -ListAvailable PowershellGet)) {
# WMF 4 image build
Write-Verbose -Verbose "Installing Pester via nuget"
nuget install Pester -Version $requiredPesterVersion -source https://www.powershellgallery.com/api/v2 -outputDirectory "$env:ProgramFiles\WindowsPowerShell\Modules\." -ExcludeVersion
}
else {
# Visual Studio 2017 build (has already Pester v3, therefore a different installation mechanism is needed to make it also use the new version 4)
Write-Verbose -Verbose "Installing Pester via Install-Module"
Install-Module -Name Pester -Force -SkipPublisherCheck -Scope CurrentUser
}
}

if ($null -eq (Get-Module -ListAvailable PowershellGet)) {
# WMF 4 image build
Write-Verbose -Verbose "Installing platyPS via nuget"
nuget install platyPS -Version 0.9.0 -source https://www.powershellgallery.com/api/v2 -outputDirectory "$Env:ProgramFiles\WindowsPowerShell\Modules\." -ExcludeVersion
}
else {
Write-Verbose -Verbose "Installing platyPS via Install-Module"
Install-Module -Name platyPS -Force -Scope CurrentUser -RequiredVersion '0.9.0'
}

# the legacy WMF4 image only has the old preview SDKs of dotnet
$globalDotJson = Get-Content (Join-Path $PSScriptRoot '..\global.json') -Raw | ConvertFrom-Json
$dotNetCoreSDKVersion = $globalDotJson.sdk.version
if (-not ((dotnet --version).StartsWith($dotNetCoreSDKVersion))) {
# don't try to run this script on linux - we have to do the negative check because IsLinux will be defined in core, but not windows
if (-not ((dotnet --version).StartsWith($dotNetCoreSDKVersion)) -and ! $IsLinux ) {
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 # https://github.com/dotnet/announcements/issues/77
Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile dotnet-install.ps1
.\dotnet-install.ps1 -Version $dotNetCoreSDKVersion
Remove-Item .\dotnet-install.ps1
}
}

# Implements the AppVeyor 'build_script' step
function Invoke-AppVeyorBuild {
Param(
[Parameter(Mandatory)]
[ValidateSet('FullCLR', 'NetStandard')]
$BuildType,

[Parameter(Mandatory)]
[ValidateSet('Release', 'PSv3Release', 'PSv4Release')]
$BuildConfiguration,

[Parameter(Mandatory)]
[ValidateScript( {Test-Path $_})]
$CheckoutPath
)

$PSVersionTable
Write-Verbose "Pester version: $((Get-Command Invoke-Pester).Version)" -Verbose
Write-Verbose ".NET SDK version: $(dotnet --version)" -Verbose
Push-Location $CheckoutPath
[Environment]::SetEnvironmentVariable("DOTNET_SKIP_FIRST_TIME_EXPERIENCE", 1) # avoid unneccessary initialization in CI
if ($BuildType -eq 'FullCLR') {
.\buildCoreClr.ps1 -Framework net451 -Configuration $BuildConfiguration -Build
}
elseif ($BuildType -eq 'NetStandard') {
.\buildCoreClr.ps1 -Framework netstandard2.0 -Configuration Release -Build
}
.\build.ps1 -BuildDocs
Pop-Location
}

# Implements AppVeyor 'test_script' step
function Invoke-AppveyorTest {
Param(
Expand Down Expand Up @@ -97,4 +71,4 @@ function Invoke-AppveyorFinish {
# You can add other artifacts here
(Get-ChildItem $zipFile)
) | ForEach-Object { Push-AppveyorArtifact $_.FullName }
}
}

0 comments on commit 5c01978

Please sign in to comment.