Skip to content

Commit d5a7dce

Browse files
authored
ci: add link to CI App product (#589)
1 parent 6aa80b5 commit d5a7dce

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

tests/conftest.py

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,29 @@
2020

2121
config.httplib["distributed_tracing"] = True
2222
patch(httplib=True)
23+
24+
from pytest import hookimpl
25+
26+
@hookimpl(hookwrapper=True)
27+
def pytest_terminal_summary(terminalreporter, exitstatus, config):
28+
yield # do normal output
29+
30+
ci_pipeline_id = os.getenv("GITHUB_RUN_ID", None)
31+
dd_service = os.getenv("DD_SERVICE", None)
32+
if ci_pipeline_id and dd_service:
33+
terminalreporter.ensure_newline()
34+
terminalreporter.section("test reports", purple=True, bold=True)
35+
terminalreporter.line(
36+
"* View test APM traces and detailed time reports on Datadog (can take a few minutes to become available):"
37+
)
38+
terminalreporter.line(
39+
"* https://app.datadoghq.com/ci/test-runs?query="
40+
"%40test.service%3A{}%20%40ci.pipeline.id%3A{}&index=citest".format(
41+
dd_service, ci_pipeline_id
42+
)
43+
)
44+
45+
2346
except ImportError:
2447
pass
2548

@@ -62,7 +85,10 @@ def pytest_bdd_before_step(request, feature, scenario, step, step_func):
6285

6386
context = tracer.get_call_context()
6487
span = tracer.start_span(
65-
step.type, resource=step.name, span_type=step.type, child_of=context,
88+
step.type,
89+
resource=step.name,
90+
span_type=step.type,
91+
child_of=context,
6692
)
6793
setattr(step_func, "__dd_span__", span)
6894

@@ -208,9 +234,11 @@ def context(vcr, unique, unique_lower, freezer):
208234
@pytest.fixture(scope="session")
209235
def record_mode(request):
210236
"""Manage compatibility with DD client libraries."""
211-
return {"false": "none", "true": "rewrite", "none": "new_episodes",}[
212-
os.getenv("RECORD", "false").lower()
213-
]
237+
return {
238+
"false": "none",
239+
"true": "rewrite",
240+
"none": "new_episodes",
241+
}[os.getenv("RECORD", "false").lower()]
214242

215243

216244
def _disable_recording():

0 commit comments

Comments
 (0)