Skip to content

Commit a0005dc

Browse files
committed
ci: Deduplicate config and enable coverage report in every job
Signed-off-by: Ferenc Géczi <[email protected]>
1 parent f497c3b commit a0005dc

File tree

1 file changed

+53
-58
lines changed

1 file changed

+53
-58
lines changed

.circleci/config.yml

Lines changed: 53 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,39 @@ commands:
3535
sudo apt update
3636
sudo apt install libcouchbase-dev -y
3737
38+
run-tests-with-coverage-report:
39+
parameters:
40+
cassandra:
41+
default: ""
42+
type: string
43+
couchbase:
44+
default: ""
45+
type: string
46+
gevent:
47+
default: ""
48+
type: string
49+
tests:
50+
default: "tests"
51+
type: string
52+
steps:
53+
- run:
54+
name: Run Tests With Coverage Report
55+
environment:
56+
INSTANA_TEST: "true"
57+
CASSANDRA_TEST: "<<parameters.cassandra>>"
58+
COUCHBASE_TEST: "<<parameters.couchbase>>"
59+
GEVENT_TEST: "<<parameters.gevent>>"
60+
command: |
61+
. venv/bin/activate
62+
coverage run --source=instana -m pytest -v <<parameters.tests>>
63+
coverage report -m
64+
coverage html
65+
66+
store-coverage-report:
67+
steps:
68+
- store_artifacts:
69+
path: htmlcov
70+
3871
jobs:
3972
python37:
4073
docker:
@@ -57,15 +90,8 @@ jobs:
5790
- checkout
5891
- pip-install-deps:
5992
requirements: "tests/requirements-307.txt"
60-
- run:
61-
name: run tests
62-
environment:
63-
INSTANA_TEST: "true"
64-
command: |
65-
. venv/bin/activate
66-
# We uninstall uvloop as it interferes with asyncio changing the event loop policy
67-
pip uninstall -y uvloop
68-
pytest -v
93+
- run-tests-with-coverage-report
94+
- store-coverage-report
6995

7096
python38:
7197
docker:
@@ -87,17 +113,8 @@ jobs:
87113
steps:
88114
- checkout
89115
- pip-install-deps
90-
- run:
91-
name: run tests
92-
environment:
93-
INSTANA_TEST: "true"
94-
command: |
95-
. venv/bin/activate
96-
coverage run --source=instana -m pytest -v
97-
coverage report -m
98-
coverage html
99-
- store_artifacts:
100-
path: htmlcov
116+
- run-tests-with-coverage-report
117+
- store-coverage-report
101118

102119
python39:
103120
docker:
@@ -119,13 +136,8 @@ jobs:
119136
steps:
120137
- checkout
121138
- pip-install-deps
122-
- run:
123-
name: run tests
124-
environment:
125-
INSTANA_TEST: "true"
126-
command: |
127-
. venv/bin/activate
128-
pytest -v
139+
- run-tests-with-coverage-report
140+
- store-coverage-report
129141

130142
python310:
131143
docker:
@@ -148,13 +160,8 @@ jobs:
148160
- checkout
149161
- pip-install-deps:
150162
requirements: "tests/requirements-310.txt"
151-
- run:
152-
name: run tests
153-
environment:
154-
INSTANA_TEST: "true"
155-
command: |
156-
. venv/bin/activate
157-
pytest -v
163+
- run-tests-with-coverage-report
164+
- store-coverage-report
158165

159166
py38couchbase:
160167
docker:
@@ -166,14 +173,10 @@ jobs:
166173
- install-couchbase-deps
167174
- pip-install-deps:
168175
requirements: "tests/requirements-couchbase.txt"
169-
- run:
170-
name: run tests
171-
environment:
172-
INSTANA_TEST: "true"
173-
COUCHBASE_TEST: "true"
174-
command: |
175-
. venv/bin/activate
176-
pytest -v tests/clients/test_couchbase.py
176+
- run-tests-with-coverage-report:
177+
couchbase: "true"
178+
tests: "tests/clients/test_couchbase.py"
179+
- store-coverage-report
177180

178181
py37cassandra:
179182
docker:
@@ -187,14 +190,10 @@ jobs:
187190
- checkout
188191
- pip-install-deps:
189192
requirements: "tests/requirements-cassandra.txt"
190-
- run:
191-
name: run tests
192-
environment:
193-
INSTANA_TEST: "true"
194-
CASSANDRA_TEST: "true"
195-
command: |
196-
. venv/bin/activate
197-
pytest -v tests/clients/test_cassandra-driver.py
193+
- run-tests-with-coverage-report:
194+
cassandra: "true"
195+
tests: "tests/clients/test_cassandra-driver.py"
196+
- store-coverage-report
198197

199198
py38gevent:
200199
docker:
@@ -204,14 +203,10 @@ jobs:
204203
- checkout
205204
- pip-install-deps:
206205
requirements: "tests/requirements-gevent.txt"
207-
- run:
208-
name: run tests
209-
environment:
210-
INSTANA_TEST: "true"
211-
GEVENT_TEST: "true"
212-
command: |
213-
. venv/bin/activate
214-
pytest -v tests/frameworks/test_gevent.py
206+
- run-tests-with-coverage-report:
207+
gevent: "true"
208+
tests: "tests/frameworks/test_gevent.py"
209+
- store-coverage-report
215210

216211
workflows:
217212
version: 2

0 commit comments

Comments
 (0)