|
| 1 | +# |
| 2 | +# Continuous Integration (CI) |
| 3 | +# This pipeline validates the module for StaticAnalysis and Unit Test issues. |
| 4 | +# |
| 5 | + |
| 6 | +trigger: |
| 7 | +- master |
| 8 | + |
| 9 | +# Intionally not having the PR trigger, as we want to kick off PR validation manually after code inspection |
| 10 | +#pr: |
| 11 | +#- master |
| 12 | + |
| 13 | +pool: |
| 14 | + vmImage: 'vs2017-win2016' |
| 15 | + |
| 16 | +steps: |
| 17 | + - powershell: | |
| 18 | + Install-Module -Name PSScriptAnalyzer -Repository PSGallery -Scope CurrentUser -AllowClobber -SkipPublisherCheck -Force -Verbose |
| 19 | + displayName: 'Install PSScriptAnalyzer' |
| 20 | +
|
| 21 | + - powershell: | |
| 22 | + $results = Invoke-ScriptAnalyzer -Path ./ –Recurse |
| 23 | + $results | ForEach-Object { Write-Host "##vso[task.logissue type=$($_.Severity);sourcepath=$($_.ScriptPath);linenumber=$($_.Line);columnnumber=$($_.Column);]$($_.Message)" } |
| 24 | + displayName: 'Run Static Code Analysis (PSScriptAnalyzer)' |
| 25 | +
|
| 26 | + - powershell: | |
| 27 | + Install-Module -Name Pester -Repository PSGallery -Scope CurrentUser -AllowClobber -SkipPublisherCheck -Force -Verbose |
| 28 | + displayName: 'Install Pester' |
| 29 | +
|
| 30 | + - powershell: | |
| 31 | + Invoke-Pester -CodeCoverage .\*.ps*1 -CodeCoverageOutputFile ./coverage.xml -CodeCoverageOutputFileFormat JaCoCo -EnableExit -Strict -OutputFile ./test-results.xml -OutputFormat NUnitXml |
| 32 | + workingDirectory: '$(System.DefaultWorkingDirectory)' |
| 33 | + displayName: 'Run Unit Tests via Pester' |
| 34 | + env: |
| 35 | + ciAccessToken: $(GitHubAccessToken) |
| 36 | + ciOwnerName: $(GitHubOwnerName) |
| 37 | + ciOrganizatioName: $(GitHubOrganizationName) |
| 38 | +
|
| 39 | + - task: PublishTestResults@2 |
| 40 | + displayName: 'Publish Test Results' |
| 41 | + inputs: |
| 42 | + testRunTitle: 'Windows Test Results for Pester' |
| 43 | + buildPlatform: 'Windows' |
| 44 | + testRunner: NUnit |
| 45 | + testResultsFiles: './test-results.xml' |
| 46 | + failTaskOnFailedTests: true # required to fail build when tests fail |
| 47 | + condition: succeededOrFailed() |
| 48 | + |
| 49 | + - task: PublishCodeCoverageResults@1 |
| 50 | + displayName: 'Publish code coverage' |
| 51 | + inputs: |
| 52 | + codeCoverageTool: 'JaCoCo' |
| 53 | + summaryFileLocation: './coverage.xml' |
| 54 | + failIfCoverageEmpty: true |
| 55 | + condition: and(succeededOrFailed(), eq(variables['System.PullRequest.IsFork'], false)) |
0 commit comments