1
0
Fork 0
mirror of https://github.com/actions/go-versions synced 2024-11-08 22:52:38 +00:00
go-versions/azure-pipelines/templates/test-job.yml

76 lines
2.3 KiB
YAML
Raw Normal View History

jobs:
- job: Test_Go
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 "go"
- task: DownloadPipelineArtifact@2
inputs:
source: 'current'
artifact: 'go-$(Version)-$(Platform)-$(Architecture)'
path: $(Build.ArtifactStagingDirectory)
- task: ExtractFiles@1
inputs:
archiveFilePatterns: '$(Build.ArtifactStagingDirectory)/go-$(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: GoTool@0
inputs:
version: '$(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 Go' is not available here yet."
Write-Host "In testing step (Go.Tests.ps1) we analyze build log of 'GoTool' task"
Write-Host "to determine if Go 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="./Go.Tests.ps1";
Parameters=@{
Version="$(Version)";
}
}
Invoke-Pester -Script $pesterParams -OutputFile "$(Build.SourcesDirectory)/tests/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: "Go $(Version)-$(Platform)"
condition: always()