Skip to content

Commit

Permalink
Refactor PSake File to Perform Deployment in Azure DevOps - Fixes #179 (
Browse files Browse the repository at this point in the history
#182)

* Added support for running integration tests in Azure DevOps

* Suppress confirmation of installation of PSDepend module during CI

* Prevent AppVeyor CI from executing deploy task

* Correct Azure Pipelines Windows build environment variables

* Add Publish Artifacts task to Windows Azure Pipeline

* Add Publish step to Azure Pipeline CI topublish psakefile

* Added missing Changelog entries

* Fix Azure Pipelines YAML

* Correct YAML again

* Added PSDepend File Artifact to Azure Pipeline CI

* Added build file artifact

* Reworked CI Build Task to Update Git with version number

* Correct Artefact PSDepend path

* Prepare Release Pipeline

* Correct Zip File artefact

* Changed Azure DevOps Build Number format

* Correct spelling of Name variable

* Correct Build Number

* Update Module Artefact name in Azure DevOps pipeline

* Clean up Deploy Code

* Prepare for Deployment

* Change Deploy to run in any environment

* Add Dignostic Code to PSake

* Change build to always publish test results even if failed

* Refactor Build Code

* Fix Psake File

* Change the Deploy Folder that the PSake file picks up

* Update the Verbose information in the Deploy

* Final Tweak to Deploy Output

* Final updates to CHANGELOG.MD
  • Loading branch information
PlagueHO authored Oct 3, 2018
1 parent 4d588a0 commit a3aca37
Show file tree
Hide file tree
Showing 7 changed files with 260 additions and 185 deletions.
12 changes: 8 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

## Unreleased

- Fixed RU Display [Issue #168](https://github.com/PlagueHO/CosmosDB/issues/168)
- Fixed Powershell Core `Invoke-WebRequest` error handling
- Fixed retry logic bug (`$fatal` initially set to `$true` instead of `$false`)
- Fixed stored procedure debug logging output
- Fixed RU display - fixes [Issue #168](https://github.com/PlagueHO/CosmosDB/issues/168)
- Fixed Powershell Core `Invoke-WebRequest` error handling.
- Fixed retry logic bug (`$fatal` initially set to `$true` instead of `$false`).
- Fixed stored procedure debug logging output.
- Rework CI process to simplify code.
- Enabled integration test execution in Azure DevOps Pipelines - fixes [Issue #179](https://github.com/PlagueHO/CosmosDB/issues/179)
- Added artifact publish tasks for Azure Pipeline.
- Refactored module deployment process to occur in Azure DevOps pipeline - fixes [Issue #181](https://github.com/PlagueHO/CosmosDB/issues/181)

## 2.1.7.675

Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ environment:
secure: b/CtRX2iDdREmV5mOgoqK9g6HObrPhjNkjeTxrYMgJbiYYmzvivV1Xp52M79NxDN

build_script:
- ps: . .\build.ps1 -Deploy
- ps: . .\build.ps1
53 changes: 52 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,58 @@
name: $(rev:r)
jobs:
- job: Build_PS_Win2016
pool:
vmImage: vs2017-win2016

steps:
- powershell: |
.\build.ps1 -Verbose
displayName: 'Build and Test'
env:
azureApplicationId: $(azureApplicationId)
azureApplicationPassword: $(azureApplicationPassword)
azureSubscriptionId: $(azureSubscriptionId)
azureTenantId: $(azureTenantId)
- task: PublishTestResults@2
inputs:
testRunner: 'NUnit'
testResultsFiles: '**/TestResults.xml'
testRunTitle: 'PS_Win2016'
displayName: 'Publish Test Results'
condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed')

- job: Build_PSCore_Ubuntu1604
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: 'staging/CosmosDB'
artifactName: 'CosmosDB'
displayName: 'Publish Module'

- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: 'staging/zip'
artifactName: 'zip'
displayName: 'Publish Module'

- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: 'psakefile.ps1'
artifactName: 'scripts'
displayName: 'Publish PSake File'

- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: 'cosmosdb.depend.psd1'
artifactName: 'scripts'
displayName: 'Publish PSDepend File'

- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: 'build.ps1'
artifactName: 'scripts'
displayName: 'Publish Build File'

- job: Build_PSCore_Ubuntu1604
pool:
vmImage: ubuntu-16.04

Expand All @@ -29,17 +67,24 @@ jobs:
- script: |
pwsh -c '.\build.ps1'
displayName: 'Build and Test'
env:
azureApplicationId: $(azureApplicationId)
azureApplicationPassword: $(azureApplicationPassword)
azureSubscriptionId: $(azureSubscriptionId)
azureTenantId: $(azureTenantId)
- task: PublishTestResults@2
inputs:
testRunner: 'NUnit'
testResultsFiles: '**/TestResults.xml'
testRunTitle: 'PSCore_Ubuntu1604'
displayName: 'Publish Test Results'
condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed')

- job: Build_PSCore_MacOS1013
pool:
vmImage: xcode9-macos10.13

steps:
- script: |
brew update
Expand All @@ -50,10 +95,16 @@ jobs:
- script: |
pwsh -c '.\build.ps1'
displayName: 'Build and Test'
env:
azureApplicationId: $(azureApplicationId)
azureApplicationPassword: $(azureApplicationPassword)
azureSubscriptionId: $(azureSubscriptionId)
azureTenantId: $(azureTenantId)
- task: PublishTestResults@2
inputs:
testRunner: 'NUnit'
testResultsFiles: '**/TestResults.xml'
testRunTitle: 'PSCore_MacOS1013'
displayName: 'Publish Test Results'
condition: in(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues', 'Failed')
57 changes: 27 additions & 30 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -1,45 +1,42 @@
[CmdletBinding()]
param (
[Parameter()]
[Switch]
$Deploy
)
[System.String[]]
$TaskList = 'Default',

Write-Verbose -Message 'Beginning build process...'
[Parameter()]
[System.Collections.Hashtable]
$Parameters,

$task = 'Default'
if ($Deploy)
{
$task = 'Deploy'
}
[Parameter()]
[System.Collections.Hashtable]
$Properties
)

Write-Verbose -Message ('Beginning ''{0}'' process...' -f ($TaskList -join ','))

# Bootstrap the environment
$null = Get-PackageProvider -Name NuGet -ForceBootstrap

# Install PSDepend module
# Install PSake module if it is not already installed
if (-not (Get-Module -Name PSDepend -ListAvailable))
{
$installModuleParameters = @{
Name = 'PSDepend'
Force = $true
AllowClobber = $true
Repository = 'PSGallery'
}
try
{
Install-Module @installModuleParameters
}
catch
{
Install-Module @installModuleParameters -Scope CurrentUser
}
Install-Module -Name PSDepend -Scope CurrentUser -Force -Confirm:$false
}

# Install all other build dependencies
# Install build dependencies required for Init task
Import-Module -Name PSDepend
Invoke-PSDepend -Path $PSScriptRoot -Force -Import -Install

Set-BuildEnvironment -Force

Invoke-Psake -buildFile $ENV:BHProjectPath\psakefile.ps1 -taskList $task -nologo
Invoke-PSDepend `
-Path $PSScriptRoot `
-Force `
-Import `
-Install `
-Tags 'Bootstrap'

# Execute the PSake tasts from the psakefile.ps1
Invoke-Psake `
-buildFile (Join-Path -Path $PSScriptRoot -ChildPath 'psakefile.ps1') `
-nologo `
@PSBoundParameters

exit ( [int]( -not $psake.build_success ) )
54 changes: 42 additions & 12 deletions cosmosdb.depend.psd1
Original file line number Diff line number Diff line change
@@ -1,67 +1,97 @@
@{
psake = @{
psake = @{
Name = 'psake'
DependencyType = 'PSGalleryModule'
Parameters = @{
Repository = 'PSGallery'
SkipPublisherCheck = $true
}
Target = 'CurrentUser'
Version = '4.7.0'
Version = '4.7.4'
Tags = 'Bootstrap'
}

Pester = @{
Pester = @{
Name = 'Pester'
DependencyType = 'PSGalleryModule'
Parameters = @{
Repository = 'PSGallery'
SkipPublisherCheck = $true
}
Target = 'CurrentUser'
Version = '4.3.1'
Version = '4.4.0'
Tags = 'Test'
}

PSScriptAnalyzer = @{
PSScriptAnalyzer = @{
Name = 'PSScriptAnalyzer'
DependencyType = 'PSGalleryModule'
Parameters = @{
Repository = 'PSGallery'
SkipPublisherCheck = $true
}
Target = 'CurrentUser'
Version = '1.16.1'
Version = '1.17.1'
Tags = 'Test'
}

BuildHelpers = @{
BuildHelpers = @{
Name = 'BuildHelpers'
DependencyType = 'PSGalleryModule'
Parameters = @{
Repository = 'PSGallery'
SkipPublisherCheck = $true
}
Target = 'CurrentUser'
Version = '1.0.0'
Version = '2.0.0'
Tags = 'Init'
}

PSDeploy = @{
PSDeploy = @{
Name = 'PSDeploy'
DependencyType = 'PSGalleryModule'
Parameters = @{
Repository = 'PSGallery'
SkipPublisherCheck = $true
}
Target = 'CurrentUser'
Version = '0.2.3'
Version = '1.0'
Tags = 'Deploy'
}

Platyps = @{
Platyps = @{
Name = 'Platyps'
DependencyType = 'PSGalleryModule'
Parameters = @{
Repository = 'PSGallery'
SkipPublisherCheck = $true
}
Target = 'CurrentUser'
Version = '0.9.0'
Version = '0.11.1'
Tags = 'Build'
}

'AzureRM' = @{
Name = 'AzureRM'
DependencyType = 'PSGalleryModule'
Parameters = @{
Repository = 'PSGallery'
SkipPublisherCheck = $true
}
Target = 'CurrentUser'
Version = '6.8.1'
Tags = 'Test_Desktop'
}

'AzureRM.NetCore' = @{
Name = 'AzureRM.NetCore'
DependencyType = 'PSGalleryModule'
Parameters = @{
Repository = 'PSGallery'
SkipPublisherCheck = $true
}
Target = 'CurrentUser'
Version = '0.13.1'
Tags = 'Test_Core'
}
}
Loading

0 comments on commit a3aca37

Please sign in to comment.