Skip to content

Commit

Permalink
Add azure devops pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
comnam90 committed Sep 28, 2020
1 parent fd06fad commit 82c81ce
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 3 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
Expand All @@ -10,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Added Changelog to project

- Added Azure DevOps pipeline

### Changed

- Added Requirements section to README
Expand Down Expand Up @@ -59,4 +62,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Contains table of Cluster Nodes.

[unreleased]: https://github.com/comnam90/xSConfig/compare/v0.1.2...HEAD
[0.1.2]: https://github.com/comnam90/xSConfig/releases/tag/v0.1.2
[0.1.2]: https://github.com/comnam90/xSConfig/releases/tag/v0.1.2
20 changes: 18 additions & 2 deletions build/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ if ($Bootstrap) {
Install-Module Pester -RequiredVersion $Build['PesterVersion'] -Force -Scope CurrentUser -SkipPublisherCheck
}
Import-Module Pester -RequiredVersion $Build['PesterVersion']

if (-not (Get-Module -Name PSCodeCovIo -ListAvailable)) {
Write-Warning "Module 'PSCodeCovIo' is missing. Installing 'PSCodeCovIo' ..."
Install-Module -Name PSCodeCovIo -Scope CurrentUser -Force
}
}

# Test step
Expand All @@ -26,10 +31,21 @@ if ($Test) {
throw "Cannot find the required module 'Pester' version $($Build.PesterVersion)"
}

if (-not (Get-Module -Name PSCodeCovIo -ListAvailable)) {
throw "Cannot find the 'PSCodeCovIo' module. Please specify '-Bootstrap' to install build dependencies."
}

$ModuleFiles = Get-ChildItem -Path .\src -Recurse -Include "*.psm1", "*.ps1" | Select-Object -ExpandProperty FullName
$results = Invoke-Pester -Script .\Tests -CodeCoverage $ModuleFiles -PassThru
if ($env:TF_BUILD) {
$results = Invoke-Pester "./Tests" -OutputFormat NUnitXml -OutputFile TestResults.xml -CodeCoverage $ModuleFiles -CodeCoverageOutputFileFormat 'JaCoCo' -CodeCoverageOutputFile "$Env:AgentTemp\CoverageResults.xml" -PassThru
if ($results.FailedCount -gt 0) { throw "$($results.FailedCount) tests failed." }
} else {
$results = Invoke-Pester -Script "./Tests" -CodeCoverage $ModuleFiles -PassThru
}

if ($CodeCoverage) {
"Coverage: {0:N2} %" -f (($results.CodeCoverage.NumberOfCommandsExecuted / $results.CodeCoverage.NumberOfCommandsAnalyzed) * 100)
Export-CodeCovIoJson -CodeCoverage $results.CodeCoverage -RepoRoot $pwd -Path coverage.json

Invoke-WebRequest -Uri 'https://codecov.io/bash' -OutFile codecov.sh
}
}
93 changes: 93 additions & 0 deletions build/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
stages:
displayName: 'Thaw Frozen Bread'
jobs:
- job: Srv2019_64bit
displayName: 'Server 2019 - 64 bit'
pool: 'AzPS7.1-Preview'
steps:
- task: PowerShell@2
displayName: 'Run tests (individual .ps1 files) - Windows PowerShell - x64'
inputs:
targetType: Inline
script: ./Azure-Pipelines/build.ps1 -Bootstrap -Test
env:
AgentTemp: $(Agent.TempDirectory)
- task: PowerShell@2
displayName: 'Run tests (individual .ps1 files) - PowerShell 7.1 Preview 5 - x64'
inputs:
targetType: Inline
script: ./Azure-Pipelines/build.ps1 -Bootstrap -Test
pwsh: true
env:
AgentTemp: $(Agent.TempDirectory)
- job: Win10_32bit
displayName: 'Windows 10 - 32 bit'
pool: 'LabPS7x86'
steps:
- task: PowerShell@2
displayName: 'Run tests (individual .ps1 files) - Windows PowerShell - x86'
inputs:
targetType: Inline
script: ./Azure-Pipelines/build.ps1 -Bootstrap -Test
env:
AgentTemp: $(Agent.TempDirectory)
- task: PowerShell@2
displayName: 'Run tests (individual .ps1 files) - PowerShell 7.1 Preview 5 - x86'
inputs:
targetType: Inline
script: ./Azure-Pipelines/build.ps1 -Bootstrap -Test
pwsh: true
env:
AgentTemp: $(Agent.TempDirectory)
- stage: Build
displayName: 'Run Build'
jobs:
- job: 'Build'
displayName: 'Build & test'
pool:
vmImage: 'windows-2019'
steps:
- task: PowerShell@2
displayName: 'Run tests'
inputs:
targetType: Inline
script: ./build/build.ps1 -Bootstrap -Test -CodeCoverage
env:
AgentTemp: $(Agent.TempDirectory)

- task: PublishTestResults@2
displayName: 'Publish test results'
inputs:
testRunner: NUnit
testResultsFiles: '**/TestResults.xml'
condition: succeededOrFailed()
- task: PublishCodeCoverageResults@1
displayName: 'Publish code coverage results'
inputs:
summaryFileLocation: $(Agent.TempDirectory)/CoverageResults.xml
pathToSources: $(Agent.TempDirectory)
condition: succeededOrFailed()

- task: Bash@3
displayName: 'Upload coverage to Codecov'
inputs:
targetType: 'filePath' # Optional. Options: filePath, inline
filePath: ./codecov.sh
arguments: -f coverage.json -t $(CODECOV_TOKEN)
#script: '# Write your commands here# Use the environment variables input below to pass secret variables to this script' # Required when targetType == Inline
#workingDirectory: # Optional
#failOnStderr: false # Optional

- task: PublishPipelineArtifact@0
displayName: 'Publish compiled module artifact'
inputs:
artifactName: 'xSConfig'
targetPath: ./src
condition: succeededOrFailed()

- task: PublishPipelineArtifact@0
displayName: 'Publish Pipelines scripts as artifact'
inputs:
artifactName: 'PipelinesScripts'
targetPath: ./build
condition: succeededOrFailed()

0 comments on commit 82c81ce

Please sign in to comment.