Skip to content

hmcts/vh-video-api

Repository files navigation

vh-video-api

HMCTS

Build Status

VideoApi.Client package in vh-packages feed in Azure Artifacts

Quality Gate Status

SDS

Build Status

VideoApi.Client package in vh-packages feed in Azure Artifacts

Quality Gate Status

Running Sonar Analysis

dotnet sonarscanner begin /k:"vh-video-api" /d:sonar.cs.opencover.reportsPaths="VideoAPI/Artifacts/Coverage/coverage.opencover.xml" /d:sonar.coverage.exclusions="VideoApi/Program.cs,VideoApi/Startup.cs,VideoApi/Extensions/**,VideoApi/Swagger/**,**/VideoApi/ConfigureServicesExtensions.cs,**/Testing.Common/**,**/Testing.Common/Helper/,Helper/Builders/Api/,Helper/Builders/Domain/,VideoApi.Common/**,VideoApi.DAL/Mappings/**,VideoApi.DAL/SeedData/**,VideoApi.DAL/VideoApiDbContext.cs,VideoApi.DAL/**/DesignTimeHearingsContextFactory.cs,VideoApi.DAL/Migrations/**,VideoApi.Domain/Ddd/**,VideoApi.Domain/Validations/**" /d:sonar.cpd.exclusions="VideoApi.DAL/Migrations/**" /d:sonar.verbose=true
dotnet build VideoAPI/VideoApi.sln
dotnet sonarscanner end

Running code coverage

First ensure you are running a terminal in the VideoAPI directory of this repository and then run the following commands.

dotnet test --no-build VideoApi.UnitTests/VideoApi.UnitTests.csproj /p:CollectCoverage=true /p:CoverletOutputFormat="\"opencover,cobertura,json,lcov\"" /p:CoverletOutput=../Artifacts/Coverage/ /p:MergeWith='../Artifacts/Coverage/coverage.json' /p:Exclude="\"[*]VideoApi.Extensions.*,[VideoApi]VideoApi.ConfigureServicesExtensions,[VideoApi]VideoApi.Startup,[VideoApi]VideoApi.Program,[*]VideoApi.Swagger.*,[VideoApi.*Tests?]*,[*]VideoApi.DAL.SeedData.*,[*]VideoApi.DAL.Migrations.*,[*]VideoApi.DAL.Mappings.*,[*]VideoApi.Domain.Ddd.*,[*]VideoApi.Domain.Validations.*,[VideoApi.DAL]VideoApi.DAL.VideoApiDbContext,[VideoApi.DAL]VideoApi.DAL.DesignTimeHearingsContextFactory,[*]VideoApi.Common.*,[*]Testing.Common.*,[*]VideoApi.Services.*\""

dotnet test --no-build VideoApi.IntegrationTests/VideoApi.IntegrationTests.csproj /p:CollectCoverage=true /p:CoverletOutputFormat="\"opencover,cobertura,json,lcov\"" /p:CoverletOutput=../Artifacts/Coverage/ /p:MergeWith='../Artifacts/Coverage/coverage.json' /p:Exclude="\"[*]VideoApi.Extensions.*,[VideoApi]VideoApi.ConfigureServicesExtensions,[VideoApi]VideoApi.Startup,[VideoApi]VideoApi.Program,[*]VideoApi.Swagger.*,[VideoApi.*Tests?]*,[*]VideoApi.DAL.SeedData.*,[*]VideoApi.DAL.Migrations.*,[*]VideoApi.DAL.Mappings.*,[*]VideoApi.Domain.Ddd.*,[*]VideoApi.Domain.Validations.*,[VideoApi.DAL]VideoApi.DAL.VideoApiDbContext,[VideoApi.DAL]VideoApi.DAL.DesignTimeHearingsContextFactory,[*]VideoApi.Common.*,[*]Testing.Common.*,[*]VideoApi.Services.*\""

Generate HTML Report

Under the unit test project directory

dotnet reportgenerator "-reports:./Coverage/coverage.opencover.xml" "-targetDir:./Artifacts/Coverage/Report" -reporttypes:Html -sourcedirs:./VideoApi

##Branch name git hook will run on pre commit and control the standard for new branch name.

The branch name should start with: feature/VIH-XXXX-branchName (X - is digit). If git version is less than 2.9 the pre-commit file from the .githooks folder need copy to local .git/hooks folder. To change git hooks directory to directory under source control run (works only for git version 2.9 or greater) : $ git config core.hooksPath .githooks

##Commit message The commit message will be validated by prepare-commit-msg hook. The commit message format should start with : 'feature/VIH-XXXX : ' folowing by 8 or more characters description of commit, otherwise the warning message will be presented.

Run Zap scan locally

To run Zap scan locally update the following settings and run acceptance\integration tests

User Secrets:

  • "Services:VideoApiUrl": "https://VideoApi_AC/"

Update following configuration under appsettings.json under VideoApi.AcceptanceTests or VideoApi.IntegrationTests

  • "Services:VideoApiUrl": "https://VideoApi_AC/"
  • "ZapConfiguration:ZapScan": true
  • "ConnectionStrings:VhVideoApi": "Server=localhost,1433;Database=VhVideoApi;User=sa;Password=VeryStrongPassword!;" (IntegrationTest alone)

Note: Ensure you have Docker desktop engine installed and setup

Running all tests in Docker

Open a terminal at the root level of the repository and run the following command

docker-compose -f "docker-compose.tests.yml" up --build --abort-on-container-exit

You may need to create a .env file to store the environment variables