Skip to content

Commit

Permalink
feat: blob reporting and test reports (#22)
Browse files Browse the repository at this point in the history
* chore: artifact publishing

* fix: linting

* chore: param name

* chore: check path exisits

* fix: correct param

* chore: fix name

* chore: remove second it

* feat: new build test dotnet pipeline

* chore: one report task

* chore: debug

* chore: try full path

* chore: debug

* feat: scaffoling cli

* chore: reports

* chore: fixes

* chore: remove check

* chore: blob storage and junit

* chore: update task

* fix: right context

* fix: stop making silly mistakes

* fix: change the results path as current dir

* fix: total path and file

* chore: script instead of task

* fix: linting and docs
  • Loading branch information
estherthetesteramido committed May 14, 2020
1 parent cd39c7e commit 6c909ed
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 22 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# GEneric
# Generic
.pytest_cache
.idea
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
############################################################################################################
# desc: Boostrap a template using the scaffolding-cli
# params: working dir, version spec, sample config file, sample config path (eg. tests), custom registry
# return: templated solution
# pre-reqs: published packages and templates, example config file
############################################################################################################

parameters:
working_directory: ''
version_spec: ''
sample_config: ''
sample_config_path: ''
customRegistry: ''

steps:
# Ensure Node.js 12 is active
- task: NodeTool@0
inputs:
versionSpec: ${{ parameters.version_spec }}
customRegistry: ${{ parameters.customRegistry }}
displayName: 'Use Node.js ${{ parameters.version_spec }}'

- task: Npm@1
displayName: 'Build: Scaffold project from sample config'
inputs:
command: 'custom'
customCommand: 'npx @amidostacks/scaffolding-cli -run -c ${{ parameters.sample_config}}'
workingDir: ${{ parameters.sample_config_path }}
verbose: true
customRegistry: ${{ parameters.customRegistry }}
37 changes: 37 additions & 0 deletions azDevOps/azure/templates/v2/steps/build-test-dotnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
parameters:
test_path: ''
package_path: ''
package_feed: ''
# .NET Core version variable
dotnet_core_version: '2.2.x'

steps:
- bash: |
echo 'Testing ${{ parameters.test_path }}'
echo 'Building ${{ parameters.package_path }}'
echo 'Restoring from ${{ parameters.package_feed }}'
displayName: 'Display: Package Path Info'
- task: UseDotNet@2
displayName: 'Use .NET Core SDK ${{ parameters.dotnet_core_version }}'
inputs:
packageType: sdk
version: ${{ parameters.dotnet_core_version }}
installationPath: $(Agent.ToolsDirectory)/dotnet

- task: DotNetCoreCLI@2
displayName: 'Build: Restore'
inputs:
command: 'restore'
projects: '${{ parameters.package_path }}**/*.csproj'
feedsToUse: 'select'
vstsFeed: '${{ parameters.package_feed }}'
includeNuGetOrg: true

- task: DotNetCoreCLI@2
displayName: 'Test: Unit Tests'
inputs:
command: 'test'
projects: '${{ parameters.test_path }}/*.csproj'
arguments: '--no-restore'
failOnStderr: true
25 changes: 4 additions & 21 deletions azDevOps/azure/templates/v2/steps/test-functional-testcafe.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,25 @@
############################################################################################################
# desc: Runs the functional (e2e) tests on a deployed webapp with Testcafe
# params: Env vars, workingDirectory, testcafe_browser_list (default to all)
# params: Env vars, working_directory, testcafe_browser_list (default to all)
# return: Publishes test results, screenshots
# pre-reqs: deployed webapp
############################################################################################################

parameters:
env_vars: {}
workingDirectory: ''
working_directory: ''
testcafe_browser_list: 'all'

steps:
# Install test runtime dependencies (not installing modules listed in devDependencies)
- script: npm install
displayName: 'Install test dependencies'
workingDirectory: ${{ parameters.workingDirectory }}
workingDirectory: ${{ parameters.working_directory }}

# Run tests with Testcafe
- script: npm run test:e2e -- ${{ parameters.testcafe_browser_list }}
displayName: 'Test: Run Testcafe tests against specified browsers'
workingDirectory: ${{ parameters.workingDirectory }}
workingDirectory: ${{ parameters.working_directory }}
env:
${{ each var in parameters.env_vars }}:
${{ var.key }}: ${{ var.value }}

# Publish Artifacts: Cypress will automatically capture screenshots when a failure happens
- task: PublishPipelineArtifact@1
inputs:
artifactName: 'screenshots'
targetPath: '${{ parameters.workingDirectory }}/screenshots'
displayName: 'Publish Screenshots (TestCafe)'
condition: failed()

# Publish CI test results
- task: PublishTestResults@2
inputs:
testRunner: xUnit
testResultsFiles: '**/testcafe-xunit-test-report.xml'
testRunTitle: 'TestCafe Tests'
displayName: 'Publish test results'
condition: succeededOrFailed()
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
############################################################################################################
# desc: Publishes test reports and converts xunit/junit xml into html and uploads to specified blob container
# params: test tool (eg, cypress, testcafe, selenium), working dir, blob storage account, storage container
# tests results path, blob prefix
# return:
# pre-reqs:
############################################################################################################

parameters:
test_tool_name: ''
artifacts: {}
working_directory: ''
test_results_storage: ''
test_results_blob_prefix: ''
test_results_container: 'testresults'
test_results_path: $(working_directory)

steps:
# Takes a number of artifacts to publish (like screenshots, videos) and publishes them
- ${{ each var in parameters.artifacts }}:
task: PublishPipelineArtifact@1
inputs:
artifactName: ${{ var.key }}
targetPath: ${{ var.value }}
displayName: 'Test Artifact: ${{ var.key }}'
condition: failed()

# Publish CI test results to Azure Devops artifacts
- task: PublishTestResults@2
inputs:
testRunner: jUnit
testResultsFiles: '${{ parameters.test_tool_name }}-xunit-test-report.xml'
searchFolder: ${{ parameters.working_directory }}
testRunTitle: '${{ parameters.test_tool_name }} Tests'
displayName: 'Publish: ${{ parameters.test_tool_name }} results'
condition: succeededOrFailed()

# Coverets the xml output into a standalone html report
- bash: |
npx xunit-viewer -r ${{ parameters.test_tool_name }}-xunit-test-report.xml -o ${{ parameters.test_tool_name }}-xunit-test-results.html -t ${{ parameters.test_tool_name }}
workingDirectory: ${{ parameters.working_directory }}
displayName: 'Generate ${{ parameters.test_tool_name }} HTML Report'
# Upload html report to blob storage
- bash: |
az login --service-principal --username $azure_client_id --password $azure_client_secret --tenant $azure_tenant_id
az account set -s $azure_subscription_id
az storage copy -s ${{ parameters.test_tool_name }}-xunit-test-results.html -d https://${{ parameters.test_results_storage }}.blob.core.windows.net/${{ parameters.test_results_container }}/${{ parameters.test_results_blob_prefix }} --recursive
az logout --username $azure_client_id
displayName: 'Copy: ${{ parameters.test_tool_name }} HTML Report Blob Storge '
workingDirectory: ${{ parameters.working_directory }}
env:
azure_client_id: $(azure_client_id)
azure_client_secret: $(azure_client_secret)
azure_subscription_id: $(azure_subscription_id)
azure_tenant_id: $(azure_tenant_id)

0 comments on commit 6c909ed

Please sign in to comment.