Skip to content

Instantly share code, notes, and snippets.

@chris-gunawardena
Created December 28, 2020 09:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chris-gunawardena/a9d82acf8cd4220688bf5b40271d1eb0 to your computer and use it in GitHub Desktop.
Save chris-gunawardena/a9d82acf8cd4220688bf5b40271d1eb0 to your computer and use it in GitHub Desktop.
trigger: none
# trigger:
# branches:
# include:
# - feature/3809-faster-tests
#schedules:
# - cron: "*/15 * * * *"
# displayName: every 15 min build
# always: true
# branches:
# include:
# - feature/3809-faster-tests
variables:
NPM_CACHE_FOLDER: $(Pipeline.Workspace)/.npm
pool:
vmImage: 'ubuntu-latest'
stages:
- stage: Test
displayName: 'Test Stage'
jobs:
- job: Unit_tests
displayName: 'Unit tests Job'
steps:
- task: DotNetCoreCLI@2
displayName: 'Requester unit tests'
inputs:
command: test
arguments: '--configuration $(buildConfiguration)' # /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=$(Build.SourcesDirectory)/TestResults/Coverage/
publishTestResults: true
workingDirectory: 'Core/Blacksmith.Core.Generator.Test'
# - task: PublishCodeCoverageResults@1
# displayName: 'Publish code coverage report'
# inputs:
# codeCoverageTool: 'Cobertura'
# summaryFileLocation: '$(Build.SourcesDirectory)/TestResults/Coverage/coverage.cobertura.xml'
- job: Integration_tests
displayName: 'Angular component test job'
steps:
- task: Cache@2
displayName: 'Cache npm'
inputs:
key: 'npm | "$(Agent.OS)" | UI/ClientApp/package-lock.json'
restoreKeys: |
npm | "$(Agent.OS)"
path: $(NPM_CACHE_FOLDER)
- task: Npm@1
displayName: 'Install npm packages'
inputs:
command: 'custom'
workingDir: 'UI/ClientApp'
customCommand: 'clean-install --cache $(NPM_CACHE_FOLDER)'
- task: Npm@1
displayName: 'Run tests'
inputs:
command: 'custom'
workingDir: 'UI/ClientApp'
customCommand: 'run test:ci'
- task: PublishTestResults@2
displayName: 'Upload test reports'
condition: succeededOrFailed()
inputs:
testRunTitle: 'Angular tests'
testResultsFormat: 'JUnit'
testResultsFiles: 'UI/ClientApp/testresults/junit/unit-test-result.xml'
failTaskOnFailedTests: false
- task: PublishCodeCoverageResults@1
displayName: 'Publish code coverage report'
inputs:
codeCoverageTool: 'Cobertura'
summaryFileLocation: 'UI/ClientApp/testresults/coverage/cobertura-coverage.xml'
- job: FE_build_job
displayName: 'Frontend Build job'
steps:
- task: Cache@2
displayName: 'Cache npm'
inputs:
key: 'npm | "$(Agent.OS)" | UI/ClientApp/package-lock.json'
restoreKeys: |
npm | "$(Agent.OS)"
path: $(NPM_CACHE_FOLDER)
- task: Npm@1
displayName: 'Install npm packages'
inputs:
command: 'custom'
workingDir: 'UI/ClientApp'
customCommand: 'install --only=prod --cache $(NPM_CACHE_FOLDER)'
- task: Npm@1
displayName: 'Buld angular'
inputs:
command: 'custom'
workingDir: 'UI/ClientApp'
customCommand: 'run build:local'
- task: PublishPipelineArtifact@1
inputs:
displayName: 'Publish Artifact: Front-end for testing'
targetPath: '$(Build.SourcesDirectory)/UI/ClientApp/dist/'
artifactName: 'angular-local-build-for-e2e-testing'
- job: E2E_testsV2
displayName: 'End to end tests v2 using cypress'
dependsOn: FE_build_job
# strategy:
# parallel: 2
steps:
- task: DownloadPipelineArtifact@2
inputs:
artifact: 'angular-local-build-for-e2e-testing'
path: $(Build.SourcesDirectory)/UI/ClientApp/dist
- task: FuncToolsInstaller@0
displayName: 'Install azure func cli'
inputs:
version: '3.0.2996'
- task: Cache@2
displayName: 'Cache npm'
inputs:
key: 'npm | "$(Agent.OS)" | UI/ClientApp/package-lock.json'
restoreKeys: |
npm | "$(Agent.OS)"
path: $(NPM_CACHE_FOLDER)
- task: Npm@1
displayName: 'Install npm packages'
inputs:
command: 'custom'
workingDir: 'UI/ClientApp'
customCommand: 'install --only=prod --cache $(NPM_CACHE_FOLDER)'
- task: Npm@1
displayName: 'Run cypress tests'
inputs:
command: 'custom'
workingDir: 'UI/ClientApp'
customCommand: 'run cy:dist-serve:start'
- task: PublishTestResults@2
displayName: 'Upload test reports'
condition: succeededOrFailed()
inputs:
testRunTitle: 'Cypress E2E tests'
testResultsFormat: 'JUnit'
testResultsFiles: 'UI/ClientApp/cypress/reports/**/test-output-*.xml'
failTaskOnFailedTests: false
- task: PublishPipelineArtifact@1
displayName: 'Upload videos'
inputs:
displayName: 'Publish Artifact: E2E test videos'
targetPath: '$(Build.SourcesDirectory)/UI/ClientApp/cypress/videos'
artifactName: 'cypress-e2e-test-videos'
condition: succeededOrFailed()
continueOnError: true
- task: PublishPipelineArtifact@1
displayName: 'Upload screenshots'
inputs:
displayName: 'Publish Artifact: E2E test screenshots'
targetPath: '$(Build.SourcesDirectory)/UI/ClientApp/cypress/screenshots'
artifactName: 'cypress-e2e-test-screenshots'
condition: failed()
continueOnError: true
# - job: E2E_tests
# displayName: 'OLD End to end tests'
# dependsOn: FE_build_job
# # strategy:
# # parallel: 3 https://github.com/PBoraMSFT/ParallelTestingSample-Mocha/blob/master/azure-pipelines.yml
# steps:
# - task: DownloadPipelineArtifact@2
# inputs:
# artifact: 'angular-local-build-for-e2e-testing'
# path: $(Build.SourcesDirectory)/www
# - task: FuncToolsInstaller@0
# displayName: 'Install azure func cli'
# inputs:
# version: '3.0.2996'
# - task: Cache@2
# displayName: Cache Maven local repo
# inputs:
# key: 'maven | "$(Agent.OS)" | UIAutomatedTests/pom.xml'
# restoreKeys: |
# maven | "$(Agent.OS)"
# maven
# path: $(MAVEN_CACHE_FOLDER)
# - task: Maven@3
# inputs:
# mavenPomFile: 'UIAutomatedTests/pom.xml'
# goals: 'test'
# publishJUnitResults: true
# javaHomeOption: 'JDKVersion'
# mavenVersionOption: 'Default'
# mavenAuthenticateFeed: false
# effectivePomSkip: false
# sonarQubeRunAnalysis: false
# testResultsFiles: 'UIAutomatedTests/target/cucumber-reports/Cucumber.xml'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment