From eb782dea6c89da4e915fd9e7dd30dc2d126c3ac2 Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Tue, 20 Aug 2019 12:26:02 -0700 Subject: [PATCH] Update CI system for PsPackageProject release 0.1.13 (#23) --- build.ps1 | 29 +++++++++++++++++++++++++++-- dobuild.ps1 | 8 ++++++++ pspackageproject.json | 1 + src/.ci/ci.yml | 14 +++++++++++++- src/.ci/test.yml | 9 ++++++--- 5 files changed, 55 insertions(+), 6 deletions(-) diff --git a/build.ps1 b/build.ps1 index e1c4a4d..10a5318 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,6 +1,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. +# Do NOT edit this file. Edit dobuild.ps1 +[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingWriteHost", "")] param ( [Parameter(ParameterSetName="build")] [switch] @@ -10,6 +12,13 @@ param ( [switch] $Build, + [Parameter(ParameterSetName="publish")] + [switch] + $Publish, + [Parameter(ParameterSetName="publish")] + [switch] + $Signed, + [Parameter(ParameterSetName="build")] [switch] $Test, @@ -29,13 +38,24 @@ $config = Get-PSPackageProjectConfiguration -ConfigPath $PSScriptRoot $script:ModuleName = $config.ModuleName $script:SrcPath = $config.SourcePath $script:OutDirectory = $config.BuildOutputPath +$script:SignedDirectory = $config.SignedOutputPath $script:TestPath = $config.TestPath $script:ModuleRoot = $PSScriptRoot $script:Culture = $config.Culture $script:HelpPath = $config.HelpPath -. "$PSScriptRoot\dobuild.ps1" +if ($env:TF_BUILD) { + $vstsCommandString = "vso[task.setvariable variable=BUILD_OUTPUT_PATH]$OutDirectory" + Write-Host ("sending " + $vstsCommandString) + Write-Host "##$vstsCommandString" + + $vstsCommandString = "vso[task.setvariable variable=SIGNED_OUTPUT_PATH]$SignedDirectory" + Write-Host ("sending " + $vstsCommandString) + Write-Host "##$vstsCommandString" +} + +. $PSScriptRoot\dobuild.ps1 if ( ! ( Get-Module -ErrorAction SilentlyContinue PSPackageProject) ) { Install-Module PSPackageProject @@ -58,7 +78,12 @@ else if ($Build.IsPresent) { $sb = (Get-Item Function:DoBuild).ScriptBlock - Invoke-PSPackageProjectBuild -BuildScript $sb + Invoke-PSPackageProjectBuild -BuildScript $sb -SkipPublish +} + +if ($Publish.IsPresent) +{ + Invoke-PSPackageProjectPublish -Signed:$Signed.IsPresent } if ( $Test.IsPresent ) { diff --git a/dobuild.ps1 b/dobuild.ps1 index 42b5d78..068dcf6 100644 --- a/dobuild.ps1 +++ b/dobuild.ps1 @@ -1,3 +1,11 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +##################################################### +# Do NOT edit anything outside the DoBuild function. +# You can define functions inside the scope of DoBuild. +##################################################### + <# .DESCRIPTION Implement build and packaging of the package and place the output $OutDirectory/$ModuleName diff --git a/pspackageproject.json b/pspackageproject.json index 845327c..b82b9c8 100644 --- a/pspackageproject.json +++ b/pspackageproject.json @@ -2,6 +2,7 @@ "HelpPath": "help", "ModuleName": "PSDesiredStateConfiguration", "BuildOutputPath": "out", + "SignedOutputPath": "signed", "SourcePath": "src/PSDesiredStateConfiguration", "TestPath": "test", "Culture": "en-US" diff --git a/src/.ci/ci.yml b/src/.ci/ci.yml index 99b7b8c..3501a32 100644 --- a/src/.ci/ci.yml +++ b/src/.ci/ci.yml @@ -23,15 +23,27 @@ stages: - pwsh: | Install-Module -Name "platyPS","Pester" -Force displayName: Install dependencies + timeoutInMinutes: 10 - pwsh: | Install-Module -Name "PSScriptAnalyzer" -RequiredVersion 1.18.0 -Force displayName: Install PSScriptAnalyzer + timeoutInMinutes: 10 - pwsh: | Install-Module -Name PSPackageProject -Force displayName: Install PSPackageProject module + timeoutInMinutes: 10 - pwsh: | $(Build.SourcesDirectory)/build.ps1 -Build - displayName: Build and publish artifact + displayName: Build + - pwsh: | + Write-Verbose "BUILD_OUTPUT_PATH- $env:BUILD_OUTPUT_PATH" -Verbose + Write-Verbose "SIGNED_OUTPUT_PATH- $env:SIGNED_OUTPUT_PATH" -Verbose + Copy-Item $env:BUILD_OUTPUT_PATH $env:SIGNED_OUTPUT_PATH -Recurse -Force + displayName: Build Signing Placeholder + - pwsh: | + $(Build.SourcesDirectory)/build.ps1 -Publish -Signed + displayName: Publish + timeoutInMinutes: 10 - stage: Test displayName: Test Package diff --git a/src/.ci/test.yml b/src/.ci/test.yml index 2a68d5c..062cf8c 100644 --- a/src/.ci/test.yml +++ b/src/.ci/test.yml @@ -59,11 +59,13 @@ jobs: - ${{ parameters.powershellExecutable }}: | Install-Module -Name "platyPS","Pester" -Force displayName: Install dependencies + timeoutInMinutes: 10 - ${{ parameters.powershellExecutable }}: | Install-Module -Name "PSScriptAnalyzer" -RequiredVersion 1.18.0 -Force displayName: Install dependencies - + timeoutInMinutes: 10 + - ${{ parameters.powershellExecutable }}: | Install-Module -Name PSPackageProject -Force displayName: Install PSPackageProject module @@ -85,6 +87,7 @@ jobs: $moduleName = $config.ModuleName Save-Module -Repository $sourceName -Name $moduleName -Path $config.BuildOutputPath displayName: Extract product artifact + timeoutInMinutes: 10 - ${{ parameters.powershellExecutable }}: | Invoke-PSPackageProjectTest -Type Functional @@ -96,10 +99,10 @@ jobs: displayName: Execute static analysis tests errorActionPreference: continue condition: succeededOrFailed() - continueOnError: true + - ${{ parameters.powershellExecutable }}: | Unregister-PSRepository -Name 'pspackageproject-local-repo' -ErrorAction Ignore displayName: Unregister temporary PSRepository condition: always() - + timeoutInMinutes: 10