trigger: - master - releases/* pool: QuickTest variables: DOCKER_BUILDKIT: 1 SA_PASSWORD: SA!password HARDWARE_ID: LinuxV1.ZDhiZjhiZjgtMjIwNS00MWQ1LThiMGEtMjM2ZjZhMzc2MGMz resources: containers: - container: db endpoint: centronACR image: centron.azurecr.io/centron_db/version2:0213def19b183ffb83ce9649468ad914384c0bcb env: MSSQL_SA_PASSWORD: $(SA_PASSWORD) ports: - 1433:1433 options: --name db # When an integration test uses emails, uncomment this (+ in the services) to add the mailcatcher container # - container: smtp # endpoint: centronACR # image: centron.azurecr.io/mailcatcher:latest # ports: # - 1025:1025 # - 1080:1080 # options: --name centron-smtp-1 jobs: - job: run displayName: Run unit & integration tests services: db: db # centron-smtp-1: smtp steps: - checkout: self fetchDepth: 0 - task: UseDotNet@2 displayName: 'Install .NET SDK' inputs: packageType: 'sdk' useGlobalJson: true workingDirectory: '$(Build.SourcesDirectory)' - script: 'cp ./src/webservice/Centron.Host.Console/additional.props.docker ./src/webservice/Centron.Host.Console/additional.props' displayName: Move config - script: 'rm ./src/webservice/Centron.Host.Console/app.config' displayName: Remove config - script: | versionNumber="$(/home/centron/.dotnet/tools/nbgv get-version -v Version)" gitCommitId="$(/home/centron/.dotnet/tools/nbgv get-version -v GitCommitIdShort)" echo "versionNumber: $versionNumber" echo "gitCommitId: $gitCommitId" sed -i "s/1.0.0.0<\/Version>/$versionNumber<\/Version>/" ../../Directory.Build.props sed -i "s/<\/GitCommitId>/$gitCommitId<\/GitCommitId>/" ../../Directory.Build.props displayName: 'Set Azure DevOps Build Version' workingDirectory: 'deployment/centron' - script: 'dotnet build "./src/webservice/Centron.Host.Console/Centron.Host.Console.csproj"' displayName: Build webservice - script: 'cp ./tests/Centron.Tests.Integration/WebServiceConfig.xml ./src/webservice/Centron.Host.Console/bin/Debug/net10.0/WebServiceConfig.xml' displayName: Copy config - script: 'dotnet run --project "./src/webservice/Centron.Host.Console/Centron.Host.Console.csproj" > webservice.txt &' env: HARDWARE_ID: $(HARDWARE_ID) displayName: Run webservice - script: | max_retries=30 counter=0 until $(curl --output /dev/null --silent --fail http://localhost:1234/CentronService); do if [ $counter -eq $max_retries ]; then echo "Failed to start webservice" exit 1 fi counter=$((counter+1)) echo "Waiting for webservice..." sleep 1 done displayName: Wait for webservice - script: > dotnet test "./tests/backend/Centron.Tests.BL/Centron.Tests.BL.csproj" --logger "trx;LogFileName=TestResults.trx" --results-directory "artifacts/tests/backend/bl/" displayName: 'Run unit tests for backend/Centron.BL' - task: PublishTestResults@2 condition: always() displayName: 'Publish unit tests for backend/Centron.BL' inputs: testResultsFormat: VSTest testResultsFiles: 'artifacts/tests/backend/bl/TestResults.trx' testRunTitle: 'backend/Centron.Tests.BL' buildConfiguration: 'Release' failTaskOnFailedTests: true mergeTestResults: true - script: > dotnet test "./tests/backend/Centron.Tests.DAO/Centron.Tests.DAO.csproj" --logger "trx;LogFileName=TestResults.trx" --results-directory "artifacts/tests/backend/dao/" displayName: 'Run unit tests for backend/Centron.DAO' - task: PublishTestResults@2 condition: always() displayName: 'Publish unit tests for backend/Centron.DAO' inputs: testResultsFormat: VSTest testResultsFiles: 'artifacts/tests/backend/dao/TestResults.trx' testRunTitle: 'backend/Centron.Tests.DAO' buildConfiguration: 'Release' failTaskOnFailedTests: true mergeTestResults: true - script: > dotnet test "./tests/shared/Centron.Tests.Core/Centron.Tests.Core.csproj" --logger "trx;LogFileName=TestResults.trx" --results-directory "artifacts/tests/shared/core/" displayName: 'Run unit tests for shared/Centron.Core' - task: PublishTestResults@2 condition: always() displayName: 'Publish unit tests for shared/Centron.Core' inputs: testResultsFormat: VSTest testResultsFiles: 'artifacts/tests/shared/core/TestResults.trx' testRunTitle: 'shared/Centron.Tests.Core' buildConfiguration: 'Release' failTaskOnFailedTests: true mergeTestResults: true # Integration tests temporarily disabled # - script: > # dotnet test "./tests/Centron.Tests.Integration/Centron.Tests.Integration.csproj" # --logger "trx;LogFileName=TestResults.trx" # --results-directory "artifacts/tests/integration/" # displayName: 'Run integration tests' # - task: PublishTestResults@2 # condition: always() # displayName: 'Publish integration tests' # inputs: # testResultsFormat: VSTest # testResultsFiles: 'artifacts/tests/integration/TestResults.trx' # testRunTitle: 'Centron.Tests.Integration' # buildConfiguration: 'Release' # failTaskOnFailedTests: true # mergeTestResults: true - script: | pkill -f "Centron.Host.Console" || true displayName: 'Cleanup webservice' condition: always() - publish: webservice.txt artifact: webservice_$(System.JobAttempt) displayName: Publish webservice log condition: always() continueOnError: true - script: docker image prune -f --filter "dangling=true" displayName: Cleanup dangling images condition: always() continueOnError: true