108 строки
2.8 KiB
YAML
108 строки
2.8 KiB
YAML
# Azure DevOps
|
|
# CI job for running VM pipelines
|
|
|
|
parameters:
|
|
|
|
- name: 'name'
|
|
type: 'string'
|
|
|
|
- name: 'displayName'
|
|
type: 'string'
|
|
|
|
- name: 'buildConfiguration'
|
|
type: 'string'
|
|
default: 'Release'
|
|
|
|
- name: 'imageName'
|
|
type: 'string'
|
|
|
|
- name: 'coverage'
|
|
type: 'string'
|
|
default: 'false'
|
|
|
|
- name: 'publishResults'
|
|
type: 'string'
|
|
default: 'true'
|
|
|
|
- name: 'platform'
|
|
type: 'string'
|
|
default: 'linux'
|
|
|
|
- name: 'bicepIntegration'
|
|
type: 'string'
|
|
default: 'false'
|
|
|
|
- name: pwsh
|
|
type: 'boolean'
|
|
default: true
|
|
|
|
jobs:
|
|
- job: ${{ parameters.name }}
|
|
displayName: ${{ parameters.displayName }}
|
|
pool:
|
|
vmImage: ${{ parameters.imageName }}
|
|
variables:
|
|
COVERAGE: ${{ parameters.coverage }}
|
|
PUBLISHRESULTS: ${{ parameters.publishResults }}
|
|
skipComponentGovernanceDetection: true
|
|
steps:
|
|
|
|
# Install pipeline dependencies
|
|
- task: PowerShell@2
|
|
inputs:
|
|
targetType: inline
|
|
script: ./.azure-pipelines/pipeline-deps.ps1
|
|
pwsh: ${{ parameters.pwsh }}
|
|
displayName: 'Install dependencies'
|
|
|
|
# Download module
|
|
- task: DownloadPipelineArtifact@2
|
|
displayName: 'Download module'
|
|
inputs:
|
|
artifact: PSRule.Rules.Azure
|
|
path: $(Build.SourcesDirectory)/out/modules/PSRule.Rules.Azure
|
|
|
|
# Build module
|
|
- task: PowerShell@2
|
|
inputs:
|
|
targetType: inline
|
|
script: Invoke-Build TestModule -Configuration ${{ parameters.buildConfiguration }} -Build $(Build.BuildNumber)
|
|
pwsh: ${{ parameters.pwsh }}
|
|
env:
|
|
COVERAGE: ${{ parameters.coverage }}
|
|
RUN_BICEP_INTEGRATION: ${{ parameters.bicepIntegration }}
|
|
displayName: 'Test module'
|
|
|
|
# Pester test results
|
|
- task: PublishTestResults@2
|
|
displayName: 'Publish Pester results'
|
|
inputs:
|
|
testRunTitle: 'Pester on ${{ parameters.imageName }}'
|
|
testRunner: NUnit
|
|
testResultsFiles: 'reports/pester-unit.xml'
|
|
mergeTestResults: true
|
|
platform: ${{ parameters.name }}
|
|
configuration: ${{ parameters.buildConfiguration }}
|
|
publishRunAttachments: true
|
|
condition: and(succeededOrFailed(), eq(variables['PUBLISHRESULTS'], 'true'))
|
|
|
|
# Generate Code Coverage report
|
|
- task: Palmmedia.reportgenerator.reportgenerator-build-release-task.reportgenerator@4
|
|
displayName: 'Code coverage report generator'
|
|
inputs:
|
|
reports: 'reports/pester-coverage.xml'
|
|
targetdir: 'reports/coverage'
|
|
sourcedirs: 'src/PSRule.Rules.Azure'
|
|
reporttypes: 'HtmlInline_AzurePipelines;Cobertura;SonarQube;Badges'
|
|
tag: $(Build.BuildNumber)
|
|
condition: eq(variables['COVERAGE'], 'true')
|
|
|
|
# Publish Code Coverage report
|
|
- task: PublishCodeCoverageResults@1
|
|
displayName: 'Publish Pester code coverage'
|
|
inputs:
|
|
codeCoverageTool: 'Cobertura'
|
|
summaryFileLocation: 'reports/coverage/Cobertura.xml'
|
|
reportDirectory: 'reports/coverage'
|
|
condition: eq(variables['COVERAGE'], 'true')
|