Use CircleCI version 2.1 at the top of your .circleci/config.yml file.
1
version: 2.1
Add the orbs
stanza below your version, invoking the orb:
1
2
orbs:
test-coverage: deepsource/test-coverage@1.1.0
Use test-coverage
elements in your existing workflows and jobs.
Opt-in to use of uncertified orbs on your organization’s Security settings page.
Example usage of DeepSource test-coverage orb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
version: '2.1'
orbs:
deepsource: deepsource/test-coverage
jobs:
run-test:
docker:
- image: cimg/python:3.8.5
steps:
- checkout
- run: pytest --cov --cov-report=xml
- deepsource/report:
coverage-file: ./coverage.xml
dsn: ${DEEPSOURCE_DSN}
key: python
workflows: null
Report the test coverage file generated after running the tests to DeepSource.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
coverage-file | Path to the coverage data file. e.g. ./coverage.xml | No | '' | string |
dsn | DeepSource DSN of this repository. It is available under Settings → Reporting tab of the repository page on DeepSource.
| No | ${DEEPSOURCE_DSN} | string |
key | Programming language shortcode for which coverage is reported. Supported languages are — go, javascript, python, ruby
| No | '' | string |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# This code is licensed from CircleCI to the user under the MIT license.
# See here for details: https://circleci.com/developer/orbs/licensing
version: 2.1
description: |
Upload test coverage reports to DeepSource to track test coverage and see which lines are not covered by tests yet. DeepSource is an automated code review tool that helps developers find and fix bugs in their code.
display:
home_url: https://deepsource.io/
source_url: https://github.com/deepsourcelabs/test-coverage-orb
commands:
report:
description: |
Report the test coverage file generated after running the tests to DeepSource.
parameters:
coverage-file:
default: ""
description: Path to the coverage data file. e.g. ./coverage.xml
type: string
dsn:
default: ${DEEPSOURCE_DSN}
description: |
DeepSource DSN of this repository. It is available under Settings → Reporting tab of the repository page on DeepSource.
type: string
key:
default: ""
description: |
Programming language shortcode for which coverage is reported. Supported languages are — go, javascript, python, ruby
type: string
steps:
- run:
command: |
# Install DeepSource CLI
curl https://deepsource.io/cli | sh
# Set the DSN
DEEPSOURCE_DSN=<< parameters.dsn >>
# Report coverage artifact to the 'test-coverage' analyzer
./bin/deepsource report --analyzer test-coverage \
--key << parameters.key >> \
--value-file << parameters.coverage-file >>
name: Report coverage file to DeepSource
examples:
report_python_coverage:
description: Example usage of DeepSource test-coverage orb
usage:
version: "2.1"
orbs:
deepsource: deepsource/test-coverage
jobs:
run-test:
docker:
- image: cimg/python:3.8.5
steps:
- checkout
- run: pytest --cov --cov-report=xml
- deepsource/report:
coverage-file: ./coverage.xml
dsn: ${DEEPSOURCE_DSN}
key: python
workflows: null