From 181d74b0ae176ed4432e9a9987d966d33c1fb64a Mon Sep 17 00:00:00 2001 From: Fati Iseni Date: Mon, 24 Jul 2023 17:01:45 +0200 Subject: [PATCH] Added and updated scripts for test and coverage reports. --- .dockerignore | 3 ++- .editorconfig | 4 ++++ Ardalis.Specification.sln | 5 +++-- Dockerfile | 7 +++++-- GetCoverage.sh | 1 - docker-compose.yml | 2 +- RunTests.bat => run-tests-docker.bat | 0 RunTests.sh => run-tests-docker.sh | 1 + run-tests.sh | 13 +++++++++++++ 9 files changed, 29 insertions(+), 7 deletions(-) delete mode 100644 GetCoverage.sh rename RunTests.bat => run-tests-docker.bat (100%) rename RunTests.sh => run-tests-docker.sh (84%) create mode 100644 run-tests.sh diff --git a/.dockerignore b/.dockerignore index b95e158d..3017cf2b 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,3 @@ .vs/ -.git/ \ No newline at end of file +.git/ +**/TestResults \ No newline at end of file diff --git a/.editorconfig b/.editorconfig index 147fc4ef..0263c935 100644 --- a/.editorconfig +++ b/.editorconfig @@ -9,6 +9,10 @@ indent_style = space # Standard properties end_of_line = crlf +# bash scripts +[*.{sh,bash}] +end_of_line = lf + # XML project files [*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}] indent_size = 2 diff --git a/Ardalis.Specification.sln b/Ardalis.Specification.sln index 366ecdf5..28dbcbf3 100644 --- a/Ardalis.Specification.sln +++ b/Ardalis.Specification.sln @@ -16,8 +16,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Docker", "Docker", "{A74A4C .dockerignore = .dockerignore docker-compose.yml = docker-compose.yml Dockerfile = Dockerfile - RunTests.bat = RunTests.bat - RunTests.sh = RunTests.sh + run-tests-docker.bat = run-tests-docker.bat + run-tests-docker.sh = run-tests-docker.sh + run-tests.sh = run-tests.sh EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_Solution Items", "_Solution Items", "{C443291A-7311-455F-9AC6-995EB29DD6D2}" diff --git a/Dockerfile b/Dockerfile index 9587d62b..034a6a75 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,11 +2,14 @@ FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build WORKDIR / COPY . ./ + ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.8.0/wait /wait -#RUN chmod +x /wait RUN /bin/bash -c 'ls -la /wait; chmod +x /wait; ls -la /wait' # install the report generator tool RUN dotnet tool install dotnet-reportgenerator-globaltool --version 5.1.23 --tool-path /tools -CMD /wait && dotnet test -f net7.0 Specification/tests/Ardalis.Specification.UnitTests/Ardalis.Specification.UnitTests.csproj --collect:"XPlat Code Coverage" && dotnet test -f net7.0 Specification.EntityFrameworkCore/tests/Ardalis.Specification.EntityFrameworkCore.IntegrationTests/Ardalis.Specification.EntityFrameworkCore.IntegrationTests.csproj --collect:"XPlat Code Coverage" && tools/reportgenerator -reports:Specification*/**/coverage.cobertura.xml -targetdir:/var/temp/coverage -reporttypes:HtmlInline_AzurePipelines\;HTMLChart\;Cobertura +CMD /wait && \ +dotnet build ci.slnf --configuration release && \ +dotnet test -f net7.0 ci.slnf --configuration release --no-build --no-restore --collect:"xplat code coverage" && \ +tools/reportgenerator -reports:Specification*/**/coverage.cobertura.xml -targetdir:/var/temp/TestResults -assemblyfilters:"-*Tests*;" diff --git a/GetCoverage.sh b/GetCoverage.sh deleted file mode 100644 index 6220950e..00000000 --- a/GetCoverage.sh +++ /dev/null @@ -1 +0,0 @@ -reportgenerator "-reports:.\TestResults\coverage.integration.cobertura.xml;.\TestResults\coverage.unit.cobertura.xml" "-targetdir:.\CodeCoverage" "-reportTypes:HtmlInline_AzurePipelines;Cobertura" \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index b3b8aa41..8c510048 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,7 +8,7 @@ services: environment: WAIT_HOSTS: databaseEF:1433 volumes: - - ./TestResults:/var/temp + - ./TestResults:/var/temp/TestResults depends_on: - databaseEF diff --git a/RunTests.bat b/run-tests-docker.bat similarity index 100% rename from RunTests.bat rename to run-tests-docker.bat diff --git a/RunTests.sh b/run-tests-docker.sh similarity index 84% rename from RunTests.sh rename to run-tests-docker.sh index be53c1f1..7f1f5ea6 100644 --- a/RunTests.sh +++ b/run-tests-docker.sh @@ -1,2 +1,3 @@ +#!/bin/bash docker-compose build docker-compose up --abort-on-container-exit diff --git a/run-tests.sh b/run-tests.sh new file mode 100644 index 00000000..e4a6e638 --- /dev/null +++ b/run-tests.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +find . -type d -name TestResults -exec rm -rf {} \; > /dev/null 2>&1 + +testtarget="$1" + +if [ "$testtarget" = "" ]; then +testtarget="ci.slnf" +fi + +dotnet build "$testtarget" --configuration release +dotnet test "$testtarget" --configuration release --no-build --no-restore --collect:"xplat code coverage" +reportgenerator -reports:Specification*/**/coverage.cobertura.xml -targetdir:TestResults -assemblyfilters:"-*Tests*;"