node-versions/azure-pipelines/templates/test-job.yml
Dmitry Shibanov 434ca92b37
Move helpers to submodule (#19)
* add common helpers

* minor changes

* remove from git helpers

* add submodules

* setup 4 version for pester

Co-authored-by: Dmitry Shibanov <v-dmshib@microsoft.com>
2020-06-02 18:21:42 +03:00

76 lines
2.3 KiB
YAML

jobs:
- job: Test_Node
pool:
name: Azure Pipelines
vmImage: $(VmImage)
steps:
- checkout: self
submodules: true
- task: PowerShell@2
displayName: Fully cleanup the toolcache directory before testing
inputs:
targetType: filePath
filePath: helpers/clean-toolcache.ps1
arguments: -ToolName "node"
- task: DownloadPipelineArtifact@2
inputs:
source: 'current'
artifact: 'node-$(Version)-$(Platform)-$(Architecture)'
path: $(Build.ArtifactStagingDirectory)
- task: ExtractFiles@1
inputs:
archiveFilePatterns: '$(Build.ArtifactStagingDirectory)/node-$(Version)-$(Platform)-$(Architecture).*'
destinationFolder: $(Build.BinariesDirectory)
cleanDestinationFolder: false
- task: PowerShell@2
displayName: 'Apply build artifact to the local machines'
inputs:
targetType: inline
script: |
if ("$(Platform)" -match 'win32') { powershell ./setup.ps1 } else { sh ./setup.sh }
workingDirectory: '$(Build.BinariesDirectory)'
- task: NodeTool@0
displayName: 'Use Node $(Version)'
inputs:
versionSpec: $(Version)
- task: PowerShell@2
displayName: 'Wait for the logs'
inputs:
targetType: inline
script: |
Write-Host "Fake step that do nothing"
Write-Host "We need it because log of previous step 'Use Node' is not available here yet."
Write-Host "In testing step (Node.Tests.ps1) we analyze build log of 'Use Node' task"
Write-Host "to determine if Node.js version was consumed from cache and was downloaded"
- task: PowerShell@2
displayName: 'Run tests'
inputs:
TargetType: inline
script: |
Install-Module Pester -Force -Scope CurrentUser -RequiredVersion 4.10.1
Import-Module Pester
$pesterParams = @{
Path="./Node.Tests.ps1";
Parameters=@{
Version="$(Version)";
}
}
Invoke-Pester -Script $pesterParams -OutputFile "test_results.xml" -OutputFormat NUnitXml
workingDirectory: '$(Build.SourcesDirectory)/tests'
- task: PublishTestResults@2
displayName: 'Publish test results'
inputs:
testResultsFiles: '*.xml'
testResultsFormat: NUnit
searchFolder: 'tests'
failTaskOnFailedTests: true
testRunTitle: "Node.js $(Version)-$(Platform)"
condition: always()