Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding code coverage and test reporting to Azure Pipelines #219

Merged
merged 4 commits into from
Jul 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion .azure-pipelines/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,26 @@ steps:
inputs:
command: custom
verbose: false
customCommand: 'run just-test'
customCommand: 'run test:coverage'

- task: PublishTestResults@2
displayName: 'Publish Test Results'
inputs:
testResultsFiles: 'out-cov/*-results.xml'
testRunTitle: '$(Agent.OS)-$(node_version)'
condition: succeededOrFailed()

- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: 'cobertura'
summaryFileLocation: coverage/cobertura-coverage.xml
reportDirectory: coverage/lcov-report
condition: succeededOrFailed()

# Uncomment to push results to CodeCov.io, will need a token in a secret variable
# - bash: |
# bash <(curl https://codecov.io/bash) -t $TOKEN -f coverage/cobertura-coverage.xml
# displayName: 'codecov'
# condition: succeededOrFailed()
# env:
# TOKEN: $(CODECOV_TOKEN)
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ Features
- `Copy the Current Color to the Clipboard` - Shows the current color and copies it to the clipboard
- This command can be executed from the command palette or by clicking the statusBar item for peacock's color

DevOps

- [Adding code coverage and test reporting to Azure Pipelines](https://github.com/johnpapa/vscode-peacock/pull/219)

## 2.5.0

Features
Expand Down Expand Up @@ -63,7 +67,7 @@ Linting and Formatting
- Added prettier
- Added eslint and removed tslint (using eslint for ts)

Testing
DevOps

- Refactored tests after the new yo code generated test model.
- Added code coverage
Expand Down
5 changes: 4 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ trigger:
- master
- greenkeeper/*
pr:
- master
branches:
include:
- '*'
# must quote since "*" is a YAML reserved character; we want a string

jobs:
- job: Linux
Expand Down
62 changes: 32 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@
"test-compile": "tsc -p ./ && npm run webpack",
"test": "npm run test-compile && npm run just-test",
"test-all": "npm run test && npm run just-live-share-test",
"test:coverage": "npm run test-compile && npm run just-test -- --coverage"
"test:coverage": "npm run just-test -- --coverage"
},
"devDependencies": {
"@types/glob": "^7.1.1",
Expand All @@ -296,6 +296,7 @@
"istanbul-lib-source-maps": "^3.0.6",
"istanbul-reports": "^2.2.6",
"mocha": "^6.1.4",
"mocha-multi-reporters": "^1.1.7",
"prettier": "^1.18.2",
"sinon": "7.3.2",
"ts-loader": "^5.3.3",
Expand Down
7 changes: 6 additions & 1 deletion src/test/coverage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ export function createReport(): void {
watermarks,
});

const reports = [iReports.create('json'), iReports.create('lcov'), iReports.create('html')];
const reports = [
iReports.create('json'),
iReports.create('lcov'),
iReports.create('html'),
iReports.create('cobertura'),
];
reports.forEach(report => tree.visit(report, context));
}

Expand Down
7 changes: 7 additions & 0 deletions src/test/suite/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ export function run(): Promise<void> {
timeout: 7500, // longer timeout, in case
useColors: true, // colored output from test results
//----------------------------------------
reporter: "mocha-multi-reporters",
reporterOptions: {
reporterEnabled: "spec, xunit",
xunitReporterOptions: {
output: path.join(__dirname, "..", "..", "test-results.xml")
}
}
});
mocha.useColors(true);

Expand Down