Skip to content
This repository was archived by the owner on Dec 8, 2021. It is now read-only.
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
154 changes: 154 additions & 0 deletions Modules/Microsoft.PowerShell.ThreadJob/.ci/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
name: $(BuildDefinitionName)-$(date:yyMM).$(date:dd)$(rev:rrr)
trigger:
# Batch merge builds together while a merge build is running
batch: true
branches:
include:
- master
pr:
branches:
include:
- master

stages:
- stage: Build
displayName: Build PowerShell Package
jobs:
- job: BuildPkg
displayName: Build Package
pool:
name: Package ES CodeHub Lab E
steps:
- powershell: |
$powerShellPath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'powershell'
Invoke-WebRequest -Uri https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.ps1 -outfile ./install-powershell.ps1
./install-powershell.ps1 -Destination $powerShellPath
$vstsCommandString = "vso[task.setvariable variable=PATH]$powerShellPath;$env:PATH"
Write-Host "sending " + $vstsCommandString
Write-Host "##$vstsCommandString"
displayName: Install PowerShell Core

- task: UseDotNet@2
displayName: 'Install .NET Core 3.1.100 sdk'
inputs:
packageType: sdk
version: 3.1.100

- task: PkgESSetupBuild@10
displayName: 'Package ES - Setup Build'
inputs:
productName: PSRemotingTools
useDfs: false

- pwsh: |
Get-ChildItem -Path env:
displayName: Capture environment for build
condition: succeededOrFailed()

- pwsh: |
dir $env:USERPROFILE\Documents\PowerShell\Modules\* -Directory -ErrorAction SilentlyContinue | Remove-Item -Recurse -Force -Verbose -ErrorAction SilentlyContinue
displayName: Clean PowerShell modules directory

- pwsh: |
Get-Module -Name PowerShellGet -ListAvailable
Import-Module -Name PowerShellGet
displayName: Import PowerShellGet Module

- pwsh: |
Install-Module -Name "platyPS","Pester" -Force
displayName: Install dependencies
- pwsh: |
Install-Module -Name "PSScriptAnalyzer" -RequiredVersion 1.18.0 -Force
displayName: Install PSScriptAnalyzer
- pwsh: |
Install-Module -Name PSPackageProject -Force
displayName: Install PSPackageProject module
- pwsh: |
$(Build.SourcesDirectory)/build.ps1 -Build -BuildConfiguration Release
displayName: Build and publish artifact

- pwsh: |
Install-Module -Name PSPackageProject -Force
$config = Get-PSPackageProjectConfiguration
$signSrcPath = "$($config.BuildOutputPath)\$($config.ModuleName)"
$signOutPath = "$($config.BuildOutputPath)\$($config.ModuleName)\Signed"
if (! (Test-Path -Path $signOutPath)) {
$null = New-Item -Path $signOutPath -ItemType Directory
}
$signXmlPath = "$($config.SourcePath)\..\sign-module-files.xml"
# Set signing src path variable
$vstsCommandString = "vso[task.setvariable variable=signSrcPath]${signSrcPath}"
Write-Host "sending " + $vstsCommandString
Write-Host "##$vstsCommandString"
# Set signing out path variable
$vstsCommandString = "vso[task.setvariable variable=signOutPath]${signOutPath}"
Write-Host "sending " + $vstsCommandString
Write-Host "##$vstsCommandString"
# Set signing xml path
$vstsCommandString = "vso[task.setvariable variable=signXmlPath]${signXmlPath}"
Write-Host "sending " + $vstsCommandString
Write-Host "##$vstsCommandString"
displayName: Set up for code signing

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

- task: PkgESCodeSign@10
displayName: Sign build files
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
inputs:
signConfigXml: '$(signXmlPath)'
inPathRoot: '$(signSrcPath)'
outPathRoot: '$(signOutPath)'
binVersion: Production
binVersionOverride: ''
condition: and(and(succeeded(), eq(variables['Build.Reason'], 'Manual')), ne(variables['SkipSigning'], 'True'))

- stage: Compliance
displayName: Compliance
dependsOn: Build
jobs:
- job: ComplianceJob
pool:
name: Package ES CodeHub Lab E
steps:
- template: compliance.yml

- stage: Test
displayName: Test Package
dependsOn: Build
jobs:
- template: test.yml
parameters:
jobName: TestPkgWin
displayName: PowerShell Core on Windows
imageName: windows-2019

# - template: test.yml
# parameters:
# jobName: TestPkgWinPS
# displayName: Windows PowerShell on Windows
# imageName: windows-2019
# powershellExecutable: powershell

- template: test.yml
parameters:
jobName: TestPkgUbuntu16
displayName: PowerShell Core on Ubuntu 16.04
imageName: ubuntu-16.04

- template: test.yml
parameters:
jobName: TestPkgWinMacOS
displayName: PowerShell Core on macOS
imageName: macOS-10.14

- stage: Release
displayName: Release Package
condition: and(and(succeeded(), eq(variables['Build.Reason'], 'Manual')), eq(variables['Publish'], 'True'))
jobs:
- template: release.yml

109 changes: 109 additions & 0 deletions Modules/Microsoft.PowerShell.ThreadJob/.ci/compliance.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
steps:

- powershell: |
$powerShellPath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'powershell'
Invoke-WebRequest -Uri https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.ps1 -outfile ./install-powershell.ps1
./install-powershell.ps1 -Destination $powerShellPath
$vstsCommandString = "vso[task.setvariable variable=PATH]$powerShellPath;$env:PATH"
Write-Host "sending " + $vstsCommandString
Write-Host "##$vstsCommandString"
displayName: Install PowerShell Core

- pwsh: |
Install-Module -Name "platyPS","Pester" -Force
displayName: Install platyPS

- pwsh: |
Install-Module -Name "PSScriptAnalyzer" -RequiredVersion 1.18.0 -Force
displayName: Install PSScripAnalyzer

- pwsh: |
Install-Module -Name PSPackageProject -Force
displayName: Install PSPackageProject module

- task: DownloadBuildArtifacts@0
displayName: 'Download artifacts'
inputs:
buildType: current
downloadType: specifc
itemPattern: '**/*.nupkg'
downloadPath: '$(System.ArtifactsDirectory)'

- pwsh: |
$sourceName = 'pspackageproject-local-repo'
Register-PSRepository -Name $sourceName -SourceLocation '$(System.ArtifactsDirectory)' -ErrorAction Ignore
$config = Get-PSPackageProjectConfiguration
$buildOutputPath = $config.BuildOutputPath
$null = New-Item -ItemType Directory -Path $buildOutputPath -Verbose
$moduleName = $config.ModuleName
Save-Module -Repository $sourceName -Name $moduleName -Path $config.BuildOutputPath
$vstsCommandString = "vso[task.setvariable variable=BUILD_SOURCE]$($config.BuildOutputPath)"
Write-Host "sending " + $vstsCommandString
Write-Host "##$vstsCommandString"
displayName: Extract product artifact

- pwsh: |
$config = Get-PSPackageProjectConfiguration
dir "$($config.BuildOutputPath)/*" -r 2>$null
displayName: 'BuildOutputPath directory'

- task: securedevelopmentteam.vss-secure-development-tools.build-task-antimalware.AntiMalware@3
displayName: 'Run Defender Scan'

- task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@2
displayName: 'Run CredScan'
inputs:
toolMajorVersion: V2
debugMode: false
continueOnError: true

- task: securedevelopmentteam.vss-secure-development-tools.build-task-binskim.BinSkim@3
displayName: 'Run BinSkim '
inputs:
InputType: Basic
AnalyzeTarget: '$(BUILD_SOURCE)\Microsoft.PowerShell.SecretManagement\Microsoft.PowerShell.SecretManagement.dll'
AnalyzeSymPath: 'SRV*'
AnalyzeVerbose: true
AnalyzeHashes: true
AnalyzeStatistics: true
continueOnError: true

- task: securedevelopmentteam.vss-secure-development-tools.build-task-policheck.PoliCheck@1
displayName: 'Run PoliCheck'
inputs:
targetType: F
optionsFC: 0
optionsXS: 0
optionsPE: '1|2|3|4'
optionsHMENABLE: 0
# optionsRulesDBPath: '$(Build.SourcesDirectory)\tools\terms\PowerShell-Terms-Rules.mdb'
# optionsFTPATH: '$(Build.SourcesDirectory)\tools\terms\FileTypeSet.xml'
toolVersion: 5.8.2.1
continueOnError: true

- task: securedevelopmentteam.vss-secure-development-tools.build-task-publishsecurityanalysislogs.PublishSecurityAnalysisLogs@2
displayName: 'Publish Security Analysis Logs to Build Artifacts'
continueOnError: true

- task: securedevelopmentteam.vss-secure-development-tools.build-task-uploadtotsa.TSAUpload@1
displayName: 'TSA upload to Codebase: PSThreadJob_201912 Stamp: Azure'
inputs:
codeBaseName: PSThreadJob_201912
tsaVersion: TsaV2
uploadFortifySCA: false
uploadFxCop: false
uploadModernCop: false
uploadPREfast: false
uploadRoslyn: false
uploadTSLint: false
uploadAPIScan: false

- task: securedevelopmentteam.vss-secure-development-tools.build-task-report.SdtReport@1
displayName: 'Create Security Analysis Report'
inputs:
TsvFile: false
APIScan: false
BinSkim: false
CredScan: true
PoliCheck: true
PoliCheckBreakOn: Severity2Above
23 changes: 23 additions & 0 deletions Modules/Microsoft.PowerShell.ThreadJob/.ci/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
parameters:
jobName: release
imageName: windows-2019
displayName: Release

jobs:
- job: ${{ parameters.jobName }}
pool:
vmImage: ${{ parameters.imageName }}
displayName: ${{ parameters.displayName }}
steps:
- task: DownloadBuildArtifacts@0
displayName: 'Download artifacts'
inputs:
buildType: current
downloadType: single
artifactName: NuPkg
downloadPath: '$(System.ArtifactsDirectory)'
- task: NuGetToolInstaller@1
displayName: 'Install NuGet'
- pwsh: |
nuget push $(System.ArtifactsDirectory)\nupkg\*.nupkg -ApiKey $(NuGetApiKey) -Source https://www.powershellgallery.com/api/v2/package/ -NonInteractive
displayName: Publish Package
57 changes: 57 additions & 0 deletions Modules/Microsoft.PowerShell.ThreadJob/.ci/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
parameters:
jobName: TestPkgWin
imageName: windows-2019
displayName: PowerShell Core on Windows
powershellExecutable: pwsh

jobs:
- job: ${{ parameters.jobName }}
pool:
vmImage: ${{ parameters.imageName }}
displayName: ${{ parameters.displayName }}
steps:
- ${{ parameters.powershellExecutable }}: |
Install-Module -Name "platyPS","Pester" -Force
displayName: Install dependencies

- ${{ parameters.powershellExecutable }}: |
Install-Module -Name "PSScriptAnalyzer" -RequiredVersion 1.18.0 -Force
displayName: Install dependencies

- ${{ parameters.powershellExecutable }}: |
Install-Module -Name PSPackageProject -Force
displayName: Install PSPackageProject module

- task: DownloadBuildArtifacts@0
displayName: 'Download artifacts'
inputs:
buildType: current
downloadType: specific
itemPattern: '**/*.nupkg'
downloadPath: '$(System.ArtifactsDirectory)'

- ${{ parameters.powershellExecutable }}: |
$sourceName = 'pspackageproject-local-repo'
Register-PSRepository -Name $sourceName -SourceLocation '$(System.ArtifactsDirectory)' -ErrorAction Ignore
$config = Get-PSPackageProjectConfiguration
$buildOutputPath = $config.BuildOutputPath
$null = New-Item -ItemType Directory -Path $buildOutputPath -Verbose
$moduleName = $config.ModuleName
Save-Module -Repository $sourceName -Name $moduleName -Path $config.BuildOutputPath
displayName: Extract product artifact

- ${{ parameters.powershellExecutable }}: |
Invoke-PSPackageProjectTest -Type Functional
displayName: Execute functional tests
errorActionPreference: continue

- ${{ parameters.powershellExecutable }}: |
Invoke-PSPackageProjectTest -Type StaticAnalysis
displayName: Execute static analysis tests
errorActionPreference: continue
condition: succeededOrFailed()

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