Skip to content

Commit

Permalink
Fixed issues with build scripts that caused invalid publishing of cod…
Browse files Browse the repository at this point in the history
…e coverage and unit/integration tests. (#313)
  • Loading branch information
gwgrubbs committed Jun 14, 2022
1 parent d4b4d1e commit 90c82b9
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 18 deletions.
10 changes: 5 additions & 5 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ stages:
inputs:
command: test
projects: $(Pipeline.Workspace)\$(stageLocationName)\test\HatTrick.DbEx.MsSql.Test.Unit\*.csproj
arguments: '--configuration $(buildConfiguration) --logger "trx;LogFileName=$(Pipeline.Workspace)\$(stageLocationName)\tmp\mssql-core.tests.trx" /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:Include="[HatTrick.DbEx.*Sql*]*" /p:Exclude="[*Test]*"'
arguments: '--configuration $(buildConfiguration) --logger "trx;LogFileName=mssql-core.tests.trx" /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:Include="[HatTrick.DbEx.*Sql*]*" /p:Exclude="[*Test]*"'
- task: PublishTestResults@2
displayName: 'Publish Test Results to Temp'
inputs:
testResultsFormat: xUnit
testResultsFiles: $(Pipeline.Workspace)\$(stageLocationName)\tmp\mssql-*.tests.trx
testResultsFiles: $(Pipeline.Workspace)\$(stageLocationName)\TestResults\mssql-core.tests.trx
testRunTitle: 'MSSQL (Core)'
mergeTestResults: true
failTaskOnFailedTests: true
Expand Down Expand Up @@ -114,12 +114,12 @@ stages:
inputs:
command: test
projects: $(Pipeline.Workspace)\$(stageLocationName)\test\HatTrick.DbEx.MsSql.Extensions.DependencyInjection.Test\*.csproj
arguments: '--configuration $(buildConfiguration) --logger "trx;LogFileName=$(Pipeline.Workspace)\$(stageLocationName)\tmp\mssql-dependency-injection.tests.trx" /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:Include="[HatTrick.DbEx.*Sql.*]*" /p:Exclude="[*Test]*"'
arguments: '--configuration $(buildConfiguration) --logger "trx;LogFileName=mssql-dependency-injection.tests.trx" /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:Include="[HatTrick.DbEx.*Sql.*]*" /p:Exclude="[*Test]*"'
- task: PublishTestResults@2
displayName: 'Publish Test Results to Temp'
inputs:
testResultsFormat: xUnit
testResultsFiles: $(Pipeline.Workspace)\$(stageLocationName)\tmp\mssql-*.tests.trx
testResultsFiles: $(Pipeline.Workspace)\$(stageLocationName)\TestResults\mssql-dependency-injection.tests.trx
testRunTitle: 'MSSQL (Dependency Injection)'
mergeTestResults: true
failTaskOnFailedTests: true
Expand Down Expand Up @@ -151,7 +151,7 @@ stages:
displayName: 'Correct Source Paths in Coverage Files'
inputs:
filePath: $(Pipeline.Workspace)\$(stageLocationName)\build\fix-code-coverage-files.ps1
arguments: '-CodeCoverageFilePaths "$(Pipeline.Workspace)\mssql-core-results\coverage.net6.0.cobertura.xml;$(Pipeline.Workspace)\mssql-core-results\coverage.net6.0.cobertura.xml;$(Pipeline.Workspace)\mssql-2017-results\coverage.net6.0.cobertura.xml;$(Pipeline.Workspace)\mssql-2019-results\coverage.net6.0.cobertura.xml;$(Pipeline.Workspace)\mssql-dependency-injection-results\coverage.net6.0.cobertura.xml" -PathToSourceFiles "$(Pipeline.Workspace)\$(stageLocationName)\src\"'
arguments: '-CodeCoverageFilePaths "$(Pipeline.Workspace)\mssql-core-results\coverage.net6.0.cobertura.xml;$(Pipeline.Workspace)\mssql-2017-results\coverage.net6.0.cobertura.xml;$(Pipeline.Workspace)\mssql-2019-results\coverage.net6.0.cobertura.xml;$(Pipeline.Workspace)\mssql-dependency-injection-results\coverage.net6.0.cobertura.xml" -PathToSourceFiles "$(Pipeline.Workspace)\$(stageLocationName)\src\"'
workingDirectory: $(Pipeline.Workspace)\$(stageLocationName)\build
pwsh: true
- task: reportgenerator@5
Expand Down
2 changes: 1 addition & 1 deletion build/dockerfile-dotnetcore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ FROM mcr.microsoft.com/dotnet/sdk:6.0 AS unit_test_build
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.5.0/wait /wait
RUN chmod +x /wait

CMD /wait && dotnet test /db-ex/test/HatTrick.DbEx.MsSql.Test.Integration/HatTrick.DbEx.MsSql.Test.Integration.csproj --configuration ${BUILD_CONFIGURATION} --logger "trx;LogFileName=/results/mssql-${MSSQL_VERSION}.tests.trx" /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:Include="[HatTrick.DbEx.*Sql]*" /p:Exclude="[*Test]*" && cp /db-ex/test/HatTrick.DbEx.MsSql.Test.Integration/*.cobertura.xml /results
CMD /wait && dotnet test /db-ex/test/HatTrick.DbEx.MsSql.Test.Integration/HatTrick.DbEx.MsSql.Test.Integration.csproj --configuration ${BUILD_CONFIGURATION} --logger "trx;LogFileName=/db-ex/test/HatTrick.DbEx.MsSql.Test.Integration/TestResults/mssql-${MSSQL_VERSION}.tests.trx" /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:Include="[HatTrick.DbEx.*Sql]*" /p:Exclude="[*Test]*" && cp /db-ex/test/HatTrick.DbEx.MsSql.Test.Integration/*.cobertura.xml /db-ex/test/HatTrick.DbEx.MsSql.Test.Integration/TestResults
11 changes: 7 additions & 4 deletions build/mssql/create-docker-config.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ Param
[Parameter(Mandatory,ValueFromPipelineByPropertyName)]
[string]$BUILD_CONFIGURATION,
[Parameter(Mandatory,ValueFromPipelineByPropertyName)]
[string]$TARGET_FRAMEWORK_MONIKER
[string]$TARGET_FRAMEWORK_MONIKER,
[Parameter(Mandatory,ValueFromPipelineByPropertyName)]
[string]$ROOT_PATH
)

Write-Host "Command Line Parameters:"
Write-Host "-------------------------------"
Write-Host "MSSQL_VERSION: " $MSSQL_VERSION
Write-Host "BUILD_CONFIGURATION: " $BUILD_CONFIGURATION
Write-Host "TARGET_FRAMEWORK_MONIKER: " $TARGET_FRAMEWORK_MONIKER
Write-Host "ROOT_PATH: " $ROOT_PATH

$destination = Split-Path (Split-Path -Path (Get-Location).Path -Parent) -Parent
$destinationFile = $destination + "/.env"
Expand All @@ -27,9 +30,9 @@ if (Test-Path $destinationFile) {
}

$values = @(
("MSSQL_VERSION", "BUILD_CONFIGURATION", "TARGET_FRAMEWORK_MONIKER", "PORT", "MSSQL_PWD"),
($MSSQL_VERSION, $BUILD_CONFIGURATION, $TARGET_FRAMEWORK_MONIKER, $PORT, $MSSQL_PWD),
($null, $null, $null, $null, $null)
("MSSQL_VERSION", "BUILD_CONFIGURATION", "TARGET_FRAMEWORK_MONIKER", "PORT", "MSSQL_PWD", "ROOT_PATH"),
($MSSQL_VERSION, $BUILD_CONFIGURATION, $TARGET_FRAMEWORK_MONIKER, $PORT, $MSSQL_PWD, $ROOT_PATH),
($null, $null, $null, $null, $null, $null, $null)
)

if ([System.IO.File]::Exists($envFile) -eq $true)
Expand Down
3 changes: 1 addition & 2 deletions build/mssql/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ services:
MSSQL_VERSION: ${MSSQL_VERSION}
BUILD_CONFIGURATION: ${BUILD_CONFIGURATION}
volumes:
- ./results:/results
- ./:/db-ex
- ${ROOT_PATH}:/db-ex
depends_on:
- mssql
10 changes: 5 additions & 5 deletions build/mssql/mssql-integration-testing-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
displayName: 'Create Docker Config Files'
inputs:
filePath: ${{ parameters.buildTemplatesPath }}/create-docker-config.ps1
arguments: '-MSSQL_VERSION ${{ mssqlVersion }} -BUILD_CONFIGURATION ${{ parameters.buildConfiguration }} -TARGET_FRAMEWORK_MONIKER ${{ parameters.targetFrameworkMoniker }}'
arguments: '-MSSQL_VERSION ${{ mssqlVersion }} -BUILD_CONFIGURATION ${{ parameters.buildConfiguration }} -TARGET_FRAMEWORK_MONIKER ${{ parameters.targetFrameworkMoniker }} -ROOT_PATH ${{ parameters.rootPath }}'
workingDirectory: ${{ parameters.buildTemplatesPath }}

- task: DockerCompose@0
Expand All @@ -29,17 +29,17 @@ jobs:
dockerComposeFile: ${{ parameters.rootPath }}/docker-compose.yml
action: 'Run a Docker Compose command'
dockerComposeCommand: 'up --abort-on-container-exit'
currentWorkingDirectory: ${{ parameters.rootPath }}
currentWorkingDirectory: ${{ parameters.rootPath }}

- task: PublishTestResults@2
displayName: 'Publish Test Results'
inputs:
testResultsFormat: xUnit
testResultsFiles: ${{ parameters.rootPath }}/results/mssql-${{ mssqlVersion }}.tests.trx
testResultsFormat: VSTest # MUST be VSTest. If xUnit is used the publish task will report "No Result Found to Publish", even though the file exists
testResultsFiles: ${{ parameters.rootPath }}/test/HatTrick.DbEx.MsSql.Test.Integration/TestResults/mssql-${{ mssqlVersion }}.tests.trx
testRunTitle: 'MSSQL ${{ mssqlVersion }}'
mergeTestResults: true
failTaskOnFailedTests: true

- publish: ${{ parameters.rootPath }}/results
- publish: ${{ parameters.rootPath }}/test/HatTrick.DbEx.MsSql.Test.Integration/TestResults
displayName: 'Publish Results to Staging Location'
artifact: mssql-${{ mssqlVersion }}-results
2 changes: 1 addition & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

## [0.9.1] - 2022-06-10
## [0.9.1] - 2022-06-14

### Added
- Benchmark reports
Expand Down

0 comments on commit 90c82b9

Please sign in to comment.