diff --git a/eng/pipelines/templates/jobs/archetype-sdk-client.yml b/eng/pipelines/templates/jobs/archetype-sdk-client.yml
index 3b958d311436..79559432f62c 100644
--- a/eng/pipelines/templates/jobs/archetype-sdk-client.yml
+++ b/eng/pipelines/templates/jobs/archetype-sdk-client.yml
@@ -2,9 +2,6 @@ parameters:
- name: ServiceDirectory
type: string
default: ''
- - name: RunTests
- type: boolean
- default: false
- name: RunLiveTests
type: boolean
default: false
@@ -113,8 +110,7 @@ stages:
GoWorkspace: $(GO_WORKSPACE_PATH)
Image: $(vm.image)
GoVersion: $(go.version)
- RunTests: ${{ parameters.RunTests }}
- TestProxy: true
+ TestProxy: true # Do we need this conditional if it's always true? @benbp
EnvVars:
AZURE_RECORD_MODE: 'playback'
diff --git a/eng/pipelines/templates/steps/build-test.yml b/eng/pipelines/templates/steps/build-test.yml
index f7ae77754ea9..2245f8da47a8 100644
--- a/eng/pipelines/templates/steps/build-test.yml
+++ b/eng/pipelines/templates/steps/build-test.yml
@@ -14,9 +14,6 @@ parameters:
- name: TestProxy
type: boolean
default: false
- - name: RunTests
- type: boolean
- default: false
- name: EnvVars
type: object
default: {}
@@ -44,56 +41,48 @@ steps:
arguments: -vet -skipBuild -filter '${{ parameters.ServiceDirectory }}'
workingDirectory: '${{ parameters.GoWorkspace }}'
- - ${{ if eq(parameters.RunTests, 'true') }}:
- - pwsh: |
- go install github.com/jstemmer/go-junit-report@v0.9.1
- go install github.com/axw/gocov/gocov@v1.0.0
- go install github.com/AlekSi/gocov-xml@v1.0.0
- go install github.com/matm/gocov-html@v0.0.0-20200509184451-71874e2e203b
- go install github.com/wadey/gocovmerge@v0.0.0-20160331181800-b5bfa59ec0ad
- displayName: "Install Coverage and Junit Dependencies"
- workingDirectory: '${{parameters.GoWorkspace}}'
-
- - ${{ if eq(parameters.TestProxy, true) }}:
- - template: /eng/common/testproxy/test-proxy-docker.yml
+ - pwsh: |
+ go install github.com/jstemmer/go-junit-report@v0.9.1
+ go install github.com/axw/gocov/gocov@v1.0.0
+ go install github.com/AlekSi/gocov-xml@v1.0.0
+ go install github.com/matm/gocov-html@v0.0.0-20200509184451-71874e2e203b
+ displayName: "Install Coverage and Junit Dependencies"
+ workingDirectory: '${{parameters.GoWorkspace}}'
- - task: PowerShell@2
- displayName: 'Run Tests'
- inputs:
- targetType: 'filePath'
- filePath: ./eng/scripts/run_tests.ps1
- arguments: '${{ parameters.ServiceDirectory }}'
- pwsh: true
- env:
- GO111MODULE: 'on'
- PROXY_CERT: $(Build.SourcesDirectory)/eng/common/testproxy/dotnet-devcert.crt
- ${{ insert }}: ${{ parameters.EnvVars }}
+ - ${{ if eq(parameters.TestProxy, true) }}:
+ - template: /eng/common/testproxy/test-proxy-docker.yml
- - ${{ if eq(parameters.TestProxy, true) }}:
- - pwsh: |
- # ambitious_azsdk_test_proxy is the hardcoded container name used
- # by the test proxy startup script
- docker logs ambitious_azsdk_test_proxy
- displayName: 'Dump Test Proxy logs'
- condition: succeededOrFailed()
-
- - pwsh: ./eng/scripts/create_coverage.ps1 ${{parameters.ServiceDirectory}}
- displayName: 'Generate Coverage XML'
- env:
- GO111MODULE: 'off'
+ - task: PowerShell@2
+ displayName: 'Run Tests'
+ inputs:
+ targetType: 'filePath'
+ filePath: ./eng/scripts/run_tests.ps1
+ arguments: '${{ parameters.ServiceDirectory }}'
+ pwsh: true
+ env:
+ GO111MODULE: 'on'
+ PROXY_CERT: $(Build.SourcesDirectory)/eng/common/testproxy/dotnet-devcert.crt
+ ${{ insert }}: ${{ parameters.EnvVars }}
- - task: PublishTestResults@2
+ - ${{ if eq(parameters.TestProxy, true) }}:
+ - pwsh: |
+ # ambitious_azsdk_test_proxy is the hardcoded container name used
+ # by the test proxy startup script
+ docker logs ambitious_azsdk_test_proxy
+ displayName: 'Dump Test Proxy logs'
condition: succeededOrFailed()
- inputs:
- testRunner: JUnit
- testResultsFiles: '${{parameters.GoWorkspace}}sdk/${{parameters.ServiceDirectory}}/**/report.xml'
- testRunTitle: 'Go ${{ parameters.GoVersion }} on ${{ parameters.Image }}'
- failTaskOnFailedTests: true
- - task: PublishCodeCoverageResults@1
- condition: succeededOrFailed()
- inputs:
- codeCoverageTool: Cobertura
- summaryFileLocation: './coverage.xml'
- additionalCodeCoverageFiles: './coverage.html'
- failIfCoverageEmpty: true
+ - task: PublishTestResults@2
+ condition: succeededOrFailed()
+ inputs:
+ testRunner: JUnit
+ testResultsFiles: '${{parameters.GoWorkspace}}sdk/${{parameters.ServiceDirectory}}/**/report.xml'
+ testRunTitle: 'Go ${{ parameters.GoVersion }} on ${{ parameters.Image }}'
+ failTaskOnFailedTests: true
+
+ - task: PublishCodeCoverageResults@1
+ condition: succeededOrFailed()
+ inputs:
+ codeCoverageTool: Cobertura
+ summaryFileLocation: './coverage.xml'
+ additionalCodeCoverageFiles: './coverage.html'
diff --git a/eng/scripts/create_coverage.ps1 b/eng/scripts/create_coverage.ps1
deleted file mode 100644
index fda55891e46b..000000000000
--- a/eng/scripts/create_coverage.ps1
+++ /dev/null
@@ -1,38 +0,0 @@
-#Requires -Version 7.0
-
-Param(
- [string] $serviceDirectory
-)
-
-$repoRoot = Resolve-Path "$PSScriptRoot/../../"
-
-Write-Host "repoRoot $repoRoot"
-
-Write-Host $serviceDirectory
-Push-Location sdk/$serviceDirectory
-
-$coverageFiles = [Collections.Generic.List[String]]@()
-Get-ChildItem -recurse -path . -filter coverage.txt | ForEach-Object {
- $covFile = $_.FullName
- Write-Host "Adding $covFile to the list of code coverage files"
- $coverageFiles.Add($covFile)
-}
-
-# merge coverage files
-gocovmerge $coverageFiles > mergedCoverage.txt
-gocov convert ./mergedCoverage.txt > ./coverage.json
-
-# gocov converts rely on standard input
-Get-Content ./coverage.json | gocov-xml > ./coverage.xml
-Get-Content ./coverage.json | gocov-html > ./coverage.html
-
-Move-Item ./coverage.xml $repoRoot
-Move-Item ./coverage.html $repoRoot
-
-# use internal tool to fail if coverage is too low
-Pop-Location
-
-go run $repoRoot/eng/tools/internal/coverage/coverage.go `
- -config $repoRoot/eng/config.json `
- -serviceDirectory $serviceDirectory `
- -searchDirectory $repoRoot
diff --git a/eng/scripts/get_test_dirs.ps1 b/eng/scripts/get_test_dirs.ps1
deleted file mode 100644
index 83aa5aa132af..000000000000
--- a/eng/scripts/get_test_dirs.ps1
+++ /dev/null
@@ -1,27 +0,0 @@
-Param(
- [string] $serviceDir
-)
-
-. (Join-Path $PSScriptRoot .. common scripts common.ps1)
-
-$testDirs = @()
-
-foreach ($sdk in (Get-AllPackageInfoFromRepo $serviceDir))
-{
- # find each directory under $serviceDir that contains Go test files
- foreach ($testFile in (Get-ChildItem -recurse -path $sdk.DirectoryPath -filter *_test.go))
- {
- $cdir = $testFile.Directory.FullName
- $tests = Select-String -Path $testFile 'Test' -AllMatches
-
- if ($tests.Count -gt 0) {
- if ($testDirs -notcontains $cdir) {
- Write-Host "Adding $cdir to list of test directories"
- $testDirs += $cdir
- }
- }
- }
-}
-
-# return the list of test directories
-return $testDirs
\ No newline at end of file
diff --git a/eng/scripts/run_tests.ps1 b/eng/scripts/run_tests.ps1
index 8f326adbb0ee..df53b34a79b1 100644
--- a/eng/scripts/run_tests.ps1
+++ b/eng/scripts/run_tests.ps1
@@ -4,22 +4,41 @@ Param(
[string] $serviceDirectory
)
-Write-Host "Finding test directories in 'sdk/$serviceDirectory'"
-$testDirs = & $PSScriptRoot/get_test_dirs.ps1 -serviceDir $serviceDirectory
-Write-Host $testDirs
-
-foreach ($td in $testDirs) {
- Push-Location $td
- Write-Host "##[command]Executing 'go test -run "^Test" -v -coverprofile coverage.txt .' in $td"
- go test -run "^Test" -v -coverprofile coverage.txt . | Tee-Object -FilePath outfile.txt
- if ($LASTEXITCODE) {
- exit $LASTEXITCODE
- }
- Get-Content outfile.txt | go-junit-report > report.xml
-
- # if no tests were actually run (e.g. examples) delete the coverage file so it's omitted from the coverage report
- if (Select-String -path ./report.xml -pattern '' -simplematch -quiet) {
- Write-Host "##[command]Deleting empty coverage file"
- Remove-Item coverage.txt
- }
+Push-Location sdk/$serviceDirectory
+Write-Host "##[command] Executing 'go test -run "^Test" -v -coverprofile coverage.txt ./...' in sdk/$serviceDirectory"
+
+go test -run "^Test" -v -coverprofile coverage.txt ./... | Tee-Object -FilePath outfile.txt
+if ($LASTEXITCODE) {
+ exit $LASTEXITCODE
}
+Get-Content outfile.txt | go-junit-report > report.xml
+
+# if no tests were actually run (e.g. examples) delete the coverage file so it's omitted from the coverage report
+if (Select-String -path ./report.xml -pattern '' -simplematch -quiet) {
+ Write-Host "##[command]Deleting empty coverage file"
+ Remove-Item coverage.txt
+ Remove-Item outfile.txt
+ Remove-Item report.xml
+
+ Pop-Location
+} else {
+ # Tests were actually run create a coverage report
+ $repoRoot = Resolve-Path "$PSScriptRoot/../../"
+
+ gocov convert ./coverage.txt > ./coverage.json
+
+ # gocov converts rely on standard input
+ Get-Content ./coverage.json | gocov-xml > ./coverage.xml
+ Get-Content ./coverage.json | gocov-html > ./coverage.html
+
+ Move-Item ./coverage.xml $repoRoot
+ Move-Item ./coverage.html $repoRoot
+
+ # use internal tool to fail if coverage is too low
+ Pop-Location
+
+ go run $repoRoot/eng/tools/internal/coverage/coverage.go `
+ -config $repoRoot/eng/config.json `
+ -serviceDirectory $serviceDirectory `
+ -searchDirectory $repoRoot
+}
\ No newline at end of file
diff --git a/sdk/azcore/ci.yml b/sdk/azcore/ci.yml
index ecad658282d7..aab9218538da 100644
--- a/sdk/azcore/ci.yml
+++ b/sdk/azcore/ci.yml
@@ -27,4 +27,3 @@ stages:
- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml
parameters:
ServiceDirectory: azcore
- RunTests: true
diff --git a/sdk/data/azcosmos/ci.yml b/sdk/data/azcosmos/ci.yml
index ad4e91e6f5b0..c11b45b43a48 100644
--- a/sdk/data/azcosmos/ci.yml
+++ b/sdk/data/azcosmos/ci.yml
@@ -24,7 +24,6 @@ stages:
- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml
parameters:
ServiceDirectory: 'data/azcosmos'
- RunTests: true
- stage: Emulator
displayName: 'Cosmos Emulator'
jobs:
@@ -70,11 +69,10 @@ stages:
- template: /eng/pipelines/templates/steps/create-go-workspace.yml
- template: /eng/pipelines/templates/steps/build-test.yml
- parameters:
+ parameters:
ServiceDirectory: 'data/azcosmos'
GoWorkspace: $(GO_WORKSPACE_PATH)
Image: $(vm.image)
GoVersion: $(go.version)
- RunTests: true
- EnvVars:
+ EnvVars:
EMULATOR: 'true'
\ No newline at end of file
diff --git a/sdk/data/aztables/ci.yml b/sdk/data/aztables/ci.yml
index 02e52d56cf5f..d46e8d5b2a56 100644
--- a/sdk/data/aztables/ci.yml
+++ b/sdk/data/aztables/ci.yml
@@ -25,5 +25,4 @@ stages:
- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml
parameters:
ServiceDirectory: 'data/aztables'
- RunTests: true
RunLiveTests: true
diff --git a/sdk/internal/ci.yml b/sdk/internal/ci.yml
index 2643ad4f4ae9..8a5d6dee609d 100644
--- a/sdk/internal/ci.yml
+++ b/sdk/internal/ci.yml
@@ -27,5 +27,4 @@ stages:
- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml
parameters:
ServiceDirectory: internal
- RunTests: true
LicenseCheck: false
diff --git a/sdk/keyvault/azsecrets/ci.yml b/sdk/keyvault/azsecrets/ci.yml
index 8023dcd47b3f..3e196e0c80e4 100644
--- a/sdk/keyvault/azsecrets/ci.yml
+++ b/sdk/keyvault/azsecrets/ci.yml
@@ -26,5 +26,4 @@ stages:
- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml
parameters:
ServiceDirectory: 'keyvault/azsecrets'
- RunTests: true
RunLiveTests: true
diff --git a/sdk/messaging/azservicebus/ci.yml b/sdk/messaging/azservicebus/ci.yml
index 7b66819b725c..aa57612dee90 100644
--- a/sdk/messaging/azservicebus/ci.yml
+++ b/sdk/messaging/azservicebus/ci.yml
@@ -16,7 +16,7 @@ pr:
- main
- feature/*
- hotfix/*
- - release/*
+ - release/*
paths:
include:
- sdk/messaging/azservicebus
@@ -25,5 +25,4 @@ stages:
- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml
parameters:
ServiceDirectory: 'messaging/azservicebus'
- RunTests: true
RunLiveTests: true
diff --git a/sdk/storage/azblob/ci.yml b/sdk/storage/azblob/ci.yml
index bfd1c60a45c3..29a16aba8a1f 100644
--- a/sdk/storage/azblob/ci.yml
+++ b/sdk/storage/azblob/ci.yml
@@ -25,4 +25,3 @@ stages:
- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml
parameters:
ServiceDirectory: 'storage/azblob'
- RunTests: true
diff --git a/sdk/template/aztemplate/ci.yml b/sdk/template/aztemplate/ci.yml
index 8f2379e50fd7..cf7ab0a27bc6 100644
--- a/sdk/template/aztemplate/ci.yml
+++ b/sdk/template/aztemplate/ci.yml
@@ -28,4 +28,3 @@ stages:
- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml
parameters:
ServiceDirectory: 'template/aztemplate'
- RunTests: true