Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 18 additions & 21 deletions .ci/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,42 +49,39 @@ stages:
- pwsh: |
$modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules'
Write-Verbose -Verbose "Install PowerShellGet V3 to temp module path"
Save-Module -Name PowerShellGet -Path $modulePath -MinimumVersion 3.0.0-beta10 -AllowPrerelease -Force
Write-Verbose -Verbose "Install PlatyPS to temp module path"
Save-Module -Name "platyPS" -Path $modulePath -Force
Write-Verbose -Verbose "Install PSScriptAnalyzer to temp module path"
Save-Module -Name "PSScriptAnalyzer" -Path $modulePath -RequiredVersion 1.18.0 -Force
Write-Verbose -Verbose "Install Pester 4.X to temp module path"
Save-Module -Name "Pester" -MaximumVersion 4.99 -Path $modulePath -Force
Write-Verbose -Verbose "Install PSPackageProject to temp module path"
Save-Module -Name PSPackageProject -Path $modulePath -Force
displayName: Install PSPackageProject and dependencies
Save-Module -Name PowerShellGet -Path $modulePath -MinimumVersion 3.0.19-beta19 -AllowPrerelease -Force
displayName: Install PowerShellGetV3

- pwsh: |
$modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules'
$env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath
$modPath = Join-Path -Path $modulePath -ChildPath PSPackageProject
Write-Verbose -Verbose "Importing PSPackageProject from: $modPath"
Import-Module -Name $modPath -Force
Write-Verbose -Verbose "Importing build utilities (buildtools.psd1)"
Import-Module -Name $(Build.SourcesDirectory)/buildtools.psd1 -Force
#
$(Build.SourcesDirectory)/build.ps1 -Build -Clean -BuildConfiguration Release
displayName: Build and publish artifact
displayName: Build module

- pwsh: |
$modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules'
$env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath
$modPath = Join-Path -Path $modulePath -ChildPath PSPackageProject
Write-Verbose -Verbose "Importing PSPackageProject from: $modPath"
Import-Module -Name $modPath -Force
$config = Get-PSPackageProjectConfiguration
Write-Verbose -Verbose "Importing build utilities (buildtools.psd1)"
Import-Module -Name $(Build.SourcesDirectory)/buildtools.psd1 -Force
#
$(Build.SourcesDirectory)/build.ps1 -Publish
displayName: Publish module nuget package and upload package artifact

- pwsh: |
$modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules'
$env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath
Write-Verbose -Verbose "Importing build utilities (buildtools.psd1)"
Import-Module -Name $(Build.SourcesDirectory)/buildtools.psd1 -Force
$config = Get-BuildConfiguration
#
$srcModulePath = Resolve-Path -Path "$($config.BuildOutputPath)/$($config.ModuleName)"
Get-ChildItem $srcModulePath
$artifactName = "$($config.ModuleName)"
Write-Host "##vso[artifact.upload containerfolder=$artifactName;artifactname=$artifactName;]$srcModulePath"
#
$(Build.SourcesDirectory)/build.ps1 -Publish
displayName: Create module artifact
displayName: Upload module artifact

- stage: Compliance
displayName: Compliance
Expand Down
62 changes: 27 additions & 35 deletions .ci/ci_auto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ schedules:

variables:
- group: ESRP
# Prevents auto-injection of nuget-security-analysis (not needed for open source projects)
- name: skipNugetSecurityAnalysis
value: true

resources:
repositories:
Expand Down Expand Up @@ -49,41 +52,25 @@ stages:
- pwsh: |
$modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules'
Write-Verbose -Verbose "Install PowerShellGet V3 to temp module path"
Save-Module -Name PowerShellGet -Path $modulePath -MinimumVersion 3.0.0-beta10 -AllowPrerelease -Force
Write-Verbose -Verbose "Install PlatyPS to temp module path"
Save-Module -Name "platyPS" -Path $modulePath -Force
Write-Verbose -Verbose "Install PSScriptAnalyzer to temp module path"
Save-Module -Name "PSScriptAnalyzer" -Path $modulePath -RequiredVersion 1.18.0 -Force
Write-Verbose -Verbose "Install Pester 4.X to temp module path"
Save-Module -Name "Pester" -MaximumVersion 4.99 -Path $modulePath -Force
Write-Verbose -Verbose "Install PSPackageProject to temp module path"
Save-Module -Name PSPackageProject -Path $modulePath -Force
displayName: Install PSPackageProject and dependencies

- pwsh: |
Get-ChildItem -Path env:
Get-ChildItem -Path . -Recurse -Directory
displayName: Capture environment for build
condition: succeededOrFailed()
Save-Module -Name PowerShellGet -Path $modulePath -MinimumVersion 3.0.19-beta19 -AllowPrerelease -Force
displayName: Install PowerShellGetV3

- pwsh: |
$modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules'
$env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath
$modPath = Join-Path -Path $modulePath -ChildPath PSPackageProject
Write-Verbose -Verbose "Importing PSPackageProject from: $modPath"
Import-Module -Name $modPath -Force
Write-Verbose -Verbose "Importing build utilities (buildtools.psd1)"
Import-Module -Name $(Build.SourcesDirectory)/buildtools.psd1 -Force
#
$(Build.SourcesDirectory)/build.ps1 -Build -Clean -BuildConfiguration Release
displayName: Build and publish artifact
displayName: Build module

- pwsh: |
$modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules'
$env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath
$modPath = Join-Path -Path $modulePath -ChildPath PSPackageProject
Write-Verbose -Verbose "Importing PSPackageProject from: $modPath"
Import-Module -Name $modPath -Force
Write-Verbose -Verbose "Importing build utilities (buildtools.psd1)"
Import-Module -Name $(Build.SourcesDirectory)/buildtools.psd1 -Force
#
$config = Get-PSPackageProjectConfiguration
$config = Get-BuildConfiguration
$signSrcPath = "$($config.BuildOutputPath)\$($config.ModuleName)"
$signOutPath = "$($config.SignedOutputPath)\$($config.ModuleName)"
if (! (Test-Path -Path $signOutPath)) {
Expand All @@ -99,7 +86,7 @@ stages:
$vstsCommandString = "vso[task.setvariable variable=signOutPath]${signOutPath}"
Write-Host "sending " + $vstsCommandString
Write-Host "##$vstsCommandString"
displayName: Set signing path variables for possible module code signing
displayName: Set signing path variables for module code signing

- pwsh: |
Get-ChildItem -Path env:
Expand All @@ -122,27 +109,32 @@ stages:
- pwsh: |
$modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules'
$env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath
$modPath = Join-Path -Path $modulePath -ChildPath PSPackageProject
Write-Verbose -Verbose "Importing PSPackageProject from: $modPath"
Import-Module -Name $modPath -Force
Write-Verbose -Verbose "Importing build utilities (buildtools.psd1)"
Import-Module -Name $(Build.SourcesDirectory)/buildtools.psd1 -Force
#
$(Build.SourcesDirectory)/build.ps1 -Publish -Signed
displayName: Create module artifact
if ($env:ShouldSign -ne 'True')
{
$(Build.SourcesDirectory)/build.ps1 -Publish
}
else
{
$(Build.SourcesDirectory)/build.ps1 -Publish -Signed
}
displayName: Publish module nuget package and upload package artifact
condition: succeeded()

- pwsh: |
$modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules'
$env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath
$modPath = Join-Path -Path $modulePath -ChildPath PSPackageProject
Write-Verbose -Verbose "Importing PSPackageProject from: $modPath"
Import-Module -Name $modPath -Force
Write-Verbose -Verbose "Importing build utilities (buildtools.psd1)"
Import-Module -Name $(Build.SourcesDirectory)/buildtools.psd1 -Force
#
$config = Get-PSPackageProjectConfiguration
$config = Get-BuildConfiguration
$srcModulePath = Resolve-Path -Path "$($config.SignedOutputPath)/$($config.ModuleName)"
Get-ChildItem $srcModulePath
$artifactName = "$($config.ModuleName)"
Write-Host "##vso[artifact.upload containerfolder=$artifactName;artifactname=$artifactName;]$srcModulePath"
displayName: Create and upload the module artifacts
displayName: Upload the module artifact
condition: succeeded()

- stage: Compliance
Expand Down
61 changes: 34 additions & 27 deletions .ci/ci_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ pr: none

variables:
- group: ESRP
# Prevents auto-injection of nuget-security-analysis (not needed for open source projects)
- name: skipNugetSecurityAnalysis
value: true

resources:
repositories:
Expand Down Expand Up @@ -40,16 +43,8 @@ stages:
- pwsh: |
$modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules'
Write-Verbose -Verbose "Install PowerShellGet V3 to temp module path"
Save-Module -Name PowerShellGet -Path $modulePath -MinimumVersion 3.0.0-beta10 -AllowPrerelease -Force
Write-Verbose -Verbose "Install PlatyPS to temp module path"
Save-Module -Name "platyPS" -Path $modulePath -Force
Write-Verbose -Verbose "Install PSScriptAnalyzer to temp module path"
Save-Module -Name "PSScriptAnalyzer" -Path $modulePath -RequiredVersion 1.18.0 -Force
Write-Verbose -Verbose "Install Pester 4.X to temp module path"
Save-Module -Name "Pester" -MaximumVersion 4.99 -Path $modulePath -Force
Write-Verbose -Verbose "Install PSPackageProject to temp module path"
Save-Module -Name PSPackageProject -Path $modulePath -Force
displayName: Install PSPackageProject and dependencies
Save-Module -Name PowerShellGet -Path $modulePath -MinimumVersion 3.0.19-beta19 -AllowPrerelease -Force
displayName: Install PowerShellGetV3

- pwsh: |
Get-ChildItem -Path env:
Expand All @@ -60,21 +55,19 @@ stages:
- pwsh: |
$modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules'
$env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath
$modPath = Join-Path -Path $modulePath -ChildPath PSPackageProject
Write-Verbose -Verbose "Importing PSPackageProject from: $modPath"
Import-Module -Name $modPath -Force
Write-Verbose -Verbose "Importing build utilities (buildtools.psd1)"
Import-Module -Name $(Build.SourcesDirectory)/buildtools.psd1 -Force
#
$(Build.SourcesDirectory)/build.ps1 -Build -Clean -BuildConfiguration Release
displayName: Build and publish artifact
displayName: Build module

- pwsh: |
$modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules'
$env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath
$modPath = Join-Path -Path $modulePath -ChildPath PSPackageProject
Write-Verbose -Verbose "Importing PSPackageProject from: $modPath"
Import-Module -Name $modPath -Force
Write-Verbose -Verbose "Importing build utilities (buildtools.psd1)"
Import-Module -Name $(Build.SourcesDirectory)/buildtools.psd1 -Force
#
$config = Get-PSPackageProjectConfiguration
$config = Get-BuildConfiguration
$signSrcPath = "$($config.BuildOutputPath)\$($config.ModuleName)"
$signOutPath = "$($config.SignedOutputPath)\$($config.ModuleName)"
if (! (Test-Path -Path $signOutPath)) {
Expand All @@ -90,12 +83,12 @@ stages:
$vstsCommandString = "vso[task.setvariable variable=signOutPath]${signOutPath}"
Write-Host "sending " + $vstsCommandString
Write-Host "##$vstsCommandString"
displayName: Set signing variables for possible module code signing
displayName: Set signing variables for module code signing

- pwsh: |
Get-ChildItem -Path env:
Get-ChildItem -Path . -Recurse -Directory
displayName: Capture environment for code signing
displayName: Capture environment for module code signing
condition: succeededOrFailed()

- template: EsrpSign.yml@ComplianceRepo
Expand All @@ -120,26 +113,40 @@ stages:
- pwsh: |
$modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules'
$env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath
$modPath = Join-Path -Path $modulePath -ChildPath PSPackageProject
Write-Verbose -Verbose "Importing PSPackageProject from: $modPath"
Import-Module -Name $modPath -Force
Write-Verbose -Verbose "Importing build utilities (buildtools.psd1)"
Import-Module -Name $(Build.SourcesDirectory)/buildtools.psd1 -Force
#
$config = Get-PSPackageProjectConfiguration
if ($env:SkipSigning -eq 'True')
{
$srcModulePath = Resolve-Path -Path "$($config.BuildOutputPath)/$($config.ModuleName)"
$(Build.SourcesDirectory)/build.ps1 -Publish
}
else
{
$srcModulePath = Resolve-Path -Path "$($config.SignedOutputPath)/$($config.ModuleName)"
$(Build.SourcesDirectory)/build.ps1 -Publish -Signed
}
displayName: Publish module nuget package and upload package artifact
condition: succeeded()

- pwsh: |
$modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules'
$env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath
Write-Verbose -Verbose "Importing build utilities (buildtools.psd1)"
Import-Module -Name $(Build.SourcesDirectory)/buildtools.psd1 -Force
#
$config = Get-BuildConfiguration
if ($env:SkipSigning -eq 'True')
{
$srcModulePath = Resolve-Path -Path "$($config.BuildOutputPath)/$($config.ModuleName)"
}
else
{
$srcModulePath = Resolve-Path -Path "$($config.SignedOutputPath)/$($config.ModuleName)"
}
# Publish un-packaged module directory
Get-ChildItem $srcModulePath
$artifactName = "$($config.ModuleName)"
Write-Host "##vso[artifact.upload containerfolder=$artifactName;artifactname=$artifactName;]$srcModulePath"
displayName: Create module artifact
displayName: Upload the module artifact

- stage: Compliance
displayName: Compliance
Expand Down
60 changes: 14 additions & 46 deletions .ci/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ parameters:
imageName: windows-latest
displayName: PowerShell Core on Windows
powershellExecutable: pwsh
buildDirectory: '.'

jobs:
- job: ${{ parameters.jobName }}
Expand Down Expand Up @@ -37,64 +38,31 @@ jobs:
- ${{ parameters.powershellExecutable }}: |
$modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules'
Write-Verbose -Verbose "Install PowerShellGet V3 to temp module path"
Save-Module -Name PowerShellGet -Path $modulePath -MinimumVersion 3.0.0-beta10 -AllowPrerelease -Force
Write-Verbose -Verbose "Install PlatyPS to temp module path"
Save-Module -Name "platyPS" -Path $modulePath -Force
Write-Verbose -Verbose "Install PSScriptAnalyzer to temp module path"
Save-Module -Name "PSScriptAnalyzer" -Path $modulePath -RequiredVersion 1.18.0 -Force
Save-Module -Name PowerShellGet -Path $modulePath -MinimumVersion 3.0.19-beta19 -AllowPrerelease -Force
Write-Verbose -Verbose "Install Pester 4.X to temp module path"
Save-Module -Name "Pester" -MaximumVersion 4.99 -Path $modulePath -Force
Write-Verbose -Verbose "Install PSPackageProject to temp module path"
Save-Module -Name PSPackageProject -Path $modulePath -Force
Write-Verbose -Verbose "Install SecretManagement to temp module path"
Save-Module -Name "Microsoft.PowerShell.SecretManagement" -Path $modulePath -AllowPrerelease -Repository PSGallery -Force
displayName: Install PSPackageProject and dependencies
Write-Verbose -Verbose "Install Microsoft.PowerShell.SecretManagement to temp module path"
Save-Module -Name "Microsoft.PowerShell.SecretManagement" -Path $modulePath -Force
displayName: Install PowerShellGetV3, Pester, and SecretManagment

- ${{ parameters.powershellExecutable }}: |
$modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules'
$env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath
$modPath = Join-Path -Path $modulePath -ChildPath PSPackageProject
Write-Verbose -Verbose "Importing PSPackageProject from: $modPath"
Import-Module -Name $modPath -Force
Write-Verbose -Verbose "Importing build utilities (buildtools.psd1)"
Import-Module -Name (Join-Path -Path '${{ parameters.buildDirectory }}' -ChildPath 'buildtools.psd1') -Force
#
$sourceName = 'pspackageproject-local-repo'
Register-PackageSource -Name $sourceName -Location "$(System.ArtifactsDirectory)" -ProviderName PowerShellGet -Force -ErrorAction Ignore
Get-PackageSource -Name $sourceName
$config = Get-PSPackageProjectConfiguration
$buildOutputPath = $config.BuildOutputPath
Write-Verbose -Verbose -Message "PSPackage build output path: $buildOutputPath"
$null = New-Item -ItemType Directory -Path $buildOutputPath -Verbose
$moduleName = $config.ModuleName
Write-Verbose -Verbose "Saving package $sourceName to $($config.BuildOutputPath)"
Save-Package -Name $moduleName -Source $sourceName -ProviderName PowerShellGet -Path $config.BuildOutputPath -AllowPrereleaseVersions -Force
displayName: Extract product artifact
Install-ModulePackageForTest -PackagePath "$(System.ArtifactsDirectory)"
displayName: Install module for test from downloaded artifact
workingDirectory: ${{ parameters.buildDirectory }}

- ${{ parameters.powershellExecutable }}: |
$modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules'
$env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath
$modPath = Join-Path -Path $modulePath -ChildPath PSPackageProject
Write-Verbose -Verbose "Importing PSPackageProject from: $modPath"
Import-Module -Name $modPath -Force
Get-Module
Write-Verbose -Verbose "Importing build utilities (buildtools.psd1)"
Import-Module -Name (Join-Path -Path '${{ parameters.buildDirectory }}' -ChildPath 'buildtools.psd1') -Force
#
Invoke-PSPackageProjectTest -Type Functional
Invoke-ModuleTests -Type Functional
displayName: Execute functional tests
errorActionPreference: continue

- ${{ parameters.powershellExecutable }}: |
$modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules'
$env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath
$modPath = Join-Path -Path $modulePath -ChildPath PSPackageProject
Write-Verbose -Verbose "Importing PSPackageProject from: $modPath"
Import-Module -Name $modPath -Force
Get-Module
#
Invoke-PSPackageProjectTest -Type StaticAnalysis
displayName: Execute static analysis tests
workingDirectory: ${{ parameters.buildDirectory }}
errorActionPreference: continue
condition: succeededOrFailed()

- ${{ parameters.powershellExecutable }}: |
Unregister-PSRepository -Name 'pspackageproject-local-repo' -ErrorAction Ignore
displayName: Unregister temporary PSRepository
condition: always()
Loading