Skip to content

Commit 37afe38

Browse files
authored
feat(ci-insights): Parse MERGIFY_TEST_FLAKY_DETECTION_ENABLED variable (#172)
This variable is used to set the `mergify.test.flaky_detection_enabled` field to OpenTelemetry spans. This field will then be used to know which user has configured flaky test detection. Fixes: MRGFY-5753
1 parent 750d416 commit 37afe38

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

pytest_mergify/resources/mergify.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ class MergifyResourceDetector(ResourceDetector):
77
"""Detects OpenTelemetry Resource attributes for Mergify fields."""
88

99
OPENTELEMETRY_MERGIFY_MAPPING = {
10+
"mergify.test.flaky_detection_enabled": (
11+
str,
12+
"MERGIFY_TEST_FLAKY_DETECTION_ENABLED",
13+
),
1014
"mergify.test.job.name": (str, "MERGIFY_TEST_JOB_NAME"),
1115
}
1216

tests/test_resources.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,15 @@ def test_span_resources_attributes_mergify(
3737
pytester_with_spans: conftest.PytesterWithSpanT,
3838
monkeypatch: pytest.MonkeyPatch,
3939
) -> None:
40+
monkeypatch.setenv("MERGIFY_TEST_FLAKY_DETECTION_ENABLED", "true")
4041
monkeypatch.setenv("MERGIFY_TEST_JOB_NAME", "f00b4r")
42+
4143
result, spans = pytester_with_spans()
4244
assert spans is not None
45+
assert all(
46+
span.resource.attributes["mergify.test.flaky_detection_enabled"] == "true"
47+
for span in spans.values()
48+
)
4349
assert all(
4450
span.resource.attributes["mergify.test.job.name"] == "f00b4r"
4551
for span in spans.values()

0 commit comments

Comments
 (0)