From ee34bef578b3374a6b1af7cbf364cd4c281a6c21 Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Tue, 20 Oct 2020 01:54:04 +0200 Subject: [PATCH 01/34] feat: pytest integration --- conftest.py | 3 + ddtrace/contrib/pytest/__init__.py | 103 ++++++++++++++++++++++++++++ ddtrace/ext/__init__.py | 1 + ddtrace/ext/ci.py | 24 +++++++ ddtrace/ext/test.py | 36 ++++++++++ setup.py | 3 +- tests/contrib/pytest/__init__.py | 0 tests/contrib/pytest/test_pytest.py | 86 +++++++++++++++++++++++ 8 files changed, 255 insertions(+), 1 deletion(-) create mode 100644 ddtrace/contrib/pytest/__init__.py create mode 100644 ddtrace/ext/ci.py create mode 100644 ddtrace/ext/test.py create mode 100644 tests/contrib/pytest/__init__.py create mode 100644 tests/contrib/pytest/test_pytest.py diff --git a/conftest.py b/conftest.py index 9e3fef991eb..df46253e3d3 100644 --- a/conftest.py +++ b/conftest.py @@ -11,6 +11,9 @@ import pytest +# DEV: Enable "testdir" fixture https://docs.pytest.org/en/stable/reference.html#testdir +pytest_plugins = "pytester" + PY_DIR_PATTERN = re.compile(r"^py[23][0-9]$") diff --git a/ddtrace/contrib/pytest/__init__.py b/ddtrace/contrib/pytest/__init__.py new file mode 100644 index 00000000000..93fff296ea2 --- /dev/null +++ b/ddtrace/contrib/pytest/__init__.py @@ -0,0 +1,103 @@ +import pytest + +from ddtrace.ext import SpanTypes, test + +from ...pin import Pin + +HELP_MSG = "Enable tracing of pytest functions." + + +def _extract_span(item): + """Extract span from `pytest.Item` instance.""" + return getattr(item, "_datadog_span", None) + + +def _store_span(item, span): + """Store span at `pytest.Item` instance.""" + setattr(item, "_datadog_span", span) + + +def pytest_addoption(parser): + """Add ddtrace options.""" + group = parser.getgroup("ddtrace") + + group._addoption( + "--ddtrace", + action="store_true", + dest="ddtrace", + default=False, + help=HELP_MSG, + ) + + parser.addini("ddtrace", HELP_MSG, type="bool") + + +def pytest_configure(config): + config.addinivalue_line("markers", "dd_tags(**kwargs): add tags to current span") + + if config.getoption("ddtrace", default=config.getini("ddtrace")): + Pin().onto(config) + + +def pytest_sessionfinish(session, exitstatus): + """Flush open tracer.""" + pin = Pin.get_from(session.config) + if pin is not None: + pin.tracer.shutdown() + + +@pytest.fixture(scope="function") +def ddspan(request): + pin = Pin.get_from(request.config) + if pin: + return _extract_span(request.node) + + +@pytest.hookimpl(tryfirst=True, hookwrapper=True) +def pytest_runtest_setup(item): + pin = Pin.get_from(item.config) + if pin: + span = pin.tracer.start_span(SpanTypes.TEST.value, resource=item.nodeid, span_type=SpanTypes.TEST.value) + + tags = [marker.kwargs for marker in item.iter_markers(name="dd_tags")] + for tag in tags: + for key, value in tag.items(): + span.set_tag(key, value) + + _store_span(item, span) + + yield + + +@pytest.hookimpl(hookwrapper=True) +def pytest_runtest_makereport(item, call): + """Store outcome for tracing.""" + outcome = yield + + span = _extract_span(item) + if span is None: + return + + if (call.when == "call" and span.get_tag(test.STATUS) is None) or ( + call.when == "setup" and call.excinfo is not None + ): + try: + result = outcome.get_result() + if result.skipped: + span.set_tag(test.STATUS, test.Status.SKIP.value) + elif result.passed: + span.set_tag(test.STATUS, test.Status.PASS.value) + else: + raise RuntimeWarning(result) + except Exception: + span.set_traceback() + span.set_tag(test.STATUS, test.Status.FAIL.value) + + +@pytest.hookimpl(hookwrapper=True) +def pytest_runtest_teardown(item, nextitem): + yield + + span = _extract_span(item) + if span: + span.finish() diff --git a/ddtrace/ext/__init__.py b/ddtrace/ext/__init__.py index d05d30392ae..c3c3758ee5f 100644 --- a/ddtrace/ext/__init__.py +++ b/ddtrace/ext/__init__.py @@ -14,6 +14,7 @@ class SpanTypes(Enum): REDIS = "redis" SQL = "sql" TEMPLATE = "template" + TEST = "test" WEB = "web" WORKER = "worker" diff --git a/ddtrace/ext/ci.py b/ddtrace/ext/ci.py new file mode 100644 index 00000000000..d72fc9bd1e9 --- /dev/null +++ b/ddtrace/ext/ci.py @@ -0,0 +1,24 @@ +""" +tags for common CI attributes +""" + +# Job URL +CI_JOB_URL = "ci.job.url" + +# Pipeline ID +CI_PIPELINE_ID = "ci.pipeline.id" + +# Pipeline Name +CI_PIPELINE_NAME = "ci.pipeline.name" + +# Pipeline Number +CI_PIPELINE_NUMBER = "ci.pipeline.number" + +# Pipeline URL +CI_PIPELINE_URL = "ci.pipeline.url" + +# Provider +CI_PROVIDER = "ci.provider.name" + +# Workspace Path +CI_WORKSPACE_PATH = "ci.workspace_path" diff --git a/ddtrace/ext/test.py b/ddtrace/ext/test.py new file mode 100644 index 00000000000..5062334d1b6 --- /dev/null +++ b/ddtrace/ext/test.py @@ -0,0 +1,36 @@ +""" +tags for common test attributes +""" + +from enum import Enum + +# Test Arguments +TEST_ARGUMENTS = "test.arguments" + +# Test Framework +TEST_FRAMEWORK = "test.framework" + +# Test Name +TEST_NAME = "test.name" + +# Skip Reason +TEST_SKIP_REASON = "test.skip_reason" + +# Test Status +TEST_STATUS = "test.status" +STATUS = TEST_STATUS + +# Test Suite +TEST_SUITE = "test.suite" + +# Traits +TEST_TRAITS = "test.traits" + +# Test Type +TEST_TYPE = "test.type" + + +class Status(Enum): + PASS = "pass" + FAIL = "fail" + SKIP = "skip" diff --git a/setup.py b/setup.py index 6d39d0b4305..08e05dfd8a5 100644 --- a/setup.py +++ b/setup.py @@ -165,7 +165,8 @@ def get_exts_for(name): "console_scripts": [ "ddtrace-run = ddtrace.commands.ddtrace_run:main", "pyddprofile = ddtrace.profiling.__main__:main", - ] + ], + "pytest11": ["ddtrace = ddtrace.contrib.pytest"], }, classifiers=[ "Programming Language :: Python", diff --git a/tests/contrib/pytest/__init__.py b/tests/contrib/pytest/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/contrib/pytest/test_pytest.py b/tests/contrib/pytest/test_pytest.py new file mode 100644 index 00000000000..eb23c09a093 --- /dev/null +++ b/tests/contrib/pytest/test_pytest.py @@ -0,0 +1,86 @@ +import os + +import pytest + +from ddtrace import Pin +from ddtrace.ext import test + +from ... import TracerTestCase + + +class TestPytest(TracerTestCase): + @pytest.fixture(autouse=True) + def initdir(self, testdir): + self.testdir = testdir + + def inline_run(self, *args): + """Execute test script with test tracer.""" + + class PinTracer: + @staticmethod + def pytest_configure(config): + Pin.override(config, tracer=self.tracer) + + return self.testdir.inline_run(*args, plugins=(PinTracer(),)) + + def test_parameterize_case(self): + """Test parametrize case.""" + py_file = self.testdir.makepyfile( + """ + import pytest + + @pytest.mark.parametrize('abc', [1, 2, 3, 4, pytest.param(5, marks=pytest.mark.skip)]) + class Test1(object): + def test_1(self, abc): + assert abc in {1, 2, 3} + """ + ) + file_name = os.path.basename(py_file.strpath) + rec = self.inline_run("--ddtrace", file_name) + rec.assertoutcome(passed=3, failed=1, skipped=1) + spans = self.tracer.writer.pop() + + assert len(spans) == 5 + + def test_skip(self): + """Test parametrize case.""" + py_file = self.testdir.makepyfile( + """ + import pytest + + @pytest.mark.skip(reason="decorator") + def test_decorator(): + pass + + def test_body(): + pytest.skip("body") + """ + ) + file_name = os.path.basename(py_file.strpath) + rec = self.inline_run("--ddtrace", file_name) + rec.assertoutcome(skipped=2) + spans = self.tracer.writer.pop() + + assert len(spans) == 2 + assert spans[0].get_tag(test.STATUS) == test.Status.SKIP.value + assert spans[1].get_tag(test.STATUS) == test.Status.SKIP.value + + def test_fixture(self): + """Test ddspan fixture.""" + py_file = self.testdir.makepyfile( + """ + import pytest + + def test_fixture(ddspan): + assert ddspan is not None + ddspan.set_tag("world", "hello") + """ + ) + file_name = os.path.basename(py_file.strpath) + rec = self.inline_run("--ddtrace", file_name) + rec.assertoutcome(passed=1) + spans = self.tracer.writer.pop() + + assert len(spans) == 1 + assert spans[0].get_tag("world") == "hello" + assert spans[0].get_tag(test.STATUS) == test.Status.PASS.value From 6ade010acdc55f57bc54d49eb39e7f172181765d Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Tue, 20 Oct 2020 12:55:47 +0200 Subject: [PATCH 02/34] add skip reason --- ddtrace/contrib/pytest/__init__.py | 19 ++++++++++++++++++- ddtrace/ext/test.py | 17 ++++++++--------- tests/contrib/pytest/test_pytest.py | 2 ++ 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/ddtrace/contrib/pytest/__init__.py b/ddtrace/contrib/pytest/__init__.py index 93fff296ea2..d632e33f122 100644 --- a/ddtrace/contrib/pytest/__init__.py +++ b/ddtrace/contrib/pytest/__init__.py @@ -1,10 +1,17 @@ import pytest +from _pytest.skipping import evaluate_skip_marks from ddtrace.ext import SpanTypes, test from ...pin import Pin HELP_MSG = "Enable tracing of pytest functions." +FRAMEWORK = "pytest" + + +def is_enabled(config): + """Check if the ddtrace plugin is enabled.""" + return config.getoption("ddtrace", default=config.getini("ddtrace")) def _extract_span(item): @@ -35,7 +42,7 @@ def pytest_addoption(parser): def pytest_configure(config): config.addinivalue_line("markers", "dd_tags(**kwargs): add tags to current span") - if config.getoption("ddtrace", default=config.getini("ddtrace")): + if is_enabled(config): Pin().onto(config) @@ -59,6 +66,11 @@ def pytest_runtest_setup(item): if pin: span = pin.tracer.start_span(SpanTypes.TEST.value, resource=item.nodeid, span_type=SpanTypes.TEST.value) + span.set_tag(test.FRAMEWORK, FRAMEWORK) + span.set_tag(test.NAME, item.name) + span.set_tag(test.SUITE, item.module.__name__) + span.set_tag(test.TYPE, SpanTypes.TEST.value) + tags = [marker.kwargs for marker in item.iter_markers(name="dd_tags")] for tag in tags: for key, value in tag.items(): @@ -85,6 +97,11 @@ def pytest_runtest_makereport(item, call): result = outcome.get_result() if result.skipped: span.set_tag(test.STATUS, test.Status.SKIP.value) + skip = evaluate_skip_marks(item) + if skip is None and call.excinfo is not None: + span.set_tag(test.SKIP_REASON, call.excinfo.value) + elif skip is not None: + span.set_tag(test.SKIP_REASON, skip.reason) elif result.passed: span.set_tag(test.STATUS, test.Status.PASS.value) else: diff --git a/ddtrace/ext/test.py b/ddtrace/ext/test.py index 5062334d1b6..c25a336c727 100644 --- a/ddtrace/ext/test.py +++ b/ddtrace/ext/test.py @@ -5,29 +5,28 @@ from enum import Enum # Test Arguments -TEST_ARGUMENTS = "test.arguments" +ARGUMENTS = TEST_ARGUMENTS = "test.arguments" # Test Framework -TEST_FRAMEWORK = "test.framework" +FRAMEWORK = TEST_FRAMEWORK = "test.framework" # Test Name -TEST_NAME = "test.name" +NAME = TEST_NAME = "test.name" # Skip Reason -TEST_SKIP_REASON = "test.skip_reason" +SKIP_REASON = TEST_SKIP_REASON = "test.skip_reason" # Test Status -TEST_STATUS = "test.status" -STATUS = TEST_STATUS +STATUS = TEST_STATUS = "test.status" # Test Suite -TEST_SUITE = "test.suite" +SUITE = TEST_SUITE = "test.suite" # Traits -TEST_TRAITS = "test.traits" +TRAITS = TEST_TRAITS = "test.traits" # Test Type -TEST_TYPE = "test.type" +TYPE = TEST_TYPE = "test.type" class Status(Enum): diff --git a/tests/contrib/pytest/test_pytest.py b/tests/contrib/pytest/test_pytest.py index eb23c09a093..5ec92d115d9 100644 --- a/tests/contrib/pytest/test_pytest.py +++ b/tests/contrib/pytest/test_pytest.py @@ -63,7 +63,9 @@ def test_body(): assert len(spans) == 2 assert spans[0].get_tag(test.STATUS) == test.Status.SKIP.value + assert spans[0].get_tag(test.SKIP_REASON) == "decorator" assert spans[1].get_tag(test.STATUS) == test.Status.SKIP.value + assert spans[1].get_tag(test.SKIP_REASON) == "body" def test_fixture(self): """Test ddspan fixture.""" From 279148c054bfa5b18b2af967bea747089ff377c9 Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Tue, 20 Oct 2020 13:07:14 +0200 Subject: [PATCH 03/34] add release notes --- releasenotes/notes/pytest-d174e595f0c8abd0.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 releasenotes/notes/pytest-d174e595f0c8abd0.yaml diff --git a/releasenotes/notes/pytest-d174e595f0c8abd0.yaml b/releasenotes/notes/pytest-d174e595f0c8abd0.yaml new file mode 100644 index 00000000000..85c17c6cd36 --- /dev/null +++ b/releasenotes/notes/pytest-d174e595f0c8abd0.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + pytest integration. + This enables the `pytest `_ runner to trace test executions. From 093088e7f18db93ecdc6b4292b369dbe2dda0e89 Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Tue, 20 Oct 2020 13:44:34 +0200 Subject: [PATCH 04/34] move to plugin and add analytics sample rate --- conftest.py | 2 +- ddtrace/contrib/pytest/__init__.py | 120 -------------------------- ddtrace/contrib/pytest/constants.py | 3 + ddtrace/contrib/pytest/plugin.py | 128 ++++++++++++++++++++++++++++ setup.py | 2 +- 5 files changed, 133 insertions(+), 122 deletions(-) create mode 100644 ddtrace/contrib/pytest/constants.py create mode 100644 ddtrace/contrib/pytest/plugin.py diff --git a/conftest.py b/conftest.py index df46253e3d3..fbec4f44e2d 100644 --- a/conftest.py +++ b/conftest.py @@ -12,7 +12,7 @@ import pytest # DEV: Enable "testdir" fixture https://docs.pytest.org/en/stable/reference.html#testdir -pytest_plugins = "pytester" +pytest_plugins = ("pytester",) PY_DIR_PATTERN = re.compile(r"^py[23][0-9]$") diff --git a/ddtrace/contrib/pytest/__init__.py b/ddtrace/contrib/pytest/__init__.py index d632e33f122..e69de29bb2d 100644 --- a/ddtrace/contrib/pytest/__init__.py +++ b/ddtrace/contrib/pytest/__init__.py @@ -1,120 +0,0 @@ -import pytest -from _pytest.skipping import evaluate_skip_marks - -from ddtrace.ext import SpanTypes, test - -from ...pin import Pin - -HELP_MSG = "Enable tracing of pytest functions." -FRAMEWORK = "pytest" - - -def is_enabled(config): - """Check if the ddtrace plugin is enabled.""" - return config.getoption("ddtrace", default=config.getini("ddtrace")) - - -def _extract_span(item): - """Extract span from `pytest.Item` instance.""" - return getattr(item, "_datadog_span", None) - - -def _store_span(item, span): - """Store span at `pytest.Item` instance.""" - setattr(item, "_datadog_span", span) - - -def pytest_addoption(parser): - """Add ddtrace options.""" - group = parser.getgroup("ddtrace") - - group._addoption( - "--ddtrace", - action="store_true", - dest="ddtrace", - default=False, - help=HELP_MSG, - ) - - parser.addini("ddtrace", HELP_MSG, type="bool") - - -def pytest_configure(config): - config.addinivalue_line("markers", "dd_tags(**kwargs): add tags to current span") - - if is_enabled(config): - Pin().onto(config) - - -def pytest_sessionfinish(session, exitstatus): - """Flush open tracer.""" - pin = Pin.get_from(session.config) - if pin is not None: - pin.tracer.shutdown() - - -@pytest.fixture(scope="function") -def ddspan(request): - pin = Pin.get_from(request.config) - if pin: - return _extract_span(request.node) - - -@pytest.hookimpl(tryfirst=True, hookwrapper=True) -def pytest_runtest_setup(item): - pin = Pin.get_from(item.config) - if pin: - span = pin.tracer.start_span(SpanTypes.TEST.value, resource=item.nodeid, span_type=SpanTypes.TEST.value) - - span.set_tag(test.FRAMEWORK, FRAMEWORK) - span.set_tag(test.NAME, item.name) - span.set_tag(test.SUITE, item.module.__name__) - span.set_tag(test.TYPE, SpanTypes.TEST.value) - - tags = [marker.kwargs for marker in item.iter_markers(name="dd_tags")] - for tag in tags: - for key, value in tag.items(): - span.set_tag(key, value) - - _store_span(item, span) - - yield - - -@pytest.hookimpl(hookwrapper=True) -def pytest_runtest_makereport(item, call): - """Store outcome for tracing.""" - outcome = yield - - span = _extract_span(item) - if span is None: - return - - if (call.when == "call" and span.get_tag(test.STATUS) is None) or ( - call.when == "setup" and call.excinfo is not None - ): - try: - result = outcome.get_result() - if result.skipped: - span.set_tag(test.STATUS, test.Status.SKIP.value) - skip = evaluate_skip_marks(item) - if skip is None and call.excinfo is not None: - span.set_tag(test.SKIP_REASON, call.excinfo.value) - elif skip is not None: - span.set_tag(test.SKIP_REASON, skip.reason) - elif result.passed: - span.set_tag(test.STATUS, test.Status.PASS.value) - else: - raise RuntimeWarning(result) - except Exception: - span.set_traceback() - span.set_tag(test.STATUS, test.Status.FAIL.value) - - -@pytest.hookimpl(hookwrapper=True) -def pytest_runtest_teardown(item, nextitem): - yield - - span = _extract_span(item) - if span: - span.finish() diff --git a/ddtrace/contrib/pytest/constants.py b/ddtrace/contrib/pytest/constants.py new file mode 100644 index 00000000000..eb17fb79728 --- /dev/null +++ b/ddtrace/contrib/pytest/constants.py @@ -0,0 +1,3 @@ +FRAMEWORK = "pytest" + +HELP_MSG = "Enable tracing of pytest functions." diff --git a/ddtrace/contrib/pytest/plugin.py b/ddtrace/contrib/pytest/plugin.py new file mode 100644 index 00000000000..012f8012046 --- /dev/null +++ b/ddtrace/contrib/pytest/plugin.py @@ -0,0 +1,128 @@ +import pytest +from _pytest.skipping import evaluate_skip_marks + +from ddtrace.constants import ANALYTICS_SAMPLE_RATE_KEY +from ddtrace.ext import SpanTypes, test + +from ...pin import Pin +from .constants import FRAMEWORK, HELP_MSG + + +def is_enabled(config): + """Check if the ddtrace plugin is enabled.""" + return config.getoption("ddtrace", default=config.getini("ddtrace")) + + +def _extract_span(item): + """Extract span from `pytest.Item` instance.""" + return getattr(item, "_datadog_span", None) + + +def _store_span(item, span): + """Store span at `pytest.Item` instance.""" + setattr(item, "_datadog_span", span) + + +def pytest_addoption(parser): + """Add ddtrace options.""" + group = parser.getgroup("ddtrace") + + group._addoption( + "--ddtrace", + action="store_true", + dest="ddtrace", + default=False, + help=HELP_MSG, + ) + + parser.addini("ddtrace", HELP_MSG, type="bool") + + +def pytest_configure(config): + config.addinivalue_line("markers", "dd_tags(**kwargs): add tags to current span") + + if is_enabled(config): + Pin().onto(config) + + +def pytest_sessionfinish(session, exitstatus): + """Flush open tracer.""" + pin = Pin.get_from(session.config) + if pin is not None: + pin.tracer.shutdown() + + +@pytest.fixture(scope="function") +def ddspan(request): + pin = Pin.get_from(request.config) + if pin: + return _extract_span(request.node) + + +@pytest.hookimpl(tryfirst=True, hookwrapper=True) +def pytest_runtest_setup(item): + pin = Pin.get_from(item.config) + if pin: + span = pin.tracer.start_span(SpanTypes.TEST.value, resource=item.nodeid, span_type=SpanTypes.TEST.value) + + span.set_tag(ANALYTICS_SAMPLE_RATE_KEY, True) + span.set_tag(test.FRAMEWORK, FRAMEWORK) + span.set_tag(test.NAME, item.name) + span.set_tag(test.SUITE, item.module.__name__) + span.set_tag(test.TYPE, SpanTypes.TEST.value) + + tags = [marker.kwargs for marker in item.iter_markers(name="dd_tags")] + for tag in tags: + for key, value in tag.items(): + span.set_tag(key, value) + + _store_span(item, span) + + yield + + +def _extract_reason(item, call): + skip = evaluate_skip_marks(item) + if skip is None and call.excinfo is not None: + return call.excinfo.value + elif skip is not None: + return skip.reason + + +@pytest.hookimpl(hookwrapper=True) +def pytest_runtest_makereport(item, call): + """Store outcome for tracing.""" + outcome = yield + + span = _extract_span(item) + if span is None: + return + + called_without_status = call.when == "call" and span.get_tag(test.STATUS) is None + failed_setup = call.when == "setup" and call.excinfo is not None + if not called_without_status and not failed_setup: + return + + try: + result = outcome.get_result() + if result.skipped: + span.set_tag(test.STATUS, test.Status.SKIP.value) + reason = _extract_reason(item, call) + if reason is not None: + span.set_tag(test.SKIP_REASON, reason) + elif result.passed: + span.set_tag(test.STATUS, test.Status.PASS.value) + else: + raise RuntimeWarning(result) + except Exception: + span.set_traceback() + span.set_tag(test.STATUS, test.Status.FAIL.value) + + +@pytest.hookimpl(hookwrapper=True) +def pytest_runtest_teardown(item, nextitem): + yield + + span = _extract_span(item) + if span: + span.finish() diff --git a/setup.py b/setup.py index 08e05dfd8a5..f52d9283fa7 100644 --- a/setup.py +++ b/setup.py @@ -166,7 +166,7 @@ def get_exts_for(name): "ddtrace-run = ddtrace.commands.ddtrace_run:main", "pyddprofile = ddtrace.profiling.__main__:main", ], - "pytest11": ["ddtrace = ddtrace.contrib.pytest"], + "pytest11": ["ddtrace = ddtrace.contrib.pytest.plugin"], }, classifiers=[ "Programming Language :: Python", From 7a8384e0adbd9149031b940a803195e43ec2b0e3 Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Tue, 20 Oct 2020 16:38:22 +0200 Subject: [PATCH 05/34] update ci matrix --- .circleci/config.yml | 8 +++++++- ddtrace/contrib/pytest/plugin.py | 6 +----- tests/contrib/pytest/test_pytest.py | 2 +- tox.ini | 15 ++++++++++----- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 924cc0ec440..184cbb78445 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -548,6 +548,12 @@ jobs: - run_tox_scenario: pattern: '^pylibmc_contrib-' + pytest: + executor: ddtrace_dev + steps: + - run_tox_scenario: + pattern: '^pytest_contrib' + pymemcache: executor: ddtrace_dev docker: @@ -615,7 +621,7 @@ jobs: steps: - run_tox_scenario: pattern: '^sanic_contrib-' - + starlette: executor: ddtrace_dev steps: diff --git a/ddtrace/contrib/pytest/plugin.py b/ddtrace/contrib/pytest/plugin.py index 012f8012046..fe6b2e227d0 100644 --- a/ddtrace/contrib/pytest/plugin.py +++ b/ddtrace/contrib/pytest/plugin.py @@ -1,5 +1,4 @@ import pytest -from _pytest.skipping import evaluate_skip_marks from ddtrace.constants import ANALYTICS_SAMPLE_RATE_KEY from ddtrace.ext import SpanTypes, test @@ -82,11 +81,8 @@ def pytest_runtest_setup(item): def _extract_reason(item, call): - skip = evaluate_skip_marks(item) - if skip is None and call.excinfo is not None: + if call.excinfo is not None: return call.excinfo.value - elif skip is not None: - return skip.reason @pytest.hookimpl(hookwrapper=True) diff --git a/tests/contrib/pytest/test_pytest.py b/tests/contrib/pytest/test_pytest.py index 5ec92d115d9..e237e6bb946 100644 --- a/tests/contrib/pytest/test_pytest.py +++ b/tests/contrib/pytest/test_pytest.py @@ -21,7 +21,7 @@ class PinTracer: def pytest_configure(config): Pin.override(config, tracer=self.tracer) - return self.testdir.inline_run(*args, plugins=(PinTracer(),)) + return self.testdir.inline_run(*args, plugins=[PinTracer()]) def test_parameterize_case(self): """Test parametrize case.""" diff --git a/tox.ini b/tox.ini index 68fa3b09f6c..3c3f75f182c 100644 --- a/tox.ini +++ b/tox.ini @@ -53,10 +53,10 @@ envlist = # 4.x celery bumps kombu to 4.4+, which requires redis 3.2 or later, this tests against # older redis with an older kombu, and newer kombu/newer redis. # https://github.com/celery/kombu/blob/3e60e6503a77b9b1a987cf7954659929abac9bac/Changelog#L35 - celery_contrib-py{27,35,36}-celery{40,41}-{redis210-kombu43,redis32-kombu44} + celery_contrib-py{27,35,36}-celery{40,41}-{redis210-kombu43,redis32-kombu44}-pytest3 # Celery 4.2 is now limited to Kombu 4.3 # https://github.com/celery/celery/commit/1571d414461f01ae55be63a03e2adaa94dbcb15d - celery_contrib-py{27,35,36}-celery42-redis210-kombu43 + celery_contrib-py{27,35,36}-celery42-redis210-kombu43-pytest3 # Celery 4.3 wants Kombu >= 4.4 and Redis >= 3.2 # Python 3.7 needs Celery 4.3 celery_contrib-py{27,35,36,37,38}-celery43-redis32-kombu44 @@ -131,6 +131,8 @@ envlist = pymysql_contrib-py{27,35,36,37,38}-pymysql{07,08,09,} pynamodb_contrib-{py27,py35,py36,py37,py38}-pynamodb{40,41,42,43,}-moto1 pyodbc_contrib-py{27,35,36,37,38}-pyodbc{3,4} + pytest_contrib-py27-pytest4 + pytest_contrib-py{35,36,37,38}-pytest{4,5,6,} pyramid_contrib{,_autopatch}-py{27,35,36,37,38}-pyramid{17,18,19,110,}-webtest redis_contrib-py{27,35,36,37,38}-redis{210,30,32,33,34,35,} rediscluster_contrib-py{27,35,36,37,38}-rediscluster{135,136,200,}-redis210 @@ -180,9 +182,6 @@ extras = deps = cython -# use pytest >= 3 for all but celery versions - !celery40-!celery41-!celery42: pytest>=3 - celery40,celery41,celery42: pytest>=3,<4 pytest-mock opentracing # test dependencies installed in all envs @@ -433,6 +432,11 @@ deps = pyodbc: pyodbc pyodbc4: pyodbc>=4.0,<5.0 pyodbc3: pyodbc>=3.0,<4.0 + pytest: pytest>=3 + pytest3: pytest>=3.0,<4.0 + pytest4: pytest==4.6 # last 2.7 and 3.4 + pytest5: pytest>=5.0,<6.0 + pytest6: pytest>=6.0,<7.0 redis: redis redis210: redis>=2.10,<2.11 redis30: redis>=3.0,<3.1 @@ -551,6 +555,7 @@ commands = pymysql_contrib: pytest {posargs} tests/contrib/pymysql pynamodb_contrib: pytest {posargs} tests/contrib/pynamodb pyodbc_contrib: pytest {posargs} tests/contrib/pyodbc + pytest_contrib: pytest {posargs} tests/contrib/pytest pyramid_contrib: pytest {posargs} tests/contrib/pyramid/test_pyramid.py pyramid_contrib_autopatch: python tests/ddtrace_run.py pytest {posargs} tests/contrib/pyramid/test_pyramid_autopatch.py redis_contrib: pytest {posargs} tests/contrib/redis From e0e127edad5f84adf79c00458ffbee987fcd3b1d Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Tue, 20 Oct 2020 17:09:38 +0200 Subject: [PATCH 06/34] use pytest_runtest_protocol --- ddtrace/contrib/pytest/plugin.py | 20 +++++++------------- tests/contrib/pytest/test_pytest.py | 20 +++++++++++++++++++- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/ddtrace/contrib/pytest/plugin.py b/ddtrace/contrib/pytest/plugin.py index fe6b2e227d0..4ab460e5a21 100644 --- a/ddtrace/contrib/pytest/plugin.py +++ b/ddtrace/contrib/pytest/plugin.py @@ -59,10 +59,13 @@ def ddspan(request): @pytest.hookimpl(tryfirst=True, hookwrapper=True) -def pytest_runtest_setup(item): +def pytest_runtest_protocol(item, nextitem): pin = Pin.get_from(item.config) - if pin: - span = pin.tracer.start_span(SpanTypes.TEST.value, resource=item.nodeid, span_type=SpanTypes.TEST.value) + if pin is None: + yield + return + + with pin.tracer.trace(SpanTypes.TEST.value, resource=item.nodeid, span_type=SpanTypes.TEST.value) as span: span.set_tag(ANALYTICS_SAMPLE_RATE_KEY, True) span.set_tag(test.FRAMEWORK, FRAMEWORK) @@ -77,7 +80,7 @@ def pytest_runtest_setup(item): _store_span(item, span) - yield + yield def _extract_reason(item, call): @@ -113,12 +116,3 @@ def pytest_runtest_makereport(item, call): except Exception: span.set_traceback() span.set_tag(test.STATUS, test.Status.FAIL.value) - - -@pytest.hookimpl(hookwrapper=True) -def pytest_runtest_teardown(item, nextitem): - yield - - span = _extract_span(item) - if span: - span.finish() diff --git a/tests/contrib/pytest/test_pytest.py b/tests/contrib/pytest/test_pytest.py index e237e6bb946..92ca9811d60 100644 --- a/tests/contrib/pytest/test_pytest.py +++ b/tests/contrib/pytest/test_pytest.py @@ -19,10 +19,28 @@ def inline_run(self, *args): class PinTracer: @staticmethod def pytest_configure(config): - Pin.override(config, tracer=self.tracer) + if Pin.get_from(config) is not None: + Pin.override(config, tracer=self.tracer) return self.testdir.inline_run(*args, plugins=[PinTracer()]) + def test_disabled(self): + """Test without --ddtrace.""" + py_file = self.testdir.makepyfile( + """ + import pytest + + def test_no_trace(ddspan): + assert ddspan is None + """ + ) + file_name = os.path.basename(py_file.strpath) + rec = self.inline_run(file_name) + rec.assertoutcome(passed=1) + spans = self.tracer.writer.pop() + + assert len(spans) == 0 + def test_parameterize_case(self): """Test parametrize case.""" py_file = self.testdir.makepyfile( From b73b909948be33541ce97665515d566ac67badcc Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Tue, 20 Oct 2020 17:12:01 +0200 Subject: [PATCH 07/34] add pytest to circleci --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 184cbb78445..2d060aa9950 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -959,6 +959,7 @@ workflows: - pynamodb: *requires_pre_test - pyodbc: *requires_pre_test - pyramid: *requires_pre_test + - pytest: *requires_pre_test - redis: *requires_pre_test - rediscluster: *requires_pre_test - requests: *requires_pre_test From 617059cf82840539a315f1484fa0c6fcd52fde03 Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Tue, 20 Oct 2020 17:54:48 +0200 Subject: [PATCH 08/34] use config for analytics --- ddtrace/contrib/pytest/__init__.py | 4 ++++ ddtrace/contrib/pytest/plugin.py | 8 +++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ddtrace/contrib/pytest/__init__.py b/ddtrace/contrib/pytest/__init__.py index e69de29bb2d..c66bba71a2f 100644 --- a/ddtrace/contrib/pytest/__init__.py +++ b/ddtrace/contrib/pytest/__init__.py @@ -0,0 +1,4 @@ +from ddtrace import config + +# pytest default settings +config._add("pytest", {}) diff --git a/ddtrace/contrib/pytest/plugin.py b/ddtrace/contrib/pytest/plugin.py index 4ab460e5a21..c7c2bdfafa9 100644 --- a/ddtrace/contrib/pytest/plugin.py +++ b/ddtrace/contrib/pytest/plugin.py @@ -1,8 +1,8 @@ import pytest -from ddtrace.constants import ANALYTICS_SAMPLE_RATE_KEY -from ddtrace.ext import SpanTypes, test +from ddtrace import config as ddconfig +from ...ext import SpanTypes, test from ...pin import Pin from .constants import FRAMEWORK, HELP_MSG @@ -41,7 +41,7 @@ def pytest_configure(config): config.addinivalue_line("markers", "dd_tags(**kwargs): add tags to current span") if is_enabled(config): - Pin().onto(config) + Pin(_config=ddconfig.pytest).onto(config) def pytest_sessionfinish(session, exitstatus): @@ -66,8 +66,6 @@ def pytest_runtest_protocol(item, nextitem): return with pin.tracer.trace(SpanTypes.TEST.value, resource=item.nodeid, span_type=SpanTypes.TEST.value) as span: - - span.set_tag(ANALYTICS_SAMPLE_RATE_KEY, True) span.set_tag(test.FRAMEWORK, FRAMEWORK) span.set_tag(test.NAME, item.name) span.set_tag(test.SUITE, item.module.__name__) From 9a7b1fecea4ce026afa5ce90690d97ef5aca52d3 Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Wed, 21 Oct 2020 16:57:23 +0200 Subject: [PATCH 09/34] add support for ci and git tags --- ddtrace/contrib/pytest/plugin.py | 11 +-- ddtrace/ext/ci.py | 24 ------ ddtrace/ext/ci/__init__.py | 24 ++++++ ddtrace/ext/ci/services/__init__.py | 0 ddtrace/ext/ci/services/appveyor.py | 20 +++++ ddtrace/ext/ci/services/azure_pipelines.py | 29 +++++++ ddtrace/ext/ci/services/bitbucket.py | 16 ++++ ddtrace/ext/ci/services/buildkite.py | 18 +++++ ddtrace/ext/ci/services/circle_ci.py | 17 ++++ ddtrace/ext/ci/services/github_actions.py | 18 +++++ ddtrace/ext/ci/services/gitlab.py | 19 +++++ ddtrace/ext/ci/services/jenkins.py | 24 ++++++ ddtrace/ext/ci/services/teamcity.py | 21 +++++ ddtrace/ext/ci/services/travis.py | 19 +++++ ddtrace/ext/git.py | 15 ++++ ddtrace/ext/provider.py | 90 ++++++++++++++++++++++ tests/tracer/test_ext.py | 14 ++++ 17 files changed, 350 insertions(+), 29 deletions(-) delete mode 100644 ddtrace/ext/ci.py create mode 100644 ddtrace/ext/ci/__init__.py create mode 100644 ddtrace/ext/ci/services/__init__.py create mode 100644 ddtrace/ext/ci/services/appveyor.py create mode 100644 ddtrace/ext/ci/services/azure_pipelines.py create mode 100644 ddtrace/ext/ci/services/bitbucket.py create mode 100644 ddtrace/ext/ci/services/buildkite.py create mode 100644 ddtrace/ext/ci/services/circle_ci.py create mode 100644 ddtrace/ext/ci/services/github_actions.py create mode 100644 ddtrace/ext/ci/services/gitlab.py create mode 100644 ddtrace/ext/ci/services/jenkins.py create mode 100644 ddtrace/ext/ci/services/teamcity.py create mode 100644 ddtrace/ext/ci/services/travis.py create mode 100644 ddtrace/ext/git.py create mode 100644 ddtrace/ext/provider.py diff --git a/ddtrace/contrib/pytest/plugin.py b/ddtrace/contrib/pytest/plugin.py index c7c2bdfafa9..6b07ec57917 100644 --- a/ddtrace/contrib/pytest/plugin.py +++ b/ddtrace/contrib/pytest/plugin.py @@ -3,6 +3,7 @@ from ddtrace import config as ddconfig from ...ext import SpanTypes, test +from ...ext.provider import Provider from ...pin import Pin from .constants import FRAMEWORK, HELP_MSG @@ -41,7 +42,7 @@ def pytest_configure(config): config.addinivalue_line("markers", "dd_tags(**kwargs): add tags to current span") if is_enabled(config): - Pin(_config=ddconfig.pytest).onto(config) + Pin(tags=Provider.from_env().astags(), _config=ddconfig.pytest).onto(config) def pytest_sessionfinish(session, exitstatus): @@ -66,15 +67,15 @@ def pytest_runtest_protocol(item, nextitem): return with pin.tracer.trace(SpanTypes.TEST.value, resource=item.nodeid, span_type=SpanTypes.TEST.value) as span: + span.set_tags(pin.tags) span.set_tag(test.FRAMEWORK, FRAMEWORK) span.set_tag(test.NAME, item.name) span.set_tag(test.SUITE, item.module.__name__) span.set_tag(test.TYPE, SpanTypes.TEST.value) - tags = [marker.kwargs for marker in item.iter_markers(name="dd_tags")] - for tag in tags: - for key, value in tag.items(): - span.set_tag(key, value) + markers = [marker.kwargs for marker in item.iter_markers(name="dd_tags")] + for tags in markers: + span.set_tags(tags) _store_span(item, span) diff --git a/ddtrace/ext/ci.py b/ddtrace/ext/ci.py deleted file mode 100644 index d72fc9bd1e9..00000000000 --- a/ddtrace/ext/ci.py +++ /dev/null @@ -1,24 +0,0 @@ -""" -tags for common CI attributes -""" - -# Job URL -CI_JOB_URL = "ci.job.url" - -# Pipeline ID -CI_PIPELINE_ID = "ci.pipeline.id" - -# Pipeline Name -CI_PIPELINE_NAME = "ci.pipeline.name" - -# Pipeline Number -CI_PIPELINE_NUMBER = "ci.pipeline.number" - -# Pipeline URL -CI_PIPELINE_URL = "ci.pipeline.url" - -# Provider -CI_PROVIDER = "ci.provider.name" - -# Workspace Path -CI_WORKSPACE_PATH = "ci.workspace_path" diff --git a/ddtrace/ext/ci/__init__.py b/ddtrace/ext/ci/__init__.py new file mode 100644 index 00000000000..342c867ccab --- /dev/null +++ b/ddtrace/ext/ci/__init__.py @@ -0,0 +1,24 @@ +""" +tags for common CI attributes +""" + +# Job URL +JOB_URL = "ci.job.url" + +# Pipeline ID +PIPELINE_ID = "ci.pipeline.id" + +# Pipeline Name +PIPELINE_NAME = "ci.pipeline.name" + +# Pipeline Number +PIPELINE_NUMBER = "ci.pipeline.number" + +# Pipeline URL +PIPELINE_URL = "ci.pipeline.url" + +# Provider +PROVIDER_NAME = "ci.provider.name" + +# Workspace Path +WORKSPACE_PATH = "ci.workspace_path" diff --git a/ddtrace/ext/ci/services/__init__.py b/ddtrace/ext/ci/services/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/ddtrace/ext/ci/services/appveyor.py b/ddtrace/ext/ci/services/appveyor.py new file mode 100644 index 00000000000..2380abb0949 --- /dev/null +++ b/ddtrace/ext/ci/services/appveyor.py @@ -0,0 +1,20 @@ +ENV_KEY = "APPVEYOR" + + +def match(env): + return env.get(ENV_KEY) is not None + + +def extract(env): + return dict( + provider_name="appveyor", + repository_url=env.get("APPVEYOR_REPO_NAME"), + commit_sha=env.get("APPVEYOR_REPO_COMMIT"), + workspace_path=env.get("APPVEYOR_BUILD_FOLDER"), + pipeline_id=env.get("APPVEYOR_BUILD_ID"), + pipeline_number=env.get("APPVEYOR_BUILD_NUMBER"), + pipeline_url="https://ci.appveyor.com/project/{0}/builds/{1}".format( + env.get("APPVEYOR_PROJECT_SLUG"), env.get("APPVEYOR_BUILD_ID") + ), + branch=env.get("APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH") or env.get("APPVEYOR_REPO_BRANCH"), + ) diff --git a/ddtrace/ext/ci/services/azure_pipelines.py b/ddtrace/ext/ci/services/azure_pipelines.py new file mode 100644 index 00000000000..08aa743527a --- /dev/null +++ b/ddtrace/ext/ci/services/azure_pipelines.py @@ -0,0 +1,29 @@ +ENV_KEY = "TF_BUILD" + + +def match(env): + return env.get(ENV_KEY) is not None + + +def extract(env): + return dict( + provider_name="azurepipelines", + workspace_path=env.get("BUILD_SOURCESDIRECTORY"), + pipeline_id=env.get("BUILD_BUILDID"), + pipeline_name=env.get("BUILD_DEFINITIONNAME"), + pipeline_number=env.get("BUILD_BUILDNUMBER"), + pipeline_url=all( + (env.get("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"), env.get("SYSTEM_TEAMPROJECT"), env.get("BUILD_BUILDID")) + ) + and "{0}{1}/_build/results?buildId={2}&_a=summary".format( + env.get("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"), env.get("SYSTEM_TEAMPROJECT"), env.get("BUILD_BUILDID") + ) + or None, + repository_url=env.get("BUILD_REPOSITORY_URI"), + commit_sha=env.get("SYSTEM_PULLREQUEST_SOURCECOMMITID") or env.get("BUILD_SOURCEVERSION"), + branch=( + env.get("SYSTEM_PULLREQUEST_SOURCEBRANCH") + or env.get("BUILD_SOURCEBRANCH") + or env.get("BUILD_SOURCEBRANCHNAME") + ), + ) diff --git a/ddtrace/ext/ci/services/bitbucket.py b/ddtrace/ext/ci/services/bitbucket.py new file mode 100644 index 00000000000..c3eff7002d4 --- /dev/null +++ b/ddtrace/ext/ci/services/bitbucket.py @@ -0,0 +1,16 @@ +ENV_KEY = "BITBUCKET_COMMIT" + + +def match(env): + return env.get(ENV_KEY) is not None + + +def extract(env): + return dict( + provider_name="bitbucketpipelines", + repository_url=env.get("BITBUCKET_GIT_SSH_ORIGIN"), + commit_sha=env.get("BITBUCKET_COMMIT"), + workspace_path=env.get("BITBUCKET_CLONE_DIR"), + pipeline_id=env.get("BITBUCKET_PIPELINE_UUID"), + pipeline_number=env.get("BITBUCKET_BUILD_NUMBER"), + ) diff --git a/ddtrace/ext/ci/services/buildkite.py b/ddtrace/ext/ci/services/buildkite.py new file mode 100644 index 00000000000..8150a92ee1f --- /dev/null +++ b/ddtrace/ext/ci/services/buildkite.py @@ -0,0 +1,18 @@ +ENV_KEY = "BUILDKITE" + + +def match(env): + return env.get(ENV_KEY) is not None + + +def extract(env): + return dict( + provider_name="buildkite", + repository_url=env.get("BUILDKITE_REPO"), + commit_sha=env.get("BUILDKITE_COMMIT"), + workspace_path=env.get("BUILDKITE_BUILD_CHECKOUT_PATH"), + pipeline_id=env.get("BUILDKITE_BUILD_ID"), + pipeline_number=env.get("BUILDKITE_BUILD_NUMBER"), + pipeline_url=env.get("BUILDKITE_BUILD_URL"), + branch=env.get("BUILDKITE_BRANCH"), + ) diff --git a/ddtrace/ext/ci/services/circle_ci.py b/ddtrace/ext/ci/services/circle_ci.py new file mode 100644 index 00000000000..dea4b9b18bc --- /dev/null +++ b/ddtrace/ext/ci/services/circle_ci.py @@ -0,0 +1,17 @@ +ENV_KEY = "CIRCLECI" + + +def match(env): + return env.get(ENV_KEY) is not None + + +def extract(env): + return dict( + provider_name="circleci", + repository_url=env.get("CIRCLE_REPOSITORY_URL"), + commit_sha=env.get("CIRCLE_SHA1"), + workspace_path=env.get("CIRCLE_WORKING_DIRECTORY"), + pipeline_number=env.get("CIRCLE_BUILD_NUM"), + pipeline_url=env.get("CIRCLE_BUILD_URL"), + branch=env.get("CIRCLE_BRANCH"), + ) diff --git a/ddtrace/ext/ci/services/github_actions.py b/ddtrace/ext/ci/services/github_actions.py new file mode 100644 index 00000000000..ed9c87f4c8f --- /dev/null +++ b/ddtrace/ext/ci/services/github_actions.py @@ -0,0 +1,18 @@ +ENV_KEY = "GITHUB_SHA" + + +def match(env): + return env.get(ENV_KEY) is not None + + +def extract(env): + return dict( + provider_name="github", + repository_url=env.get("GITHUB_REPOSITORY"), + commit_sha=env.get("GITHUB_SHA"), + workspace_path=env.get("GITHUB_WORKSPACE"), + pipeline_id=env.get("GITHUB_RUN_ID"), + pipeline_number=env.get("GITHUB_RUN_NUMBER"), + pipeline_url="{0}/commit/{1}/checks".format(env.get("GITHUB_REPOSITORY"), env.get("GITHUB_SHA")), + branch=env.get("GITHUB_REF"), + ) diff --git a/ddtrace/ext/ci/services/gitlab.py b/ddtrace/ext/ci/services/gitlab.py new file mode 100644 index 00000000000..a29d78d6e68 --- /dev/null +++ b/ddtrace/ext/ci/services/gitlab.py @@ -0,0 +1,19 @@ +ENV_KEY = "GITLAB_CI" + + +def match(env): + return env.get(ENV_KEY) is not None + + +def extract(env): + return dict( + provider_name="gitlab", + repository_url=env.get("CI_REPOSITORY_URL"), + commit_sha=env.get("CI_COMMIT_SHA"), + workspace_path=env.get("CI_PROJECT_DIR"), + pipeline_id=env.get("CI_PIPELINE_ID"), + pipeline_number=env.get("CI_PIPELINE_IID"), + pipeline_url=env.get("CI_PIPELINE_URL"), + job_url=env.get("CI_JOB_URL"), + branch=env.get("CI_COMMIT_BRANCH") or env.get("CI_COMMIT_REF_NAME"), + ) diff --git a/ddtrace/ext/ci/services/jenkins.py b/ddtrace/ext/ci/services/jenkins.py new file mode 100644 index 00000000000..ffd48f432a2 --- /dev/null +++ b/ddtrace/ext/ci/services/jenkins.py @@ -0,0 +1,24 @@ +import re + +_RE_ORIGIN = re.compile(r"^origin/") + + +ENV_KEY = "JENKINS_URL" + + +def match(env): + return env.get(ENV_KEY) is not None + + +def extract(env): + return dict( + provider_name="jenkins", + repository_url=env.get("GIT_URL"), + commit_sha=env.get("GIT_COMMIT"), + workspace_path=env.get("WORKSPACE"), + pipeline_id=env.get("BUILD_ID"), + pipeline_number=env.get("BUILD_NUMBER"), + pipeline_url=env.get("BUILD_URL"), + job_url=env.get("JOB_URL"), + branch=_RE_ORIGIN.sub("", env.get("GIT_BRANCH")), + ) diff --git a/ddtrace/ext/ci/services/teamcity.py b/ddtrace/ext/ci/services/teamcity.py new file mode 100644 index 00000000000..3dc3187b1fa --- /dev/null +++ b/ddtrace/ext/ci/services/teamcity.py @@ -0,0 +1,21 @@ +ENV_KEY = "TEAMCITY_VERSION" + + +def match(env): + return env.get(ENV_KEY) is not None + + +def extract(env): + return dict( + provider_name="teamcity", + repository_url=env.get("BUILD_VCS_URL"), + commit_sha=env.get("BUILD_VCS_NUMBER"), + workspace_path=env.get("BUILD_CHECKOUTDIR"), + pipeline_id=env.get("BUILD_ID"), + pipeline_number=env.get("BUILD_NUMBER"), + pipeline_url=( + "{0}/viewLog.html?buildId={1}".format(env.get("SERVER_URL"), env.get("BUILD_ID")) + if env.get("SERVER_URL") and env.get("BUILD_ID") + else None + ), + ) diff --git a/ddtrace/ext/ci/services/travis.py b/ddtrace/ext/ci/services/travis.py new file mode 100644 index 00000000000..bf5d8fe7aae --- /dev/null +++ b/ddtrace/ext/ci/services/travis.py @@ -0,0 +1,19 @@ +ENV_KEY = "TRAVIS" + + +def match(env): + return env.get(ENV_KEY) is not None + + +def extract(env): + return dict( + provider_name="travis", + repository_url=env.get("TRAVIS_REPO_SLUG"), + commit_sha=env.get("TRAVIS_COMMIT"), + workspace_path=env.get("TRAVIS_BUILD_DIR"), + pipeline_id=env.get("TRAVIS_BUILD_ID"), + pipeline_number=env.get("TRAVIS_BUILD_NUMBER"), + pipeline_url=env.get("TRAVIS_BUILD_WEB_URL"), + job_url=env.get("TRAVIS_JOB_WEB_URL"), + branch=env.get("TRAVIS_PULL_REQUEST_BRANCH") or env.get("TRAVIS_BRANCH"), + ) diff --git a/ddtrace/ext/git.py b/ddtrace/ext/git.py new file mode 100644 index 00000000000..d1009334a22 --- /dev/null +++ b/ddtrace/ext/git.py @@ -0,0 +1,15 @@ +""" +tags for common git attributes +""" + +# Git Branch +BRANCH = GIT_BRANCH = "git.branch" + +# Git Commit SHA +COMMIT_SHA = GIT_COMMIT_SHA = "git.commit.sha" + +# Git Repository URL +REPOSITORY_URL = GIT_REPOSITORY_URL = "git.repository_url" + +# Git Tag +TAG = GIT_TAG = "git.tag" diff --git a/ddtrace/ext/provider.py b/ddtrace/ext/provider.py new file mode 100644 index 00000000000..8ca8fdcbbec --- /dev/null +++ b/ddtrace/ext/provider.py @@ -0,0 +1,90 @@ +""" +common CI providers +""" + +import os +import re +from functools import partial + +from ddtrace.vendor import attr + +from .ci.services import ( + appveyor, + azure_pipelines, + bitbucket, + buildkite, + circle_ci, + github_actions, + gitlab, + jenkins, + teamcity, + travis, +) +from . import ci, git +from ..internal.logger import get_logger + +log = get_logger(__name__) + +_PROVIDER_METADATA_KEY = "ddtrace.ext.provider" + + +def field(name, *args, **kwargs): + kwargs.setdefault("default", None) + kwargs.setdefault("metadata", {}) + kwargs["metadata"][_PROVIDER_METADATA_KEY] = name + return attr.ib(*args, **kwargs) + + +_RE_BRANCH_PREFIX = re.compile(r"^refs/(heads/)?") + + +@attr.s(kw_only=True, eq=False, order=False, slots=True, frozen=True) +class Provider(object): + + # CI properties + job_url = field(ci.JOB_URL) + pipeline_id = field(ci.PIPELINE_ID) + pipeline_name = field(ci.PIPELINE_NAME) + pipeline_number = field(ci.PIPELINE_NUMBER) + pipeline_url = field(ci.PIPELINE_URL) + provider_name = field(ci.PROVIDER_NAME) + workspace_path = field(ci.WORKSPACE_PATH) + + # Git properties + branch = field(git.BRANCH, converter=attr.converters.optional(lambda value: _RE_BRANCH_PREFIX.sub("", value))) + commit_sha = field(git.COMMIT_SHA) + repository_url = field(git.REPOSITORY_URL) + tag = field(git.TAG) + + def astags(self): + """Add provider information to span.""" + return {_PROVIDER_LABELS[name]: value for name, value in attr.asdict(self).items() if value is not None} + + _registered_providers = ( + travis, + circle_ci, + jenkins, + gitlab, + appveyor, + azure_pipelines, + github_actions, + teamcity, + buildkite, + ) + + @classmethod + def from_env(cls, env=None): + """Build provider information from environment variables.""" + env = os.environ if env is None else env + + for provider in cls._registered_providers: + if provider.match(env): + try: + return cls(**provider.extract(env)) + except Exception: + log.error("could not create '{0}' provider info".format(provider.__name__)) + + return cls() + + +_PROVIDER_LABELS = {f.name: f.metadata[_PROVIDER_METADATA_KEY] for f in attr.fields(Provider)} diff --git a/tests/tracer/test_ext.py b/tests/tracer/test_ext.py index ec60a39369e..c47c0e9c618 100644 --- a/tests/tracer/test_ext.py +++ b/tests/tracer/test_ext.py @@ -1,4 +1,8 @@ +import pytest + from ddtrace.ext import aws +from ddtrace.ext import ci +from ddtrace.ext import provider def test_flatten_dict(): @@ -6,3 +10,13 @@ def test_flatten_dict(): d = dict(A=1, B=2, C=dict(A=3, B=4, C=dict(A=5, B=6))) e = dict(A=1, B=2, C_A=3, C_B=4, C_C_A=5, C_C_B=6) assert aws._flatten_dict(d, sep="_") == e + + +AZURE = [ + ({"TF_BUILD": "true", "BUILD_DEFINITIONNAME": "name"}, {ci.PROVIDER_NAME: "azurepipelines", ci.PIPELINE_NAME: "name"}), +] + + +@pytest.mark.parametrize("environment,tags", AZURE) +def test_ci_providers(environment, tags): + assert tags == provider.Provider.from_env(environment).astags() \ No newline at end of file From 20cc0ea9ea9e6780c6a1727d4f0cb8a006bea133 Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Wed, 21 Oct 2020 17:25:09 +0200 Subject: [PATCH 10/34] more tests and fixed code style --- ddtrace/contrib/pytest/plugin.py | 2 +- ddtrace/ext/provider.py | 4 ++-- tests/contrib/pytest/test_pytest.py | 24 ++++++++++++++++++++++-- tests/tracer/test_ext.py | 7 +++++-- 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/ddtrace/contrib/pytest/plugin.py b/ddtrace/contrib/pytest/plugin.py index 6b07ec57917..7796c0ce70a 100644 --- a/ddtrace/contrib/pytest/plugin.py +++ b/ddtrace/contrib/pytest/plugin.py @@ -10,7 +10,7 @@ def is_enabled(config): """Check if the ddtrace plugin is enabled.""" - return config.getoption("ddtrace", default=config.getini("ddtrace")) + return config.getoption("ddtrace") or config.getini("ddtrace") def _extract_span(item): diff --git a/ddtrace/ext/provider.py b/ddtrace/ext/provider.py index 8ca8fdcbbec..63951afa01e 100644 --- a/ddtrace/ext/provider.py +++ b/ddtrace/ext/provider.py @@ -4,7 +4,6 @@ import os import re -from functools import partial from ddtrace.vendor import attr @@ -62,6 +61,7 @@ def astags(self): _registered_providers = ( travis, + bitbucket, circle_ci, jenkins, gitlab, @@ -82,7 +82,7 @@ def from_env(cls, env=None): try: return cls(**provider.extract(env)) except Exception: - log.error("could not create '{0}' provider info".format(provider.__name__)) + log.error("could not create '{0}' provider info", provider.__name__) return cls() diff --git a/tests/contrib/pytest/test_pytest.py b/tests/contrib/pytest/test_pytest.py index 92ca9811d60..c26a575f395 100644 --- a/tests/contrib/pytest/test_pytest.py +++ b/tests/contrib/pytest/test_pytest.py @@ -41,6 +41,24 @@ def test_no_trace(ddspan): assert len(spans) == 0 + def test_ini(self): + """Test ini config.""" + self.testdir.makefile(".ini", pytest="[pytest]\nddtrace=1\n") + py_file = self.testdir.makepyfile( + """ + import pytest + + def test_ini(ddspan): + assert ddspan is not None + """ + ) + file_name = os.path.basename(py_file.strpath) + rec = self.inline_run(file_name) + rec.assertoutcome(passed=1) + spans = self.tracer.writer.pop() + + assert len(spans) == 1 + def test_parameterize_case(self): """Test parametrize case.""" py_file = self.testdir.makepyfile( @@ -85,12 +103,13 @@ def test_body(): assert spans[1].get_tag(test.STATUS) == test.Status.SKIP.value assert spans[1].get_tag(test.SKIP_REASON) == "body" - def test_fixture(self): - """Test ddspan fixture.""" + def test_tags(self): + """Test ddspan tags.""" py_file = self.testdir.makepyfile( """ import pytest + @pytest.mark.dd_tags(mark="dd_tags") def test_fixture(ddspan): assert ddspan is not None ddspan.set_tag("world", "hello") @@ -103,4 +122,5 @@ def test_fixture(ddspan): assert len(spans) == 1 assert spans[0].get_tag("world") == "hello" + assert spans[0].get_tag("mark") == "dd_tags" assert spans[0].get_tag(test.STATUS) == test.Status.PASS.value diff --git a/tests/tracer/test_ext.py b/tests/tracer/test_ext.py index c47c0e9c618..42ffcf8cf0e 100644 --- a/tests/tracer/test_ext.py +++ b/tests/tracer/test_ext.py @@ -13,10 +13,13 @@ def test_flatten_dict(): AZURE = [ - ({"TF_BUILD": "true", "BUILD_DEFINITIONNAME": "name"}, {ci.PROVIDER_NAME: "azurepipelines", ci.PIPELINE_NAME: "name"}), + ( + {"TF_BUILD": "true", "BUILD_DEFINITIONNAME": "name"}, + {ci.PROVIDER_NAME: "azurepipelines", ci.PIPELINE_NAME: "name"}, + ), ] @pytest.mark.parametrize("environment,tags", AZURE) def test_ci_providers(environment, tags): - assert tags == provider.Provider.from_env(environment).astags() \ No newline at end of file + assert tags == provider.Provider.from_env(environment).astags() From 2fa8255e29ccf2d4bbd611a3c192d0adbc0d3c2d Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Thu, 22 Oct 2020 10:00:23 +0200 Subject: [PATCH 11/34] simlify --- ddtrace/contrib/pytest/plugin.py | 4 ++-- ddtrace/ext/ci/services/appveyor.py | 4 ---- ddtrace/ext/ci/services/azure_pipelines.py | 4 ---- ddtrace/ext/ci/services/bitbucket.py | 4 ---- ddtrace/ext/ci/services/buildkite.py | 4 ---- ddtrace/ext/ci/services/circle_ci.py | 4 ---- ddtrace/ext/ci/services/github_actions.py | 4 ---- ddtrace/ext/ci/services/gitlab.py | 4 ---- ddtrace/ext/ci/services/jenkins.py | 4 ---- ddtrace/ext/ci/services/teamcity.py | 4 ---- ddtrace/ext/ci/services/travis.py | 4 ---- ddtrace/ext/provider.py | 2 +- 12 files changed, 3 insertions(+), 43 deletions(-) diff --git a/ddtrace/contrib/pytest/plugin.py b/ddtrace/contrib/pytest/plugin.py index 7796c0ce70a..c1f5ce81a8b 100644 --- a/ddtrace/contrib/pytest/plugin.py +++ b/ddtrace/contrib/pytest/plugin.py @@ -82,7 +82,7 @@ def pytest_runtest_protocol(item, nextitem): yield -def _extract_reason(item, call): +def _extract_reason(call): if call.excinfo is not None: return call.excinfo.value @@ -105,7 +105,7 @@ def pytest_runtest_makereport(item, call): result = outcome.get_result() if result.skipped: span.set_tag(test.STATUS, test.Status.SKIP.value) - reason = _extract_reason(item, call) + reason = _extract_reason(call) if reason is not None: span.set_tag(test.SKIP_REASON, reason) elif result.passed: diff --git a/ddtrace/ext/ci/services/appveyor.py b/ddtrace/ext/ci/services/appveyor.py index 2380abb0949..4fda9c4888a 100644 --- a/ddtrace/ext/ci/services/appveyor.py +++ b/ddtrace/ext/ci/services/appveyor.py @@ -1,10 +1,6 @@ ENV_KEY = "APPVEYOR" -def match(env): - return env.get(ENV_KEY) is not None - - def extract(env): return dict( provider_name="appveyor", diff --git a/ddtrace/ext/ci/services/azure_pipelines.py b/ddtrace/ext/ci/services/azure_pipelines.py index 08aa743527a..8f032599dbe 100644 --- a/ddtrace/ext/ci/services/azure_pipelines.py +++ b/ddtrace/ext/ci/services/azure_pipelines.py @@ -1,10 +1,6 @@ ENV_KEY = "TF_BUILD" -def match(env): - return env.get(ENV_KEY) is not None - - def extract(env): return dict( provider_name="azurepipelines", diff --git a/ddtrace/ext/ci/services/bitbucket.py b/ddtrace/ext/ci/services/bitbucket.py index c3eff7002d4..80d797bd968 100644 --- a/ddtrace/ext/ci/services/bitbucket.py +++ b/ddtrace/ext/ci/services/bitbucket.py @@ -1,10 +1,6 @@ ENV_KEY = "BITBUCKET_COMMIT" -def match(env): - return env.get(ENV_KEY) is not None - - def extract(env): return dict( provider_name="bitbucketpipelines", diff --git a/ddtrace/ext/ci/services/buildkite.py b/ddtrace/ext/ci/services/buildkite.py index 8150a92ee1f..52f689332a7 100644 --- a/ddtrace/ext/ci/services/buildkite.py +++ b/ddtrace/ext/ci/services/buildkite.py @@ -1,10 +1,6 @@ ENV_KEY = "BUILDKITE" -def match(env): - return env.get(ENV_KEY) is not None - - def extract(env): return dict( provider_name="buildkite", diff --git a/ddtrace/ext/ci/services/circle_ci.py b/ddtrace/ext/ci/services/circle_ci.py index dea4b9b18bc..0f0d79de13c 100644 --- a/ddtrace/ext/ci/services/circle_ci.py +++ b/ddtrace/ext/ci/services/circle_ci.py @@ -1,10 +1,6 @@ ENV_KEY = "CIRCLECI" -def match(env): - return env.get(ENV_KEY) is not None - - def extract(env): return dict( provider_name="circleci", diff --git a/ddtrace/ext/ci/services/github_actions.py b/ddtrace/ext/ci/services/github_actions.py index ed9c87f4c8f..6b08d8ec4d2 100644 --- a/ddtrace/ext/ci/services/github_actions.py +++ b/ddtrace/ext/ci/services/github_actions.py @@ -1,10 +1,6 @@ ENV_KEY = "GITHUB_SHA" -def match(env): - return env.get(ENV_KEY) is not None - - def extract(env): return dict( provider_name="github", diff --git a/ddtrace/ext/ci/services/gitlab.py b/ddtrace/ext/ci/services/gitlab.py index a29d78d6e68..8194b39bb14 100644 --- a/ddtrace/ext/ci/services/gitlab.py +++ b/ddtrace/ext/ci/services/gitlab.py @@ -1,10 +1,6 @@ ENV_KEY = "GITLAB_CI" -def match(env): - return env.get(ENV_KEY) is not None - - def extract(env): return dict( provider_name="gitlab", diff --git a/ddtrace/ext/ci/services/jenkins.py b/ddtrace/ext/ci/services/jenkins.py index ffd48f432a2..e9861b38eed 100644 --- a/ddtrace/ext/ci/services/jenkins.py +++ b/ddtrace/ext/ci/services/jenkins.py @@ -6,10 +6,6 @@ ENV_KEY = "JENKINS_URL" -def match(env): - return env.get(ENV_KEY) is not None - - def extract(env): return dict( provider_name="jenkins", diff --git a/ddtrace/ext/ci/services/teamcity.py b/ddtrace/ext/ci/services/teamcity.py index 3dc3187b1fa..fbdfdaaaac1 100644 --- a/ddtrace/ext/ci/services/teamcity.py +++ b/ddtrace/ext/ci/services/teamcity.py @@ -1,10 +1,6 @@ ENV_KEY = "TEAMCITY_VERSION" -def match(env): - return env.get(ENV_KEY) is not None - - def extract(env): return dict( provider_name="teamcity", diff --git a/ddtrace/ext/ci/services/travis.py b/ddtrace/ext/ci/services/travis.py index bf5d8fe7aae..57073d8867b 100644 --- a/ddtrace/ext/ci/services/travis.py +++ b/ddtrace/ext/ci/services/travis.py @@ -1,10 +1,6 @@ ENV_KEY = "TRAVIS" -def match(env): - return env.get(ENV_KEY) is not None - - def extract(env): return dict( provider_name="travis", diff --git a/ddtrace/ext/provider.py b/ddtrace/ext/provider.py index 63951afa01e..4c4671ea0aa 100644 --- a/ddtrace/ext/provider.py +++ b/ddtrace/ext/provider.py @@ -78,7 +78,7 @@ def from_env(cls, env=None): env = os.environ if env is None else env for provider in cls._registered_providers: - if provider.match(env): + if env.get(provider.ENV_KEY) is not None: try: return cls(**provider.extract(env)) except Exception: From 20c4b4d7d582ba36529432fcadbe5100114d2c45 Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Thu, 22 Oct 2020 10:19:50 +0200 Subject: [PATCH 12/34] module import --- ddtrace/ext/ci/services/__init__.py | 28 ++++++++++++++++++++++++++++ ddtrace/ext/provider.py | 29 +++-------------------------- 2 files changed, 31 insertions(+), 26 deletions(-) diff --git a/ddtrace/ext/ci/services/__init__.py b/ddtrace/ext/ci/services/__init__.py index e69de29bb2d..a93a233492a 100644 --- a/ddtrace/ext/ci/services/__init__.py +++ b/ddtrace/ext/ci/services/__init__.py @@ -0,0 +1,28 @@ +from . import ( + appveyor, + azure_pipelines, + bitbucket, + buildkite, + circle_ci, + github_actions, + gitlab, + jenkins, + teamcity, + travis, +) + + +PROVIDERS = ( + travis, + bitbucket, + circle_ci, + jenkins, + gitlab, + appveyor, + azure_pipelines, + github_actions, + teamcity, + buildkite, +) + +__all__ = ("PROVIDERS",) diff --git a/ddtrace/ext/provider.py b/ddtrace/ext/provider.py index 4c4671ea0aa..3c859a1faba 100644 --- a/ddtrace/ext/provider.py +++ b/ddtrace/ext/provider.py @@ -7,18 +7,6 @@ from ddtrace.vendor import attr -from .ci.services import ( - appveyor, - azure_pipelines, - bitbucket, - buildkite, - circle_ci, - github_actions, - gitlab, - jenkins, - teamcity, - travis, -) from . import ci, git from ..internal.logger import get_logger @@ -59,25 +47,14 @@ def astags(self): """Add provider information to span.""" return {_PROVIDER_LABELS[name]: value for name, value in attr.asdict(self).items() if value is not None} - _registered_providers = ( - travis, - bitbucket, - circle_ci, - jenkins, - gitlab, - appveyor, - azure_pipelines, - github_actions, - teamcity, - buildkite, - ) - @classmethod def from_env(cls, env=None): """Build provider information from environment variables.""" + from .ci import services + env = os.environ if env is None else env - for provider in cls._registered_providers: + for provider in services.PROVIDERS: if env.get(provider.ENV_KEY) is not None: try: return cls(**provider.extract(env)) From 9d749095cb3b8430033e3056178f22ffad3f6ff6 Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Thu, 22 Oct 2020 10:39:05 +0200 Subject: [PATCH 13/34] add simple docstring --- ddtrace/contrib/pytest/__init__.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ddtrace/contrib/pytest/__init__.py b/ddtrace/contrib/pytest/__init__.py index c66bba71a2f..a45c48b8a12 100644 --- a/ddtrace/contrib/pytest/__init__.py +++ b/ddtrace/contrib/pytest/__init__.py @@ -1,3 +1,13 @@ +""" +Enable traced execution of tests using ``pytest`` runner by +running ``pytest --ddtrace`` or by modifying any configuration +file read by Pytest (``pytest.ini``, ``setup.cfg``, ...):: + + [pytest] + ddtrace = 1 + +""" + from ddtrace import config # pytest default settings From f945d83155863b3580e62776d2e1cee96a52eca0 Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Thu, 22 Oct 2020 11:29:47 +0200 Subject: [PATCH 14/34] span.kind --- ddtrace/constants.py | 1 + ddtrace/contrib/pytest/constants.py | 1 + ddtrace/contrib/pytest/plugin.py | 4 +++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ddtrace/constants.py b/ddtrace/constants.py index 8e2a900e34e..78ebe77ac82 100644 --- a/ddtrace/constants.py +++ b/ddtrace/constants.py @@ -11,6 +11,7 @@ VERSION_KEY = 'version' SERVICE_KEY = 'service.name' SERVICE_VERSION_KEY = 'service.version' +SPAN_KIND = 'span.kind' SPAN_MEASURED_KEY = '_dd.measured' NUMERIC_TAGS = (ANALYTICS_SAMPLE_RATE_KEY, ) diff --git a/ddtrace/contrib/pytest/constants.py b/ddtrace/contrib/pytest/constants.py index eb17fb79728..b8214471261 100644 --- a/ddtrace/contrib/pytest/constants.py +++ b/ddtrace/contrib/pytest/constants.py @@ -1,3 +1,4 @@ FRAMEWORK = "pytest" +KIND = "test" HELP_MSG = "Enable tracing of pytest functions." diff --git a/ddtrace/contrib/pytest/plugin.py b/ddtrace/contrib/pytest/plugin.py index c1f5ce81a8b..b8aeb9de5b5 100644 --- a/ddtrace/contrib/pytest/plugin.py +++ b/ddtrace/contrib/pytest/plugin.py @@ -2,10 +2,11 @@ from ddtrace import config as ddconfig +from ...constants import SPAN_KIND from ...ext import SpanTypes, test from ...ext.provider import Provider from ...pin import Pin -from .constants import FRAMEWORK, HELP_MSG +from .constants import FRAMEWORK, HELP_MSG, KIND def is_enabled(config): @@ -68,6 +69,7 @@ def pytest_runtest_protocol(item, nextitem): with pin.tracer.trace(SpanTypes.TEST.value, resource=item.nodeid, span_type=SpanTypes.TEST.value) as span: span.set_tags(pin.tags) + span.set_tag(SPAN_KIND, KIND) span.set_tag(test.FRAMEWORK, FRAMEWORK) span.set_tag(test.NAME, item.name) span.set_tag(test.SUITE, item.module.__name__) From 9716a7494d5b0a08a45a31012c71f3cf21c9831b Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Thu, 22 Oct 2020 11:45:49 +0200 Subject: [PATCH 15/34] add deprecated git.commit_sha --- ddtrace/ext/provider.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ddtrace/ext/provider.py b/ddtrace/ext/provider.py index 3c859a1faba..ca64dd806cc 100644 --- a/ddtrace/ext/provider.py +++ b/ddtrace/ext/provider.py @@ -25,7 +25,7 @@ def field(name, *args, **kwargs): _RE_BRANCH_PREFIX = re.compile(r"^refs/(heads/)?") -@attr.s(kw_only=True, eq=False, order=False, slots=True, frozen=True) +@attr.s(kw_only=True, eq=False, order=False, slots=True) class Provider(object): # CI properties @@ -43,6 +43,13 @@ class Provider(object): repository_url = field(git.REPOSITORY_URL) tag = field(git.TAG) + # Deprecated properties + _deprecated_commit_sha = field("git.commit_sha") + + @_deprecated_commit_sha.default + def _default_deprecated_commit_sha(self): + return self.commit_sha + def astags(self): """Add provider information to span.""" return {_PROVIDER_LABELS[name]: value for name, value in attr.asdict(self).items() if value is not None} From 7ee6a1cb8dda8c524cace18efba4848a655dbcd0 Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Thu, 22 Oct 2020 13:13:12 +0200 Subject: [PATCH 16/34] deprecated field fix --- ddtrace/ext/provider.py | 23 +++++++++++------------ tests/tracer/test_ext.py | 14 ++++++++++++-- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/ddtrace/ext/provider.py b/ddtrace/ext/provider.py index ca64dd806cc..88246ad465a 100644 --- a/ddtrace/ext/provider.py +++ b/ddtrace/ext/provider.py @@ -16,7 +16,6 @@ def field(name, *args, **kwargs): - kwargs.setdefault("default", None) kwargs.setdefault("metadata", {}) kwargs["metadata"][_PROVIDER_METADATA_KEY] = name return attr.ib(*args, **kwargs) @@ -29,19 +28,19 @@ def field(name, *args, **kwargs): class Provider(object): # CI properties - job_url = field(ci.JOB_URL) - pipeline_id = field(ci.PIPELINE_ID) - pipeline_name = field(ci.PIPELINE_NAME) - pipeline_number = field(ci.PIPELINE_NUMBER) - pipeline_url = field(ci.PIPELINE_URL) - provider_name = field(ci.PROVIDER_NAME) - workspace_path = field(ci.WORKSPACE_PATH) + job_url = field(ci.JOB_URL, default=None) + pipeline_id = field(ci.PIPELINE_ID, default=None) + pipeline_name = field(ci.PIPELINE_NAME, default=None) + pipeline_number = field(ci.PIPELINE_NUMBER, default=None) + pipeline_url = field(ci.PIPELINE_URL, default=None) + provider_name = field(ci.PROVIDER_NAME, default=None) + workspace_path = field(ci.WORKSPACE_PATH, default=None) # Git properties - branch = field(git.BRANCH, converter=attr.converters.optional(lambda value: _RE_BRANCH_PREFIX.sub("", value))) - commit_sha = field(git.COMMIT_SHA) - repository_url = field(git.REPOSITORY_URL) - tag = field(git.TAG) + branch = field(git.BRANCH, default=None, converter=attr.converters.optional(lambda value: _RE_BRANCH_PREFIX.sub("", value))) + commit_sha = field(git.COMMIT_SHA, default=None) + repository_url = field(git.REPOSITORY_URL, default=None) + tag = field(git.TAG, default=None) # Deprecated properties _deprecated_commit_sha = field("git.commit_sha") diff --git a/tests/tracer/test_ext.py b/tests/tracer/test_ext.py index 42ffcf8cf0e..4582b088331 100644 --- a/tests/tracer/test_ext.py +++ b/tests/tracer/test_ext.py @@ -2,6 +2,7 @@ from ddtrace.ext import aws from ddtrace.ext import ci +from ddtrace.ext import git from ddtrace.ext import provider @@ -14,8 +15,17 @@ def test_flatten_dict(): AZURE = [ ( - {"TF_BUILD": "true", "BUILD_DEFINITIONNAME": "name"}, - {ci.PROVIDER_NAME: "azurepipelines", ci.PIPELINE_NAME: "name"}, + { + "TF_BUILD": "true", + "BUILD_DEFINITIONNAME": "name", + "BUILD_SOURCEVERSION": "0000000000000000000000000000000000000000", + }, + { + ci.PROVIDER_NAME: "azurepipelines", + ci.PIPELINE_NAME: "name", + git.COMMIT_SHA: "0000000000000000000000000000000000000000", + "git.commit_sha": "0000000000000000000000000000000000000000", # deprecated field + }, ), ] From ff142f3cf9dc6173905896543898d6a00504384e Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Thu, 22 Oct 2020 13:15:26 +0200 Subject: [PATCH 17/34] black --- ddtrace/ext/provider.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ddtrace/ext/provider.py b/ddtrace/ext/provider.py index 88246ad465a..7416aad4fdc 100644 --- a/ddtrace/ext/provider.py +++ b/ddtrace/ext/provider.py @@ -37,7 +37,9 @@ class Provider(object): workspace_path = field(ci.WORKSPACE_PATH, default=None) # Git properties - branch = field(git.BRANCH, default=None, converter=attr.converters.optional(lambda value: _RE_BRANCH_PREFIX.sub("", value))) + branch = field( + git.BRANCH, default=None, converter=attr.converters.optional(lambda value: _RE_BRANCH_PREFIX.sub("", value)) + ) commit_sha = field(git.COMMIT_SHA, default=None) repository_url = field(git.REPOSITORY_URL, default=None) tag = field(git.TAG, default=None) From b2daffc7ab1d7aee3ac446a6e8de62204abc2bbb Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Mon, 26 Oct 2020 23:04:53 +0100 Subject: [PATCH 18/34] ddtrace.ext.ci:tags --- ddtrace/contrib/pytest/__init__.py | 2 +- ddtrace/contrib/pytest/plugin.py | 13 +- ddtrace/ext/ci.py | 208 +++++++++++++++++++++ ddtrace/ext/ci/__init__.py | 24 --- ddtrace/ext/ci/services/__init__.py | 28 --- ddtrace/ext/ci/services/appveyor.py | 16 -- ddtrace/ext/ci/services/azure_pipelines.py | 25 --- ddtrace/ext/ci/services/bitbucket.py | 12 -- ddtrace/ext/ci/services/buildkite.py | 14 -- ddtrace/ext/ci/services/circle_ci.py | 13 -- ddtrace/ext/ci/services/github_actions.py | 14 -- ddtrace/ext/ci/services/gitlab.py | 15 -- ddtrace/ext/ci/services/jenkins.py | 20 -- ddtrace/ext/ci/services/teamcity.py | 17 -- ddtrace/ext/ci/services/travis.py | 15 -- ddtrace/ext/git.py | 9 +- ddtrace/ext/provider.py | 75 -------- tests/contrib/pytest/test_pytest.py | 1 + tests/tracer/test_ext.py | 3 +- 19 files changed, 225 insertions(+), 299 deletions(-) create mode 100644 ddtrace/ext/ci.py delete mode 100644 ddtrace/ext/ci/__init__.py delete mode 100644 ddtrace/ext/ci/services/__init__.py delete mode 100644 ddtrace/ext/ci/services/appveyor.py delete mode 100644 ddtrace/ext/ci/services/azure_pipelines.py delete mode 100644 ddtrace/ext/ci/services/bitbucket.py delete mode 100644 ddtrace/ext/ci/services/buildkite.py delete mode 100644 ddtrace/ext/ci/services/circle_ci.py delete mode 100644 ddtrace/ext/ci/services/github_actions.py delete mode 100644 ddtrace/ext/ci/services/gitlab.py delete mode 100644 ddtrace/ext/ci/services/jenkins.py delete mode 100644 ddtrace/ext/ci/services/teamcity.py delete mode 100644 ddtrace/ext/ci/services/travis.py delete mode 100644 ddtrace/ext/provider.py diff --git a/ddtrace/contrib/pytest/__init__.py b/ddtrace/contrib/pytest/__init__.py index a45c48b8a12..d2a80a3ca48 100644 --- a/ddtrace/contrib/pytest/__init__.py +++ b/ddtrace/contrib/pytest/__init__.py @@ -11,4 +11,4 @@ from ddtrace import config # pytest default settings -config._add("pytest", {}) +config._add("pytest", dict(_default_service="pytest")) diff --git a/ddtrace/contrib/pytest/plugin.py b/ddtrace/contrib/pytest/plugin.py index b8aeb9de5b5..47ba0054f31 100644 --- a/ddtrace/contrib/pytest/plugin.py +++ b/ddtrace/contrib/pytest/plugin.py @@ -2,9 +2,9 @@ from ddtrace import config as ddconfig +from ..trace_utils import int_service from ...constants import SPAN_KIND -from ...ext import SpanTypes, test -from ...ext.provider import Provider +from ...ext import SpanTypes, ci, test from ...pin import Pin from .constants import FRAMEWORK, HELP_MSG, KIND @@ -43,7 +43,7 @@ def pytest_configure(config): config.addinivalue_line("markers", "dd_tags(**kwargs): add tags to current span") if is_enabled(config): - Pin(tags=Provider.from_env().astags(), _config=ddconfig.pytest).onto(config) + Pin(tags=ci.tags(), _config=ddconfig.pytest).onto(config) def pytest_sessionfinish(session, exitstatus): @@ -67,7 +67,12 @@ def pytest_runtest_protocol(item, nextitem): yield return - with pin.tracer.trace(SpanTypes.TEST.value, resource=item.nodeid, span_type=SpanTypes.TEST.value) as span: + with pin.tracer.trace( + SpanTypes.TEST.value, + service=int_service(pin, ddconfig.pytest), + resource=item.nodeid, + span_type=SpanTypes.TEST.value, + ) as span: span.set_tags(pin.tags) span.set_tag(SPAN_KIND, KIND) span.set_tag(test.FRAMEWORK, FRAMEWORK) diff --git a/ddtrace/ext/ci.py b/ddtrace/ext/ci.py new file mode 100644 index 00000000000..1cfc576bfbe --- /dev/null +++ b/ddtrace/ext/ci.py @@ -0,0 +1,208 @@ +""" +tags for common CI attributes +""" +import os +import re + +from . import git + +# Job URL +JOB_URL = "ci.job.url" + +# Pipeline ID +PIPELINE_ID = "ci.pipeline.id" + +# Pipeline Name +PIPELINE_NAME = "ci.pipeline.name" + +# Pipeline Number +PIPELINE_NUMBER = "ci.pipeline.number" + +# Pipeline URL +PIPELINE_URL = "ci.pipeline.url" + +# Provider +PROVIDER_NAME = "ci.provider.name" + +# Workspace Path +WORKSPACE_PATH = "ci.workspace_path" + +_RE_ORIGIN = re.compile(r"^origin/") +_RE_BRANCH_PREFIX = re.compile(r"^refs/(heads/)?") + + +def tags(env=None): + env = os.environ if env is None else env + for key, extract in PROVIDERS: + if key in env: + tags = extract(env) + + # Post process special cases + branch = tags.get(git.BRANCH) + if branch: + tags[git.BRANCH] = _RE_BRANCH_PREFIX.sub("", branch) + tags[git.DEPRECATED_COMMIT_SHA] = tags.get(git.COMMIT_SHA) + tags = {k: v for k, v in tags.items() if v is not None} + + return tags + return {} + + +def extract_appveyor(env): + return { + PROVIDER_NAME: "appveyor", + git.REPOSITORY_URL: env.get("APPVEYOR_REPO_NAME"), + git.COMMIT_SHA: env.get("APPVEYOR_REPO_COMMIT"), + WORKSPACE_PATH: env.get("APPVEYOR_BUILD_FOLDER"), + PIPELINE_ID: env.get("APPVEYOR_BUILD_ID"), + PIPELINE_NUMBER: env.get("APPVEYOR_BUILD_NUMBER"), + PIPELINE_URL: "https://ci.appveyor.com/project/{0}/builds/{1}".format( + env.get("APPVEYOR_PROJECT_SLUG"), env.get("APPVEYOR_BUILD_ID") + ), + git.BRANCH: env.get("APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH") or env.get("APPVEYOR_REPO_BRANCH"), + } + + +def extract_azure_pipelines(env): + return { + PROVIDER_NAME:"azurepipelines", + WORKSPACE_PATH: env.get("BUILD_SOURCESDIRECTORY"), + PIPELINE_ID: env.get("BUILD_BUILDID"), + PIPELINE_NAME: env.get("BUILD_DEFINITIONNAME"), + PIPELINE_NUMBER: env.get("BUILD_BUILDNUMBER"), + PIPELINE_URL: all( + (env.get("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"), env.get("SYSTEM_TEAMPROJECT"), env.get("BUILD_BUILDID")) + ) + and "{0}{1}/_build/results?buildId={2}&_a=summary".format( + env.get("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"), env.get("SYSTEM_TEAMPROJECT"), env.get("BUILD_BUILDID") + ) + or None, + git.REPOSITORY_URL:env.get("BUILD_REPOSITORY_URI"), + git.COMMIT_SHA: env.get("SYSTEM_PULLREQUEST_SOURCECOMMITID") or env.get("BUILD_SOURCEVERSION"), + git.BRANCH: ( + env.get("SYSTEM_PULLREQUEST_SOURCEBRANCH") + or env.get("BUILD_SOURCEBRANCH") + or env.get("BUILD_SOURCEBRANCHNAME") + ), + } + + +def extract_bitbucket(env): + return { + PROVIDER_NAME:"bitbucketpipelines", + git.REPOSITORY_URL:env.get("BITBUCKET_GIT_SSH_ORIGIN"), + git.COMMIT_SHA: env.get("BITBUCKET_COMMIT"), + WORKSPACE_PATH: env.get("BITBUCKET_CLONE_DIR"), + PIPELINE_ID: env.get("BITBUCKET_PIPELINE_UUID"), + PIPELINE_NUMBER: env.get("BITBUCKET_BUILD_NUMBER"), + } + + +def extract_buildkite(env): + return { + PROVIDER_NAME:"buildkite", + git.REPOSITORY_URL:env.get("BUILDKITE_REPO"), + git.COMMIT_SHA: env.get("BUILDKITE_COMMIT"), + WORKSPACE_PATH: env.get("BUILDKITE_BUILD_CHECKOUT_PATH"), + PIPELINE_ID: env.get("BUILDKITE_BUILD_ID"), + PIPELINE_NUMBER: env.get("BUILDKITE_BUILD_NUMBER"), + PIPELINE_URL: env.get("BUILDKITE_BUILD_URL"), + git.BRANCH: env.get("BUILDKITE_BRANCH"), + } + + +def extract_circle_ci(env): + return { + PROVIDER_NAME:"circleci", + git.REPOSITORY_URL:env.get("CIRCLE_REPOSITORY_URL"), + git.COMMIT_SHA: env.get("CIRCLE_SHA1"), + WORKSPACE_PATH: env.get("CIRCLE_WORKING_DIRECTORY"), + PIPELINE_NUMBER: env.get("CIRCLE_BUILD_NUM"), + PIPELINE_URL: env.get("CIRCLE_BUILD_URL"), + git.BRANCH: env.get("CIRCLE_BRANCH"), + } + + +def extract_github_actions(env): + return { + PROVIDER_NAME:"github", + git.REPOSITORY_URL:env.get("GITHUB_REPOSITORY"), + git.COMMIT_SHA: env.get("GITHUB_SHA"), + WORKSPACE_PATH: env.get("GITHUB_WORKSPACE"), + PIPELINE_ID: env.get("GITHUB_RUN_ID"), + PIPELINE_NUMBER: env.get("GITHUB_RUN_NUMBER"), + PIPELINE_URL: "{0}/commit/{1}/checks".format(env.get("GITHUB_REPOSITORY"), env.get("GITHUB_SHA")), + git.BRANCH: env.get("GITHUB_REF"), + } + + +def extract_gitlab(env): + return { + PROVIDER_NAME:"gitlab", + git.REPOSITORY_URL:env.get("CI_REPOSITORY_URL"), + git.COMMIT_SHA: env.get("CI_COMMIT_SHA"), + WORKSPACE_PATH: env.get("CI_PROJECT_DIR"), + PIPELINE_ID: env.get("CI_PIPELINE_ID"), + PIPELINE_NUMBER: env.get("CI_PIPELINE_IID"), + PIPELINE_URL: env.get("CI_PIPELINE_URL"), + JOB_URL: env.get("CI_JOB_URL"), + git.BRANCH: env.get("CI_COMMIT_BRANCH") or env.get("CI_COMMIT_REF_NAME"), + } + + +def extract_jenkins(env): + return { + PROVIDER_NAME:"jenkins", + git.REPOSITORY_URL:env.get("GIT_URL"), + git.COMMIT_SHA: env.get("GIT_COMMIT"), + WORKSPACE_PATH: env.get("WORKSPACE"), + PIPELINE_ID: env.get("BUILD_ID"), + PIPELINE_NUMBER: env.get("BUILD_NUMBER"), + PIPELINE_URL: env.get("BUILD_URL"), + JOB_URL: env.get("JOB_URL"), + git.BRANCH: _RE_ORIGIN.sub("", env.get("GIT_BRANCH")), + } + + +def extract_teamcity(env): + return { + PROVIDER_NAME:"teamcity", + git.REPOSITORY_URL:env.get("BUILD_VCS_URL"), + git.COMMIT_SHA: env.get("BUILD_VCS_NUMBER"), + WORKSPACE_PATH: env.get("BUILD_CHECKOUTDIR"), + PIPELINE_ID: env.get("BUILD_ID"), + PIPELINE_NUMBER: env.get("BUILD_NUMBER"), + PIPELINE_URL: ( + "{0}/viewLog.html?buildId={1}".format(env.get("SERVER_URL"), env.get("BUILD_ID")) + if env.get("SERVER_URL") and env.get("BUILD_ID") + else None + ), + } + + +def extract_travis(env): + return { + PROVIDER_NAME:"travis", + git.REPOSITORY_URL:env.get("TRAVIS_REPO_SLUG"), + git.COMMIT_SHA: env.get("TRAVIS_COMMIT"), + WORKSPACE_PATH: env.get("TRAVIS_BUILD_DIR"), + PIPELINE_ID: env.get("TRAVIS_BUILD_ID"), + PIPELINE_NUMBER: env.get("TRAVIS_BUILD_NUMBER"), + PIPELINE_URL: env.get("TRAVIS_BUILD_WEB_URL"), + JOB_URL: env.get("TRAVIS_JOB_WEB_URL"), + git.BRANCH: env.get("TRAVIS_PULL_REQUEST_BRANCH") or env.get("TRAVIS_BRANCH"), + } + + +PROVIDERS = ( + ('APPVEYOR', extract_appveyor), + ('TF_BUILD', extract_azure_pipelines), + ('BITBUCKET_COMMIT', extract_bitbucket), + ('BUILDKITE', extract_buildkite), + ('CIRCLECI', extract_circle_ci), + ('GITHUB_SHA', extract_github_actions), + ('GITLAB_CI', extract_gitlab), + ('JENKINS_URL', extract_jenkins), + ('TEAMCITY_VERSION', extract_teamcity), + ('TRAVIS', extract_travis), +) diff --git a/ddtrace/ext/ci/__init__.py b/ddtrace/ext/ci/__init__.py deleted file mode 100644 index 342c867ccab..00000000000 --- a/ddtrace/ext/ci/__init__.py +++ /dev/null @@ -1,24 +0,0 @@ -""" -tags for common CI attributes -""" - -# Job URL -JOB_URL = "ci.job.url" - -# Pipeline ID -PIPELINE_ID = "ci.pipeline.id" - -# Pipeline Name -PIPELINE_NAME = "ci.pipeline.name" - -# Pipeline Number -PIPELINE_NUMBER = "ci.pipeline.number" - -# Pipeline URL -PIPELINE_URL = "ci.pipeline.url" - -# Provider -PROVIDER_NAME = "ci.provider.name" - -# Workspace Path -WORKSPACE_PATH = "ci.workspace_path" diff --git a/ddtrace/ext/ci/services/__init__.py b/ddtrace/ext/ci/services/__init__.py deleted file mode 100644 index a93a233492a..00000000000 --- a/ddtrace/ext/ci/services/__init__.py +++ /dev/null @@ -1,28 +0,0 @@ -from . import ( - appveyor, - azure_pipelines, - bitbucket, - buildkite, - circle_ci, - github_actions, - gitlab, - jenkins, - teamcity, - travis, -) - - -PROVIDERS = ( - travis, - bitbucket, - circle_ci, - jenkins, - gitlab, - appveyor, - azure_pipelines, - github_actions, - teamcity, - buildkite, -) - -__all__ = ("PROVIDERS",) diff --git a/ddtrace/ext/ci/services/appveyor.py b/ddtrace/ext/ci/services/appveyor.py deleted file mode 100644 index 4fda9c4888a..00000000000 --- a/ddtrace/ext/ci/services/appveyor.py +++ /dev/null @@ -1,16 +0,0 @@ -ENV_KEY = "APPVEYOR" - - -def extract(env): - return dict( - provider_name="appveyor", - repository_url=env.get("APPVEYOR_REPO_NAME"), - commit_sha=env.get("APPVEYOR_REPO_COMMIT"), - workspace_path=env.get("APPVEYOR_BUILD_FOLDER"), - pipeline_id=env.get("APPVEYOR_BUILD_ID"), - pipeline_number=env.get("APPVEYOR_BUILD_NUMBER"), - pipeline_url="https://ci.appveyor.com/project/{0}/builds/{1}".format( - env.get("APPVEYOR_PROJECT_SLUG"), env.get("APPVEYOR_BUILD_ID") - ), - branch=env.get("APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH") or env.get("APPVEYOR_REPO_BRANCH"), - ) diff --git a/ddtrace/ext/ci/services/azure_pipelines.py b/ddtrace/ext/ci/services/azure_pipelines.py deleted file mode 100644 index 8f032599dbe..00000000000 --- a/ddtrace/ext/ci/services/azure_pipelines.py +++ /dev/null @@ -1,25 +0,0 @@ -ENV_KEY = "TF_BUILD" - - -def extract(env): - return dict( - provider_name="azurepipelines", - workspace_path=env.get("BUILD_SOURCESDIRECTORY"), - pipeline_id=env.get("BUILD_BUILDID"), - pipeline_name=env.get("BUILD_DEFINITIONNAME"), - pipeline_number=env.get("BUILD_BUILDNUMBER"), - pipeline_url=all( - (env.get("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"), env.get("SYSTEM_TEAMPROJECT"), env.get("BUILD_BUILDID")) - ) - and "{0}{1}/_build/results?buildId={2}&_a=summary".format( - env.get("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"), env.get("SYSTEM_TEAMPROJECT"), env.get("BUILD_BUILDID") - ) - or None, - repository_url=env.get("BUILD_REPOSITORY_URI"), - commit_sha=env.get("SYSTEM_PULLREQUEST_SOURCECOMMITID") or env.get("BUILD_SOURCEVERSION"), - branch=( - env.get("SYSTEM_PULLREQUEST_SOURCEBRANCH") - or env.get("BUILD_SOURCEBRANCH") - or env.get("BUILD_SOURCEBRANCHNAME") - ), - ) diff --git a/ddtrace/ext/ci/services/bitbucket.py b/ddtrace/ext/ci/services/bitbucket.py deleted file mode 100644 index 80d797bd968..00000000000 --- a/ddtrace/ext/ci/services/bitbucket.py +++ /dev/null @@ -1,12 +0,0 @@ -ENV_KEY = "BITBUCKET_COMMIT" - - -def extract(env): - return dict( - provider_name="bitbucketpipelines", - repository_url=env.get("BITBUCKET_GIT_SSH_ORIGIN"), - commit_sha=env.get("BITBUCKET_COMMIT"), - workspace_path=env.get("BITBUCKET_CLONE_DIR"), - pipeline_id=env.get("BITBUCKET_PIPELINE_UUID"), - pipeline_number=env.get("BITBUCKET_BUILD_NUMBER"), - ) diff --git a/ddtrace/ext/ci/services/buildkite.py b/ddtrace/ext/ci/services/buildkite.py deleted file mode 100644 index 52f689332a7..00000000000 --- a/ddtrace/ext/ci/services/buildkite.py +++ /dev/null @@ -1,14 +0,0 @@ -ENV_KEY = "BUILDKITE" - - -def extract(env): - return dict( - provider_name="buildkite", - repository_url=env.get("BUILDKITE_REPO"), - commit_sha=env.get("BUILDKITE_COMMIT"), - workspace_path=env.get("BUILDKITE_BUILD_CHECKOUT_PATH"), - pipeline_id=env.get("BUILDKITE_BUILD_ID"), - pipeline_number=env.get("BUILDKITE_BUILD_NUMBER"), - pipeline_url=env.get("BUILDKITE_BUILD_URL"), - branch=env.get("BUILDKITE_BRANCH"), - ) diff --git a/ddtrace/ext/ci/services/circle_ci.py b/ddtrace/ext/ci/services/circle_ci.py deleted file mode 100644 index 0f0d79de13c..00000000000 --- a/ddtrace/ext/ci/services/circle_ci.py +++ /dev/null @@ -1,13 +0,0 @@ -ENV_KEY = "CIRCLECI" - - -def extract(env): - return dict( - provider_name="circleci", - repository_url=env.get("CIRCLE_REPOSITORY_URL"), - commit_sha=env.get("CIRCLE_SHA1"), - workspace_path=env.get("CIRCLE_WORKING_DIRECTORY"), - pipeline_number=env.get("CIRCLE_BUILD_NUM"), - pipeline_url=env.get("CIRCLE_BUILD_URL"), - branch=env.get("CIRCLE_BRANCH"), - ) diff --git a/ddtrace/ext/ci/services/github_actions.py b/ddtrace/ext/ci/services/github_actions.py deleted file mode 100644 index 6b08d8ec4d2..00000000000 --- a/ddtrace/ext/ci/services/github_actions.py +++ /dev/null @@ -1,14 +0,0 @@ -ENV_KEY = "GITHUB_SHA" - - -def extract(env): - return dict( - provider_name="github", - repository_url=env.get("GITHUB_REPOSITORY"), - commit_sha=env.get("GITHUB_SHA"), - workspace_path=env.get("GITHUB_WORKSPACE"), - pipeline_id=env.get("GITHUB_RUN_ID"), - pipeline_number=env.get("GITHUB_RUN_NUMBER"), - pipeline_url="{0}/commit/{1}/checks".format(env.get("GITHUB_REPOSITORY"), env.get("GITHUB_SHA")), - branch=env.get("GITHUB_REF"), - ) diff --git a/ddtrace/ext/ci/services/gitlab.py b/ddtrace/ext/ci/services/gitlab.py deleted file mode 100644 index 8194b39bb14..00000000000 --- a/ddtrace/ext/ci/services/gitlab.py +++ /dev/null @@ -1,15 +0,0 @@ -ENV_KEY = "GITLAB_CI" - - -def extract(env): - return dict( - provider_name="gitlab", - repository_url=env.get("CI_REPOSITORY_URL"), - commit_sha=env.get("CI_COMMIT_SHA"), - workspace_path=env.get("CI_PROJECT_DIR"), - pipeline_id=env.get("CI_PIPELINE_ID"), - pipeline_number=env.get("CI_PIPELINE_IID"), - pipeline_url=env.get("CI_PIPELINE_URL"), - job_url=env.get("CI_JOB_URL"), - branch=env.get("CI_COMMIT_BRANCH") or env.get("CI_COMMIT_REF_NAME"), - ) diff --git a/ddtrace/ext/ci/services/jenkins.py b/ddtrace/ext/ci/services/jenkins.py deleted file mode 100644 index e9861b38eed..00000000000 --- a/ddtrace/ext/ci/services/jenkins.py +++ /dev/null @@ -1,20 +0,0 @@ -import re - -_RE_ORIGIN = re.compile(r"^origin/") - - -ENV_KEY = "JENKINS_URL" - - -def extract(env): - return dict( - provider_name="jenkins", - repository_url=env.get("GIT_URL"), - commit_sha=env.get("GIT_COMMIT"), - workspace_path=env.get("WORKSPACE"), - pipeline_id=env.get("BUILD_ID"), - pipeline_number=env.get("BUILD_NUMBER"), - pipeline_url=env.get("BUILD_URL"), - job_url=env.get("JOB_URL"), - branch=_RE_ORIGIN.sub("", env.get("GIT_BRANCH")), - ) diff --git a/ddtrace/ext/ci/services/teamcity.py b/ddtrace/ext/ci/services/teamcity.py deleted file mode 100644 index fbdfdaaaac1..00000000000 --- a/ddtrace/ext/ci/services/teamcity.py +++ /dev/null @@ -1,17 +0,0 @@ -ENV_KEY = "TEAMCITY_VERSION" - - -def extract(env): - return dict( - provider_name="teamcity", - repository_url=env.get("BUILD_VCS_URL"), - commit_sha=env.get("BUILD_VCS_NUMBER"), - workspace_path=env.get("BUILD_CHECKOUTDIR"), - pipeline_id=env.get("BUILD_ID"), - pipeline_number=env.get("BUILD_NUMBER"), - pipeline_url=( - "{0}/viewLog.html?buildId={1}".format(env.get("SERVER_URL"), env.get("BUILD_ID")) - if env.get("SERVER_URL") and env.get("BUILD_ID") - else None - ), - ) diff --git a/ddtrace/ext/ci/services/travis.py b/ddtrace/ext/ci/services/travis.py deleted file mode 100644 index 57073d8867b..00000000000 --- a/ddtrace/ext/ci/services/travis.py +++ /dev/null @@ -1,15 +0,0 @@ -ENV_KEY = "TRAVIS" - - -def extract(env): - return dict( - provider_name="travis", - repository_url=env.get("TRAVIS_REPO_SLUG"), - commit_sha=env.get("TRAVIS_COMMIT"), - workspace_path=env.get("TRAVIS_BUILD_DIR"), - pipeline_id=env.get("TRAVIS_BUILD_ID"), - pipeline_number=env.get("TRAVIS_BUILD_NUMBER"), - pipeline_url=env.get("TRAVIS_BUILD_WEB_URL"), - job_url=env.get("TRAVIS_JOB_WEB_URL"), - branch=env.get("TRAVIS_PULL_REQUEST_BRANCH") or env.get("TRAVIS_BRANCH"), - ) diff --git a/ddtrace/ext/git.py b/ddtrace/ext/git.py index d1009334a22..46b6aa88cfc 100644 --- a/ddtrace/ext/git.py +++ b/ddtrace/ext/git.py @@ -3,13 +3,14 @@ """ # Git Branch -BRANCH = GIT_BRANCH = "git.branch" +BRANCH = "git.branch" # Git Commit SHA -COMMIT_SHA = GIT_COMMIT_SHA = "git.commit.sha" +COMMIT_SHA = "git.commit.sha" +DEPRECATED_COMMIT_SHA = "git.commit_sha" # Git Repository URL -REPOSITORY_URL = GIT_REPOSITORY_URL = "git.repository_url" +REPOSITORY_URL = "git.repository_url" # Git Tag -TAG = GIT_TAG = "git.tag" +TAG = "git.tag" diff --git a/ddtrace/ext/provider.py b/ddtrace/ext/provider.py deleted file mode 100644 index 7416aad4fdc..00000000000 --- a/ddtrace/ext/provider.py +++ /dev/null @@ -1,75 +0,0 @@ -""" -common CI providers -""" - -import os -import re - -from ddtrace.vendor import attr - -from . import ci, git -from ..internal.logger import get_logger - -log = get_logger(__name__) - -_PROVIDER_METADATA_KEY = "ddtrace.ext.provider" - - -def field(name, *args, **kwargs): - kwargs.setdefault("metadata", {}) - kwargs["metadata"][_PROVIDER_METADATA_KEY] = name - return attr.ib(*args, **kwargs) - - -_RE_BRANCH_PREFIX = re.compile(r"^refs/(heads/)?") - - -@attr.s(kw_only=True, eq=False, order=False, slots=True) -class Provider(object): - - # CI properties - job_url = field(ci.JOB_URL, default=None) - pipeline_id = field(ci.PIPELINE_ID, default=None) - pipeline_name = field(ci.PIPELINE_NAME, default=None) - pipeline_number = field(ci.PIPELINE_NUMBER, default=None) - pipeline_url = field(ci.PIPELINE_URL, default=None) - provider_name = field(ci.PROVIDER_NAME, default=None) - workspace_path = field(ci.WORKSPACE_PATH, default=None) - - # Git properties - branch = field( - git.BRANCH, default=None, converter=attr.converters.optional(lambda value: _RE_BRANCH_PREFIX.sub("", value)) - ) - commit_sha = field(git.COMMIT_SHA, default=None) - repository_url = field(git.REPOSITORY_URL, default=None) - tag = field(git.TAG, default=None) - - # Deprecated properties - _deprecated_commit_sha = field("git.commit_sha") - - @_deprecated_commit_sha.default - def _default_deprecated_commit_sha(self): - return self.commit_sha - - def astags(self): - """Add provider information to span.""" - return {_PROVIDER_LABELS[name]: value for name, value in attr.asdict(self).items() if value is not None} - - @classmethod - def from_env(cls, env=None): - """Build provider information from environment variables.""" - from .ci import services - - env = os.environ if env is None else env - - for provider in services.PROVIDERS: - if env.get(provider.ENV_KEY) is not None: - try: - return cls(**provider.extract(env)) - except Exception: - log.error("could not create '{0}' provider info", provider.__name__) - - return cls() - - -_PROVIDER_LABELS = {f.name: f.metadata[_PROVIDER_METADATA_KEY] for f in attr.fields(Provider)} diff --git a/tests/contrib/pytest/test_pytest.py b/tests/contrib/pytest/test_pytest.py index c26a575f395..8fdf8c36c3f 100644 --- a/tests/contrib/pytest/test_pytest.py +++ b/tests/contrib/pytest/test_pytest.py @@ -121,6 +121,7 @@ def test_fixture(ddspan): spans = self.tracer.writer.pop() assert len(spans) == 1 + assert spans[0].service == "pytest" assert spans[0].get_tag("world") == "hello" assert spans[0].get_tag("mark") == "dd_tags" assert spans[0].get_tag(test.STATUS) == test.Status.PASS.value diff --git a/tests/tracer/test_ext.py b/tests/tracer/test_ext.py index 4582b088331..309db80d8a4 100644 --- a/tests/tracer/test_ext.py +++ b/tests/tracer/test_ext.py @@ -3,7 +3,6 @@ from ddtrace.ext import aws from ddtrace.ext import ci from ddtrace.ext import git -from ddtrace.ext import provider def test_flatten_dict(): @@ -32,4 +31,4 @@ def test_flatten_dict(): @pytest.mark.parametrize("environment,tags", AZURE) def test_ci_providers(environment, tags): - assert tags == provider.Provider.from_env(environment).astags() + assert tags == ci.tags(environment) From 45ab2ecaac72da991aeeda276498bbca81eb6738 Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Tue, 27 Oct 2020 16:51:42 +0100 Subject: [PATCH 19/34] add tests for azurepipelines --- ddtrace/ext/ci.py | 100 +++---- tests/tracer/test_ext.py | 567 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 611 insertions(+), 56 deletions(-) diff --git a/ddtrace/ext/ci.py b/ddtrace/ext/ci.py index 1cfc576bfbe..81381a053d3 100644 --- a/ddtrace/ext/ci.py +++ b/ddtrace/ext/ci.py @@ -27,8 +27,8 @@ # Workspace Path WORKSPACE_PATH = "ci.workspace_path" -_RE_ORIGIN = re.compile(r"^origin/") -_RE_BRANCH_PREFIX = re.compile(r"^refs/(heads/)?") +_RE_TAGS = re.compile(r"^tags/") +_RE_BRANCH_PREFIX = re.compile(r"^(refs/(heads/)|origin/)?") def tags(env=None): @@ -40,8 +40,14 @@ def tags(env=None): # Post process special cases branch = tags.get(git.BRANCH) if branch: - tags[git.BRANCH] = _RE_BRANCH_PREFIX.sub("", branch) + tags[git.BRANCH] = _RE_TAGS.sub("", _RE_BRANCH_PREFIX.sub("", branch)) + tag = tags.get(git.TAG) + if tag: + tags[git.TAG] = _RE_TAGS.sub("", _RE_BRANCH_PREFIX.sub("", tag)) tags[git.DEPRECATED_COMMIT_SHA] = tags.get(git.COMMIT_SHA) + workspace_path = tags.get(WORKSPACE_PATH) + if workspace_path: + tags[WORKSPACE_PATH] = os.path.expanduser(workspace_path) tags = {k: v for k, v in tags.items() if v is not None} return tags @@ -64,33 +70,37 @@ def extract_appveyor(env): def extract_azure_pipelines(env): + print(env.get("SYSTEM_TEAMFOUNDATIONSERVERURI"), env.get("SYSTEM_TEAMPROJECT"), env.get("BUILD_BUILDID")) + if env.get("SYSTEM_TEAMFOUNDATIONSERVERURI") and env.get("SYSTEM_TEAMPROJECT") and env.get("BUILD_BUILDID"): + base_url = "{0}{1}/_build/results?buildId={2}".format( + env.get("SYSTEM_TEAMFOUNDATIONSERVERURI"), env.get("SYSTEM_TEAMPROJECT"), env.get("BUILD_BUILDID") + ) + pipeline_url = base_url + "&_a=summary" + job_url = base_url + "&view=logs&j={0}&t={1}".format(env.get("SYSTEM_JOBID"), env.get("SYSTEM_TASKINSTANCEID")) + else: + pipeline_url = job_url = None + branch_or_tag = ( + env.get("SYSTEM_PULLREQUEST_SOURCEBRANCH") or env.get("BUILD_SOURCEBRANCH") or env.get("BUILD_SOURCEBRANCHNAME") + ) return { - PROVIDER_NAME:"azurepipelines", + PROVIDER_NAME: "azurepipelines", WORKSPACE_PATH: env.get("BUILD_SOURCESDIRECTORY"), PIPELINE_ID: env.get("BUILD_BUILDID"), PIPELINE_NAME: env.get("BUILD_DEFINITIONNAME"), - PIPELINE_NUMBER: env.get("BUILD_BUILDNUMBER"), - PIPELINE_URL: all( - (env.get("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"), env.get("SYSTEM_TEAMPROJECT"), env.get("BUILD_BUILDID")) - ) - and "{0}{1}/_build/results?buildId={2}&_a=summary".format( - env.get("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"), env.get("SYSTEM_TEAMPROJECT"), env.get("BUILD_BUILDID") - ) - or None, - git.REPOSITORY_URL:env.get("BUILD_REPOSITORY_URI"), + PIPELINE_NUMBER: env.get("BUILD_BUILDID"), + PIPELINE_URL: pipeline_url, + JOB_URL: job_url, + git.REPOSITORY_URL: env.get("SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI") or env.get("BUILD_REPOSITORY_URI"), git.COMMIT_SHA: env.get("SYSTEM_PULLREQUEST_SOURCECOMMITID") or env.get("BUILD_SOURCEVERSION"), - git.BRANCH: ( - env.get("SYSTEM_PULLREQUEST_SOURCEBRANCH") - or env.get("BUILD_SOURCEBRANCH") - or env.get("BUILD_SOURCEBRANCHNAME") - ), + git.BRANCH: branch_or_tag if "tags/" not in branch_or_tag else None, + git.TAG: branch_or_tag if "tags/" in branch_or_tag else None, } def extract_bitbucket(env): return { - PROVIDER_NAME:"bitbucketpipelines", - git.REPOSITORY_URL:env.get("BITBUCKET_GIT_SSH_ORIGIN"), + PROVIDER_NAME: "bitbucketpipelines", + git.REPOSITORY_URL: env.get("BITBUCKET_GIT_SSH_ORIGIN"), git.COMMIT_SHA: env.get("BITBUCKET_COMMIT"), WORKSPACE_PATH: env.get("BITBUCKET_CLONE_DIR"), PIPELINE_ID: env.get("BITBUCKET_PIPELINE_UUID"), @@ -100,8 +110,8 @@ def extract_bitbucket(env): def extract_buildkite(env): return { - PROVIDER_NAME:"buildkite", - git.REPOSITORY_URL:env.get("BUILDKITE_REPO"), + PROVIDER_NAME: "buildkite", + git.REPOSITORY_URL: env.get("BUILDKITE_REPO"), git.COMMIT_SHA: env.get("BUILDKITE_COMMIT"), WORKSPACE_PATH: env.get("BUILDKITE_BUILD_CHECKOUT_PATH"), PIPELINE_ID: env.get("BUILDKITE_BUILD_ID"), @@ -113,8 +123,8 @@ def extract_buildkite(env): def extract_circle_ci(env): return { - PROVIDER_NAME:"circleci", - git.REPOSITORY_URL:env.get("CIRCLE_REPOSITORY_URL"), + PROVIDER_NAME: "circleci", + git.REPOSITORY_URL: env.get("CIRCLE_REPOSITORY_URL"), git.COMMIT_SHA: env.get("CIRCLE_SHA1"), WORKSPACE_PATH: env.get("CIRCLE_WORKING_DIRECTORY"), PIPELINE_NUMBER: env.get("CIRCLE_BUILD_NUM"), @@ -125,8 +135,8 @@ def extract_circle_ci(env): def extract_github_actions(env): return { - PROVIDER_NAME:"github", - git.REPOSITORY_URL:env.get("GITHUB_REPOSITORY"), + PROVIDER_NAME: "github", + git.REPOSITORY_URL: env.get("GITHUB_REPOSITORY"), git.COMMIT_SHA: env.get("GITHUB_SHA"), WORKSPACE_PATH: env.get("GITHUB_WORKSPACE"), PIPELINE_ID: env.get("GITHUB_RUN_ID"), @@ -138,8 +148,8 @@ def extract_github_actions(env): def extract_gitlab(env): return { - PROVIDER_NAME:"gitlab", - git.REPOSITORY_URL:env.get("CI_REPOSITORY_URL"), + PROVIDER_NAME: "gitlab", + git.REPOSITORY_URL: env.get("CI_REPOSITORY_URL"), git.COMMIT_SHA: env.get("CI_COMMIT_SHA"), WORKSPACE_PATH: env.get("CI_PROJECT_DIR"), PIPELINE_ID: env.get("CI_PIPELINE_ID"), @@ -152,22 +162,22 @@ def extract_gitlab(env): def extract_jenkins(env): return { - PROVIDER_NAME:"jenkins", - git.REPOSITORY_URL:env.get("GIT_URL"), + PROVIDER_NAME: "jenkins", + git.REPOSITORY_URL: env.get("GIT_URL"), git.COMMIT_SHA: env.get("GIT_COMMIT"), WORKSPACE_PATH: env.get("WORKSPACE"), PIPELINE_ID: env.get("BUILD_ID"), PIPELINE_NUMBER: env.get("BUILD_NUMBER"), PIPELINE_URL: env.get("BUILD_URL"), JOB_URL: env.get("JOB_URL"), - git.BRANCH: _RE_ORIGIN.sub("", env.get("GIT_BRANCH")), + git.BRANCH: env.get("GIT_BRANCH"), } def extract_teamcity(env): return { - PROVIDER_NAME:"teamcity", - git.REPOSITORY_URL:env.get("BUILD_VCS_URL"), + PROVIDER_NAME: "teamcity", + git.REPOSITORY_URL: env.get("BUILD_VCS_URL"), git.COMMIT_SHA: env.get("BUILD_VCS_NUMBER"), WORKSPACE_PATH: env.get("BUILD_CHECKOUTDIR"), PIPELINE_ID: env.get("BUILD_ID"), @@ -182,8 +192,8 @@ def extract_teamcity(env): def extract_travis(env): return { - PROVIDER_NAME:"travis", - git.REPOSITORY_URL:env.get("TRAVIS_REPO_SLUG"), + PROVIDER_NAME: "travis", + git.REPOSITORY_URL: env.get("TRAVIS_REPO_SLUG"), git.COMMIT_SHA: env.get("TRAVIS_COMMIT"), WORKSPACE_PATH: env.get("TRAVIS_BUILD_DIR"), PIPELINE_ID: env.get("TRAVIS_BUILD_ID"), @@ -195,14 +205,14 @@ def extract_travis(env): PROVIDERS = ( - ('APPVEYOR', extract_appveyor), - ('TF_BUILD', extract_azure_pipelines), - ('BITBUCKET_COMMIT', extract_bitbucket), - ('BUILDKITE', extract_buildkite), - ('CIRCLECI', extract_circle_ci), - ('GITHUB_SHA', extract_github_actions), - ('GITLAB_CI', extract_gitlab), - ('JENKINS_URL', extract_jenkins), - ('TEAMCITY_VERSION', extract_teamcity), - ('TRAVIS', extract_travis), + ("APPVEYOR", extract_appveyor), + ("TF_BUILD", extract_azure_pipelines), + ("BITBUCKET_COMMIT", extract_bitbucket), + ("BUILDKITE", extract_buildkite), + ("CIRCLECI", extract_circle_ci), + ("GITHUB_SHA", extract_github_actions), + ("GITLAB_CI", extract_gitlab), + ("JENKINS_URL", extract_jenkins), + ("TEAMCITY_VERSION", extract_teamcity), + ("TRAVIS", extract_travis), ) diff --git a/tests/tracer/test_ext.py b/tests/tracer/test_ext.py index 309db80d8a4..cab654ce1bf 100644 --- a/tests/tracer/test_ext.py +++ b/tests/tracer/test_ext.py @@ -13,22 +13,567 @@ def test_flatten_dict(): AZURE = [ - ( + [ { - "TF_BUILD": "true", - "BUILD_DEFINITIONNAME": "name", - "BUILD_SOURCEVERSION": "0000000000000000000000000000000000000000", + "BUILD_BUILDID": "azure-pipelines-build-id", + "BUILD_DEFINITIONNAME": "azure-pipelines-name", + "BUILD_REPOSITORY_URI": "sample", + "BUILD_SOURCEBRANCH": "master", + "BUILD_SOURCESDIRECTORY": "/foo/bar", + "BUILD_SOURCEVERSION": "commit", + "SYSTEM_JOBID": "azure-pipelines-job-id", + "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", + "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", + "SYSTEM_TEAMPROJECT": "azure-pipelines-project", + "TF_BUILD": "True", }, { - ci.PROVIDER_NAME: "azurepipelines", - ci.PIPELINE_NAME: "name", - git.COMMIT_SHA: "0000000000000000000000000000000000000000", - "git.commit_sha": "0000000000000000000000000000000000000000", # deprecated field + "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", + "ci.pipeline.id": "azure-pipelines-build-id", + "ci.pipeline.name": "azure-pipelines-name", + "ci.pipeline.number": "azure-pipelines-build-id", + "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", + "ci.provider.name": "azurepipelines", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "commit", + "git.commit_sha": "commit", + "git.repository_url": "sample", }, - ), + ], + [ + { + "BUILD_BUILDID": "azure-pipelines-build-id", + "BUILD_DEFINITIONNAME": "azure-pipelines-name", + "BUILD_REPOSITORY_URI": "sample", + "BUILD_SOURCEBRANCH": "master", + "BUILD_SOURCESDIRECTORY": "/foo/bar", + "BUILD_SOURCEVERSION": "commit", + "SYSTEM_JOBID": "azure-pipelines-job-id", + "SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI": "", + "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", + "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", + "SYSTEM_TEAMPROJECT": "azure-pipelines-project", + "TF_BUILD": "True", + }, + { + "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", + "ci.pipeline.id": "azure-pipelines-build-id", + "ci.pipeline.name": "azure-pipelines-name", + "ci.pipeline.number": "azure-pipelines-build-id", + "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", + "ci.provider.name": "azurepipelines", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "commit", + "git.commit_sha": "commit", + "git.repository_url": "sample", + }, + ], + [ + { + "BUILD_BUILDID": "azure-pipelines-build-id", + "BUILD_DEFINITIONNAME": "azure-pipelines-name", + "BUILD_REPOSITORY_URI": "sample", + "BUILD_SOURCEBRANCH": "master", + "BUILD_SOURCESDIRECTORY": "/foo/bar", + "BUILD_SOURCEVERSION": "commit", + "SYSTEM_JOBID": "azure-pipelines-job-id", + "SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI": "sample2", + "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", + "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", + "SYSTEM_TEAMPROJECT": "azure-pipelines-project", + "TF_BUILD": "True", + }, + { + "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", + "ci.pipeline.id": "azure-pipelines-build-id", + "ci.pipeline.name": "azure-pipelines-name", + "ci.pipeline.number": "azure-pipelines-build-id", + "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", + "ci.provider.name": "azurepipelines", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "commit", + "git.commit_sha": "commit", + "git.repository_url": "sample2", + }, + ], + [ + { + "BUILD_BUILDID": "azure-pipelines-build-id", + "BUILD_DEFINITIONNAME": "azure-pipelines-name", + "BUILD_REPOSITORY_URI": "sample", + "BUILD_SOURCEBRANCH": "master", + "BUILD_SOURCESDIRECTORY": "/foo/bar", + "BUILD_SOURCEVERSION": "commit", + "SYSTEM_JOBID": "azure-pipelines-job-id", + "SYSTEM_PULLREQUEST_SOURCEBRANCH": "", + "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", + "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", + "SYSTEM_TEAMPROJECT": "azure-pipelines-project", + "TF_BUILD": "True", + }, + { + "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", + "ci.pipeline.id": "azure-pipelines-build-id", + "ci.pipeline.name": "azure-pipelines-name", + "ci.pipeline.number": "azure-pipelines-build-id", + "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", + "ci.provider.name": "azurepipelines", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "commit", + "git.commit_sha": "commit", + "git.repository_url": "sample", + }, + ], + [ + { + "BUILD_BUILDID": "azure-pipelines-build-id", + "BUILD_DEFINITIONNAME": "azure-pipelines-name", + "BUILD_REPOSITORY_URI": "sample", + "BUILD_SOURCEBRANCH": "master", + "BUILD_SOURCESDIRECTORY": "/foo/bar", + "BUILD_SOURCEVERSION": "commit", + "SYSTEM_JOBID": "azure-pipelines-job-id", + "SYSTEM_PULLREQUEST_SOURCECOMMITID": "", + "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", + "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", + "SYSTEM_TEAMPROJECT": "azure-pipelines-project", + "TF_BUILD": "True", + }, + { + "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", + "ci.pipeline.id": "azure-pipelines-build-id", + "ci.pipeline.name": "azure-pipelines-name", + "ci.pipeline.number": "azure-pipelines-build-id", + "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", + "ci.provider.name": "azurepipelines", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "commit", + "git.commit_sha": "commit", + "git.repository_url": "sample", + }, + ], + [ + { + "BUILD_BUILDID": "azure-pipelines-build-id", + "BUILD_DEFINITIONNAME": "azure-pipelines-name", + "BUILD_REPOSITORY_URI": "sample", + "BUILD_SOURCEBRANCH": "origin/master", + "BUILD_SOURCESDIRECTORY": "foo/bar", + "BUILD_SOURCEVERSION": "commit", + "SYSTEM_JOBID": "azure-pipelines-job-id", + "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", + "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", + "SYSTEM_TEAMPROJECT": "azure-pipelines-project", + "TF_BUILD": "True", + }, + { + "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", + "ci.pipeline.id": "azure-pipelines-build-id", + "ci.pipeline.name": "azure-pipelines-name", + "ci.pipeline.number": "azure-pipelines-build-id", + "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", + "ci.provider.name": "azurepipelines", + "ci.workspace_path": "foo/bar", + "git.branch": "master", + "git.commit.sha": "commit", + "git.commit_sha": "commit", + "git.repository_url": "sample", + }, + ], + [ + { + "BUILD_BUILDID": "azure-pipelines-build-id", + "BUILD_DEFINITIONNAME": "azure-pipelines-name", + "BUILD_REPOSITORY_URI": "sample", + "BUILD_SOURCEBRANCH": "origin/master", + "BUILD_SOURCESDIRECTORY": "/foo/bar~", + "BUILD_SOURCEVERSION": "commit", + "HOME": "/not-my-home", + "SYSTEM_JOBID": "azure-pipelines-job-id", + "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", + "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", + "SYSTEM_TEAMPROJECT": "azure-pipelines-project", + "TF_BUILD": "True", + "USERPROFILE": "/not-my-home", + }, + { + "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", + "ci.pipeline.id": "azure-pipelines-build-id", + "ci.pipeline.name": "azure-pipelines-name", + "ci.pipeline.number": "azure-pipelines-build-id", + "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", + "ci.provider.name": "azurepipelines", + "ci.workspace_path": "/foo/bar~", + "git.branch": "master", + "git.commit.sha": "commit", + "git.commit_sha": "commit", + "git.repository_url": "sample", + }, + ], + [ + { + "BUILD_BUILDID": "azure-pipelines-build-id", + "BUILD_DEFINITIONNAME": "azure-pipelines-name", + "BUILD_REPOSITORY_URI": "sample", + "BUILD_SOURCEBRANCH": "origin/master", + "BUILD_SOURCESDIRECTORY": "/foo/~/bar", + "BUILD_SOURCEVERSION": "commit", + "HOME": "/not-my-home", + "SYSTEM_JOBID": "azure-pipelines-job-id", + "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", + "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", + "SYSTEM_TEAMPROJECT": "azure-pipelines-project", + "TF_BUILD": "True", + "USERPROFILE": "/not-my-home", + }, + { + "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", + "ci.pipeline.id": "azure-pipelines-build-id", + "ci.pipeline.name": "azure-pipelines-name", + "ci.pipeline.number": "azure-pipelines-build-id", + "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", + "ci.provider.name": "azurepipelines", + "ci.workspace_path": "/foo/~/bar", + "git.branch": "master", + "git.commit.sha": "commit", + "git.commit_sha": "commit", + "git.repository_url": "sample", + }, + ], + [ + { + "BUILD_BUILDID": "azure-pipelines-build-id", + "BUILD_DEFINITIONNAME": "azure-pipelines-name", + "BUILD_REPOSITORY_URI": "sample", + "BUILD_SOURCEBRANCH": "origin/master", + "BUILD_SOURCESDIRECTORY": "~/foo/bar", + "BUILD_SOURCEVERSION": "commit", + "HOME": "/not-my-home", + "SYSTEM_JOBID": "azure-pipelines-job-id", + "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", + "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", + "SYSTEM_TEAMPROJECT": "azure-pipelines-project", + "TF_BUILD": "True", + "USERPROFILE": "/not-my-home", + }, + { + "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", + "ci.pipeline.id": "azure-pipelines-build-id", + "ci.pipeline.name": "azure-pipelines-name", + "ci.pipeline.number": "azure-pipelines-build-id", + "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", + "ci.provider.name": "azurepipelines", + "ci.workspace_path": "/not-my-home/foo/bar", + "git.branch": "master", + "git.commit.sha": "commit", + "git.commit_sha": "commit", + "git.repository_url": "sample", + }, + ], + [ + { + "BUILD_BUILDID": "azure-pipelines-build-id", + "BUILD_DEFINITIONNAME": "azure-pipelines-name", + "BUILD_REPOSITORY_URI": "sample", + "BUILD_SOURCEBRANCH": "origin/master", + "BUILD_SOURCESDIRECTORY": "~foo/bar", + "BUILD_SOURCEVERSION": "commit", + "HOME": "/not-my-home", + "SYSTEM_JOBID": "azure-pipelines-job-id", + "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", + "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", + "SYSTEM_TEAMPROJECT": "azure-pipelines-project", + "TF_BUILD": "True", + "USERPROFILE": "/not-my-home", + }, + { + "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", + "ci.pipeline.id": "azure-pipelines-build-id", + "ci.pipeline.name": "azure-pipelines-name", + "ci.pipeline.number": "azure-pipelines-build-id", + "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", + "ci.provider.name": "azurepipelines", + "ci.workspace_path": "~foo/bar", + "git.branch": "master", + "git.commit.sha": "commit", + "git.commit_sha": "commit", + "git.repository_url": "sample", + }, + ], + [ + { + "BUILD_BUILDID": "azure-pipelines-build-id", + "BUILD_DEFINITIONNAME": "azure-pipelines-name", + "BUILD_REPOSITORY_URI": "sample", + "BUILD_SOURCEBRANCH": "origin/master", + "BUILD_SOURCESDIRECTORY": "~", + "BUILD_SOURCEVERSION": "commit", + "HOME": "/not-my-home", + "SYSTEM_JOBID": "azure-pipelines-job-id", + "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", + "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", + "SYSTEM_TEAMPROJECT": "azure-pipelines-project", + "TF_BUILD": "True", + "USERPROFILE": "/not-my-home", + }, + { + "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", + "ci.pipeline.id": "azure-pipelines-build-id", + "ci.pipeline.name": "azure-pipelines-name", + "ci.pipeline.number": "azure-pipelines-build-id", + "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", + "ci.provider.name": "azurepipelines", + "ci.workspace_path": "/not-my-home", + "git.branch": "master", + "git.commit.sha": "commit", + "git.commit_sha": "commit", + "git.repository_url": "sample", + }, + ], + [ + { + "BUILD_BUILDID": "azure-pipelines-build-id", + "BUILD_DEFINITIONNAME": "azure-pipelines-name", + "BUILD_REPOSITORY_URI": "sample", + "BUILD_SOURCEBRANCH": "origin/master", + "BUILD_SOURCESDIRECTORY": "/foo/bar", + "BUILD_SOURCEVERSION": "commit", + "SYSTEM_JOBID": "azure-pipelines-job-id", + "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", + "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", + "SYSTEM_TEAMPROJECT": "azure-pipelines-project", + "TF_BUILD": "True", + }, + { + "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", + "ci.pipeline.id": "azure-pipelines-build-id", + "ci.pipeline.name": "azure-pipelines-name", + "ci.pipeline.number": "azure-pipelines-build-id", + "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", + "ci.provider.name": "azurepipelines", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "commit", + "git.commit_sha": "commit", + "git.repository_url": "sample", + }, + ], + [ + { + "BUILD_BUILDID": "azure-pipelines-build-id", + "BUILD_DEFINITIONNAME": "azure-pipelines-name", + "BUILD_REPOSITORY_URI": "sample", + "BUILD_SOURCEBRANCH": "refs/heads/master", + "BUILD_SOURCESDIRECTORY": "/foo/bar", + "BUILD_SOURCEVERSION": "commit", + "SYSTEM_JOBID": "azure-pipelines-job-id", + "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", + "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", + "SYSTEM_TEAMPROJECT": "azure-pipelines-project", + "TF_BUILD": "True", + }, + { + "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", + "ci.pipeline.id": "azure-pipelines-build-id", + "ci.pipeline.name": "azure-pipelines-name", + "ci.pipeline.number": "azure-pipelines-build-id", + "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", + "ci.provider.name": "azurepipelines", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "commit", + "git.commit_sha": "commit", + "git.repository_url": "sample", + }, + ], + [ + { + "BUILD_BUILDID": "azure-pipelines-build-id", + "BUILD_DEFINITIONNAME": "azure-pipelines-name", + "BUILD_REPOSITORY_URI": "sample", + "BUILD_SOURCEBRANCH": "refs/heads/feature/one", + "BUILD_SOURCESDIRECTORY": "/foo/bar", + "BUILD_SOURCEVERSION": "commit", + "SYSTEM_JOBID": "azure-pipelines-job-id", + "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", + "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", + "SYSTEM_TEAMPROJECT": "azure-pipelines-project", + "TF_BUILD": "True", + }, + { + "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", + "ci.pipeline.id": "azure-pipelines-build-id", + "ci.pipeline.name": "azure-pipelines-name", + "ci.pipeline.number": "azure-pipelines-build-id", + "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", + "ci.provider.name": "azurepipelines", + "ci.workspace_path": "/foo/bar", + "git.branch": "feature/one", + "git.commit.sha": "commit", + "git.commit_sha": "commit", + "git.repository_url": "sample", + }, + ], + [ + { + "BUILD_BUILDID": "azure-pipelines-build-id", + "BUILD_DEFINITIONNAME": "azure-pipelines-name", + "BUILD_REPOSITORY_URI": "sample", + "BUILD_SOURCEBRANCH": "origin/tags/0.1.0", + "BUILD_SOURCESDIRECTORY": "/foo/bar", + "BUILD_SOURCEVERSION": "commit", + "SYSTEM_JOBID": "azure-pipelines-job-id", + "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", + "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", + "SYSTEM_TEAMPROJECT": "azure-pipelines-project", + "TF_BUILD": "True", + }, + { + "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", + "ci.pipeline.id": "azure-pipelines-build-id", + "ci.pipeline.name": "azure-pipelines-name", + "ci.pipeline.number": "azure-pipelines-build-id", + "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", + "ci.provider.name": "azurepipelines", + "ci.workspace_path": "/foo/bar", + "git.commit.sha": "commit", + "git.commit_sha": "commit", + "git.repository_url": "sample", + "git.tag": "0.1.0", + }, + ], + [ + { + "BUILD_BUILDID": "azure-pipelines-build-id", + "BUILD_DEFINITIONNAME": "azure-pipelines-name", + "BUILD_REPOSITORY_URI": "sample", + "BUILD_SOURCEBRANCH": "refs/heads/tags/0.1.0", + "BUILD_SOURCESDIRECTORY": "/foo/bar", + "BUILD_SOURCEVERSION": "commit", + "SYSTEM_JOBID": "azure-pipelines-job-id", + "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", + "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", + "SYSTEM_TEAMPROJECT": "azure-pipelines-project", + "TF_BUILD": "True", + }, + { + "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", + "ci.pipeline.id": "azure-pipelines-build-id", + "ci.pipeline.name": "azure-pipelines-name", + "ci.pipeline.number": "azure-pipelines-build-id", + "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", + "ci.provider.name": "azurepipelines", + "ci.workspace_path": "/foo/bar", + "git.commit.sha": "commit", + "git.commit_sha": "commit", + "git.repository_url": "sample", + "git.tag": "0.1.0", + }, + ], + [ + { + "BUILD_BUILDID": "azure-pipelines-build-id", + "BUILD_DEFINITIONNAME": "azure-pipelines-name", + "BUILD_REPOSITORY_URI": "sample", + "BUILD_SOURCEBRANCH": "origin/master", + "BUILD_SOURCESDIRECTORY": "/foo/bar", + "BUILD_SOURCEVERSION": "commit", + "SYSTEM_JOBID": "azure-pipelines-job-id", + "SYSTEM_PULLREQUEST_SOURCEBRANCH": "origin/pr", + "SYSTEM_PULLREQUEST_SOURCECOMMITID": "commitPR", + "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", + "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", + "SYSTEM_TEAMPROJECT": "azure-pipelines-project", + "TF_BUILD": "True", + }, + { + "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", + "ci.pipeline.id": "azure-pipelines-build-id", + "ci.pipeline.name": "azure-pipelines-name", + "ci.pipeline.number": "azure-pipelines-build-id", + "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", + "ci.provider.name": "azurepipelines", + "ci.workspace_path": "/foo/bar", + "git.branch": "pr", + "git.commit.sha": "commitPR", + "git.commit_sha": "commitPR", + "git.repository_url": "sample", + }, + ], + [ + { + "BUILD_BUILDID": "azure-pipelines-build-id", + "BUILD_DEFINITIONNAME": "azure-pipelines-name", + "BUILD_REPOSITORY_URI": "sample", + "BUILD_SOURCEBRANCH": "refs/heads/master", + "BUILD_SOURCESDIRECTORY": "/foo/bar", + "BUILD_SOURCEVERSION": "commit", + "SYSTEM_JOBID": "azure-pipelines-job-id", + "SYSTEM_PULLREQUEST_SOURCEBRANCH": "refs/heads/pr", + "SYSTEM_PULLREQUEST_SOURCECOMMITID": "commitPR", + "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", + "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", + "SYSTEM_TEAMPROJECT": "azure-pipelines-project", + "TF_BUILD": "True", + }, + { + "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", + "ci.pipeline.id": "azure-pipelines-build-id", + "ci.pipeline.name": "azure-pipelines-name", + "ci.pipeline.number": "azure-pipelines-build-id", + "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", + "ci.provider.name": "azurepipelines", + "ci.workspace_path": "/foo/bar", + "git.branch": "pr", + "git.commit.sha": "commitPR", + "git.commit_sha": "commitPR", + "git.repository_url": "sample", + }, + ], + [ + { + "BUILD_BUILDID": "azure-pipelines-build-id", + "BUILD_DEFINITIONNAME": "azure-pipelines-name", + "BUILD_REPOSITORY_URI": "sample", + "BUILD_SOURCEBRANCH": "refs/heads/feature/one", + "BUILD_SOURCESDIRECTORY": "/foo/bar", + "BUILD_SOURCEVERSION": "commit", + "SYSTEM_JOBID": "azure-pipelines-job-id", + "SYSTEM_PULLREQUEST_SOURCEBRANCH": "refs/heads/pr", + "SYSTEM_PULLREQUEST_SOURCECOMMITID": "commitPR", + "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", + "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", + "SYSTEM_TEAMPROJECT": "azure-pipelines-project", + "TF_BUILD": "True", + }, + { + "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", + "ci.pipeline.id": "azure-pipelines-build-id", + "ci.pipeline.name": "azure-pipelines-name", + "ci.pipeline.number": "azure-pipelines-build-id", + "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", + "ci.provider.name": "azurepipelines", + "ci.workspace_path": "/foo/bar", + "git.branch": "pr", + "git.commit.sha": "commitPR", + "git.commit_sha": "commitPR", + "git.repository_url": "sample", + }, + ], ] +def _updateenv(monkeypatch, env): + for k, v in env.items(): + monkeypatch.setenv(k, v) + + @pytest.mark.parametrize("environment,tags", AZURE) -def test_ci_providers(environment, tags): - assert tags == ci.tags(environment) +def test_ci_providers(monkeypatch, environment, tags): + _updateenv(monkeypatch, environment) + assert tags == ci.tags(), environment From 266dc990a2d890bfcf4c88c9c0f0c80b6cf48274 Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Tue, 27 Oct 2020 17:01:01 +0100 Subject: [PATCH 20/34] black --- ddtrace/ext/ci.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddtrace/ext/ci.py b/ddtrace/ext/ci.py index 81381a053d3..323c20935d7 100644 --- a/ddtrace/ext/ci.py +++ b/ddtrace/ext/ci.py @@ -90,7 +90,7 @@ def extract_azure_pipelines(env): PIPELINE_NUMBER: env.get("BUILD_BUILDID"), PIPELINE_URL: pipeline_url, JOB_URL: job_url, - git.REPOSITORY_URL: env.get("SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI") or env.get("BUILD_REPOSITORY_URI"), + git.REPOSITORY_URL: env.get("SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI") or env.get("BUILD_REPOSITORY_URI"), git.COMMIT_SHA: env.get("SYSTEM_PULLREQUEST_SOURCECOMMITID") or env.get("BUILD_SOURCEVERSION"), git.BRANCH: branch_or_tag if "tags/" not in branch_or_tag else None, git.TAG: branch_or_tag if "tags/" in branch_or_tag else None, From c3eaae771847f397075f53e07491155b9440707b Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Tue, 27 Oct 2020 18:51:56 +0100 Subject: [PATCH 21/34] appveyor --- ddtrace/ext/ci.py | 18 +- tests/tracer/test_ext.py | 414 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 426 insertions(+), 6 deletions(-) diff --git a/ddtrace/ext/ci.py b/ddtrace/ext/ci.py index 323c20935d7..902c77fa81f 100644 --- a/ddtrace/ext/ci.py +++ b/ddtrace/ext/ci.py @@ -38,12 +38,15 @@ def tags(env=None): tags = extract(env) # Post process special cases - branch = tags.get(git.BRANCH) - if branch: - tags[git.BRANCH] = _RE_TAGS.sub("", _RE_BRANCH_PREFIX.sub("", branch)) tag = tags.get(git.TAG) if tag: tags[git.TAG] = _RE_TAGS.sub("", _RE_BRANCH_PREFIX.sub("", tag)) + if git.BRANCH in tags: + del tags[git.BRANCH] + + branch = tags.get(git.BRANCH) + if branch: + tags[git.BRANCH] = _RE_TAGS.sub("", _RE_BRANCH_PREFIX.sub("", branch)) tags[git.DEPRECATED_COMMIT_SHA] = tags.get(git.COMMIT_SHA) workspace_path = tags.get(WORKSPACE_PATH) if workspace_path: @@ -57,15 +60,20 @@ def tags(env=None): def extract_appveyor(env): return { PROVIDER_NAME: "appveyor", - git.REPOSITORY_URL: env.get("APPVEYOR_REPO_NAME"), + git.REPOSITORY_URL: "https://github.com/{0}.git".format(env.get("APPVEYOR_REPO_NAME")), git.COMMIT_SHA: env.get("APPVEYOR_REPO_COMMIT"), WORKSPACE_PATH: env.get("APPVEYOR_BUILD_FOLDER"), PIPELINE_ID: env.get("APPVEYOR_BUILD_ID"), + PIPELINE_NAME: env.get("APPVEYOR_REPO_NAME"), PIPELINE_NUMBER: env.get("APPVEYOR_BUILD_NUMBER"), PIPELINE_URL: "https://ci.appveyor.com/project/{0}/builds/{1}".format( - env.get("APPVEYOR_PROJECT_SLUG"), env.get("APPVEYOR_BUILD_ID") + env.get("APPVEYOR_REPO_NAME"), env.get("APPVEYOR_BUILD_ID") + ), + JOB_URL: "https://ci.appveyor.com/project/{0}/builds/{1}".format( + env.get("APPVEYOR_REPO_NAME"), env.get("APPVEYOR_BUILD_ID") ), git.BRANCH: env.get("APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH") or env.get("APPVEYOR_REPO_BRANCH"), + git.TAG: env.get("APPVEYOR_REPO_TAG_NAME"), } diff --git a/tests/tracer/test_ext.py b/tests/tracer/test_ext.py index cab654ce1bf..f7c43019cd3 100644 --- a/tests/tracer/test_ext.py +++ b/tests/tracer/test_ext.py @@ -12,6 +12,418 @@ def test_flatten_dict(): assert aws._flatten_dict(d, sep="_") == e +APPVEYOR = [ + [ + { + "APPVEYOR": "true", + "APPVEYOR_BUILD_FOLDER": "/foo/bar", + "APPVEYOR_BUILD_ID": "appveyor-build-id", + "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", + "APPVEYOR_REPO_BRANCH": "master", + "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", + "APPVEYOR_REPO_NAME": "appveyor-repo-name", + "APPVEYOR_REPO_PROVIDER": "github" + }, + { + "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.pipeline.id": "appveyor-build-id", + "ci.pipeline.name": "appveyor-repo-name", + "ci.pipeline.number": "appveyor-pipeline-number", + "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.provider.name": "appveyor", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "appveyor-repo-commit", + "git.commit_sha": "appveyor-repo-commit", + "git.repository_url": "https://github.com/appveyor-repo-name.git" + } + ], + [ + { + "APPVEYOR": "true", + "APPVEYOR_BUILD_FOLDER": "/foo/bar", + "APPVEYOR_BUILD_ID": "appveyor-build-id", + "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", + "APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH": "", + "APPVEYOR_REPO_BRANCH": "master", + "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", + "APPVEYOR_REPO_NAME": "appveyor-repo-name", + "APPVEYOR_REPO_PROVIDER": "github" + }, + { + "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.pipeline.id": "appveyor-build-id", + "ci.pipeline.name": "appveyor-repo-name", + "ci.pipeline.number": "appveyor-pipeline-number", + "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.provider.name": "appveyor", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "appveyor-repo-commit", + "git.commit_sha": "appveyor-repo-commit", + "git.repository_url": "https://github.com/appveyor-repo-name.git" + } + ], + [ + { + "APPVEYOR": "true", + "APPVEYOR_BUILD_FOLDER": "foo/bar", + "APPVEYOR_BUILD_ID": "appveyor-build-id", + "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", + "APPVEYOR_REPO_BRANCH": "master", + "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", + "APPVEYOR_REPO_NAME": "appveyor-repo-name", + "APPVEYOR_REPO_PROVIDER": "github" + }, + { + "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.pipeline.id": "appveyor-build-id", + "ci.pipeline.name": "appveyor-repo-name", + "ci.pipeline.number": "appveyor-pipeline-number", + "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.provider.name": "appveyor", + "ci.workspace_path": "foo/bar", + "git.branch": "master", + "git.commit.sha": "appveyor-repo-commit", + "git.commit_sha": "appveyor-repo-commit", + "git.repository_url": "https://github.com/appveyor-repo-name.git" + } + ], + [ + { + "APPVEYOR": "true", + "APPVEYOR_BUILD_FOLDER": "/foo/bar~", + "APPVEYOR_BUILD_ID": "appveyor-build-id", + "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", + "APPVEYOR_REPO_BRANCH": "master", + "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", + "APPVEYOR_REPO_NAME": "appveyor-repo-name", + "APPVEYOR_REPO_PROVIDER": "github" + }, + { + "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.pipeline.id": "appveyor-build-id", + "ci.pipeline.name": "appveyor-repo-name", + "ci.pipeline.number": "appveyor-pipeline-number", + "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.provider.name": "appveyor", + "ci.workspace_path": "/foo/bar~", + "git.branch": "master", + "git.commit.sha": "appveyor-repo-commit", + "git.commit_sha": "appveyor-repo-commit", + "git.repository_url": "https://github.com/appveyor-repo-name.git" + } + ], + [ + { + "APPVEYOR": "true", + "APPVEYOR_BUILD_FOLDER": "/foo/~/bar", + "APPVEYOR_BUILD_ID": "appveyor-build-id", + "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", + "APPVEYOR_REPO_BRANCH": "master", + "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", + "APPVEYOR_REPO_NAME": "appveyor-repo-name", + "APPVEYOR_REPO_PROVIDER": "github" + }, + { + "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.pipeline.id": "appveyor-build-id", + "ci.pipeline.name": "appveyor-repo-name", + "ci.pipeline.number": "appveyor-pipeline-number", + "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.provider.name": "appveyor", + "ci.workspace_path": "/foo/~/bar", + "git.branch": "master", + "git.commit.sha": "appveyor-repo-commit", + "git.commit_sha": "appveyor-repo-commit", + "git.repository_url": "https://github.com/appveyor-repo-name.git" + } + ], + [ + { + "APPVEYOR": "true", + "APPVEYOR_BUILD_FOLDER": "~/foo/bar", + "APPVEYOR_BUILD_ID": "appveyor-build-id", + "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", + "APPVEYOR_REPO_BRANCH": "master", + "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", + "APPVEYOR_REPO_NAME": "appveyor-repo-name", + "APPVEYOR_REPO_PROVIDER": "github", + "HOME": "/not-my-home", + "USERPROFILE": "/not-my-home" + }, + { + "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.pipeline.id": "appveyor-build-id", + "ci.pipeline.name": "appveyor-repo-name", + "ci.pipeline.number": "appveyor-pipeline-number", + "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.provider.name": "appveyor", + "ci.workspace_path": "/not-my-home/foo/bar", + "git.branch": "master", + "git.commit.sha": "appveyor-repo-commit", + "git.commit_sha": "appveyor-repo-commit", + "git.repository_url": "https://github.com/appveyor-repo-name.git" + } + ], + [ + { + "APPVEYOR": "true", + "APPVEYOR_BUILD_FOLDER": "~foo/bar", + "APPVEYOR_BUILD_ID": "appveyor-build-id", + "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", + "APPVEYOR_REPO_BRANCH": "master", + "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", + "APPVEYOR_REPO_NAME": "appveyor-repo-name", + "APPVEYOR_REPO_PROVIDER": "github" + }, + { + "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.pipeline.id": "appveyor-build-id", + "ci.pipeline.name": "appveyor-repo-name", + "ci.pipeline.number": "appveyor-pipeline-number", + "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.provider.name": "appveyor", + "ci.workspace_path": "~foo/bar", + "git.branch": "master", + "git.commit.sha": "appveyor-repo-commit", + "git.commit_sha": "appveyor-repo-commit", + "git.repository_url": "https://github.com/appveyor-repo-name.git" + } + ], + [ + { + "APPVEYOR": "true", + "APPVEYOR_BUILD_FOLDER": "~", + "APPVEYOR_BUILD_ID": "appveyor-build-id", + "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", + "APPVEYOR_REPO_BRANCH": "master", + "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", + "APPVEYOR_REPO_NAME": "appveyor-repo-name", + "APPVEYOR_REPO_PROVIDER": "github", + "HOME": "/not-my-home", + "USERPROFILE": "/not-my-home" + }, + { + "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.pipeline.id": "appveyor-build-id", + "ci.pipeline.name": "appveyor-repo-name", + "ci.pipeline.number": "appveyor-pipeline-number", + "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.provider.name": "appveyor", + "ci.workspace_path": "/not-my-home", + "git.branch": "master", + "git.commit.sha": "appveyor-repo-commit", + "git.commit_sha": "appveyor-repo-commit", + "git.repository_url": "https://github.com/appveyor-repo-name.git" + } + ], + [ + { + "APPVEYOR": "true", + "APPVEYOR_BUILD_FOLDER": "/foo/bar", + "APPVEYOR_BUILD_ID": "appveyor-build-id", + "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", + "APPVEYOR_REPO_BRANCH": "master", + "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", + "APPVEYOR_REPO_NAME": "appveyor-repo-name" + }, + { + "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.pipeline.id": "appveyor-build-id", + "ci.pipeline.name": "appveyor-repo-name", + "ci.pipeline.number": "appveyor-pipeline-number", + "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.provider.name": "appveyor", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "appveyor-repo-commit", + "git.commit_sha": "appveyor-repo-commit", + "git.repository_url": "https://github.com/appveyor-repo-name.git" + } + ], + [ + { + "APPVEYOR": "true", + "APPVEYOR_BUILD_FOLDER": "/foo/bar", + "APPVEYOR_BUILD_ID": "appveyor-build-id", + "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", + "APPVEYOR_REPO_BRANCH": "origin/master", + "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", + "APPVEYOR_REPO_NAME": "appveyor-repo-name", + "APPVEYOR_REPO_PROVIDER": "github" + }, + { + "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.pipeline.id": "appveyor-build-id", + "ci.pipeline.name": "appveyor-repo-name", + "ci.pipeline.number": "appveyor-pipeline-number", + "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.provider.name": "appveyor", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "appveyor-repo-commit", + "git.commit_sha": "appveyor-repo-commit", + "git.repository_url": "https://github.com/appveyor-repo-name.git" + } + ], + [ + { + "APPVEYOR": "true", + "APPVEYOR_BUILD_FOLDER": "/foo/bar", + "APPVEYOR_BUILD_ID": "appveyor-build-id", + "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", + "APPVEYOR_REPO_BRANCH": "refs/heads/master", + "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", + "APPVEYOR_REPO_NAME": "appveyor-repo-name", + "APPVEYOR_REPO_PROVIDER": "github" + }, + { + "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.pipeline.id": "appveyor-build-id", + "ci.pipeline.name": "appveyor-repo-name", + "ci.pipeline.number": "appveyor-pipeline-number", + "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.provider.name": "appveyor", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "appveyor-repo-commit", + "git.commit_sha": "appveyor-repo-commit", + "git.repository_url": "https://github.com/appveyor-repo-name.git" + } + ], + [ + { + "APPVEYOR": "true", + "APPVEYOR_BUILD_FOLDER": "/foo/bar", + "APPVEYOR_BUILD_ID": "appveyor-build-id", + "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", + "APPVEYOR_REPO_BRANCH": "refs/heads/feature/one", + "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", + "APPVEYOR_REPO_NAME": "appveyor-repo-name", + "APPVEYOR_REPO_PROVIDER": "github" + }, + { + "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.pipeline.id": "appveyor-build-id", + "ci.pipeline.name": "appveyor-repo-name", + "ci.pipeline.number": "appveyor-pipeline-number", + "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.provider.name": "appveyor", + "ci.workspace_path": "/foo/bar", + "git.branch": "feature/one", + "git.commit.sha": "appveyor-repo-commit", + "git.commit_sha": "appveyor-repo-commit", + "git.repository_url": "https://github.com/appveyor-repo-name.git" + } + ], + [ + { + "APPVEYOR": "true", + "APPVEYOR_BUILD_FOLDER": "/foo/bar", + "APPVEYOR_BUILD_ID": "appveyor-build-id", + "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", + "APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH": "origin/pr", + "APPVEYOR_REPO_BRANCH": "origin/master", + "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", + "APPVEYOR_REPO_NAME": "appveyor-repo-name", + "APPVEYOR_REPO_PROVIDER": "github" + }, + { + "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.pipeline.id": "appveyor-build-id", + "ci.pipeline.name": "appveyor-repo-name", + "ci.pipeline.number": "appveyor-pipeline-number", + "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.provider.name": "appveyor", + "ci.workspace_path": "/foo/bar", + "git.branch": "pr", + "git.commit.sha": "appveyor-repo-commit", + "git.commit_sha": "appveyor-repo-commit", + "git.repository_url": "https://github.com/appveyor-repo-name.git" + } + ], + [ + { + "APPVEYOR": "true", + "APPVEYOR_BUILD_FOLDER": "/foo/bar", + "APPVEYOR_BUILD_ID": "appveyor-build-id", + "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", + "APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH": "refs/heads/pr", + "APPVEYOR_REPO_BRANCH": "refs/heads/master", + "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", + "APPVEYOR_REPO_NAME": "appveyor-repo-name", + "APPVEYOR_REPO_PROVIDER": "github" + }, + { + "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.pipeline.id": "appveyor-build-id", + "ci.pipeline.name": "appveyor-repo-name", + "ci.pipeline.number": "appveyor-pipeline-number", + "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.provider.name": "appveyor", + "ci.workspace_path": "/foo/bar", + "git.branch": "pr", + "git.commit.sha": "appveyor-repo-commit", + "git.commit_sha": "appveyor-repo-commit", + "git.repository_url": "https://github.com/appveyor-repo-name.git" + } + ], + [ + { + "APPVEYOR": "true", + "APPVEYOR_BUILD_FOLDER": "/foo/bar", + "APPVEYOR_BUILD_ID": "appveyor-build-id", + "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", + "APPVEYOR_REPO_BRANCH": "origin/master", + "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", + "APPVEYOR_REPO_NAME": "appveyor-repo-name", + "APPVEYOR_REPO_PROVIDER": "github", + "APPVEYOR_REPO_TAG_NAME": "origin/tags/0.1.0" + }, + { + "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.pipeline.id": "appveyor-build-id", + "ci.pipeline.name": "appveyor-repo-name", + "ci.pipeline.number": "appveyor-pipeline-number", + "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.provider.name": "appveyor", + "ci.workspace_path": "/foo/bar", + "git.commit.sha": "appveyor-repo-commit", + "git.commit_sha": "appveyor-repo-commit", + "git.repository_url": "https://github.com/appveyor-repo-name.git", + "git.tag": "0.1.0" + } + ], + [ + { + "APPVEYOR": "true", + "APPVEYOR_BUILD_FOLDER": "/foo/bar", + "APPVEYOR_BUILD_ID": "appveyor-build-id", + "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", + "APPVEYOR_REPO_BRANCH": "refs/heads/master", + "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", + "APPVEYOR_REPO_NAME": "appveyor-repo-name", + "APPVEYOR_REPO_PROVIDER": "github", + "APPVEYOR_REPO_TAG_NAME": "refs/heads/tags/0.1.0" + }, + { + "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.pipeline.id": "appveyor-build-id", + "ci.pipeline.name": "appveyor-repo-name", + "ci.pipeline.number": "appveyor-pipeline-number", + "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.provider.name": "appveyor", + "ci.workspace_path": "/foo/bar", + "git.commit.sha": "appveyor-repo-commit", + "git.commit_sha": "appveyor-repo-commit", + "git.repository_url": "https://github.com/appveyor-repo-name.git", + "git.tag": "0.1.0" + } + ] +] + + AZURE = [ [ { @@ -573,7 +985,7 @@ def _updateenv(monkeypatch, env): monkeypatch.setenv(k, v) -@pytest.mark.parametrize("environment,tags", AZURE) +@pytest.mark.parametrize("environment,tags", APPVEYOR + AZURE) def test_ci_providers(monkeypatch, environment, tags): _updateenv(monkeypatch, environment) assert tags == ci.tags(), environment From 7667b46946fbeb89ca4a0889e1d9144b07439e46 Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Wed, 28 Oct 2020 09:54:29 +0100 Subject: [PATCH 22/34] use json fixtures --- ddtrace/ext/ci.py | 1 - tests/tracer/fixtures/ci/appveyor.json | 410 ++++++++ tests/tracer/fixtures/ci/azurepipelines.json | 554 +++++++++++ tests/tracer/test_ext.py | 981 +------------------ 4 files changed, 976 insertions(+), 970 deletions(-) create mode 100644 tests/tracer/fixtures/ci/appveyor.json create mode 100644 tests/tracer/fixtures/ci/azurepipelines.json diff --git a/ddtrace/ext/ci.py b/ddtrace/ext/ci.py index 902c77fa81f..b958d476177 100644 --- a/ddtrace/ext/ci.py +++ b/ddtrace/ext/ci.py @@ -78,7 +78,6 @@ def extract_appveyor(env): def extract_azure_pipelines(env): - print(env.get("SYSTEM_TEAMFOUNDATIONSERVERURI"), env.get("SYSTEM_TEAMPROJECT"), env.get("BUILD_BUILDID")) if env.get("SYSTEM_TEAMFOUNDATIONSERVERURI") and env.get("SYSTEM_TEAMPROJECT") and env.get("BUILD_BUILDID"): base_url = "{0}{1}/_build/results?buildId={2}".format( env.get("SYSTEM_TEAMFOUNDATIONSERVERURI"), env.get("SYSTEM_TEAMPROJECT"), env.get("BUILD_BUILDID") diff --git a/tests/tracer/fixtures/ci/appveyor.json b/tests/tracer/fixtures/ci/appveyor.json new file mode 100644 index 00000000000..56e658929f0 --- /dev/null +++ b/tests/tracer/fixtures/ci/appveyor.json @@ -0,0 +1,410 @@ +[ + [ + { + "APPVEYOR": "true", + "APPVEYOR_BUILD_FOLDER": "/foo/bar", + "APPVEYOR_BUILD_ID": "appveyor-build-id", + "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", + "APPVEYOR_REPO_BRANCH": "master", + "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", + "APPVEYOR_REPO_NAME": "appveyor-repo-name", + "APPVEYOR_REPO_PROVIDER": "github" + }, + { + "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.pipeline.id": "appveyor-build-id", + "ci.pipeline.name": "appveyor-repo-name", + "ci.pipeline.number": "appveyor-pipeline-number", + "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.provider.name": "appveyor", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "appveyor-repo-commit", + "git.commit_sha": "appveyor-repo-commit", + "git.repository_url": "https://github.com/appveyor-repo-name.git" + } + ], + [ + { + "APPVEYOR": "true", + "APPVEYOR_BUILD_FOLDER": "/foo/bar", + "APPVEYOR_BUILD_ID": "appveyor-build-id", + "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", + "APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH": "", + "APPVEYOR_REPO_BRANCH": "master", + "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", + "APPVEYOR_REPO_NAME": "appveyor-repo-name", + "APPVEYOR_REPO_PROVIDER": "github" + }, + { + "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.pipeline.id": "appveyor-build-id", + "ci.pipeline.name": "appveyor-repo-name", + "ci.pipeline.number": "appveyor-pipeline-number", + "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.provider.name": "appveyor", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "appveyor-repo-commit", + "git.commit_sha": "appveyor-repo-commit", + "git.repository_url": "https://github.com/appveyor-repo-name.git" + } + ], + [ + { + "APPVEYOR": "true", + "APPVEYOR_BUILD_FOLDER": "foo/bar", + "APPVEYOR_BUILD_ID": "appveyor-build-id", + "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", + "APPVEYOR_REPO_BRANCH": "master", + "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", + "APPVEYOR_REPO_NAME": "appveyor-repo-name", + "APPVEYOR_REPO_PROVIDER": "github" + }, + { + "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.pipeline.id": "appveyor-build-id", + "ci.pipeline.name": "appveyor-repo-name", + "ci.pipeline.number": "appveyor-pipeline-number", + "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.provider.name": "appveyor", + "ci.workspace_path": "foo/bar", + "git.branch": "master", + "git.commit.sha": "appveyor-repo-commit", + "git.commit_sha": "appveyor-repo-commit", + "git.repository_url": "https://github.com/appveyor-repo-name.git" + } + ], + [ + { + "APPVEYOR": "true", + "APPVEYOR_BUILD_FOLDER": "/foo/bar~", + "APPVEYOR_BUILD_ID": "appveyor-build-id", + "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", + "APPVEYOR_REPO_BRANCH": "master", + "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", + "APPVEYOR_REPO_NAME": "appveyor-repo-name", + "APPVEYOR_REPO_PROVIDER": "github" + }, + { + "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.pipeline.id": "appveyor-build-id", + "ci.pipeline.name": "appveyor-repo-name", + "ci.pipeline.number": "appveyor-pipeline-number", + "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.provider.name": "appveyor", + "ci.workspace_path": "/foo/bar~", + "git.branch": "master", + "git.commit.sha": "appveyor-repo-commit", + "git.commit_sha": "appveyor-repo-commit", + "git.repository_url": "https://github.com/appveyor-repo-name.git" + } + ], + [ + { + "APPVEYOR": "true", + "APPVEYOR_BUILD_FOLDER": "/foo/~/bar", + "APPVEYOR_BUILD_ID": "appveyor-build-id", + "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", + "APPVEYOR_REPO_BRANCH": "master", + "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", + "APPVEYOR_REPO_NAME": "appveyor-repo-name", + "APPVEYOR_REPO_PROVIDER": "github" + }, + { + "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.pipeline.id": "appveyor-build-id", + "ci.pipeline.name": "appveyor-repo-name", + "ci.pipeline.number": "appveyor-pipeline-number", + "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.provider.name": "appveyor", + "ci.workspace_path": "/foo/~/bar", + "git.branch": "master", + "git.commit.sha": "appveyor-repo-commit", + "git.commit_sha": "appveyor-repo-commit", + "git.repository_url": "https://github.com/appveyor-repo-name.git" + } + ], + [ + { + "APPVEYOR": "true", + "APPVEYOR_BUILD_FOLDER": "~/foo/bar", + "APPVEYOR_BUILD_ID": "appveyor-build-id", + "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", + "APPVEYOR_REPO_BRANCH": "master", + "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", + "APPVEYOR_REPO_NAME": "appveyor-repo-name", + "APPVEYOR_REPO_PROVIDER": "github", + "HOME": "/not-my-home", + "USERPROFILE": "/not-my-home" + }, + { + "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.pipeline.id": "appveyor-build-id", + "ci.pipeline.name": "appveyor-repo-name", + "ci.pipeline.number": "appveyor-pipeline-number", + "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.provider.name": "appveyor", + "ci.workspace_path": "/not-my-home/foo/bar", + "git.branch": "master", + "git.commit.sha": "appveyor-repo-commit", + "git.commit_sha": "appveyor-repo-commit", + "git.repository_url": "https://github.com/appveyor-repo-name.git" + } + ], + [ + { + "APPVEYOR": "true", + "APPVEYOR_BUILD_FOLDER": "~foo/bar", + "APPVEYOR_BUILD_ID": "appveyor-build-id", + "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", + "APPVEYOR_REPO_BRANCH": "master", + "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", + "APPVEYOR_REPO_NAME": "appveyor-repo-name", + "APPVEYOR_REPO_PROVIDER": "github" + }, + { + "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.pipeline.id": "appveyor-build-id", + "ci.pipeline.name": "appveyor-repo-name", + "ci.pipeline.number": "appveyor-pipeline-number", + "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.provider.name": "appveyor", + "ci.workspace_path": "~foo/bar", + "git.branch": "master", + "git.commit.sha": "appveyor-repo-commit", + "git.commit_sha": "appveyor-repo-commit", + "git.repository_url": "https://github.com/appveyor-repo-name.git" + } + ], + [ + { + "APPVEYOR": "true", + "APPVEYOR_BUILD_FOLDER": "~", + "APPVEYOR_BUILD_ID": "appveyor-build-id", + "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", + "APPVEYOR_REPO_BRANCH": "master", + "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", + "APPVEYOR_REPO_NAME": "appveyor-repo-name", + "APPVEYOR_REPO_PROVIDER": "github", + "HOME": "/not-my-home", + "USERPROFILE": "/not-my-home" + }, + { + "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.pipeline.id": "appveyor-build-id", + "ci.pipeline.name": "appveyor-repo-name", + "ci.pipeline.number": "appveyor-pipeline-number", + "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.provider.name": "appveyor", + "ci.workspace_path": "/not-my-home", + "git.branch": "master", + "git.commit.sha": "appveyor-repo-commit", + "git.commit_sha": "appveyor-repo-commit", + "git.repository_url": "https://github.com/appveyor-repo-name.git" + } + ], + [ + { + "APPVEYOR": "true", + "APPVEYOR_BUILD_FOLDER": "/foo/bar", + "APPVEYOR_BUILD_ID": "appveyor-build-id", + "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", + "APPVEYOR_REPO_BRANCH": "master", + "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", + "APPVEYOR_REPO_NAME": "appveyor-repo-name" + }, + { + "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.pipeline.id": "appveyor-build-id", + "ci.pipeline.name": "appveyor-repo-name", + "ci.pipeline.number": "appveyor-pipeline-number", + "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.provider.name": "appveyor", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "appveyor-repo-commit", + "git.commit_sha": "appveyor-repo-commit", + "git.repository_url": "https://github.com/appveyor-repo-name.git" + } + ], + [ + { + "APPVEYOR": "true", + "APPVEYOR_BUILD_FOLDER": "/foo/bar", + "APPVEYOR_BUILD_ID": "appveyor-build-id", + "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", + "APPVEYOR_REPO_BRANCH": "origin/master", + "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", + "APPVEYOR_REPO_NAME": "appveyor-repo-name", + "APPVEYOR_REPO_PROVIDER": "github" + }, + { + "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.pipeline.id": "appveyor-build-id", + "ci.pipeline.name": "appveyor-repo-name", + "ci.pipeline.number": "appveyor-pipeline-number", + "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.provider.name": "appveyor", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "appveyor-repo-commit", + "git.commit_sha": "appveyor-repo-commit", + "git.repository_url": "https://github.com/appveyor-repo-name.git" + } + ], + [ + { + "APPVEYOR": "true", + "APPVEYOR_BUILD_FOLDER": "/foo/bar", + "APPVEYOR_BUILD_ID": "appveyor-build-id", + "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", + "APPVEYOR_REPO_BRANCH": "refs/heads/master", + "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", + "APPVEYOR_REPO_NAME": "appveyor-repo-name", + "APPVEYOR_REPO_PROVIDER": "github" + }, + { + "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.pipeline.id": "appveyor-build-id", + "ci.pipeline.name": "appveyor-repo-name", + "ci.pipeline.number": "appveyor-pipeline-number", + "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.provider.name": "appveyor", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "appveyor-repo-commit", + "git.commit_sha": "appveyor-repo-commit", + "git.repository_url": "https://github.com/appveyor-repo-name.git" + } + ], + [ + { + "APPVEYOR": "true", + "APPVEYOR_BUILD_FOLDER": "/foo/bar", + "APPVEYOR_BUILD_ID": "appveyor-build-id", + "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", + "APPVEYOR_REPO_BRANCH": "refs/heads/feature/one", + "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", + "APPVEYOR_REPO_NAME": "appveyor-repo-name", + "APPVEYOR_REPO_PROVIDER": "github" + }, + { + "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.pipeline.id": "appveyor-build-id", + "ci.pipeline.name": "appveyor-repo-name", + "ci.pipeline.number": "appveyor-pipeline-number", + "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.provider.name": "appveyor", + "ci.workspace_path": "/foo/bar", + "git.branch": "feature/one", + "git.commit.sha": "appveyor-repo-commit", + "git.commit_sha": "appveyor-repo-commit", + "git.repository_url": "https://github.com/appveyor-repo-name.git" + } + ], + [ + { + "APPVEYOR": "true", + "APPVEYOR_BUILD_FOLDER": "/foo/bar", + "APPVEYOR_BUILD_ID": "appveyor-build-id", + "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", + "APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH": "origin/pr", + "APPVEYOR_REPO_BRANCH": "origin/master", + "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", + "APPVEYOR_REPO_NAME": "appveyor-repo-name", + "APPVEYOR_REPO_PROVIDER": "github" + }, + { + "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.pipeline.id": "appveyor-build-id", + "ci.pipeline.name": "appveyor-repo-name", + "ci.pipeline.number": "appveyor-pipeline-number", + "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.provider.name": "appveyor", + "ci.workspace_path": "/foo/bar", + "git.branch": "pr", + "git.commit.sha": "appveyor-repo-commit", + "git.commit_sha": "appveyor-repo-commit", + "git.repository_url": "https://github.com/appveyor-repo-name.git" + } + ], + [ + { + "APPVEYOR": "true", + "APPVEYOR_BUILD_FOLDER": "/foo/bar", + "APPVEYOR_BUILD_ID": "appveyor-build-id", + "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", + "APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH": "refs/heads/pr", + "APPVEYOR_REPO_BRANCH": "refs/heads/master", + "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", + "APPVEYOR_REPO_NAME": "appveyor-repo-name", + "APPVEYOR_REPO_PROVIDER": "github" + }, + { + "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.pipeline.id": "appveyor-build-id", + "ci.pipeline.name": "appveyor-repo-name", + "ci.pipeline.number": "appveyor-pipeline-number", + "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.provider.name": "appveyor", + "ci.workspace_path": "/foo/bar", + "git.branch": "pr", + "git.commit.sha": "appveyor-repo-commit", + "git.commit_sha": "appveyor-repo-commit", + "git.repository_url": "https://github.com/appveyor-repo-name.git" + } + ], + [ + { + "APPVEYOR": "true", + "APPVEYOR_BUILD_FOLDER": "/foo/bar", + "APPVEYOR_BUILD_ID": "appveyor-build-id", + "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", + "APPVEYOR_REPO_BRANCH": "origin/master", + "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", + "APPVEYOR_REPO_NAME": "appveyor-repo-name", + "APPVEYOR_REPO_PROVIDER": "github", + "APPVEYOR_REPO_TAG_NAME": "origin/tags/0.1.0" + }, + { + "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.pipeline.id": "appveyor-build-id", + "ci.pipeline.name": "appveyor-repo-name", + "ci.pipeline.number": "appveyor-pipeline-number", + "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.provider.name": "appveyor", + "ci.workspace_path": "/foo/bar", + "git.commit.sha": "appveyor-repo-commit", + "git.commit_sha": "appveyor-repo-commit", + "git.repository_url": "https://github.com/appveyor-repo-name.git", + "git.tag": "0.1.0" + } + ], + [ + { + "APPVEYOR": "true", + "APPVEYOR_BUILD_FOLDER": "/foo/bar", + "APPVEYOR_BUILD_ID": "appveyor-build-id", + "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", + "APPVEYOR_REPO_BRANCH": "refs/heads/master", + "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", + "APPVEYOR_REPO_NAME": "appveyor-repo-name", + "APPVEYOR_REPO_PROVIDER": "github", + "APPVEYOR_REPO_TAG_NAME": "refs/heads/tags/0.1.0" + }, + { + "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.pipeline.id": "appveyor-build-id", + "ci.pipeline.name": "appveyor-repo-name", + "ci.pipeline.number": "appveyor-pipeline-number", + "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", + "ci.provider.name": "appveyor", + "ci.workspace_path": "/foo/bar", + "git.commit.sha": "appveyor-repo-commit", + "git.commit_sha": "appveyor-repo-commit", + "git.repository_url": "https://github.com/appveyor-repo-name.git", + "git.tag": "0.1.0" + } + ] +] diff --git a/tests/tracer/fixtures/ci/azurepipelines.json b/tests/tracer/fixtures/ci/azurepipelines.json new file mode 100644 index 00000000000..fed7f6f01d0 --- /dev/null +++ b/tests/tracer/fixtures/ci/azurepipelines.json @@ -0,0 +1,554 @@ +[ + [ + { + "BUILD_BUILDID": "azure-pipelines-build-id", + "BUILD_DEFINITIONNAME": "azure-pipelines-name", + "BUILD_REPOSITORY_URI": "sample", + "BUILD_SOURCEBRANCH": "master", + "BUILD_SOURCESDIRECTORY": "/foo/bar", + "BUILD_SOURCEVERSION": "commit", + "SYSTEM_JOBID": "azure-pipelines-job-id", + "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", + "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", + "SYSTEM_TEAMPROJECT": "azure-pipelines-project", + "TF_BUILD": "True" + }, + { + "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", + "ci.pipeline.id": "azure-pipelines-build-id", + "ci.pipeline.name": "azure-pipelines-name", + "ci.pipeline.number": "azure-pipelines-build-id", + "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", + "ci.provider.name": "azurepipelines", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "commit", + "git.commit_sha": "commit", + "git.repository_url": "sample" + } + ], + [ + { + "BUILD_BUILDID": "azure-pipelines-build-id", + "BUILD_DEFINITIONNAME": "azure-pipelines-name", + "BUILD_REPOSITORY_URI": "sample", + "BUILD_SOURCEBRANCH": "master", + "BUILD_SOURCESDIRECTORY": "/foo/bar", + "BUILD_SOURCEVERSION": "commit", + "SYSTEM_JOBID": "azure-pipelines-job-id", + "SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI": "", + "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", + "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", + "SYSTEM_TEAMPROJECT": "azure-pipelines-project", + "TF_BUILD": "True" + }, + { + "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", + "ci.pipeline.id": "azure-pipelines-build-id", + "ci.pipeline.name": "azure-pipelines-name", + "ci.pipeline.number": "azure-pipelines-build-id", + "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", + "ci.provider.name": "azurepipelines", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "commit", + "git.commit_sha": "commit", + "git.repository_url": "sample" + } + ], + [ + { + "BUILD_BUILDID": "azure-pipelines-build-id", + "BUILD_DEFINITIONNAME": "azure-pipelines-name", + "BUILD_REPOSITORY_URI": "sample", + "BUILD_SOURCEBRANCH": "master", + "BUILD_SOURCESDIRECTORY": "/foo/bar", + "BUILD_SOURCEVERSION": "commit", + "SYSTEM_JOBID": "azure-pipelines-job-id", + "SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI": "sample2", + "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", + "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", + "SYSTEM_TEAMPROJECT": "azure-pipelines-project", + "TF_BUILD": "True" + }, + { + "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", + "ci.pipeline.id": "azure-pipelines-build-id", + "ci.pipeline.name": "azure-pipelines-name", + "ci.pipeline.number": "azure-pipelines-build-id", + "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", + "ci.provider.name": "azurepipelines", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "commit", + "git.commit_sha": "commit", + "git.repository_url": "sample2" + } + ], + [ + { + "BUILD_BUILDID": "azure-pipelines-build-id", + "BUILD_DEFINITIONNAME": "azure-pipelines-name", + "BUILD_REPOSITORY_URI": "sample", + "BUILD_SOURCEBRANCH": "master", + "BUILD_SOURCESDIRECTORY": "/foo/bar", + "BUILD_SOURCEVERSION": "commit", + "SYSTEM_JOBID": "azure-pipelines-job-id", + "SYSTEM_PULLREQUEST_SOURCEBRANCH": "", + "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", + "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", + "SYSTEM_TEAMPROJECT": "azure-pipelines-project", + "TF_BUILD": "True" + }, + { + "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", + "ci.pipeline.id": "azure-pipelines-build-id", + "ci.pipeline.name": "azure-pipelines-name", + "ci.pipeline.number": "azure-pipelines-build-id", + "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", + "ci.provider.name": "azurepipelines", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "commit", + "git.commit_sha": "commit", + "git.repository_url": "sample" + } + ], + [ + { + "BUILD_BUILDID": "azure-pipelines-build-id", + "BUILD_DEFINITIONNAME": "azure-pipelines-name", + "BUILD_REPOSITORY_URI": "sample", + "BUILD_SOURCEBRANCH": "master", + "BUILD_SOURCESDIRECTORY": "/foo/bar", + "BUILD_SOURCEVERSION": "commit", + "SYSTEM_JOBID": "azure-pipelines-job-id", + "SYSTEM_PULLREQUEST_SOURCECOMMITID": "", + "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", + "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", + "SYSTEM_TEAMPROJECT": "azure-pipelines-project", + "TF_BUILD": "True" + }, + { + "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", + "ci.pipeline.id": "azure-pipelines-build-id", + "ci.pipeline.name": "azure-pipelines-name", + "ci.pipeline.number": "azure-pipelines-build-id", + "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", + "ci.provider.name": "azurepipelines", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "commit", + "git.commit_sha": "commit", + "git.repository_url": "sample" + } + ], + [ + { + "BUILD_BUILDID": "azure-pipelines-build-id", + "BUILD_DEFINITIONNAME": "azure-pipelines-name", + "BUILD_REPOSITORY_URI": "sample", + "BUILD_SOURCEBRANCH": "origin/master", + "BUILD_SOURCESDIRECTORY": "foo/bar", + "BUILD_SOURCEVERSION": "commit", + "SYSTEM_JOBID": "azure-pipelines-job-id", + "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", + "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", + "SYSTEM_TEAMPROJECT": "azure-pipelines-project", + "TF_BUILD": "True" + }, + { + "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", + "ci.pipeline.id": "azure-pipelines-build-id", + "ci.pipeline.name": "azure-pipelines-name", + "ci.pipeline.number": "azure-pipelines-build-id", + "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", + "ci.provider.name": "azurepipelines", + "ci.workspace_path": "foo/bar", + "git.branch": "master", + "git.commit.sha": "commit", + "git.commit_sha": "commit", + "git.repository_url": "sample" + } + ], + [ + { + "BUILD_BUILDID": "azure-pipelines-build-id", + "BUILD_DEFINITIONNAME": "azure-pipelines-name", + "BUILD_REPOSITORY_URI": "sample", + "BUILD_SOURCEBRANCH": "origin/master", + "BUILD_SOURCESDIRECTORY": "/foo/bar~", + "BUILD_SOURCEVERSION": "commit", + "HOME": "/not-my-home", + "SYSTEM_JOBID": "azure-pipelines-job-id", + "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", + "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", + "SYSTEM_TEAMPROJECT": "azure-pipelines-project", + "TF_BUILD": "True", + "USERPROFILE": "/not-my-home" + }, + { + "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", + "ci.pipeline.id": "azure-pipelines-build-id", + "ci.pipeline.name": "azure-pipelines-name", + "ci.pipeline.number": "azure-pipelines-build-id", + "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", + "ci.provider.name": "azurepipelines", + "ci.workspace_path": "/foo/bar~", + "git.branch": "master", + "git.commit.sha": "commit", + "git.commit_sha": "commit", + "git.repository_url": "sample" + } + ], + [ + { + "BUILD_BUILDID": "azure-pipelines-build-id", + "BUILD_DEFINITIONNAME": "azure-pipelines-name", + "BUILD_REPOSITORY_URI": "sample", + "BUILD_SOURCEBRANCH": "origin/master", + "BUILD_SOURCESDIRECTORY": "/foo/~/bar", + "BUILD_SOURCEVERSION": "commit", + "HOME": "/not-my-home", + "SYSTEM_JOBID": "azure-pipelines-job-id", + "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", + "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", + "SYSTEM_TEAMPROJECT": "azure-pipelines-project", + "TF_BUILD": "True", + "USERPROFILE": "/not-my-home" + }, + { + "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", + "ci.pipeline.id": "azure-pipelines-build-id", + "ci.pipeline.name": "azure-pipelines-name", + "ci.pipeline.number": "azure-pipelines-build-id", + "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", + "ci.provider.name": "azurepipelines", + "ci.workspace_path": "/foo/~/bar", + "git.branch": "master", + "git.commit.sha": "commit", + "git.commit_sha": "commit", + "git.repository_url": "sample" + } + ], + [ + { + "BUILD_BUILDID": "azure-pipelines-build-id", + "BUILD_DEFINITIONNAME": "azure-pipelines-name", + "BUILD_REPOSITORY_URI": "sample", + "BUILD_SOURCEBRANCH": "origin/master", + "BUILD_SOURCESDIRECTORY": "~/foo/bar", + "BUILD_SOURCEVERSION": "commit", + "HOME": "/not-my-home", + "SYSTEM_JOBID": "azure-pipelines-job-id", + "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", + "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", + "SYSTEM_TEAMPROJECT": "azure-pipelines-project", + "TF_BUILD": "True", + "USERPROFILE": "/not-my-home" + }, + { + "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", + "ci.pipeline.id": "azure-pipelines-build-id", + "ci.pipeline.name": "azure-pipelines-name", + "ci.pipeline.number": "azure-pipelines-build-id", + "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", + "ci.provider.name": "azurepipelines", + "ci.workspace_path": "/not-my-home/foo/bar", + "git.branch": "master", + "git.commit.sha": "commit", + "git.commit_sha": "commit", + "git.repository_url": "sample" + } + ], + [ + { + "BUILD_BUILDID": "azure-pipelines-build-id", + "BUILD_DEFINITIONNAME": "azure-pipelines-name", + "BUILD_REPOSITORY_URI": "sample", + "BUILD_SOURCEBRANCH": "origin/master", + "BUILD_SOURCESDIRECTORY": "~foo/bar", + "BUILD_SOURCEVERSION": "commit", + "HOME": "/not-my-home", + "SYSTEM_JOBID": "azure-pipelines-job-id", + "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", + "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", + "SYSTEM_TEAMPROJECT": "azure-pipelines-project", + "TF_BUILD": "True", + "USERPROFILE": "/not-my-home" + }, + { + "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", + "ci.pipeline.id": "azure-pipelines-build-id", + "ci.pipeline.name": "azure-pipelines-name", + "ci.pipeline.number": "azure-pipelines-build-id", + "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", + "ci.provider.name": "azurepipelines", + "ci.workspace_path": "~foo/bar", + "git.branch": "master", + "git.commit.sha": "commit", + "git.commit_sha": "commit", + "git.repository_url": "sample" + } + ], + [ + { + "BUILD_BUILDID": "azure-pipelines-build-id", + "BUILD_DEFINITIONNAME": "azure-pipelines-name", + "BUILD_REPOSITORY_URI": "sample", + "BUILD_SOURCEBRANCH": "origin/master", + "BUILD_SOURCESDIRECTORY": "~", + "BUILD_SOURCEVERSION": "commit", + "HOME": "/not-my-home", + "SYSTEM_JOBID": "azure-pipelines-job-id", + "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", + "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", + "SYSTEM_TEAMPROJECT": "azure-pipelines-project", + "TF_BUILD": "True", + "USERPROFILE": "/not-my-home" + }, + { + "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", + "ci.pipeline.id": "azure-pipelines-build-id", + "ci.pipeline.name": "azure-pipelines-name", + "ci.pipeline.number": "azure-pipelines-build-id", + "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", + "ci.provider.name": "azurepipelines", + "ci.workspace_path": "/not-my-home", + "git.branch": "master", + "git.commit.sha": "commit", + "git.commit_sha": "commit", + "git.repository_url": "sample" + } + ], + [ + { + "BUILD_BUILDID": "azure-pipelines-build-id", + "BUILD_DEFINITIONNAME": "azure-pipelines-name", + "BUILD_REPOSITORY_URI": "sample", + "BUILD_SOURCEBRANCH": "origin/master", + "BUILD_SOURCESDIRECTORY": "/foo/bar", + "BUILD_SOURCEVERSION": "commit", + "SYSTEM_JOBID": "azure-pipelines-job-id", + "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", + "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", + "SYSTEM_TEAMPROJECT": "azure-pipelines-project", + "TF_BUILD": "True" + }, + { + "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", + "ci.pipeline.id": "azure-pipelines-build-id", + "ci.pipeline.name": "azure-pipelines-name", + "ci.pipeline.number": "azure-pipelines-build-id", + "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", + "ci.provider.name": "azurepipelines", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "commit", + "git.commit_sha": "commit", + "git.repository_url": "sample" + } + ], + [ + { + "BUILD_BUILDID": "azure-pipelines-build-id", + "BUILD_DEFINITIONNAME": "azure-pipelines-name", + "BUILD_REPOSITORY_URI": "sample", + "BUILD_SOURCEBRANCH": "refs/heads/master", + "BUILD_SOURCESDIRECTORY": "/foo/bar", + "BUILD_SOURCEVERSION": "commit", + "SYSTEM_JOBID": "azure-pipelines-job-id", + "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", + "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", + "SYSTEM_TEAMPROJECT": "azure-pipelines-project", + "TF_BUILD": "True" + }, + { + "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", + "ci.pipeline.id": "azure-pipelines-build-id", + "ci.pipeline.name": "azure-pipelines-name", + "ci.pipeline.number": "azure-pipelines-build-id", + "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", + "ci.provider.name": "azurepipelines", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "commit", + "git.commit_sha": "commit", + "git.repository_url": "sample" + } + ], + [ + { + "BUILD_BUILDID": "azure-pipelines-build-id", + "BUILD_DEFINITIONNAME": "azure-pipelines-name", + "BUILD_REPOSITORY_URI": "sample", + "BUILD_SOURCEBRANCH": "refs/heads/feature/one", + "BUILD_SOURCESDIRECTORY": "/foo/bar", + "BUILD_SOURCEVERSION": "commit", + "SYSTEM_JOBID": "azure-pipelines-job-id", + "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", + "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", + "SYSTEM_TEAMPROJECT": "azure-pipelines-project", + "TF_BUILD": "True" + }, + { + "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", + "ci.pipeline.id": "azure-pipelines-build-id", + "ci.pipeline.name": "azure-pipelines-name", + "ci.pipeline.number": "azure-pipelines-build-id", + "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", + "ci.provider.name": "azurepipelines", + "ci.workspace_path": "/foo/bar", + "git.branch": "feature/one", + "git.commit.sha": "commit", + "git.commit_sha": "commit", + "git.repository_url": "sample" + } + ], + [ + { + "BUILD_BUILDID": "azure-pipelines-build-id", + "BUILD_DEFINITIONNAME": "azure-pipelines-name", + "BUILD_REPOSITORY_URI": "sample", + "BUILD_SOURCEBRANCH": "origin/tags/0.1.0", + "BUILD_SOURCESDIRECTORY": "/foo/bar", + "BUILD_SOURCEVERSION": "commit", + "SYSTEM_JOBID": "azure-pipelines-job-id", + "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", + "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", + "SYSTEM_TEAMPROJECT": "azure-pipelines-project", + "TF_BUILD": "True" + }, + { + "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", + "ci.pipeline.id": "azure-pipelines-build-id", + "ci.pipeline.name": "azure-pipelines-name", + "ci.pipeline.number": "azure-pipelines-build-id", + "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", + "ci.provider.name": "azurepipelines", + "ci.workspace_path": "/foo/bar", + "git.commit.sha": "commit", + "git.commit_sha": "commit", + "git.repository_url": "sample", + "git.tag": "0.1.0" + } + ], + [ + { + "BUILD_BUILDID": "azure-pipelines-build-id", + "BUILD_DEFINITIONNAME": "azure-pipelines-name", + "BUILD_REPOSITORY_URI": "sample", + "BUILD_SOURCEBRANCH": "refs/heads/tags/0.1.0", + "BUILD_SOURCESDIRECTORY": "/foo/bar", + "BUILD_SOURCEVERSION": "commit", + "SYSTEM_JOBID": "azure-pipelines-job-id", + "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", + "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", + "SYSTEM_TEAMPROJECT": "azure-pipelines-project", + "TF_BUILD": "True" + }, + { + "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", + "ci.pipeline.id": "azure-pipelines-build-id", + "ci.pipeline.name": "azure-pipelines-name", + "ci.pipeline.number": "azure-pipelines-build-id", + "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", + "ci.provider.name": "azurepipelines", + "ci.workspace_path": "/foo/bar", + "git.commit.sha": "commit", + "git.commit_sha": "commit", + "git.repository_url": "sample", + "git.tag": "0.1.0" + } + ], + [ + { + "BUILD_BUILDID": "azure-pipelines-build-id", + "BUILD_DEFINITIONNAME": "azure-pipelines-name", + "BUILD_REPOSITORY_URI": "sample", + "BUILD_SOURCEBRANCH": "origin/master", + "BUILD_SOURCESDIRECTORY": "/foo/bar", + "BUILD_SOURCEVERSION": "commit", + "SYSTEM_JOBID": "azure-pipelines-job-id", + "SYSTEM_PULLREQUEST_SOURCEBRANCH": "origin/pr", + "SYSTEM_PULLREQUEST_SOURCECOMMITID": "commitPR", + "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", + "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", + "SYSTEM_TEAMPROJECT": "azure-pipelines-project", + "TF_BUILD": "True" + }, + { + "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", + "ci.pipeline.id": "azure-pipelines-build-id", + "ci.pipeline.name": "azure-pipelines-name", + "ci.pipeline.number": "azure-pipelines-build-id", + "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", + "ci.provider.name": "azurepipelines", + "ci.workspace_path": "/foo/bar", + "git.branch": "pr", + "git.commit.sha": "commitPR", + "git.commit_sha": "commitPR", + "git.repository_url": "sample" + } + ], + [ + { + "BUILD_BUILDID": "azure-pipelines-build-id", + "BUILD_DEFINITIONNAME": "azure-pipelines-name", + "BUILD_REPOSITORY_URI": "sample", + "BUILD_SOURCEBRANCH": "refs/heads/master", + "BUILD_SOURCESDIRECTORY": "/foo/bar", + "BUILD_SOURCEVERSION": "commit", + "SYSTEM_JOBID": "azure-pipelines-job-id", + "SYSTEM_PULLREQUEST_SOURCEBRANCH": "refs/heads/pr", + "SYSTEM_PULLREQUEST_SOURCECOMMITID": "commitPR", + "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", + "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", + "SYSTEM_TEAMPROJECT": "azure-pipelines-project", + "TF_BUILD": "True" + }, + { + "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", + "ci.pipeline.id": "azure-pipelines-build-id", + "ci.pipeline.name": "azure-pipelines-name", + "ci.pipeline.number": "azure-pipelines-build-id", + "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", + "ci.provider.name": "azurepipelines", + "ci.workspace_path": "/foo/bar", + "git.branch": "pr", + "git.commit.sha": "commitPR", + "git.commit_sha": "commitPR", + "git.repository_url": "sample" + } + ], + [ + { + "BUILD_BUILDID": "azure-pipelines-build-id", + "BUILD_DEFINITIONNAME": "azure-pipelines-name", + "BUILD_REPOSITORY_URI": "sample", + "BUILD_SOURCEBRANCH": "refs/heads/feature/one", + "BUILD_SOURCESDIRECTORY": "/foo/bar", + "BUILD_SOURCEVERSION": "commit", + "SYSTEM_JOBID": "azure-pipelines-job-id", + "SYSTEM_PULLREQUEST_SOURCEBRANCH": "refs/heads/pr", + "SYSTEM_PULLREQUEST_SOURCECOMMITID": "commitPR", + "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", + "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", + "SYSTEM_TEAMPROJECT": "azure-pipelines-project", + "TF_BUILD": "True" + }, + { + "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", + "ci.pipeline.id": "azure-pipelines-build-id", + "ci.pipeline.name": "azure-pipelines-name", + "ci.pipeline.number": "azure-pipelines-build-id", + "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", + "ci.provider.name": "azurepipelines", + "ci.workspace_path": "/foo/bar", + "git.branch": "pr", + "git.commit.sha": "commitPR", + "git.commit_sha": "commitPR", + "git.repository_url": "sample" + } + ] +] diff --git a/tests/tracer/test_ext.py b/tests/tracer/test_ext.py index f7c43019cd3..85fde70f10a 100644 --- a/tests/tracer/test_ext.py +++ b/tests/tracer/test_ext.py @@ -1,3 +1,6 @@ +import os +import json + import pytest from ddtrace.ext import aws @@ -12,972 +15,12 @@ def test_flatten_dict(): assert aws._flatten_dict(d, sep="_") == e -APPVEYOR = [ - [ - { - "APPVEYOR": "true", - "APPVEYOR_BUILD_FOLDER": "/foo/bar", - "APPVEYOR_BUILD_ID": "appveyor-build-id", - "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", - "APPVEYOR_REPO_BRANCH": "master", - "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", - "APPVEYOR_REPO_NAME": "appveyor-repo-name", - "APPVEYOR_REPO_PROVIDER": "github" - }, - { - "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", - "ci.pipeline.id": "appveyor-build-id", - "ci.pipeline.name": "appveyor-repo-name", - "ci.pipeline.number": "appveyor-pipeline-number", - "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", - "ci.provider.name": "appveyor", - "ci.workspace_path": "/foo/bar", - "git.branch": "master", - "git.commit.sha": "appveyor-repo-commit", - "git.commit_sha": "appveyor-repo-commit", - "git.repository_url": "https://github.com/appveyor-repo-name.git" - } - ], - [ - { - "APPVEYOR": "true", - "APPVEYOR_BUILD_FOLDER": "/foo/bar", - "APPVEYOR_BUILD_ID": "appveyor-build-id", - "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", - "APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH": "", - "APPVEYOR_REPO_BRANCH": "master", - "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", - "APPVEYOR_REPO_NAME": "appveyor-repo-name", - "APPVEYOR_REPO_PROVIDER": "github" - }, - { - "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", - "ci.pipeline.id": "appveyor-build-id", - "ci.pipeline.name": "appveyor-repo-name", - "ci.pipeline.number": "appveyor-pipeline-number", - "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", - "ci.provider.name": "appveyor", - "ci.workspace_path": "/foo/bar", - "git.branch": "master", - "git.commit.sha": "appveyor-repo-commit", - "git.commit_sha": "appveyor-repo-commit", - "git.repository_url": "https://github.com/appveyor-repo-name.git" - } - ], - [ - { - "APPVEYOR": "true", - "APPVEYOR_BUILD_FOLDER": "foo/bar", - "APPVEYOR_BUILD_ID": "appveyor-build-id", - "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", - "APPVEYOR_REPO_BRANCH": "master", - "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", - "APPVEYOR_REPO_NAME": "appveyor-repo-name", - "APPVEYOR_REPO_PROVIDER": "github" - }, - { - "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", - "ci.pipeline.id": "appveyor-build-id", - "ci.pipeline.name": "appveyor-repo-name", - "ci.pipeline.number": "appveyor-pipeline-number", - "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", - "ci.provider.name": "appveyor", - "ci.workspace_path": "foo/bar", - "git.branch": "master", - "git.commit.sha": "appveyor-repo-commit", - "git.commit_sha": "appveyor-repo-commit", - "git.repository_url": "https://github.com/appveyor-repo-name.git" - } - ], - [ - { - "APPVEYOR": "true", - "APPVEYOR_BUILD_FOLDER": "/foo/bar~", - "APPVEYOR_BUILD_ID": "appveyor-build-id", - "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", - "APPVEYOR_REPO_BRANCH": "master", - "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", - "APPVEYOR_REPO_NAME": "appveyor-repo-name", - "APPVEYOR_REPO_PROVIDER": "github" - }, - { - "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", - "ci.pipeline.id": "appveyor-build-id", - "ci.pipeline.name": "appveyor-repo-name", - "ci.pipeline.number": "appveyor-pipeline-number", - "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", - "ci.provider.name": "appveyor", - "ci.workspace_path": "/foo/bar~", - "git.branch": "master", - "git.commit.sha": "appveyor-repo-commit", - "git.commit_sha": "appveyor-repo-commit", - "git.repository_url": "https://github.com/appveyor-repo-name.git" - } - ], - [ - { - "APPVEYOR": "true", - "APPVEYOR_BUILD_FOLDER": "/foo/~/bar", - "APPVEYOR_BUILD_ID": "appveyor-build-id", - "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", - "APPVEYOR_REPO_BRANCH": "master", - "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", - "APPVEYOR_REPO_NAME": "appveyor-repo-name", - "APPVEYOR_REPO_PROVIDER": "github" - }, - { - "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", - "ci.pipeline.id": "appveyor-build-id", - "ci.pipeline.name": "appveyor-repo-name", - "ci.pipeline.number": "appveyor-pipeline-number", - "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", - "ci.provider.name": "appveyor", - "ci.workspace_path": "/foo/~/bar", - "git.branch": "master", - "git.commit.sha": "appveyor-repo-commit", - "git.commit_sha": "appveyor-repo-commit", - "git.repository_url": "https://github.com/appveyor-repo-name.git" - } - ], - [ - { - "APPVEYOR": "true", - "APPVEYOR_BUILD_FOLDER": "~/foo/bar", - "APPVEYOR_BUILD_ID": "appveyor-build-id", - "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", - "APPVEYOR_REPO_BRANCH": "master", - "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", - "APPVEYOR_REPO_NAME": "appveyor-repo-name", - "APPVEYOR_REPO_PROVIDER": "github", - "HOME": "/not-my-home", - "USERPROFILE": "/not-my-home" - }, - { - "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", - "ci.pipeline.id": "appveyor-build-id", - "ci.pipeline.name": "appveyor-repo-name", - "ci.pipeline.number": "appveyor-pipeline-number", - "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", - "ci.provider.name": "appveyor", - "ci.workspace_path": "/not-my-home/foo/bar", - "git.branch": "master", - "git.commit.sha": "appveyor-repo-commit", - "git.commit_sha": "appveyor-repo-commit", - "git.repository_url": "https://github.com/appveyor-repo-name.git" - } - ], - [ - { - "APPVEYOR": "true", - "APPVEYOR_BUILD_FOLDER": "~foo/bar", - "APPVEYOR_BUILD_ID": "appveyor-build-id", - "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", - "APPVEYOR_REPO_BRANCH": "master", - "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", - "APPVEYOR_REPO_NAME": "appveyor-repo-name", - "APPVEYOR_REPO_PROVIDER": "github" - }, - { - "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", - "ci.pipeline.id": "appveyor-build-id", - "ci.pipeline.name": "appveyor-repo-name", - "ci.pipeline.number": "appveyor-pipeline-number", - "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", - "ci.provider.name": "appveyor", - "ci.workspace_path": "~foo/bar", - "git.branch": "master", - "git.commit.sha": "appveyor-repo-commit", - "git.commit_sha": "appveyor-repo-commit", - "git.repository_url": "https://github.com/appveyor-repo-name.git" - } - ], - [ - { - "APPVEYOR": "true", - "APPVEYOR_BUILD_FOLDER": "~", - "APPVEYOR_BUILD_ID": "appveyor-build-id", - "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", - "APPVEYOR_REPO_BRANCH": "master", - "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", - "APPVEYOR_REPO_NAME": "appveyor-repo-name", - "APPVEYOR_REPO_PROVIDER": "github", - "HOME": "/not-my-home", - "USERPROFILE": "/not-my-home" - }, - { - "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", - "ci.pipeline.id": "appveyor-build-id", - "ci.pipeline.name": "appveyor-repo-name", - "ci.pipeline.number": "appveyor-pipeline-number", - "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", - "ci.provider.name": "appveyor", - "ci.workspace_path": "/not-my-home", - "git.branch": "master", - "git.commit.sha": "appveyor-repo-commit", - "git.commit_sha": "appveyor-repo-commit", - "git.repository_url": "https://github.com/appveyor-repo-name.git" - } - ], - [ - { - "APPVEYOR": "true", - "APPVEYOR_BUILD_FOLDER": "/foo/bar", - "APPVEYOR_BUILD_ID": "appveyor-build-id", - "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", - "APPVEYOR_REPO_BRANCH": "master", - "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", - "APPVEYOR_REPO_NAME": "appveyor-repo-name" - }, - { - "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", - "ci.pipeline.id": "appveyor-build-id", - "ci.pipeline.name": "appveyor-repo-name", - "ci.pipeline.number": "appveyor-pipeline-number", - "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", - "ci.provider.name": "appveyor", - "ci.workspace_path": "/foo/bar", - "git.branch": "master", - "git.commit.sha": "appveyor-repo-commit", - "git.commit_sha": "appveyor-repo-commit", - "git.repository_url": "https://github.com/appveyor-repo-name.git" - } - ], - [ - { - "APPVEYOR": "true", - "APPVEYOR_BUILD_FOLDER": "/foo/bar", - "APPVEYOR_BUILD_ID": "appveyor-build-id", - "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", - "APPVEYOR_REPO_BRANCH": "origin/master", - "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", - "APPVEYOR_REPO_NAME": "appveyor-repo-name", - "APPVEYOR_REPO_PROVIDER": "github" - }, - { - "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", - "ci.pipeline.id": "appveyor-build-id", - "ci.pipeline.name": "appveyor-repo-name", - "ci.pipeline.number": "appveyor-pipeline-number", - "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", - "ci.provider.name": "appveyor", - "ci.workspace_path": "/foo/bar", - "git.branch": "master", - "git.commit.sha": "appveyor-repo-commit", - "git.commit_sha": "appveyor-repo-commit", - "git.repository_url": "https://github.com/appveyor-repo-name.git" - } - ], - [ - { - "APPVEYOR": "true", - "APPVEYOR_BUILD_FOLDER": "/foo/bar", - "APPVEYOR_BUILD_ID": "appveyor-build-id", - "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", - "APPVEYOR_REPO_BRANCH": "refs/heads/master", - "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", - "APPVEYOR_REPO_NAME": "appveyor-repo-name", - "APPVEYOR_REPO_PROVIDER": "github" - }, - { - "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", - "ci.pipeline.id": "appveyor-build-id", - "ci.pipeline.name": "appveyor-repo-name", - "ci.pipeline.number": "appveyor-pipeline-number", - "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", - "ci.provider.name": "appveyor", - "ci.workspace_path": "/foo/bar", - "git.branch": "master", - "git.commit.sha": "appveyor-repo-commit", - "git.commit_sha": "appveyor-repo-commit", - "git.repository_url": "https://github.com/appveyor-repo-name.git" - } - ], - [ - { - "APPVEYOR": "true", - "APPVEYOR_BUILD_FOLDER": "/foo/bar", - "APPVEYOR_BUILD_ID": "appveyor-build-id", - "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", - "APPVEYOR_REPO_BRANCH": "refs/heads/feature/one", - "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", - "APPVEYOR_REPO_NAME": "appveyor-repo-name", - "APPVEYOR_REPO_PROVIDER": "github" - }, - { - "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", - "ci.pipeline.id": "appveyor-build-id", - "ci.pipeline.name": "appveyor-repo-name", - "ci.pipeline.number": "appveyor-pipeline-number", - "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", - "ci.provider.name": "appveyor", - "ci.workspace_path": "/foo/bar", - "git.branch": "feature/one", - "git.commit.sha": "appveyor-repo-commit", - "git.commit_sha": "appveyor-repo-commit", - "git.repository_url": "https://github.com/appveyor-repo-name.git" - } - ], - [ - { - "APPVEYOR": "true", - "APPVEYOR_BUILD_FOLDER": "/foo/bar", - "APPVEYOR_BUILD_ID": "appveyor-build-id", - "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", - "APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH": "origin/pr", - "APPVEYOR_REPO_BRANCH": "origin/master", - "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", - "APPVEYOR_REPO_NAME": "appveyor-repo-name", - "APPVEYOR_REPO_PROVIDER": "github" - }, - { - "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", - "ci.pipeline.id": "appveyor-build-id", - "ci.pipeline.name": "appveyor-repo-name", - "ci.pipeline.number": "appveyor-pipeline-number", - "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", - "ci.provider.name": "appveyor", - "ci.workspace_path": "/foo/bar", - "git.branch": "pr", - "git.commit.sha": "appveyor-repo-commit", - "git.commit_sha": "appveyor-repo-commit", - "git.repository_url": "https://github.com/appveyor-repo-name.git" - } - ], - [ - { - "APPVEYOR": "true", - "APPVEYOR_BUILD_FOLDER": "/foo/bar", - "APPVEYOR_BUILD_ID": "appveyor-build-id", - "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", - "APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH": "refs/heads/pr", - "APPVEYOR_REPO_BRANCH": "refs/heads/master", - "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", - "APPVEYOR_REPO_NAME": "appveyor-repo-name", - "APPVEYOR_REPO_PROVIDER": "github" - }, - { - "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", - "ci.pipeline.id": "appveyor-build-id", - "ci.pipeline.name": "appveyor-repo-name", - "ci.pipeline.number": "appveyor-pipeline-number", - "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", - "ci.provider.name": "appveyor", - "ci.workspace_path": "/foo/bar", - "git.branch": "pr", - "git.commit.sha": "appveyor-repo-commit", - "git.commit_sha": "appveyor-repo-commit", - "git.repository_url": "https://github.com/appveyor-repo-name.git" - } - ], - [ - { - "APPVEYOR": "true", - "APPVEYOR_BUILD_FOLDER": "/foo/bar", - "APPVEYOR_BUILD_ID": "appveyor-build-id", - "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", - "APPVEYOR_REPO_BRANCH": "origin/master", - "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", - "APPVEYOR_REPO_NAME": "appveyor-repo-name", - "APPVEYOR_REPO_PROVIDER": "github", - "APPVEYOR_REPO_TAG_NAME": "origin/tags/0.1.0" - }, - { - "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", - "ci.pipeline.id": "appveyor-build-id", - "ci.pipeline.name": "appveyor-repo-name", - "ci.pipeline.number": "appveyor-pipeline-number", - "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", - "ci.provider.name": "appveyor", - "ci.workspace_path": "/foo/bar", - "git.commit.sha": "appveyor-repo-commit", - "git.commit_sha": "appveyor-repo-commit", - "git.repository_url": "https://github.com/appveyor-repo-name.git", - "git.tag": "0.1.0" - } - ], - [ - { - "APPVEYOR": "true", - "APPVEYOR_BUILD_FOLDER": "/foo/bar", - "APPVEYOR_BUILD_ID": "appveyor-build-id", - "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", - "APPVEYOR_REPO_BRANCH": "refs/heads/master", - "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", - "APPVEYOR_REPO_NAME": "appveyor-repo-name", - "APPVEYOR_REPO_PROVIDER": "github", - "APPVEYOR_REPO_TAG_NAME": "refs/heads/tags/0.1.0" - }, - { - "ci.job.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", - "ci.pipeline.id": "appveyor-build-id", - "ci.pipeline.name": "appveyor-repo-name", - "ci.pipeline.number": "appveyor-pipeline-number", - "ci.pipeline.url": "https://ci.appveyor.com/project/appveyor-repo-name/builds/appveyor-build-id", - "ci.provider.name": "appveyor", - "ci.workspace_path": "/foo/bar", - "git.commit.sha": "appveyor-repo-commit", - "git.commit_sha": "appveyor-repo-commit", - "git.repository_url": "https://github.com/appveyor-repo-name.git", - "git.tag": "0.1.0" - } - ] -] - - -AZURE = [ - [ - { - "BUILD_BUILDID": "azure-pipelines-build-id", - "BUILD_DEFINITIONNAME": "azure-pipelines-name", - "BUILD_REPOSITORY_URI": "sample", - "BUILD_SOURCEBRANCH": "master", - "BUILD_SOURCESDIRECTORY": "/foo/bar", - "BUILD_SOURCEVERSION": "commit", - "SYSTEM_JOBID": "azure-pipelines-job-id", - "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", - "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", - "SYSTEM_TEAMPROJECT": "azure-pipelines-project", - "TF_BUILD": "True", - }, - { - "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", - "ci.pipeline.id": "azure-pipelines-build-id", - "ci.pipeline.name": "azure-pipelines-name", - "ci.pipeline.number": "azure-pipelines-build-id", - "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", - "ci.provider.name": "azurepipelines", - "ci.workspace_path": "/foo/bar", - "git.branch": "master", - "git.commit.sha": "commit", - "git.commit_sha": "commit", - "git.repository_url": "sample", - }, - ], - [ - { - "BUILD_BUILDID": "azure-pipelines-build-id", - "BUILD_DEFINITIONNAME": "azure-pipelines-name", - "BUILD_REPOSITORY_URI": "sample", - "BUILD_SOURCEBRANCH": "master", - "BUILD_SOURCESDIRECTORY": "/foo/bar", - "BUILD_SOURCEVERSION": "commit", - "SYSTEM_JOBID": "azure-pipelines-job-id", - "SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI": "", - "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", - "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", - "SYSTEM_TEAMPROJECT": "azure-pipelines-project", - "TF_BUILD": "True", - }, - { - "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", - "ci.pipeline.id": "azure-pipelines-build-id", - "ci.pipeline.name": "azure-pipelines-name", - "ci.pipeline.number": "azure-pipelines-build-id", - "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", - "ci.provider.name": "azurepipelines", - "ci.workspace_path": "/foo/bar", - "git.branch": "master", - "git.commit.sha": "commit", - "git.commit_sha": "commit", - "git.repository_url": "sample", - }, - ], - [ - { - "BUILD_BUILDID": "azure-pipelines-build-id", - "BUILD_DEFINITIONNAME": "azure-pipelines-name", - "BUILD_REPOSITORY_URI": "sample", - "BUILD_SOURCEBRANCH": "master", - "BUILD_SOURCESDIRECTORY": "/foo/bar", - "BUILD_SOURCEVERSION": "commit", - "SYSTEM_JOBID": "azure-pipelines-job-id", - "SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI": "sample2", - "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", - "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", - "SYSTEM_TEAMPROJECT": "azure-pipelines-project", - "TF_BUILD": "True", - }, - { - "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", - "ci.pipeline.id": "azure-pipelines-build-id", - "ci.pipeline.name": "azure-pipelines-name", - "ci.pipeline.number": "azure-pipelines-build-id", - "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", - "ci.provider.name": "azurepipelines", - "ci.workspace_path": "/foo/bar", - "git.branch": "master", - "git.commit.sha": "commit", - "git.commit_sha": "commit", - "git.repository_url": "sample2", - }, - ], - [ - { - "BUILD_BUILDID": "azure-pipelines-build-id", - "BUILD_DEFINITIONNAME": "azure-pipelines-name", - "BUILD_REPOSITORY_URI": "sample", - "BUILD_SOURCEBRANCH": "master", - "BUILD_SOURCESDIRECTORY": "/foo/bar", - "BUILD_SOURCEVERSION": "commit", - "SYSTEM_JOBID": "azure-pipelines-job-id", - "SYSTEM_PULLREQUEST_SOURCEBRANCH": "", - "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", - "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", - "SYSTEM_TEAMPROJECT": "azure-pipelines-project", - "TF_BUILD": "True", - }, - { - "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", - "ci.pipeline.id": "azure-pipelines-build-id", - "ci.pipeline.name": "azure-pipelines-name", - "ci.pipeline.number": "azure-pipelines-build-id", - "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", - "ci.provider.name": "azurepipelines", - "ci.workspace_path": "/foo/bar", - "git.branch": "master", - "git.commit.sha": "commit", - "git.commit_sha": "commit", - "git.repository_url": "sample", - }, - ], - [ - { - "BUILD_BUILDID": "azure-pipelines-build-id", - "BUILD_DEFINITIONNAME": "azure-pipelines-name", - "BUILD_REPOSITORY_URI": "sample", - "BUILD_SOURCEBRANCH": "master", - "BUILD_SOURCESDIRECTORY": "/foo/bar", - "BUILD_SOURCEVERSION": "commit", - "SYSTEM_JOBID": "azure-pipelines-job-id", - "SYSTEM_PULLREQUEST_SOURCECOMMITID": "", - "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", - "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", - "SYSTEM_TEAMPROJECT": "azure-pipelines-project", - "TF_BUILD": "True", - }, - { - "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", - "ci.pipeline.id": "azure-pipelines-build-id", - "ci.pipeline.name": "azure-pipelines-name", - "ci.pipeline.number": "azure-pipelines-build-id", - "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", - "ci.provider.name": "azurepipelines", - "ci.workspace_path": "/foo/bar", - "git.branch": "master", - "git.commit.sha": "commit", - "git.commit_sha": "commit", - "git.repository_url": "sample", - }, - ], - [ - { - "BUILD_BUILDID": "azure-pipelines-build-id", - "BUILD_DEFINITIONNAME": "azure-pipelines-name", - "BUILD_REPOSITORY_URI": "sample", - "BUILD_SOURCEBRANCH": "origin/master", - "BUILD_SOURCESDIRECTORY": "foo/bar", - "BUILD_SOURCEVERSION": "commit", - "SYSTEM_JOBID": "azure-pipelines-job-id", - "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", - "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", - "SYSTEM_TEAMPROJECT": "azure-pipelines-project", - "TF_BUILD": "True", - }, - { - "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", - "ci.pipeline.id": "azure-pipelines-build-id", - "ci.pipeline.name": "azure-pipelines-name", - "ci.pipeline.number": "azure-pipelines-build-id", - "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", - "ci.provider.name": "azurepipelines", - "ci.workspace_path": "foo/bar", - "git.branch": "master", - "git.commit.sha": "commit", - "git.commit_sha": "commit", - "git.repository_url": "sample", - }, - ], - [ - { - "BUILD_BUILDID": "azure-pipelines-build-id", - "BUILD_DEFINITIONNAME": "azure-pipelines-name", - "BUILD_REPOSITORY_URI": "sample", - "BUILD_SOURCEBRANCH": "origin/master", - "BUILD_SOURCESDIRECTORY": "/foo/bar~", - "BUILD_SOURCEVERSION": "commit", - "HOME": "/not-my-home", - "SYSTEM_JOBID": "azure-pipelines-job-id", - "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", - "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", - "SYSTEM_TEAMPROJECT": "azure-pipelines-project", - "TF_BUILD": "True", - "USERPROFILE": "/not-my-home", - }, - { - "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", - "ci.pipeline.id": "azure-pipelines-build-id", - "ci.pipeline.name": "azure-pipelines-name", - "ci.pipeline.number": "azure-pipelines-build-id", - "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", - "ci.provider.name": "azurepipelines", - "ci.workspace_path": "/foo/bar~", - "git.branch": "master", - "git.commit.sha": "commit", - "git.commit_sha": "commit", - "git.repository_url": "sample", - }, - ], - [ - { - "BUILD_BUILDID": "azure-pipelines-build-id", - "BUILD_DEFINITIONNAME": "azure-pipelines-name", - "BUILD_REPOSITORY_URI": "sample", - "BUILD_SOURCEBRANCH": "origin/master", - "BUILD_SOURCESDIRECTORY": "/foo/~/bar", - "BUILD_SOURCEVERSION": "commit", - "HOME": "/not-my-home", - "SYSTEM_JOBID": "azure-pipelines-job-id", - "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", - "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", - "SYSTEM_TEAMPROJECT": "azure-pipelines-project", - "TF_BUILD": "True", - "USERPROFILE": "/not-my-home", - }, - { - "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", - "ci.pipeline.id": "azure-pipelines-build-id", - "ci.pipeline.name": "azure-pipelines-name", - "ci.pipeline.number": "azure-pipelines-build-id", - "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", - "ci.provider.name": "azurepipelines", - "ci.workspace_path": "/foo/~/bar", - "git.branch": "master", - "git.commit.sha": "commit", - "git.commit_sha": "commit", - "git.repository_url": "sample", - }, - ], - [ - { - "BUILD_BUILDID": "azure-pipelines-build-id", - "BUILD_DEFINITIONNAME": "azure-pipelines-name", - "BUILD_REPOSITORY_URI": "sample", - "BUILD_SOURCEBRANCH": "origin/master", - "BUILD_SOURCESDIRECTORY": "~/foo/bar", - "BUILD_SOURCEVERSION": "commit", - "HOME": "/not-my-home", - "SYSTEM_JOBID": "azure-pipelines-job-id", - "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", - "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", - "SYSTEM_TEAMPROJECT": "azure-pipelines-project", - "TF_BUILD": "True", - "USERPROFILE": "/not-my-home", - }, - { - "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", - "ci.pipeline.id": "azure-pipelines-build-id", - "ci.pipeline.name": "azure-pipelines-name", - "ci.pipeline.number": "azure-pipelines-build-id", - "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", - "ci.provider.name": "azurepipelines", - "ci.workspace_path": "/not-my-home/foo/bar", - "git.branch": "master", - "git.commit.sha": "commit", - "git.commit_sha": "commit", - "git.repository_url": "sample", - }, - ], - [ - { - "BUILD_BUILDID": "azure-pipelines-build-id", - "BUILD_DEFINITIONNAME": "azure-pipelines-name", - "BUILD_REPOSITORY_URI": "sample", - "BUILD_SOURCEBRANCH": "origin/master", - "BUILD_SOURCESDIRECTORY": "~foo/bar", - "BUILD_SOURCEVERSION": "commit", - "HOME": "/not-my-home", - "SYSTEM_JOBID": "azure-pipelines-job-id", - "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", - "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", - "SYSTEM_TEAMPROJECT": "azure-pipelines-project", - "TF_BUILD": "True", - "USERPROFILE": "/not-my-home", - }, - { - "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", - "ci.pipeline.id": "azure-pipelines-build-id", - "ci.pipeline.name": "azure-pipelines-name", - "ci.pipeline.number": "azure-pipelines-build-id", - "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", - "ci.provider.name": "azurepipelines", - "ci.workspace_path": "~foo/bar", - "git.branch": "master", - "git.commit.sha": "commit", - "git.commit_sha": "commit", - "git.repository_url": "sample", - }, - ], - [ - { - "BUILD_BUILDID": "azure-pipelines-build-id", - "BUILD_DEFINITIONNAME": "azure-pipelines-name", - "BUILD_REPOSITORY_URI": "sample", - "BUILD_SOURCEBRANCH": "origin/master", - "BUILD_SOURCESDIRECTORY": "~", - "BUILD_SOURCEVERSION": "commit", - "HOME": "/not-my-home", - "SYSTEM_JOBID": "azure-pipelines-job-id", - "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", - "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", - "SYSTEM_TEAMPROJECT": "azure-pipelines-project", - "TF_BUILD": "True", - "USERPROFILE": "/not-my-home", - }, - { - "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", - "ci.pipeline.id": "azure-pipelines-build-id", - "ci.pipeline.name": "azure-pipelines-name", - "ci.pipeline.number": "azure-pipelines-build-id", - "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", - "ci.provider.name": "azurepipelines", - "ci.workspace_path": "/not-my-home", - "git.branch": "master", - "git.commit.sha": "commit", - "git.commit_sha": "commit", - "git.repository_url": "sample", - }, - ], - [ - { - "BUILD_BUILDID": "azure-pipelines-build-id", - "BUILD_DEFINITIONNAME": "azure-pipelines-name", - "BUILD_REPOSITORY_URI": "sample", - "BUILD_SOURCEBRANCH": "origin/master", - "BUILD_SOURCESDIRECTORY": "/foo/bar", - "BUILD_SOURCEVERSION": "commit", - "SYSTEM_JOBID": "azure-pipelines-job-id", - "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", - "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", - "SYSTEM_TEAMPROJECT": "azure-pipelines-project", - "TF_BUILD": "True", - }, - { - "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", - "ci.pipeline.id": "azure-pipelines-build-id", - "ci.pipeline.name": "azure-pipelines-name", - "ci.pipeline.number": "azure-pipelines-build-id", - "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", - "ci.provider.name": "azurepipelines", - "ci.workspace_path": "/foo/bar", - "git.branch": "master", - "git.commit.sha": "commit", - "git.commit_sha": "commit", - "git.repository_url": "sample", - }, - ], - [ - { - "BUILD_BUILDID": "azure-pipelines-build-id", - "BUILD_DEFINITIONNAME": "azure-pipelines-name", - "BUILD_REPOSITORY_URI": "sample", - "BUILD_SOURCEBRANCH": "refs/heads/master", - "BUILD_SOURCESDIRECTORY": "/foo/bar", - "BUILD_SOURCEVERSION": "commit", - "SYSTEM_JOBID": "azure-pipelines-job-id", - "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", - "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", - "SYSTEM_TEAMPROJECT": "azure-pipelines-project", - "TF_BUILD": "True", - }, - { - "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", - "ci.pipeline.id": "azure-pipelines-build-id", - "ci.pipeline.name": "azure-pipelines-name", - "ci.pipeline.number": "azure-pipelines-build-id", - "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", - "ci.provider.name": "azurepipelines", - "ci.workspace_path": "/foo/bar", - "git.branch": "master", - "git.commit.sha": "commit", - "git.commit_sha": "commit", - "git.repository_url": "sample", - }, - ], - [ - { - "BUILD_BUILDID": "azure-pipelines-build-id", - "BUILD_DEFINITIONNAME": "azure-pipelines-name", - "BUILD_REPOSITORY_URI": "sample", - "BUILD_SOURCEBRANCH": "refs/heads/feature/one", - "BUILD_SOURCESDIRECTORY": "/foo/bar", - "BUILD_SOURCEVERSION": "commit", - "SYSTEM_JOBID": "azure-pipelines-job-id", - "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", - "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", - "SYSTEM_TEAMPROJECT": "azure-pipelines-project", - "TF_BUILD": "True", - }, - { - "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", - "ci.pipeline.id": "azure-pipelines-build-id", - "ci.pipeline.name": "azure-pipelines-name", - "ci.pipeline.number": "azure-pipelines-build-id", - "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", - "ci.provider.name": "azurepipelines", - "ci.workspace_path": "/foo/bar", - "git.branch": "feature/one", - "git.commit.sha": "commit", - "git.commit_sha": "commit", - "git.repository_url": "sample", - }, - ], - [ - { - "BUILD_BUILDID": "azure-pipelines-build-id", - "BUILD_DEFINITIONNAME": "azure-pipelines-name", - "BUILD_REPOSITORY_URI": "sample", - "BUILD_SOURCEBRANCH": "origin/tags/0.1.0", - "BUILD_SOURCESDIRECTORY": "/foo/bar", - "BUILD_SOURCEVERSION": "commit", - "SYSTEM_JOBID": "azure-pipelines-job-id", - "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", - "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", - "SYSTEM_TEAMPROJECT": "azure-pipelines-project", - "TF_BUILD": "True", - }, - { - "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", - "ci.pipeline.id": "azure-pipelines-build-id", - "ci.pipeline.name": "azure-pipelines-name", - "ci.pipeline.number": "azure-pipelines-build-id", - "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", - "ci.provider.name": "azurepipelines", - "ci.workspace_path": "/foo/bar", - "git.commit.sha": "commit", - "git.commit_sha": "commit", - "git.repository_url": "sample", - "git.tag": "0.1.0", - }, - ], - [ - { - "BUILD_BUILDID": "azure-pipelines-build-id", - "BUILD_DEFINITIONNAME": "azure-pipelines-name", - "BUILD_REPOSITORY_URI": "sample", - "BUILD_SOURCEBRANCH": "refs/heads/tags/0.1.0", - "BUILD_SOURCESDIRECTORY": "/foo/bar", - "BUILD_SOURCEVERSION": "commit", - "SYSTEM_JOBID": "azure-pipelines-job-id", - "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", - "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", - "SYSTEM_TEAMPROJECT": "azure-pipelines-project", - "TF_BUILD": "True", - }, - { - "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", - "ci.pipeline.id": "azure-pipelines-build-id", - "ci.pipeline.name": "azure-pipelines-name", - "ci.pipeline.number": "azure-pipelines-build-id", - "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", - "ci.provider.name": "azurepipelines", - "ci.workspace_path": "/foo/bar", - "git.commit.sha": "commit", - "git.commit_sha": "commit", - "git.repository_url": "sample", - "git.tag": "0.1.0", - }, - ], - [ - { - "BUILD_BUILDID": "azure-pipelines-build-id", - "BUILD_DEFINITIONNAME": "azure-pipelines-name", - "BUILD_REPOSITORY_URI": "sample", - "BUILD_SOURCEBRANCH": "origin/master", - "BUILD_SOURCESDIRECTORY": "/foo/bar", - "BUILD_SOURCEVERSION": "commit", - "SYSTEM_JOBID": "azure-pipelines-job-id", - "SYSTEM_PULLREQUEST_SOURCEBRANCH": "origin/pr", - "SYSTEM_PULLREQUEST_SOURCECOMMITID": "commitPR", - "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", - "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", - "SYSTEM_TEAMPROJECT": "azure-pipelines-project", - "TF_BUILD": "True", - }, - { - "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", - "ci.pipeline.id": "azure-pipelines-build-id", - "ci.pipeline.name": "azure-pipelines-name", - "ci.pipeline.number": "azure-pipelines-build-id", - "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", - "ci.provider.name": "azurepipelines", - "ci.workspace_path": "/foo/bar", - "git.branch": "pr", - "git.commit.sha": "commitPR", - "git.commit_sha": "commitPR", - "git.repository_url": "sample", - }, - ], - [ - { - "BUILD_BUILDID": "azure-pipelines-build-id", - "BUILD_DEFINITIONNAME": "azure-pipelines-name", - "BUILD_REPOSITORY_URI": "sample", - "BUILD_SOURCEBRANCH": "refs/heads/master", - "BUILD_SOURCESDIRECTORY": "/foo/bar", - "BUILD_SOURCEVERSION": "commit", - "SYSTEM_JOBID": "azure-pipelines-job-id", - "SYSTEM_PULLREQUEST_SOURCEBRANCH": "refs/heads/pr", - "SYSTEM_PULLREQUEST_SOURCECOMMITID": "commitPR", - "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", - "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", - "SYSTEM_TEAMPROJECT": "azure-pipelines-project", - "TF_BUILD": "True", - }, - { - "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", - "ci.pipeline.id": "azure-pipelines-build-id", - "ci.pipeline.name": "azure-pipelines-name", - "ci.pipeline.number": "azure-pipelines-build-id", - "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", - "ci.provider.name": "azurepipelines", - "ci.workspace_path": "/foo/bar", - "git.branch": "pr", - "git.commit.sha": "commitPR", - "git.commit_sha": "commitPR", - "git.repository_url": "sample", - }, - ], - [ - { - "BUILD_BUILDID": "azure-pipelines-build-id", - "BUILD_DEFINITIONNAME": "azure-pipelines-name", - "BUILD_REPOSITORY_URI": "sample", - "BUILD_SOURCEBRANCH": "refs/heads/feature/one", - "BUILD_SOURCESDIRECTORY": "/foo/bar", - "BUILD_SOURCEVERSION": "commit", - "SYSTEM_JOBID": "azure-pipelines-job-id", - "SYSTEM_PULLREQUEST_SOURCEBRANCH": "refs/heads/pr", - "SYSTEM_PULLREQUEST_SOURCECOMMITID": "commitPR", - "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", - "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", - "SYSTEM_TEAMPROJECT": "azure-pipelines-project", - "TF_BUILD": "True", - }, - { - "ci.job.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&view=logs&j=azure-pipelines-job-id&t=azure-pipelines-task-id", - "ci.pipeline.id": "azure-pipelines-build-id", - "ci.pipeline.name": "azure-pipelines-name", - "ci.pipeline.number": "azure-pipelines-build-id", - "ci.pipeline.url": "azure-pipelines-server-uri/azure-pipelines-project/_build/results?buildId=azure-pipelines-build-id&_a=summary", - "ci.provider.name": "azurepipelines", - "ci.workspace_path": "/foo/bar", - "git.branch": "pr", - "git.commit.sha": "commitPR", - "git.commit_sha": "commitPR", - "git.repository_url": "sample", - }, - ], -] +def _ci_fixtures(*names): + basepath = os.path.join(os.path.dirname(__file__), 'fixtures', 'ci') + for name in names: + with open(os.path.join(basepath, name + '.json')) as fp: + for item in json.load(fp): + yield name, item[0], item[1] def _updateenv(monkeypatch, env): @@ -985,7 +28,7 @@ def _updateenv(monkeypatch, env): monkeypatch.setenv(k, v) -@pytest.mark.parametrize("environment,tags", APPVEYOR + AZURE) -def test_ci_providers(monkeypatch, environment, tags): +@pytest.mark.parametrize("name,environment,tags", _ci_fixtures("appveyor", "azurepipelines")) +def test_ci_providers(monkeypatch, name, environment, tags): _updateenv(monkeypatch, environment) - assert tags == ci.tags(), environment + assert tags == ci.tags(), (name, environment) From 7f03003930b89bc5ac7adc0659ba281892554e55 Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Wed, 28 Oct 2020 10:43:50 +0100 Subject: [PATCH 23/34] test service_name --- tests/contrib/pytest/test_pytest.py | 65 +++++++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 3 deletions(-) diff --git a/tests/contrib/pytest/test_pytest.py b/tests/contrib/pytest/test_pytest.py index 8fdf8c36c3f..9b6070e5b32 100644 --- a/tests/contrib/pytest/test_pytest.py +++ b/tests/contrib/pytest/test_pytest.py @@ -2,7 +2,7 @@ import pytest -from ddtrace import Pin +from ddtrace import Pin, config from ddtrace.ext import test from ... import TracerTestCase @@ -10,8 +10,9 @@ class TestPytest(TracerTestCase): @pytest.fixture(autouse=True) - def initdir(self, testdir): + def fixtures(self, testdir, monkeypatch): self.testdir = testdir + self.monkeypatch = monkeypatch def inline_run(self, *args): """Execute test script with test tracer.""" @@ -24,6 +25,10 @@ def pytest_configure(config): return self.testdir.inline_run(*args, plugins=[PinTracer()]) + def subprocess_run(self, *args): + """Execute test script with test tracer.""" + return self.testdir.runpytest_subprocess(*args) + def test_disabled(self): """Test without --ddtrace.""" py_file = self.testdir.makepyfile( @@ -121,7 +126,61 @@ def test_fixture(ddspan): spans = self.tracer.writer.pop() assert len(spans) == 1 - assert spans[0].service == "pytest" assert spans[0].get_tag("world") == "hello" assert spans[0].get_tag("mark") == "dd_tags" assert spans[0].get_tag(test.STATUS) == test.Status.PASS.value + + def test_default_service_name(self): + """Test default service name.""" + py_file = self.testdir.makepyfile( + """ + def test_service(ddspan): + assert True + """ + ) + file_name = os.path.basename(py_file.strpath) + rec = self.inline_run("--ddtrace", file_name) + rec.assertoutcome(passed=1) + spans = self.tracer.writer.pop() + + assert len(spans) == 1 + assert spans[0].service == "pytest" + + def test_dd_service_name(self): + """Test integration service name.""" + self.monkeypatch.setenv("DD_SERVICE", "mysvc") + if "DD_PYTEST_SERVICE" in os.environ: + self.monkeypatch.delenv("DD_PYTEST_SERVICE") + + py_file = self.testdir.makepyfile( + """ + import os + + def test_service(ddspan): + assert 'mysvc' == os.getenv('DD_SERVICE') + assert os.getenv('DD_PYTEST_SERVICE') is None + assert 'mysvc' == ddspan.service + """ + ) + file_name = os.path.basename(py_file.strpath) + rec = self.subprocess_run("--ddtrace", file_name) + assert 0 == rec.ret + + def test_dd_pytest_service_name(self): + """Test integration service name.""" + self.monkeypatch.setenv("DD_SERVICE", "mysvc") + self.monkeypatch.setenv("DD_PYTEST_SERVICE", "pymysvc") + + py_file = self.testdir.makepyfile( + """ + import os + + def test_service(ddspan): + assert 'mysvc' == os.getenv('DD_SERVICE') + assert 'pymysvc' == os.getenv('DD_PYTEST_SERVICE') + assert 'pymysvc' == ddspan.service + """ + ) + file_name = os.path.basename(py_file.strpath) + rec = self.subprocess_run("--ddtrace", file_name) + assert 0 == rec.ret From faaa237972d97bca5ef52d09c7fe9d6158a94956 Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Wed, 28 Oct 2020 10:58:04 +0100 Subject: [PATCH 24/34] flake8 --- tests/contrib/pytest/test_pytest.py | 2 +- tests/tracer/test_ext.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/contrib/pytest/test_pytest.py b/tests/contrib/pytest/test_pytest.py index 9b6070e5b32..5426d4d2acb 100644 --- a/tests/contrib/pytest/test_pytest.py +++ b/tests/contrib/pytest/test_pytest.py @@ -2,7 +2,7 @@ import pytest -from ddtrace import Pin, config +from ddtrace import Pin from ddtrace.ext import test from ... import TracerTestCase diff --git a/tests/tracer/test_ext.py b/tests/tracer/test_ext.py index 85fde70f10a..2064d5bac43 100644 --- a/tests/tracer/test_ext.py +++ b/tests/tracer/test_ext.py @@ -5,7 +5,6 @@ from ddtrace.ext import aws from ddtrace.ext import ci -from ddtrace.ext import git def test_flatten_dict(): From 4be219089f9b3f242d06b00b93fb59b1ad793597 Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Wed, 28 Oct 2020 12:35:46 +0100 Subject: [PATCH 25/34] bitbucket --- ddtrace/ext/ci.py | 23 +- tests/tracer/fixtures/ci/bitbucket.json | 392 ++++++++++++++++++++++++ tests/tracer/test_ext.py | 2 +- 3 files changed, 410 insertions(+), 7 deletions(-) create mode 100644 tests/tracer/fixtures/ci/bitbucket.json diff --git a/ddtrace/ext/ci.py b/ddtrace/ext/ci.py index b958d476177..ddf3fa356d9 100644 --- a/ddtrace/ext/ci.py +++ b/ddtrace/ext/ci.py @@ -47,13 +47,16 @@ def tags(env=None): branch = tags.get(git.BRANCH) if branch: tags[git.BRANCH] = _RE_TAGS.sub("", _RE_BRANCH_PREFIX.sub("", branch)) + + # Add deprecated fields tags[git.DEPRECATED_COMMIT_SHA] = tags.get(git.COMMIT_SHA) + + # Expand ~ workspace_path = tags.get(WORKSPACE_PATH) if workspace_path: tags[WORKSPACE_PATH] = os.path.expanduser(workspace_path) - tags = {k: v for k, v in tags.items() if v is not None} - return tags + return {k: v for k, v in tags.items() if v is not None} return {} @@ -105,13 +108,21 @@ def extract_azure_pipelines(env): def extract_bitbucket(env): + url = "https://bitbucket.org/{0}/addon/pipelines/home#!/results/{1}".format( + env.get("BITBUCKET_REPO_FULL_NAME"), env.get("BITBUCKET_BUILD_NUMBER") + ) return { - PROVIDER_NAME: "bitbucketpipelines", - git.REPOSITORY_URL: env.get("BITBUCKET_GIT_SSH_ORIGIN"), + git.BRANCH: env.get("BITBUCKET_BRANCH"), git.COMMIT_SHA: env.get("BITBUCKET_COMMIT"), - WORKSPACE_PATH: env.get("BITBUCKET_CLONE_DIR"), - PIPELINE_ID: env.get("BITBUCKET_PIPELINE_UUID"), + git.REPOSITORY_URL: env.get("BITBUCKET_GIT_SSH_ORIGIN"), + git.TAG: env.get("BITBUCKET_TAG"), + JOB_URL: url, + PIPELINE_ID: env.get("BITBUCKET_PIPELINE_UUID", "").strip("{}}") or None, + PIPELINE_NAME: env.get("BITBUCKET_REPO_FULL_NAME"), PIPELINE_NUMBER: env.get("BITBUCKET_BUILD_NUMBER"), + PIPELINE_URL: url, + PROVIDER_NAME: "bitbucket", + WORKSPACE_PATH: env.get("BITBUCKET_CLONE_DIR"), } diff --git a/tests/tracer/fixtures/ci/bitbucket.json b/tests/tracer/fixtures/ci/bitbucket.json new file mode 100644 index 00000000000..6ceb81f3dd9 --- /dev/null +++ b/tests/tracer/fixtures/ci/bitbucket.json @@ -0,0 +1,392 @@ +[ + [ + { + "BITBUCKET_BRANCH": "master", + "BITBUCKET_BUILD_NUMBER": "bitbucket-build-num", + "BITBUCKET_CLONE_DIR": "/foo/bar", + "BITBUCKET_COMMIT": "bitbucket-commit", + "BITBUCKET_GIT_SSH_ORIGIN": "bitbucket-repo-url", + "BITBUCKET_PIPELINE_UUID": "{bitbucket-uuid}", + "BITBUCKET_REPO_FULL_NAME": "bitbucket-repo" + }, + { + "ci.job.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num", + "ci.pipeline.id": "bitbucket-uuid", + "ci.pipeline.name": "bitbucket-repo", + "ci.pipeline.number": "bitbucket-build-num", + "ci.pipeline.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num", + "ci.provider.name": "bitbucket", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "bitbucket-commit", + "git.commit_sha": "bitbucket-commit", + "git.repository_url": "bitbucket-repo-url" + } + ], + [ + { + "BITBUCKET_BRANCH": "master", + "BITBUCKET_BUILD_NUMBER": "bitbucket-build-num", + "BITBUCKET_CLONE_DIR": "/foo/bar", + "BITBUCKET_COMMIT": "bitbucket-commit", + "BITBUCKET_GIT_SSH_ORIGIN": "bitbucket-repo-url", + "BITBUCKET_PIPELINE_UUID": "{bitbucket-uuid}", + "BITBUCKET_REPO_FULL_NAME": "bitbucket-repo" + }, + { + "ci.job.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num", + "ci.pipeline.id": "bitbucket-uuid", + "ci.pipeline.name": "bitbucket-repo", + "ci.pipeline.number": "bitbucket-build-num", + "ci.pipeline.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num", + "ci.provider.name": "bitbucket", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "bitbucket-commit", + "git.commit_sha": "bitbucket-commit", + "git.repository_url": "bitbucket-repo-url" + } + ], + [ + { + "BITBUCKET_BRANCH": "master", + "BITBUCKET_BUILD_NUMBER": "bitbucket-build-num", + "BITBUCKET_CLONE_DIR": "foo/bar", + "BITBUCKET_COMMIT": "bitbucket-commit", + "BITBUCKET_GIT_SSH_ORIGIN": "bitbucket-repo-url", + "BITBUCKET_PIPELINE_UUID": "{bitbucket-uuid}", + "BITBUCKET_REPO_FULL_NAME": "bitbucket-repo" + }, + { + "ci.job.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num", + "ci.pipeline.id": "bitbucket-uuid", + "ci.pipeline.name": "bitbucket-repo", + "ci.pipeline.number": "bitbucket-build-num", + "ci.pipeline.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num", + "ci.provider.name": "bitbucket", + "ci.workspace_path": "foo/bar", + "git.branch": "master", + "git.commit.sha": "bitbucket-commit", + "git.commit_sha": "bitbucket-commit", + "git.repository_url": "bitbucket-repo-url" + } + ], + [ + { + "BITBUCKET_BRANCH": "master", + "BITBUCKET_BUILD_NUMBER": "bitbucket-build-num", + "BITBUCKET_CLONE_DIR": "/foo/bar~", + "BITBUCKET_COMMIT": "bitbucket-commit", + "BITBUCKET_GIT_SSH_ORIGIN": "bitbucket-repo-url", + "BITBUCKET_PIPELINE_UUID": "{bitbucket-uuid}", + "BITBUCKET_REPO_FULL_NAME": "bitbucket-repo" + }, + { + "ci.job.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num", + "ci.pipeline.id": "bitbucket-uuid", + "ci.pipeline.name": "bitbucket-repo", + "ci.pipeline.number": "bitbucket-build-num", + "ci.pipeline.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num", + "ci.provider.name": "bitbucket", + "ci.workspace_path": "/foo/bar~", + "git.branch": "master", + "git.commit.sha": "bitbucket-commit", + "git.commit_sha": "bitbucket-commit", + "git.repository_url": "bitbucket-repo-url" + } + ], + [ + { + "BITBUCKET_BRANCH": "master", + "BITBUCKET_BUILD_NUMBER": "bitbucket-build-num", + "BITBUCKET_CLONE_DIR": "/foo/~/bar", + "BITBUCKET_COMMIT": "bitbucket-commit", + "BITBUCKET_GIT_SSH_ORIGIN": "bitbucket-repo-url", + "BITBUCKET_PIPELINE_UUID": "{bitbucket-uuid}", + "BITBUCKET_REPO_FULL_NAME": "bitbucket-repo" + }, + { + "ci.job.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num", + "ci.pipeline.id": "bitbucket-uuid", + "ci.pipeline.name": "bitbucket-repo", + "ci.pipeline.number": "bitbucket-build-num", + "ci.pipeline.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num", + "ci.provider.name": "bitbucket", + "ci.workspace_path": "/foo/~/bar", + "git.branch": "master", + "git.commit.sha": "bitbucket-commit", + "git.commit_sha": "bitbucket-commit", + "git.repository_url": "bitbucket-repo-url" + } + ], + [ + { + "BITBUCKET_BRANCH": "master", + "BITBUCKET_BUILD_NUMBER": "bitbucket-build-num", + "BITBUCKET_CLONE_DIR": "~/foo/bar", + "BITBUCKET_COMMIT": "bitbucket-commit", + "BITBUCKET_GIT_SSH_ORIGIN": "bitbucket-repo-url", + "BITBUCKET_PIPELINE_UUID": "{bitbucket-uuid}", + "BITBUCKET_REPO_FULL_NAME": "bitbucket-repo", + "HOME": "/not-my-home", + "USERPROFILE": "/not-my-home" + }, + { + "ci.job.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num", + "ci.pipeline.id": "bitbucket-uuid", + "ci.pipeline.name": "bitbucket-repo", + "ci.pipeline.number": "bitbucket-build-num", + "ci.pipeline.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num", + "ci.provider.name": "bitbucket", + "ci.workspace_path": "/not-my-home/foo/bar", + "git.branch": "master", + "git.commit.sha": "bitbucket-commit", + "git.commit_sha": "bitbucket-commit", + "git.repository_url": "bitbucket-repo-url" + } + ], + [ + { + "BITBUCKET_BRANCH": "master", + "BITBUCKET_BUILD_NUMBER": "bitbucket-build-num", + "BITBUCKET_CLONE_DIR": "~foo/bar", + "BITBUCKET_COMMIT": "bitbucket-commit", + "BITBUCKET_GIT_SSH_ORIGIN": "bitbucket-repo-url", + "BITBUCKET_PIPELINE_UUID": "{bitbucket-uuid}", + "BITBUCKET_REPO_FULL_NAME": "bitbucket-repo" + }, + { + "ci.job.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num", + "ci.pipeline.id": "bitbucket-uuid", + "ci.pipeline.name": "bitbucket-repo", + "ci.pipeline.number": "bitbucket-build-num", + "ci.pipeline.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num", + "ci.provider.name": "bitbucket", + "ci.workspace_path": "~foo/bar", + "git.branch": "master", + "git.commit.sha": "bitbucket-commit", + "git.commit_sha": "bitbucket-commit", + "git.repository_url": "bitbucket-repo-url" + } + ], + [ + { + "BITBUCKET_BRANCH": "master", + "BITBUCKET_BUILD_NUMBER": "bitbucket-build-num", + "BITBUCKET_CLONE_DIR": "~", + "BITBUCKET_COMMIT": "bitbucket-commit", + "BITBUCKET_GIT_SSH_ORIGIN": "bitbucket-repo-url", + "BITBUCKET_PIPELINE_UUID": "{bitbucket-uuid}", + "BITBUCKET_REPO_FULL_NAME": "bitbucket-repo", + "HOME": "/not-my-home", + "USERPROFILE": "/not-my-home" + }, + { + "ci.job.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num", + "ci.pipeline.id": "bitbucket-uuid", + "ci.pipeline.name": "bitbucket-repo", + "ci.pipeline.number": "bitbucket-build-num", + "ci.pipeline.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num", + "ci.provider.name": "bitbucket", + "ci.workspace_path": "/not-my-home", + "git.branch": "master", + "git.commit.sha": "bitbucket-commit", + "git.commit_sha": "bitbucket-commit", + "git.repository_url": "bitbucket-repo-url" + } + ], + [ + { + "BITBUCKET_BRANCH": "master", + "BITBUCKET_BUILD_NUMBER": "bitbucket-build-num", + "BITBUCKET_CLONE_DIR": "/foo/bar", + "BITBUCKET_COMMIT": "bitbucket-commit", + "BITBUCKET_GIT_SSH_ORIGIN": "bitbucket-repo-url", + "BITBUCKET_PIPELINE_UUID": "{bitbucket-uuid}", + "BITBUCKET_REPO_FULL_NAME": "bitbucket-repo" + }, + { + "ci.job.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num", + "ci.pipeline.id": "bitbucket-uuid", + "ci.pipeline.name": "bitbucket-repo", + "ci.pipeline.number": "bitbucket-build-num", + "ci.pipeline.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num", + "ci.provider.name": "bitbucket", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "bitbucket-commit", + "git.commit_sha": "bitbucket-commit", + "git.repository_url": "bitbucket-repo-url" + } + ], + [ + { + "BITBUCKET_BRANCH": "origin/master", + "BITBUCKET_BUILD_NUMBER": "bitbucket-build-num", + "BITBUCKET_CLONE_DIR": "/foo/bar", + "BITBUCKET_COMMIT": "bitbucket-commit", + "BITBUCKET_GIT_SSH_ORIGIN": "bitbucket-repo-url", + "BITBUCKET_PIPELINE_UUID": "{bitbucket-uuid}", + "BITBUCKET_REPO_FULL_NAME": "bitbucket-repo" + }, + { + "ci.job.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num", + "ci.pipeline.id": "bitbucket-uuid", + "ci.pipeline.name": "bitbucket-repo", + "ci.pipeline.number": "bitbucket-build-num", + "ci.pipeline.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num", + "ci.provider.name": "bitbucket", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "bitbucket-commit", + "git.commit_sha": "bitbucket-commit", + "git.repository_url": "bitbucket-repo-url" + } + ], + [ + { + "BITBUCKET_BRANCH": "refs/heads/master", + "BITBUCKET_BUILD_NUMBER": "bitbucket-build-num", + "BITBUCKET_CLONE_DIR": "/foo/bar", + "BITBUCKET_COMMIT": "bitbucket-commit", + "BITBUCKET_GIT_SSH_ORIGIN": "bitbucket-repo-url", + "BITBUCKET_PIPELINE_UUID": "{bitbucket-uuid}", + "BITBUCKET_REPO_FULL_NAME": "bitbucket-repo" + }, + { + "ci.job.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num", + "ci.pipeline.id": "bitbucket-uuid", + "ci.pipeline.name": "bitbucket-repo", + "ci.pipeline.number": "bitbucket-build-num", + "ci.pipeline.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num", + "ci.provider.name": "bitbucket", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "bitbucket-commit", + "git.commit_sha": "bitbucket-commit", + "git.repository_url": "bitbucket-repo-url" + } + ], + [ + { + "BITBUCKET_BRANCH": "refs/heads/feature/one", + "BITBUCKET_BUILD_NUMBER": "bitbucket-build-num", + "BITBUCKET_CLONE_DIR": "/foo/bar", + "BITBUCKET_COMMIT": "bitbucket-commit", + "BITBUCKET_GIT_SSH_ORIGIN": "bitbucket-repo-url", + "BITBUCKET_PIPELINE_UUID": "{bitbucket-uuid}", + "BITBUCKET_REPO_FULL_NAME": "bitbucket-repo" + }, + { + "ci.job.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num", + "ci.pipeline.id": "bitbucket-uuid", + "ci.pipeline.name": "bitbucket-repo", + "ci.pipeline.number": "bitbucket-build-num", + "ci.pipeline.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num", + "ci.provider.name": "bitbucket", + "ci.workspace_path": "/foo/bar", + "git.branch": "feature/one", + "git.commit.sha": "bitbucket-commit", + "git.commit_sha": "bitbucket-commit", + "git.repository_url": "bitbucket-repo-url" + } + ], + [ + { + "BITBUCKET_BRANCH": "origin/master", + "BITBUCKET_BUILD_NUMBER": "bitbucket-build-num", + "BITBUCKET_CLONE_DIR": "/foo/bar", + "BITBUCKET_COMMIT": "bitbucket-commit", + "BITBUCKET_GIT_SSH_ORIGIN": "bitbucket-repo-url", + "BITBUCKET_PIPELINE_UUID": "{bitbucket-uuid}", + "BITBUCKET_REPO_FULL_NAME": "bitbucket-repo" + }, + { + "ci.job.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num", + "ci.pipeline.id": "bitbucket-uuid", + "ci.pipeline.name": "bitbucket-repo", + "ci.pipeline.number": "bitbucket-build-num", + "ci.pipeline.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num", + "ci.provider.name": "bitbucket", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "bitbucket-commit", + "git.commit_sha": "bitbucket-commit", + "git.repository_url": "bitbucket-repo-url" + } + ], + [ + { + "BITBUCKET_BRANCH": "refs/heads/master", + "BITBUCKET_BUILD_NUMBER": "bitbucket-build-num", + "BITBUCKET_CLONE_DIR": "/foo/bar", + "BITBUCKET_COMMIT": "bitbucket-commit", + "BITBUCKET_GIT_SSH_ORIGIN": "bitbucket-repo-url", + "BITBUCKET_PIPELINE_UUID": "{bitbucket-uuid}", + "BITBUCKET_REPO_FULL_NAME": "bitbucket-repo" + }, + { + "ci.job.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num", + "ci.pipeline.id": "bitbucket-uuid", + "ci.pipeline.name": "bitbucket-repo", + "ci.pipeline.number": "bitbucket-build-num", + "ci.pipeline.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num", + "ci.provider.name": "bitbucket", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "bitbucket-commit", + "git.commit_sha": "bitbucket-commit", + "git.repository_url": "bitbucket-repo-url" + } + ], + [ + { + "BITBUCKET_BRANCH": "origin/master", + "BITBUCKET_BUILD_NUMBER": "bitbucket-build-num", + "BITBUCKET_CLONE_DIR": "/foo/bar", + "BITBUCKET_COMMIT": "bitbucket-commit", + "BITBUCKET_GIT_SSH_ORIGIN": "bitbucket-repo-url", + "BITBUCKET_PIPELINE_UUID": "{bitbucket-uuid}", + "BITBUCKET_REPO_FULL_NAME": "bitbucket-repo", + "BITBUCKET_TAG": "origin/tags/0.1.0" + }, + { + "ci.job.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num", + "ci.pipeline.id": "bitbucket-uuid", + "ci.pipeline.name": "bitbucket-repo", + "ci.pipeline.number": "bitbucket-build-num", + "ci.pipeline.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num", + "ci.provider.name": "bitbucket", + "ci.workspace_path": "/foo/bar", + "git.commit.sha": "bitbucket-commit", + "git.commit_sha": "bitbucket-commit", + "git.repository_url": "bitbucket-repo-url", + "git.tag": "0.1.0" + } + ], + [ + { + "BITBUCKET_BRANCH": "refs/heads/master", + "BITBUCKET_BUILD_NUMBER": "bitbucket-build-num", + "BITBUCKET_CLONE_DIR": "/foo/bar", + "BITBUCKET_COMMIT": "bitbucket-commit", + "BITBUCKET_GIT_SSH_ORIGIN": "bitbucket-repo-url", + "BITBUCKET_PIPELINE_UUID": "{bitbucket-uuid}", + "BITBUCKET_REPO_FULL_NAME": "bitbucket-repo", + "BITBUCKET_TAG": "refs/heads/tags/0.1.0" + }, + { + "ci.job.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num", + "ci.pipeline.id": "bitbucket-uuid", + "ci.pipeline.name": "bitbucket-repo", + "ci.pipeline.number": "bitbucket-build-num", + "ci.pipeline.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num", + "ci.provider.name": "bitbucket", + "ci.workspace_path": "/foo/bar", + "git.commit.sha": "bitbucket-commit", + "git.commit_sha": "bitbucket-commit", + "git.repository_url": "bitbucket-repo-url", + "git.tag": "0.1.0" + } + ] +] diff --git a/tests/tracer/test_ext.py b/tests/tracer/test_ext.py index 2064d5bac43..9bff6834a28 100644 --- a/tests/tracer/test_ext.py +++ b/tests/tracer/test_ext.py @@ -27,7 +27,7 @@ def _updateenv(monkeypatch, env): monkeypatch.setenv(k, v) -@pytest.mark.parametrize("name,environment,tags", _ci_fixtures("appveyor", "azurepipelines")) +@pytest.mark.parametrize("name,environment,tags", _ci_fixtures("appveyor", "azurepipelines", "bitbucket")) def test_ci_providers(monkeypatch, name, environment, tags): _updateenv(monkeypatch, environment) assert tags == ci.tags(), (name, environment) From 0ec6bfdbfbc58aeeee3a3df4c3b7a8906e988f41 Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Wed, 28 Oct 2020 13:08:36 +0100 Subject: [PATCH 26/34] travis --- ddtrace/ext/ci.py | 28 +- docs/spelling_wordlist.txt | 1 + tests/tracer/fixtures/ci/travis.json | 482 +++++++++++++++++++++++++++ tests/tracer/test_ext.py | 6 +- 4 files changed, 501 insertions(+), 16 deletions(-) create mode 100644 tests/tracer/fixtures/ci/travis.json diff --git a/ddtrace/ext/ci.py b/ddtrace/ext/ci.py index ddf3fa356d9..75978285904 100644 --- a/ddtrace/ext/ci.py +++ b/ddtrace/ext/ci.py @@ -180,24 +180,22 @@ def extract_gitlab(env): def extract_jenkins(env): return { - PROVIDER_NAME: "jenkins", - git.REPOSITORY_URL: env.get("GIT_URL"), + git.BRANCH: env.get("GIT_BRANCH"), git.COMMIT_SHA: env.get("GIT_COMMIT"), - WORKSPACE_PATH: env.get("WORKSPACE"), + git.REPOSITORY_URL: env.get("GIT_URL"), + JOB_URL: env.get("JOB_URL"), PIPELINE_ID: env.get("BUILD_ID"), PIPELINE_NUMBER: env.get("BUILD_NUMBER"), PIPELINE_URL: env.get("BUILD_URL"), - JOB_URL: env.get("JOB_URL"), - git.BRANCH: env.get("GIT_BRANCH"), + PROVIDER_NAME: "jenkins", + WORKSPACE_PATH: env.get("WORKSPACE"), } def extract_teamcity(env): return { - PROVIDER_NAME: "teamcity", - git.REPOSITORY_URL: env.get("BUILD_VCS_URL"), git.COMMIT_SHA: env.get("BUILD_VCS_NUMBER"), - WORKSPACE_PATH: env.get("BUILD_CHECKOUTDIR"), + git.REPOSITORY_URL: env.get("BUILD_VCS_URL"), PIPELINE_ID: env.get("BUILD_ID"), PIPELINE_NUMBER: env.get("BUILD_NUMBER"), PIPELINE_URL: ( @@ -205,20 +203,24 @@ def extract_teamcity(env): if env.get("SERVER_URL") and env.get("BUILD_ID") else None ), + PROVIDER_NAME: "teamcity", + WORKSPACE_PATH: env.get("BUILD_CHECKOUTDIR"), } def extract_travis(env): return { - PROVIDER_NAME: "travis", - git.REPOSITORY_URL: env.get("TRAVIS_REPO_SLUG"), + git.BRANCH: env.get("TRAVIS_PULL_REQUEST_BRANCH") or env.get("TRAVIS_BRANCH"), git.COMMIT_SHA: env.get("TRAVIS_COMMIT"), - WORKSPACE_PATH: env.get("TRAVIS_BUILD_DIR"), + git.REPOSITORY_URL: "https://github.com/{0}.git".format(env.get("TRAVIS_REPO_SLUG")), + git.TAG: env.get("TRAVIS_TAG"), + JOB_URL: env.get("TRAVIS_JOB_WEB_URL"), PIPELINE_ID: env.get("TRAVIS_BUILD_ID"), + PIPELINE_NAME: env.get("TRAVIS_REPO_SLUG"), PIPELINE_NUMBER: env.get("TRAVIS_BUILD_NUMBER"), PIPELINE_URL: env.get("TRAVIS_BUILD_WEB_URL"), - JOB_URL: env.get("TRAVIS_JOB_WEB_URL"), - git.BRANCH: env.get("TRAVIS_PULL_REQUEST_BRANCH") or env.get("TRAVIS_BRANCH"), + PROVIDER_NAME: "travisci", + WORKSPACE_PATH: env.get("TRAVIS_BUILD_DIR"), } diff --git a/docs/spelling_wordlist.txt b/docs/spelling_wordlist.txt index e09fea45b5c..83bfefbf204 100644 --- a/docs/spelling_wordlist.txt +++ b/docs/spelling_wordlist.txt @@ -71,6 +71,7 @@ pymongo pymysql pynamodb pyodbc +pytest quickstart redis rediscluster diff --git a/tests/tracer/fixtures/ci/travis.json b/tests/tracer/fixtures/ci/travis.json new file mode 100644 index 00000000000..46a421e05e5 --- /dev/null +++ b/tests/tracer/fixtures/ci/travis.json @@ -0,0 +1,482 @@ +[ + [ + { + "TRAVIS": "travisCI", + "TRAVIS_BRANCH": "origin/tags/0.1.0", + "TRAVIS_BUILD_DIR": "/foo/bar", + "TRAVIS_BUILD_ID": "travis-pipeline-id", + "TRAVIS_BUILD_NUMBER": "travis-pipeline-number", + "TRAVIS_BUILD_WEB_URL": "travis-pipeline-url", + "TRAVIS_COMMIT": "travis-git-commit", + "TRAVIS_JOB_WEB_URL": "travis-job-url", + "TRAVIS_REPO_SLUG": "user/repo", + "TRAVIS_TAG": "origin/tags/0.1.0" + }, + { + "ci.job.url": "travis-job-url", + "ci.pipeline.id": "travis-pipeline-id", + "ci.pipeline.name": "user/repo", + "ci.pipeline.number": "travis-pipeline-number", + "ci.pipeline.url": "travis-pipeline-url", + "ci.provider.name": "travisci", + "ci.workspace_path": "/foo/bar", + "git.commit.sha": "travis-git-commit", + "git.commit_sha": "travis-git-commit", + "git.repository_url": "https://github.com/user/repo.git", + "git.tag": "0.1.0" + } + ], + [ + { + "TRAVIS": "travisCI", + "TRAVIS_BRANCH": "refs/heads/tags/0.1.0", + "TRAVIS_BUILD_DIR": "/foo/bar", + "TRAVIS_BUILD_ID": "travis-pipeline-id", + "TRAVIS_BUILD_NUMBER": "travis-pipeline-number", + "TRAVIS_BUILD_WEB_URL": "travis-pipeline-url", + "TRAVIS_COMMIT": "travis-git-commit", + "TRAVIS_JOB_WEB_URL": "travis-job-url", + "TRAVIS_REPO_SLUG": "user/repo", + "TRAVIS_TAG": "refs/heads/tags/0.1.0" + }, + { + "ci.job.url": "travis-job-url", + "ci.pipeline.id": "travis-pipeline-id", + "ci.pipeline.name": "user/repo", + "ci.pipeline.number": "travis-pipeline-number", + "ci.pipeline.url": "travis-pipeline-url", + "ci.provider.name": "travisci", + "ci.workspace_path": "/foo/bar", + "git.commit.sha": "travis-git-commit", + "git.commit_sha": "travis-git-commit", + "git.repository_url": "https://github.com/user/repo.git", + "git.tag": "0.1.0" + } + ], + [ + { + "TRAVIS": "travisCI", + "TRAVIS_BRANCH": "origin/master", + "TRAVIS_BUILD_ID": "travis-pipeline-id", + "TRAVIS_BUILD_NUMBER": "travis-pipeline-number", + "TRAVIS_BUILD_WEB_URL": "travis-pipeline-url", + "TRAVIS_COMMIT": "travis-git-commit", + "TRAVIS_JOB_WEB_URL": "travis-job-url", + "TRAVIS_REPO_SLUG": "user/repo" + }, + { + "ci.job.url": "travis-job-url", + "ci.pipeline.id": "travis-pipeline-id", + "ci.pipeline.name": "user/repo", + "ci.pipeline.number": "travis-pipeline-number", + "ci.pipeline.url": "travis-pipeline-url", + "ci.provider.name": "travisci", + "git.branch": "master", + "git.commit.sha": "travis-git-commit", + "git.commit_sha": "travis-git-commit", + "git.repository_url": "https://github.com/user/repo.git" + } + ], + [ + { + "TRAVIS": "travisCI", + "TRAVIS_BRANCH": "origin/master", + "TRAVIS_BUILD_DIR": "", + "TRAVIS_BUILD_ID": "travis-pipeline-id", + "TRAVIS_BUILD_NUMBER": "travis-pipeline-number", + "TRAVIS_BUILD_WEB_URL": "travis-pipeline-url", + "TRAVIS_COMMIT": "travis-git-commit", + "TRAVIS_JOB_WEB_URL": "travis-job-url", + "TRAVIS_REPO_SLUG": "user/repo" + }, + { + "ci.job.url": "travis-job-url", + "ci.pipeline.id": "travis-pipeline-id", + "ci.pipeline.name": "user/repo", + "ci.pipeline.number": "travis-pipeline-number", + "ci.pipeline.url": "travis-pipeline-url", + "ci.provider.name": "travisci", + "ci.workspace_path": "", + "git.branch": "master", + "git.commit.sha": "travis-git-commit", + "git.commit_sha": "travis-git-commit", + "git.repository_url": "https://github.com/user/repo.git" + } + ], + [ + { + "TRAVIS": "travisCI", + "TRAVIS_BRANCH": "origin/master", + "TRAVIS_BUILD_DIR": "foo/bar", + "TRAVIS_BUILD_ID": "travis-pipeline-id", + "TRAVIS_BUILD_NUMBER": "travis-pipeline-number", + "TRAVIS_BUILD_WEB_URL": "travis-pipeline-url", + "TRAVIS_COMMIT": "travis-git-commit", + "TRAVIS_JOB_WEB_URL": "travis-job-url", + "TRAVIS_PULL_REQUEST_BRANCH": "", + "TRAVIS_REPO_SLUG": "user/repo" + }, + { + "ci.job.url": "travis-job-url", + "ci.pipeline.id": "travis-pipeline-id", + "ci.pipeline.name": "user/repo", + "ci.pipeline.number": "travis-pipeline-number", + "ci.pipeline.url": "travis-pipeline-url", + "ci.provider.name": "travisci", + "ci.workspace_path": "foo/bar", + "git.branch": "master", + "git.commit.sha": "travis-git-commit", + "git.commit_sha": "travis-git-commit", + "git.repository_url": "https://github.com/user/repo.git" + } + ], + [ + { + "TRAVIS": "travisCI", + "TRAVIS_BRANCH": "origin/master", + "TRAVIS_BUILD_DIR": "foo/bar", + "TRAVIS_BUILD_ID": "travis-pipeline-id", + "TRAVIS_BUILD_NUMBER": "travis-pipeline-number", + "TRAVIS_BUILD_WEB_URL": "travis-pipeline-url", + "TRAVIS_COMMIT": "travis-git-commit", + "TRAVIS_JOB_WEB_URL": "travis-job-url", + "TRAVIS_REPO_SLUG": "user/repo" + }, + { + "ci.job.url": "travis-job-url", + "ci.pipeline.id": "travis-pipeline-id", + "ci.pipeline.name": "user/repo", + "ci.pipeline.number": "travis-pipeline-number", + "ci.pipeline.url": "travis-pipeline-url", + "ci.provider.name": "travisci", + "ci.workspace_path": "foo/bar", + "git.branch": "master", + "git.commit.sha": "travis-git-commit", + "git.commit_sha": "travis-git-commit", + "git.repository_url": "https://github.com/user/repo.git" + } + ], + [ + { + "TRAVIS": "travisCI", + "TRAVIS_BRANCH": "origin/master", + "TRAVIS_BUILD_DIR": "foo/bar", + "TRAVIS_BUILD_ID": "travis-pipeline-id", + "TRAVIS_BUILD_NUMBER": "travis-pipeline-number", + "TRAVIS_BUILD_WEB_URL": "travis-pipeline-url", + "TRAVIS_COMMIT": "travis-git-commit", + "TRAVIS_JOB_WEB_URL": "travis-job-url", + "TRAVIS_PULL_REQUEST_SLUG": "", + "TRAVIS_REPO_SLUG": "user/repo" + }, + { + "ci.job.url": "travis-job-url", + "ci.pipeline.id": "travis-pipeline-id", + "ci.pipeline.name": "user/repo", + "ci.pipeline.number": "travis-pipeline-number", + "ci.pipeline.url": "travis-pipeline-url", + "ci.provider.name": "travisci", + "ci.workspace_path": "foo/bar", + "git.branch": "master", + "git.commit.sha": "travis-git-commit", + "git.commit_sha": "travis-git-commit", + "git.repository_url": "https://github.com/user/repo.git" + } + ], + [ + { + "TRAVIS": "travisCI", + "TRAVIS_BRANCH": "origin/master", + "TRAVIS_BUILD_DIR": "/foo/bar~", + "TRAVIS_BUILD_ID": "travis-pipeline-id", + "TRAVIS_BUILD_NUMBER": "travis-pipeline-number", + "TRAVIS_BUILD_WEB_URL": "travis-pipeline-url", + "TRAVIS_COMMIT": "travis-git-commit", + "TRAVIS_JOB_WEB_URL": "travis-job-url", + "TRAVIS_REPO_SLUG": "user/repo" + }, + { + "ci.job.url": "travis-job-url", + "ci.pipeline.id": "travis-pipeline-id", + "ci.pipeline.name": "user/repo", + "ci.pipeline.number": "travis-pipeline-number", + "ci.pipeline.url": "travis-pipeline-url", + "ci.provider.name": "travisci", + "ci.workspace_path": "/foo/bar~", + "git.branch": "master", + "git.commit.sha": "travis-git-commit", + "git.commit_sha": "travis-git-commit", + "git.repository_url": "https://github.com/user/repo.git" + } + ], + [ + { + "TRAVIS": "travisCI", + "TRAVIS_BRANCH": "origin/master", + "TRAVIS_BUILD_DIR": "/foo/~/bar", + "TRAVIS_BUILD_ID": "travis-pipeline-id", + "TRAVIS_BUILD_NUMBER": "travis-pipeline-number", + "TRAVIS_BUILD_WEB_URL": "travis-pipeline-url", + "TRAVIS_COMMIT": "travis-git-commit", + "TRAVIS_JOB_WEB_URL": "travis-job-url", + "TRAVIS_REPO_SLUG": "user/repo" + }, + { + "ci.job.url": "travis-job-url", + "ci.pipeline.id": "travis-pipeline-id", + "ci.pipeline.name": "user/repo", + "ci.pipeline.number": "travis-pipeline-number", + "ci.pipeline.url": "travis-pipeline-url", + "ci.provider.name": "travisci", + "ci.workspace_path": "/foo/~/bar", + "git.branch": "master", + "git.commit.sha": "travis-git-commit", + "git.commit_sha": "travis-git-commit", + "git.repository_url": "https://github.com/user/repo.git" + } + ], + [ + { + "HOME": "/not-my-home", + "TRAVIS": "travisCI", + "TRAVIS_BRANCH": "origin/master", + "TRAVIS_BUILD_DIR": "~/foo/bar", + "TRAVIS_BUILD_ID": "travis-pipeline-id", + "TRAVIS_BUILD_NUMBER": "travis-pipeline-number", + "TRAVIS_BUILD_WEB_URL": "travis-pipeline-url", + "TRAVIS_COMMIT": "travis-git-commit", + "TRAVIS_JOB_WEB_URL": "travis-job-url", + "TRAVIS_REPO_SLUG": "user/repo", + "USERPROFILE": "/not-my-home" + }, + { + "ci.job.url": "travis-job-url", + "ci.pipeline.id": "travis-pipeline-id", + "ci.pipeline.name": "user/repo", + "ci.pipeline.number": "travis-pipeline-number", + "ci.pipeline.url": "travis-pipeline-url", + "ci.provider.name": "travisci", + "ci.workspace_path": "/not-my-home/foo/bar", + "git.branch": "master", + "git.commit.sha": "travis-git-commit", + "git.commit_sha": "travis-git-commit", + "git.repository_url": "https://github.com/user/repo.git" + } + ], + [ + { + "TRAVIS": "travisCI", + "TRAVIS_BRANCH": "origin/master", + "TRAVIS_BUILD_DIR": "~foo/bar", + "TRAVIS_BUILD_ID": "travis-pipeline-id", + "TRAVIS_BUILD_NUMBER": "travis-pipeline-number", + "TRAVIS_BUILD_WEB_URL": "travis-pipeline-url", + "TRAVIS_COMMIT": "travis-git-commit", + "TRAVIS_JOB_WEB_URL": "travis-job-url", + "TRAVIS_REPO_SLUG": "user/repo" + }, + { + "ci.job.url": "travis-job-url", + "ci.pipeline.id": "travis-pipeline-id", + "ci.pipeline.name": "user/repo", + "ci.pipeline.number": "travis-pipeline-number", + "ci.pipeline.url": "travis-pipeline-url", + "ci.provider.name": "travisci", + "ci.workspace_path": "~foo/bar", + "git.branch": "master", + "git.commit.sha": "travis-git-commit", + "git.commit_sha": "travis-git-commit", + "git.repository_url": "https://github.com/user/repo.git" + } + ], + [ + { + "HOME": "/not-my-home", + "TRAVIS": "travisCI", + "TRAVIS_BRANCH": "origin/master", + "TRAVIS_BUILD_DIR": "~", + "TRAVIS_BUILD_ID": "travis-pipeline-id", + "TRAVIS_BUILD_NUMBER": "travis-pipeline-number", + "TRAVIS_BUILD_WEB_URL": "travis-pipeline-url", + "TRAVIS_COMMIT": "travis-git-commit", + "TRAVIS_JOB_WEB_URL": "travis-job-url", + "TRAVIS_REPO_SLUG": "user/repo", + "USERPROFILE": "/not-my-home" + }, + { + "ci.job.url": "travis-job-url", + "ci.pipeline.id": "travis-pipeline-id", + "ci.pipeline.name": "user/repo", + "ci.pipeline.number": "travis-pipeline-number", + "ci.pipeline.url": "travis-pipeline-url", + "ci.provider.name": "travisci", + "ci.workspace_path": "/not-my-home", + "git.branch": "master", + "git.commit.sha": "travis-git-commit", + "git.commit_sha": "travis-git-commit", + "git.repository_url": "https://github.com/user/repo.git" + } + ], + [ + { + "TRAVIS": "travisCI", + "TRAVIS_BRANCH": "origin/master", + "TRAVIS_BUILD_DIR": "/foo/bar", + "TRAVIS_BUILD_ID": "travis-pipeline-id", + "TRAVIS_BUILD_NUMBER": "travis-pipeline-number", + "TRAVIS_BUILD_WEB_URL": "travis-pipeline-url", + "TRAVIS_COMMIT": "travis-git-commit", + "TRAVIS_JOB_WEB_URL": "travis-job-url", + "TRAVIS_REPO_SLUG": "user/repo" + }, + { + "ci.job.url": "travis-job-url", + "ci.pipeline.id": "travis-pipeline-id", + "ci.pipeline.name": "user/repo", + "ci.pipeline.number": "travis-pipeline-number", + "ci.pipeline.url": "travis-pipeline-url", + "ci.provider.name": "travisci", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "travis-git-commit", + "git.commit_sha": "travis-git-commit", + "git.repository_url": "https://github.com/user/repo.git" + } + ], + [ + { + "TRAVIS": "travisCI", + "TRAVIS_BRANCH": "refs/heads/master", + "TRAVIS_BUILD_DIR": "/foo/bar", + "TRAVIS_BUILD_ID": "travis-pipeline-id", + "TRAVIS_BUILD_NUMBER": "travis-pipeline-number", + "TRAVIS_BUILD_WEB_URL": "travis-pipeline-url", + "TRAVIS_COMMIT": "travis-git-commit", + "TRAVIS_JOB_WEB_URL": "travis-job-url", + "TRAVIS_REPO_SLUG": "user/repo" + }, + { + "ci.job.url": "travis-job-url", + "ci.pipeline.id": "travis-pipeline-id", + "ci.pipeline.name": "user/repo", + "ci.pipeline.number": "travis-pipeline-number", + "ci.pipeline.url": "travis-pipeline-url", + "ci.provider.name": "travisci", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "travis-git-commit", + "git.commit_sha": "travis-git-commit", + "git.repository_url": "https://github.com/user/repo.git" + } + ], + [ + { + "TRAVIS": "travisCI", + "TRAVIS_BRANCH": "refs/heads/feature/one", + "TRAVIS_BUILD_DIR": "/foo/bar", + "TRAVIS_BUILD_ID": "travis-pipeline-id", + "TRAVIS_BUILD_NUMBER": "travis-pipeline-number", + "TRAVIS_BUILD_WEB_URL": "travis-pipeline-url", + "TRAVIS_COMMIT": "travis-git-commit", + "TRAVIS_JOB_WEB_URL": "travis-job-url", + "TRAVIS_REPO_SLUG": "user/repo" + }, + { + "ci.job.url": "travis-job-url", + "ci.pipeline.id": "travis-pipeline-id", + "ci.pipeline.name": "user/repo", + "ci.pipeline.number": "travis-pipeline-number", + "ci.pipeline.url": "travis-pipeline-url", + "ci.provider.name": "travisci", + "ci.workspace_path": "/foo/bar", + "git.branch": "feature/one", + "git.commit.sha": "travis-git-commit", + "git.commit_sha": "travis-git-commit", + "git.repository_url": "https://github.com/user/repo.git" + } + ], + [ + { + "TRAVIS": "travisCI", + "TRAVIS_BRANCH": "origin/other", + "TRAVIS_BUILD_DIR": "/foo/bar", + "TRAVIS_BUILD_ID": "travis-pipeline-id", + "TRAVIS_BUILD_NUMBER": "travis-pipeline-number", + "TRAVIS_BUILD_WEB_URL": "travis-pipeline-url", + "TRAVIS_COMMIT": "travis-git-commit", + "TRAVIS_JOB_WEB_URL": "travis-job-url", + "TRAVIS_PULL_REQUEST_BRANCH": "origin/master", + "TRAVIS_PULL_REQUEST_SLUG": "user/repo", + "TRAVIS_REPO_SLUG": "user/repo" + }, + { + "ci.job.url": "travis-job-url", + "ci.pipeline.id": "travis-pipeline-id", + "ci.pipeline.name": "user/repo", + "ci.pipeline.number": "travis-pipeline-number", + "ci.pipeline.url": "travis-pipeline-url", + "ci.provider.name": "travisci", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "travis-git-commit", + "git.commit_sha": "travis-git-commit", + "git.repository_url": "https://github.com/user/repo.git" + } + ], + [ + { + "TRAVIS": "travisCI", + "TRAVIS_BRANCH": "origin/other", + "TRAVIS_BUILD_DIR": "/foo/bar", + "TRAVIS_BUILD_ID": "travis-pipeline-id", + "TRAVIS_BUILD_NUMBER": "travis-pipeline-number", + "TRAVIS_BUILD_WEB_URL": "travis-pipeline-url", + "TRAVIS_COMMIT": "travis-git-commit", + "TRAVIS_JOB_WEB_URL": "travis-job-url", + "TRAVIS_PULL_REQUEST_BRANCH": "refs/heads/master", + "TRAVIS_PULL_REQUEST_SLUG": "user/repo", + "TRAVIS_REPO_SLUG": "user/repo" + }, + { + "ci.job.url": "travis-job-url", + "ci.pipeline.id": "travis-pipeline-id", + "ci.pipeline.name": "user/repo", + "ci.pipeline.number": "travis-pipeline-number", + "ci.pipeline.url": "travis-pipeline-url", + "ci.provider.name": "travisci", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "travis-git-commit", + "git.commit_sha": "travis-git-commit", + "git.repository_url": "https://github.com/user/repo.git" + } + ], + [ + { + "TRAVIS": "travisCI", + "TRAVIS_BRANCH": "origin/other", + "TRAVIS_BUILD_DIR": "/foo/bar", + "TRAVIS_BUILD_ID": "travis-pipeline-id", + "TRAVIS_BUILD_NUMBER": "travis-pipeline-number", + "TRAVIS_BUILD_WEB_URL": "travis-pipeline-url", + "TRAVIS_COMMIT": "travis-git-commit", + "TRAVIS_JOB_WEB_URL": "travis-job-url", + "TRAVIS_PULL_REQUEST_BRANCH": "refs/heads/feature/one", + "TRAVIS_PULL_REQUEST_SLUG": "user/repo", + "TRAVIS_REPO_SLUG": "user/repo" + }, + { + "ci.job.url": "travis-job-url", + "ci.pipeline.id": "travis-pipeline-id", + "ci.pipeline.name": "user/repo", + "ci.pipeline.number": "travis-pipeline-number", + "ci.pipeline.url": "travis-pipeline-url", + "ci.provider.name": "travisci", + "ci.workspace_path": "/foo/bar", + "git.branch": "feature/one", + "git.commit.sha": "travis-git-commit", + "git.commit_sha": "travis-git-commit", + "git.repository_url": "https://github.com/user/repo.git" + } + ] +] diff --git a/tests/tracer/test_ext.py b/tests/tracer/test_ext.py index 9bff6834a28..164407e4c95 100644 --- a/tests/tracer/test_ext.py +++ b/tests/tracer/test_ext.py @@ -15,9 +15,9 @@ def test_flatten_dict(): def _ci_fixtures(*names): - basepath = os.path.join(os.path.dirname(__file__), 'fixtures', 'ci') + basepath = os.path.join(os.path.dirname(__file__), "fixtures", "ci") for name in names: - with open(os.path.join(basepath, name + '.json')) as fp: + with open(os.path.join(basepath, name + ".json")) as fp: for item in json.load(fp): yield name, item[0], item[1] @@ -27,7 +27,7 @@ def _updateenv(monkeypatch, env): monkeypatch.setenv(k, v) -@pytest.mark.parametrize("name,environment,tags", _ci_fixtures("appveyor", "azurepipelines", "bitbucket")) +@pytest.mark.parametrize("name,environment,tags", _ci_fixtures("appveyor", "azurepipelines", "bitbucket", "travis")) def test_ci_providers(monkeypatch, name, environment, tags): _updateenv(monkeypatch, environment) assert tags == ci.tags(), (name, environment) From bf86ce1c23a7453a9ac5e056bbc363cd2e886140 Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Mon, 2 Nov 2020 12:01:14 +0100 Subject: [PATCH 27/34] test all ci providers --- ddtrace/ext/ci.py | 134 +++-- tests/tracer/fixtures/ci/appveyor.json | 1 - tests/tracer/fixtures/ci/azurepipelines.json | 3 - tests/tracer/fixtures/ci/build_kite.json | 467 +++++++++++++++ tests/tracer/fixtures/ci/circle_ci.json | 548 +++++++++++++++++ tests/tracer/fixtures/ci/github_actions.json | 411 +++++++++++++ tests/tracer/fixtures/ci/gitlab.json | 567 ++++++++++++++++++ tests/tracer/fixtures/ci/jenkins.json | 594 +++++++++++++++++++ tests/tracer/fixtures/ci/travis.json | 4 - tests/tracer/test_ext.py | 15 +- 10 files changed, 2682 insertions(+), 62 deletions(-) create mode 100644 tests/tracer/fixtures/ci/build_kite.json create mode 100644 tests/tracer/fixtures/ci/circle_ci.json create mode 100644 tests/tracer/fixtures/ci/github_actions.json create mode 100644 tests/tracer/fixtures/ci/gitlab.json create mode 100644 tests/tracer/fixtures/ci/jenkins.json diff --git a/ddtrace/ext/ci.py b/ddtrace/ext/ci.py index 75978285904..b4679ba3c9f 100644 --- a/ddtrace/ext/ci.py +++ b/ddtrace/ext/ci.py @@ -27,40 +27,47 @@ # Workspace Path WORKSPACE_PATH = "ci.workspace_path" +_RE_REFS = re.compile(r"^refs/(heads/)?") +_RE_ORIGIN = re.compile(r"^origin/") _RE_TAGS = re.compile(r"^tags/") -_RE_BRANCH_PREFIX = re.compile(r"^(refs/(heads/)|origin/)?") +_RE_URL = re.compile(r"(https?://)[^/]*@") + + +def _normalize_ref(name): + return _RE_TAGS.sub("", _RE_ORIGIN.sub("", _RE_REFS.sub("", name))) if name is not None else None + + +def _filter_sensitive_info(url): + return _RE_URL.sub("\\1", url) if url is not None else None def tags(env=None): env = os.environ if env is None else env + tags = {} for key, extract in PROVIDERS: if key in env: tags = extract(env) + break - # Post process special cases - tag = tags.get(git.TAG) - if tag: - tags[git.TAG] = _RE_TAGS.sub("", _RE_BRANCH_PREFIX.sub("", tag)) - if git.BRANCH in tags: - del tags[git.BRANCH] - - branch = tags.get(git.BRANCH) - if branch: - tags[git.BRANCH] = _RE_TAGS.sub("", _RE_BRANCH_PREFIX.sub("", branch)) - - # Add deprecated fields - tags[git.DEPRECATED_COMMIT_SHA] = tags.get(git.COMMIT_SHA) + tags[git.TAG] = _normalize_ref(tags.get(git.TAG)) + if tags.get(git.TAG) and git.BRANCH in tags: + del tags[git.BRANCH] + tags[git.BRANCH] = _normalize_ref(tags.get(git.BRANCH)) + tags[git.DEPRECATED_COMMIT_SHA] = tags.get(git.COMMIT_SHA) + tags[git.REPOSITORY_URL] = _filter_sensitive_info(tags.get(git.REPOSITORY_URL)) - # Expand ~ - workspace_path = tags.get(WORKSPACE_PATH) - if workspace_path: - tags[WORKSPACE_PATH] = os.path.expanduser(workspace_path) + # Expand ~ + workspace_path = tags.get(WORKSPACE_PATH) + if workspace_path: + tags[WORKSPACE_PATH] = os.path.expanduser(workspace_path) - return {k: v for k, v in tags.items() if v is not None} - return {} + return {k: v for k, v in tags.items() if v is not None} def extract_appveyor(env): + url = "https://ci.appveyor.com/project/{0}/builds/{1}".format( + env.get("APPVEYOR_REPO_NAME"), env.get("APPVEYOR_BUILD_ID") + ) return { PROVIDER_NAME: "appveyor", git.REPOSITORY_URL: "https://github.com/{0}.git".format(env.get("APPVEYOR_REPO_NAME")), @@ -69,12 +76,8 @@ def extract_appveyor(env): PIPELINE_ID: env.get("APPVEYOR_BUILD_ID"), PIPELINE_NAME: env.get("APPVEYOR_REPO_NAME"), PIPELINE_NUMBER: env.get("APPVEYOR_BUILD_NUMBER"), - PIPELINE_URL: "https://ci.appveyor.com/project/{0}/builds/{1}".format( - env.get("APPVEYOR_REPO_NAME"), env.get("APPVEYOR_BUILD_ID") - ), - JOB_URL: "https://ci.appveyor.com/project/{0}/builds/{1}".format( - env.get("APPVEYOR_REPO_NAME"), env.get("APPVEYOR_BUILD_ID") - ), + PIPELINE_URL: url, + JOB_URL: url, git.BRANCH: env.get("APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH") or env.get("APPVEYOR_REPO_BRANCH"), git.TAG: env.get("APPVEYOR_REPO_TAG_NAME"), } @@ -128,63 +131,100 @@ def extract_bitbucket(env): def extract_buildkite(env): return { - PROVIDER_NAME: "buildkite", - git.REPOSITORY_URL: env.get("BUILDKITE_REPO"), + git.BRANCH: env.get("BUILDKITE_BRANCH"), git.COMMIT_SHA: env.get("BUILDKITE_COMMIT"), - WORKSPACE_PATH: env.get("BUILDKITE_BUILD_CHECKOUT_PATH"), + git.REPOSITORY_URL: env.get("BUILDKITE_REPO"), + git.TAG: env.get("BUILDKITE_TAG"), PIPELINE_ID: env.get("BUILDKITE_BUILD_ID"), + PIPELINE_NAME: env.get("BUILDKITE_PIPELINE_SLUG"), PIPELINE_NUMBER: env.get("BUILDKITE_BUILD_NUMBER"), PIPELINE_URL: env.get("BUILDKITE_BUILD_URL"), - git.BRANCH: env.get("BUILDKITE_BRANCH"), + JOB_URL: "{0}#{1}".format(env.get("BUILDKITE_BUILD_URL"), env.get("BUILDKITE_JOB_ID")), + PROVIDER_NAME: "buildkite", + WORKSPACE_PATH: env.get("BUILDKITE_BUILD_CHECKOUT_PATH"), } def extract_circle_ci(env): return { - PROVIDER_NAME: "circleci", - git.REPOSITORY_URL: env.get("CIRCLE_REPOSITORY_URL"), + git.BRANCH: env.get("CIRCLE_BRANCH"), git.COMMIT_SHA: env.get("CIRCLE_SHA1"), - WORKSPACE_PATH: env.get("CIRCLE_WORKING_DIRECTORY"), + git.REPOSITORY_URL: env.get("CIRCLE_REPOSITORY_URL"), + git.TAG: env.get("CIRCLE_TAG"), + PIPELINE_ID: env.get("CIRCLE_WORKFLOW_ID"), + PIPELINE_NAME: env.get("CIRCLE_PROJECT_REPONAME"), PIPELINE_NUMBER: env.get("CIRCLE_BUILD_NUM"), PIPELINE_URL: env.get("CIRCLE_BUILD_URL"), - git.BRANCH: env.get("CIRCLE_BRANCH"), + JOB_URL: env.get("CIRCLE_BUILD_URL"), + PROVIDER_NAME: "circleci", + WORKSPACE_PATH: env.get("CIRCLE_WORKING_DIRECTORY"), } def extract_github_actions(env): + branch_or_tag = env.get("GITHUB_HEAD_REF") or env.get("GITHUB_REF") + branch = tag = None + if "tags/" in branch_or_tag: + tag = branch_or_tag + else: + branch = branch_or_tag return { - PROVIDER_NAME: "github", - git.REPOSITORY_URL: env.get("GITHUB_REPOSITORY"), + git.BRANCH: branch, git.COMMIT_SHA: env.get("GITHUB_SHA"), - WORKSPACE_PATH: env.get("GITHUB_WORKSPACE"), + git.REPOSITORY_URL: "https://github.com/{0}.git".format(env.get("GITHUB_REPOSITORY")), + git.TAG: tag, + JOB_URL: "https://github.com/{0}/commit/{1}/checks".format(env.get("GITHUB_REPOSITORY"), env.get("GITHUB_SHA")), PIPELINE_ID: env.get("GITHUB_RUN_ID"), + PIPELINE_NAME: env.get("GITHUB_WORKFLOW"), PIPELINE_NUMBER: env.get("GITHUB_RUN_NUMBER"), - PIPELINE_URL: "{0}/commit/{1}/checks".format(env.get("GITHUB_REPOSITORY"), env.get("GITHUB_SHA")), - git.BRANCH: env.get("GITHUB_REF"), + PIPELINE_URL: "https://github.com/{0}/commit/{1}/checks".format( + env.get("GITHUB_REPOSITORY"), env.get("GITHUB_SHA") + ), + PROVIDER_NAME: "github", + WORKSPACE_PATH: env.get("GITHUB_WORKSPACE"), } def extract_gitlab(env): + url = env.get("CI_PIPELINE_URL") + if url: + url = re.sub("/-/pipelines/", "/pipelines/", url) return { - PROVIDER_NAME: "gitlab", - git.REPOSITORY_URL: env.get("CI_REPOSITORY_URL"), + git.BRANCH: env.get("CI_COMMIT_BRANCH"), git.COMMIT_SHA: env.get("CI_COMMIT_SHA"), - WORKSPACE_PATH: env.get("CI_PROJECT_DIR"), + git.REPOSITORY_URL: env.get("CI_REPOSITORY_URL"), + git.TAG: env.get("CI_COMMIT_TAG"), + JOB_URL: env.get("CI_JOB_URL"), PIPELINE_ID: env.get("CI_PIPELINE_ID"), + PIPELINE_NAME: env.get("CI_PROJECT_PATH"), PIPELINE_NUMBER: env.get("CI_PIPELINE_IID"), - PIPELINE_URL: env.get("CI_PIPELINE_URL"), - JOB_URL: env.get("CI_JOB_URL"), - git.BRANCH: env.get("CI_COMMIT_BRANCH") or env.get("CI_COMMIT_REF_NAME"), + PIPELINE_URL: url, + PROVIDER_NAME: "gitlab", + WORKSPACE_PATH: env.get("CI_PROJECT_DIR"), } def extract_jenkins(env): + branch_or_tag = env.get("GIT_BRANCH") + branch = tag = None + if "tags/" in branch_or_tag: + tag = branch_or_tag + else: + branch = branch_or_tag + name = env.get("JOB_NAME") + if name and branch: + name = re.sub("/" + _normalize_ref(branch), "", name) + if name: + name = "/".join((v for v in name.split("/") if v and "=" not in v)) + return { - git.BRANCH: env.get("GIT_BRANCH"), + git.BRANCH: branch, git.COMMIT_SHA: env.get("GIT_COMMIT"), git.REPOSITORY_URL: env.get("GIT_URL"), + git.TAG: tag, JOB_URL: env.get("JOB_URL"), - PIPELINE_ID: env.get("BUILD_ID"), + PIPELINE_ID: env.get("BUILD_TAG"), + PIPELINE_NAME: name, PIPELINE_NUMBER: env.get("BUILD_NUMBER"), PIPELINE_URL: env.get("BUILD_URL"), PROVIDER_NAME: "jenkins", diff --git a/tests/tracer/fixtures/ci/appveyor.json b/tests/tracer/fixtures/ci/appveyor.json index 56e658929f0..b3f61d48797 100644 --- a/tests/tracer/fixtures/ci/appveyor.json +++ b/tests/tracer/fixtures/ci/appveyor.json @@ -30,7 +30,6 @@ "APPVEYOR_BUILD_FOLDER": "/foo/bar", "APPVEYOR_BUILD_ID": "appveyor-build-id", "APPVEYOR_BUILD_NUMBER": "appveyor-pipeline-number", - "APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH": "", "APPVEYOR_REPO_BRANCH": "master", "APPVEYOR_REPO_COMMIT": "appveyor-repo-commit", "APPVEYOR_REPO_NAME": "appveyor-repo-name", diff --git a/tests/tracer/fixtures/ci/azurepipelines.json b/tests/tracer/fixtures/ci/azurepipelines.json index fed7f6f01d0..0b512c36f14 100644 --- a/tests/tracer/fixtures/ci/azurepipelines.json +++ b/tests/tracer/fixtures/ci/azurepipelines.json @@ -36,7 +36,6 @@ "BUILD_SOURCESDIRECTORY": "/foo/bar", "BUILD_SOURCEVERSION": "commit", "SYSTEM_JOBID": "azure-pipelines-job-id", - "SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI": "", "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", "SYSTEM_TEAMPROJECT": "azure-pipelines-project", @@ -94,7 +93,6 @@ "BUILD_SOURCESDIRECTORY": "/foo/bar", "BUILD_SOURCEVERSION": "commit", "SYSTEM_JOBID": "azure-pipelines-job-id", - "SYSTEM_PULLREQUEST_SOURCEBRANCH": "", "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", "SYSTEM_TEAMPROJECT": "azure-pipelines-project", @@ -123,7 +121,6 @@ "BUILD_SOURCESDIRECTORY": "/foo/bar", "BUILD_SOURCEVERSION": "commit", "SYSTEM_JOBID": "azure-pipelines-job-id", - "SYSTEM_PULLREQUEST_SOURCECOMMITID": "", "SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id", "SYSTEM_TEAMFOUNDATIONSERVERURI": "azure-pipelines-server-uri/", "SYSTEM_TEAMPROJECT": "azure-pipelines-project", diff --git a/tests/tracer/fixtures/ci/build_kite.json b/tests/tracer/fixtures/ci/build_kite.json new file mode 100644 index 00000000000..f6f054455f8 --- /dev/null +++ b/tests/tracer/fixtures/ci/build_kite.json @@ -0,0 +1,467 @@ +[ + [ + { + "BUILDKITE": "true", + "BUILDKITE_BRANCH": "master", + "BUILDKITE_BUILD_CHECKOUT_PATH": "/foo/bar", + "BUILDKITE_BUILD_ID": "buildkite-pipeline-id", + "BUILDKITE_BUILD_NUMBER": "buildkite-pipeline-number", + "BUILDKITE_BUILD_URL": "buildkite-build-url", + "BUILDKITE_COMMIT": "buildkite-git-commit", + "BUILDKITE_JOB_ID": "buildkite-job-id", + "BUILDKITE_PIPELINE_SLUG": "buildkite-pipeline-name", + "BUILDKITE_REPO": "http://hostname.com/repo.git" + }, + { + "ci.job.url": "buildkite-build-url#buildkite-job-id", + "ci.pipeline.id": "buildkite-pipeline-id", + "ci.pipeline.name": "buildkite-pipeline-name", + "ci.pipeline.number": "buildkite-pipeline-number", + "ci.pipeline.url": "buildkite-build-url", + "ci.provider.name": "buildkite", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "buildkite-git-commit", + "git.commit_sha": "buildkite-git-commit", + "git.repository_url": "http://hostname.com/repo.git" + } + ], + [ + { + "BUILDKITE": "true", + "BUILDKITE_BRANCH": "master", + "BUILDKITE_BUILD_CHECKOUT_PATH": "foo/bar", + "BUILDKITE_BUILD_ID": "buildkite-pipeline-id", + "BUILDKITE_BUILD_NUMBER": "buildkite-pipeline-number", + "BUILDKITE_BUILD_URL": "buildkite-build-url", + "BUILDKITE_COMMIT": "buildkite-git-commit", + "BUILDKITE_JOB_ID": "buildkite-job-id", + "BUILDKITE_PIPELINE_SLUG": "buildkite-pipeline-name", + "BUILDKITE_REPO": "http://hostname.com/repo.git" + }, + { + "ci.job.url": "buildkite-build-url#buildkite-job-id", + "ci.pipeline.id": "buildkite-pipeline-id", + "ci.pipeline.name": "buildkite-pipeline-name", + "ci.pipeline.number": "buildkite-pipeline-number", + "ci.pipeline.url": "buildkite-build-url", + "ci.provider.name": "buildkite", + "ci.workspace_path": "foo/bar", + "git.branch": "master", + "git.commit.sha": "buildkite-git-commit", + "git.commit_sha": "buildkite-git-commit", + "git.repository_url": "http://hostname.com/repo.git" + } + ], + [ + { + "BUILDKITE": "true", + "BUILDKITE_BRANCH": "master", + "BUILDKITE_BUILD_CHECKOUT_PATH": "/foo/bar~", + "BUILDKITE_BUILD_ID": "buildkite-pipeline-id", + "BUILDKITE_BUILD_NUMBER": "buildkite-pipeline-number", + "BUILDKITE_BUILD_URL": "buildkite-build-url", + "BUILDKITE_COMMIT": "buildkite-git-commit", + "BUILDKITE_JOB_ID": "buildkite-job-id", + "BUILDKITE_PIPELINE_SLUG": "buildkite-pipeline-name", + "BUILDKITE_REPO": "http://hostname.com/repo.git" + }, + { + "ci.job.url": "buildkite-build-url#buildkite-job-id", + "ci.pipeline.id": "buildkite-pipeline-id", + "ci.pipeline.name": "buildkite-pipeline-name", + "ci.pipeline.number": "buildkite-pipeline-number", + "ci.pipeline.url": "buildkite-build-url", + "ci.provider.name": "buildkite", + "ci.workspace_path": "/foo/bar~", + "git.branch": "master", + "git.commit.sha": "buildkite-git-commit", + "git.commit_sha": "buildkite-git-commit", + "git.repository_url": "http://hostname.com/repo.git" + } + ], + [ + { + "BUILDKITE": "true", + "BUILDKITE_BRANCH": "master", + "BUILDKITE_BUILD_CHECKOUT_PATH": "/foo/~/bar", + "BUILDKITE_BUILD_ID": "buildkite-pipeline-id", + "BUILDKITE_BUILD_NUMBER": "buildkite-pipeline-number", + "BUILDKITE_BUILD_URL": "buildkite-build-url", + "BUILDKITE_COMMIT": "buildkite-git-commit", + "BUILDKITE_JOB_ID": "buildkite-job-id", + "BUILDKITE_PIPELINE_SLUG": "buildkite-pipeline-name", + "BUILDKITE_REPO": "http://hostname.com/repo.git" + }, + { + "ci.job.url": "buildkite-build-url#buildkite-job-id", + "ci.pipeline.id": "buildkite-pipeline-id", + "ci.pipeline.name": "buildkite-pipeline-name", + "ci.pipeline.number": "buildkite-pipeline-number", + "ci.pipeline.url": "buildkite-build-url", + "ci.provider.name": "buildkite", + "ci.workspace_path": "/foo/~/bar", + "git.branch": "master", + "git.commit.sha": "buildkite-git-commit", + "git.commit_sha": "buildkite-git-commit", + "git.repository_url": "http://hostname.com/repo.git" + } + ], + [ + { + "BUILDKITE": "true", + "BUILDKITE_BRANCH": "master", + "BUILDKITE_BUILD_CHECKOUT_PATH": "~/foo/bar", + "BUILDKITE_BUILD_ID": "buildkite-pipeline-id", + "BUILDKITE_BUILD_NUMBER": "buildkite-pipeline-number", + "BUILDKITE_BUILD_URL": "buildkite-build-url", + "BUILDKITE_COMMIT": "buildkite-git-commit", + "BUILDKITE_JOB_ID": "buildkite-job-id", + "BUILDKITE_PIPELINE_SLUG": "buildkite-pipeline-name", + "BUILDKITE_REPO": "http://hostname.com/repo.git", + "HOME": "/not-my-home", + "USERPROFILE": "/not-my-home" + }, + { + "ci.job.url": "buildkite-build-url#buildkite-job-id", + "ci.pipeline.id": "buildkite-pipeline-id", + "ci.pipeline.name": "buildkite-pipeline-name", + "ci.pipeline.number": "buildkite-pipeline-number", + "ci.pipeline.url": "buildkite-build-url", + "ci.provider.name": "buildkite", + "ci.workspace_path": "/not-my-home/foo/bar", + "git.branch": "master", + "git.commit.sha": "buildkite-git-commit", + "git.commit_sha": "buildkite-git-commit", + "git.repository_url": "http://hostname.com/repo.git" + } + ], + [ + { + "BUILDKITE": "true", + "BUILDKITE_BRANCH": "master", + "BUILDKITE_BUILD_CHECKOUT_PATH": "~foo/bar", + "BUILDKITE_BUILD_ID": "buildkite-pipeline-id", + "BUILDKITE_BUILD_NUMBER": "buildkite-pipeline-number", + "BUILDKITE_BUILD_URL": "buildkite-build-url", + "BUILDKITE_COMMIT": "buildkite-git-commit", + "BUILDKITE_JOB_ID": "buildkite-job-id", + "BUILDKITE_PIPELINE_SLUG": "buildkite-pipeline-name", + "BUILDKITE_REPO": "http://hostname.com/repo.git", + "HOME": "/not-my-home", + "USERPROFILE": "/not-my-home" + }, + { + "ci.job.url": "buildkite-build-url#buildkite-job-id", + "ci.pipeline.id": "buildkite-pipeline-id", + "ci.pipeline.name": "buildkite-pipeline-name", + "ci.pipeline.number": "buildkite-pipeline-number", + "ci.pipeline.url": "buildkite-build-url", + "ci.provider.name": "buildkite", + "ci.workspace_path": "~foo/bar", + "git.branch": "master", + "git.commit.sha": "buildkite-git-commit", + "git.commit_sha": "buildkite-git-commit", + "git.repository_url": "http://hostname.com/repo.git" + } + ], + [ + { + "BUILDKITE": "true", + "BUILDKITE_BRANCH": "master", + "BUILDKITE_BUILD_CHECKOUT_PATH": "~", + "BUILDKITE_BUILD_ID": "buildkite-pipeline-id", + "BUILDKITE_BUILD_NUMBER": "buildkite-pipeline-number", + "BUILDKITE_BUILD_URL": "buildkite-build-url", + "BUILDKITE_COMMIT": "buildkite-git-commit", + "BUILDKITE_JOB_ID": "buildkite-job-id", + "BUILDKITE_PIPELINE_SLUG": "buildkite-pipeline-name", + "BUILDKITE_REPO": "http://hostname.com/repo.git", + "HOME": "/not-my-home", + "USERPROFILE": "/not-my-home" + }, + { + "ci.job.url": "buildkite-build-url#buildkite-job-id", + "ci.pipeline.id": "buildkite-pipeline-id", + "ci.pipeline.name": "buildkite-pipeline-name", + "ci.pipeline.number": "buildkite-pipeline-number", + "ci.pipeline.url": "buildkite-build-url", + "ci.provider.name": "buildkite", + "ci.workspace_path": "/not-my-home", + "git.branch": "master", + "git.commit.sha": "buildkite-git-commit", + "git.commit_sha": "buildkite-git-commit", + "git.repository_url": "http://hostname.com/repo.git" + } + ], + [ + { + "BUILDKITE": "true", + "BUILDKITE_BRANCH": "master", + "BUILDKITE_BUILD_CHECKOUT_PATH": "/foo/bar", + "BUILDKITE_BUILD_ID": "buildkite-pipeline-id", + "BUILDKITE_BUILD_NUMBER": "buildkite-pipeline-number", + "BUILDKITE_BUILD_URL": "buildkite-build-url", + "BUILDKITE_COMMIT": "buildkite-git-commit", + "BUILDKITE_JOB_ID": "buildkite-job-id", + "BUILDKITE_PIPELINE_SLUG": "buildkite-pipeline-name", + "BUILDKITE_REPO": "http://user@hostname.com/repo.git" + }, + { + "ci.job.url": "buildkite-build-url#buildkite-job-id", + "ci.pipeline.id": "buildkite-pipeline-id", + "ci.pipeline.name": "buildkite-pipeline-name", + "ci.pipeline.number": "buildkite-pipeline-number", + "ci.pipeline.url": "buildkite-build-url", + "ci.provider.name": "buildkite", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "buildkite-git-commit", + "git.commit_sha": "buildkite-git-commit", + "git.repository_url": "http://hostname.com/repo.git" + } + ], + [ + { + "BUILDKITE": "true", + "BUILDKITE_BRANCH": "master", + "BUILDKITE_BUILD_CHECKOUT_PATH": "/foo/bar", + "BUILDKITE_BUILD_ID": "buildkite-pipeline-id", + "BUILDKITE_BUILD_NUMBER": "buildkite-pipeline-number", + "BUILDKITE_BUILD_URL": "buildkite-build-url", + "BUILDKITE_COMMIT": "buildkite-git-commit", + "BUILDKITE_JOB_ID": "buildkite-job-id", + "BUILDKITE_PIPELINE_SLUG": "buildkite-pipeline-name", + "BUILDKITE_REPO": "http://user%E2%82%AC@hostname.com/repo.git" + }, + { + "ci.job.url": "buildkite-build-url#buildkite-job-id", + "ci.pipeline.id": "buildkite-pipeline-id", + "ci.pipeline.name": "buildkite-pipeline-name", + "ci.pipeline.number": "buildkite-pipeline-number", + "ci.pipeline.url": "buildkite-build-url", + "ci.provider.name": "buildkite", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "buildkite-git-commit", + "git.commit_sha": "buildkite-git-commit", + "git.repository_url": "http://hostname.com/repo.git" + } + ], + [ + { + "BUILDKITE": "true", + "BUILDKITE_BRANCH": "master", + "BUILDKITE_BUILD_CHECKOUT_PATH": "/foo/bar", + "BUILDKITE_BUILD_ID": "buildkite-pipeline-id", + "BUILDKITE_BUILD_NUMBER": "buildkite-pipeline-number", + "BUILDKITE_BUILD_URL": "buildkite-build-url", + "BUILDKITE_COMMIT": "buildkite-git-commit", + "BUILDKITE_JOB_ID": "buildkite-job-id", + "BUILDKITE_PIPELINE_SLUG": "buildkite-pipeline-name", + "BUILDKITE_REPO": "http://user:pwd@hostname.com/repo.git" + }, + { + "ci.job.url": "buildkite-build-url#buildkite-job-id", + "ci.pipeline.id": "buildkite-pipeline-id", + "ci.pipeline.name": "buildkite-pipeline-name", + "ci.pipeline.number": "buildkite-pipeline-number", + "ci.pipeline.url": "buildkite-build-url", + "ci.provider.name": "buildkite", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "buildkite-git-commit", + "git.commit_sha": "buildkite-git-commit", + "git.repository_url": "http://hostname.com/repo.git" + } + ], + [ + { + "BUILDKITE": "true", + "BUILDKITE_BRANCH": "master", + "BUILDKITE_BUILD_CHECKOUT_PATH": "/foo/bar", + "BUILDKITE_BUILD_ID": "buildkite-pipeline-id", + "BUILDKITE_BUILD_NUMBER": "buildkite-pipeline-number", + "BUILDKITE_BUILD_URL": "buildkite-build-url", + "BUILDKITE_COMMIT": "buildkite-git-commit", + "BUILDKITE_JOB_ID": "buildkite-job-id", + "BUILDKITE_PIPELINE_SLUG": "buildkite-pipeline-name", + "BUILDKITE_REPO": "git@hostname.com:org/repo.git" + }, + { + "ci.job.url": "buildkite-build-url#buildkite-job-id", + "ci.pipeline.id": "buildkite-pipeline-id", + "ci.pipeline.name": "buildkite-pipeline-name", + "ci.pipeline.number": "buildkite-pipeline-number", + "ci.pipeline.url": "buildkite-build-url", + "ci.provider.name": "buildkite", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "buildkite-git-commit", + "git.commit_sha": "buildkite-git-commit", + "git.repository_url": "git@hostname.com:org/repo.git" + } + ], + [ + { + "BUILDKITE": "true", + "BUILDKITE_BRANCH": "origin/master", + "BUILDKITE_BUILD_CHECKOUT_PATH": "/foo/bar", + "BUILDKITE_BUILD_ID": "buildkite-pipeline-id", + "BUILDKITE_BUILD_NUMBER": "buildkite-pipeline-number", + "BUILDKITE_BUILD_URL": "buildkite-build-url", + "BUILDKITE_COMMIT": "buildkite-git-commit", + "BUILDKITE_JOB_ID": "buildkite-job-id", + "BUILDKITE_PIPELINE_SLUG": "buildkite-pipeline-name", + "BUILDKITE_REPO": "http://hostname.com/repo.git" + }, + { + "ci.job.url": "buildkite-build-url#buildkite-job-id", + "ci.pipeline.id": "buildkite-pipeline-id", + "ci.pipeline.name": "buildkite-pipeline-name", + "ci.pipeline.number": "buildkite-pipeline-number", + "ci.pipeline.url": "buildkite-build-url", + "ci.provider.name": "buildkite", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "buildkite-git-commit", + "git.commit_sha": "buildkite-git-commit", + "git.repository_url": "http://hostname.com/repo.git" + } + ], + [ + { + "BUILDKITE": "true", + "BUILDKITE_BRANCH": "refs/heads/master", + "BUILDKITE_BUILD_CHECKOUT_PATH": "/foo/bar", + "BUILDKITE_BUILD_ID": "buildkite-pipeline-id", + "BUILDKITE_BUILD_NUMBER": "buildkite-pipeline-number", + "BUILDKITE_BUILD_URL": "buildkite-build-url", + "BUILDKITE_COMMIT": "buildkite-git-commit", + "BUILDKITE_JOB_ID": "buildkite-job-id", + "BUILDKITE_PIPELINE_SLUG": "buildkite-pipeline-name", + "BUILDKITE_REPO": "http://hostname.com/repo.git" + }, + { + "ci.job.url": "buildkite-build-url#buildkite-job-id", + "ci.pipeline.id": "buildkite-pipeline-id", + "ci.pipeline.name": "buildkite-pipeline-name", + "ci.pipeline.number": "buildkite-pipeline-number", + "ci.pipeline.url": "buildkite-build-url", + "ci.provider.name": "buildkite", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "buildkite-git-commit", + "git.commit_sha": "buildkite-git-commit", + "git.repository_url": "http://hostname.com/repo.git" + } + ], + [ + { + "BUILDKITE": "true", + "BUILDKITE_BRANCH": "refs/heads/feature/one", + "BUILDKITE_BUILD_CHECKOUT_PATH": "/foo/bar", + "BUILDKITE_BUILD_ID": "buildkite-pipeline-id", + "BUILDKITE_BUILD_NUMBER": "buildkite-pipeline-number", + "BUILDKITE_BUILD_URL": "buildkite-build-url", + "BUILDKITE_COMMIT": "buildkite-git-commit", + "BUILDKITE_JOB_ID": "buildkite-job-id", + "BUILDKITE_PIPELINE_SLUG": "buildkite-pipeline-name", + "BUILDKITE_REPO": "http://hostname.com/repo.git" + }, + { + "ci.job.url": "buildkite-build-url#buildkite-job-id", + "ci.pipeline.id": "buildkite-pipeline-id", + "ci.pipeline.name": "buildkite-pipeline-name", + "ci.pipeline.number": "buildkite-pipeline-number", + "ci.pipeline.url": "buildkite-build-url", + "ci.provider.name": "buildkite", + "ci.workspace_path": "/foo/bar", + "git.branch": "feature/one", + "git.commit.sha": "buildkite-git-commit", + "git.commit_sha": "buildkite-git-commit", + "git.repository_url": "http://hostname.com/repo.git" + } + ], + [ + { + "BUILDKITE": "true", + "BUILDKITE_BUILD_CHECKOUT_PATH": "/foo/bar", + "BUILDKITE_BUILD_ID": "buildkite-pipeline-id", + "BUILDKITE_BUILD_NUMBER": "buildkite-pipeline-number", + "BUILDKITE_BUILD_URL": "buildkite-build-url", + "BUILDKITE_COMMIT": "buildkite-git-commit", + "BUILDKITE_JOB_ID": "buildkite-job-id", + "BUILDKITE_PIPELINE_SLUG": "buildkite-pipeline-name", + "BUILDKITE_REPO": "http://hostname.com/repo.git", + "BUILDKITE_TAG": "0.1.0" + }, + { + "ci.job.url": "buildkite-build-url#buildkite-job-id", + "ci.pipeline.id": "buildkite-pipeline-id", + "ci.pipeline.name": "buildkite-pipeline-name", + "ci.pipeline.number": "buildkite-pipeline-number", + "ci.pipeline.url": "buildkite-build-url", + "ci.provider.name": "buildkite", + "ci.workspace_path": "/foo/bar", + "git.commit.sha": "buildkite-git-commit", + "git.commit_sha": "buildkite-git-commit", + "git.repository_url": "http://hostname.com/repo.git", + "git.tag": "0.1.0" + } + ], + [ + { + "BUILDKITE": "true", + "BUILDKITE_BUILD_CHECKOUT_PATH": "/foo/bar", + "BUILDKITE_BUILD_ID": "buildkite-pipeline-id", + "BUILDKITE_BUILD_NUMBER": "buildkite-pipeline-number", + "BUILDKITE_BUILD_URL": "buildkite-build-url", + "BUILDKITE_COMMIT": "buildkite-git-commit", + "BUILDKITE_JOB_ID": "buildkite-job-id", + "BUILDKITE_PIPELINE_SLUG": "buildkite-pipeline-name", + "BUILDKITE_REPO": "http://hostname.com/repo.git", + "BUILDKITE_TAG": "origin/tags/0.1.0" + }, + { + "ci.job.url": "buildkite-build-url#buildkite-job-id", + "ci.pipeline.id": "buildkite-pipeline-id", + "ci.pipeline.name": "buildkite-pipeline-name", + "ci.pipeline.number": "buildkite-pipeline-number", + "ci.pipeline.url": "buildkite-build-url", + "ci.provider.name": "buildkite", + "ci.workspace_path": "/foo/bar", + "git.commit.sha": "buildkite-git-commit", + "git.commit_sha": "buildkite-git-commit", + "git.repository_url": "http://hostname.com/repo.git", + "git.tag": "0.1.0" + } + ], + [ + { + "BUILDKITE": "true", + "BUILDKITE_BUILD_CHECKOUT_PATH": "/foo/bar", + "BUILDKITE_BUILD_ID": "buildkite-pipeline-id", + "BUILDKITE_BUILD_NUMBER": "buildkite-pipeline-number", + "BUILDKITE_BUILD_URL": "buildkite-build-url", + "BUILDKITE_COMMIT": "buildkite-git-commit", + "BUILDKITE_JOB_ID": "buildkite-job-id", + "BUILDKITE_PIPELINE_SLUG": "buildkite-pipeline-name", + "BUILDKITE_REPO": "http://hostname.com/repo.git", + "BUILDKITE_TAG": "refs/heads/tags/0.1.0" + }, + { + "ci.job.url": "buildkite-build-url#buildkite-job-id", + "ci.pipeline.id": "buildkite-pipeline-id", + "ci.pipeline.name": "buildkite-pipeline-name", + "ci.pipeline.number": "buildkite-pipeline-number", + "ci.pipeline.url": "buildkite-build-url", + "ci.provider.name": "buildkite", + "ci.workspace_path": "/foo/bar", + "git.commit.sha": "buildkite-git-commit", + "git.commit_sha": "buildkite-git-commit", + "git.repository_url": "http://hostname.com/repo.git", + "git.tag": "0.1.0" + } + ] +] diff --git a/tests/tracer/fixtures/ci/circle_ci.json b/tests/tracer/fixtures/ci/circle_ci.json new file mode 100644 index 00000000000..41553dff42f --- /dev/null +++ b/tests/tracer/fixtures/ci/circle_ci.json @@ -0,0 +1,548 @@ +[ + [ + { + "CIRCLECI": "circleCI", + "CIRCLE_BRANCH": "origin/master", + "CIRCLE_BUILD_NUM": "circleci-pipeline-number", + "CIRCLE_BUILD_URL": "circleci-build-url", + "CIRCLE_PROJECT_REPONAME": "circleci-pipeline-name", + "CIRCLE_REPOSITORY_URL": "sample", + "CIRCLE_SHA1": "circleci-git-commit", + "CIRCLE_WORKFLOW_ID": "circleci-pipeline-id" + }, + { + "ci.job.url": "circleci-build-url", + "ci.pipeline.id": "circleci-pipeline-id", + "ci.pipeline.name": "circleci-pipeline-name", + "ci.pipeline.number": "circleci-pipeline-number", + "ci.pipeline.url": "circleci-build-url", + "ci.provider.name": "circleci", + "git.branch": "master", + "git.commit.sha": "circleci-git-commit", + "git.commit_sha": "circleci-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "CIRCLECI": "circleCI", + "CIRCLE_BRANCH": "origin/master", + "CIRCLE_BUILD_NUM": "circleci-pipeline-number", + "CIRCLE_BUILD_URL": "circleci-build-url", + "CIRCLE_PROJECT_REPONAME": "circleci-pipeline-name", + "CIRCLE_REPOSITORY_URL": "sample", + "CIRCLE_SHA1": "circleci-git-commit", + "CIRCLE_WORKFLOW_ID": "circleci-pipeline-id" + }, + { + "ci.job.url": "circleci-build-url", + "ci.pipeline.id": "circleci-pipeline-id", + "ci.pipeline.name": "circleci-pipeline-name", + "ci.pipeline.number": "circleci-pipeline-number", + "ci.pipeline.url": "circleci-build-url", + "ci.provider.name": "circleci", + "git.branch": "master", + "git.commit.sha": "circleci-git-commit", + "git.commit_sha": "circleci-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "CIRCLECI": "circleCI", + "CIRCLE_BRANCH": "origin/master", + "CIRCLE_BUILD_NUM": "circleci-pipeline-number", + "CIRCLE_BUILD_URL": "circleci-build-url", + "CIRCLE_PROJECT_REPONAME": "circleci-pipeline-name", + "CIRCLE_REPOSITORY_URL": "sample", + "CIRCLE_SHA1": "circleci-git-commit", + "CIRCLE_WORKFLOW_ID": "circleci-pipeline-id", + "CIRCLE_WORKING_DIRECTORY": "/foo/bar" + }, + { + "ci.job.url": "circleci-build-url", + "ci.pipeline.id": "circleci-pipeline-id", + "ci.pipeline.name": "circleci-pipeline-name", + "ci.pipeline.number": "circleci-pipeline-number", + "ci.pipeline.url": "circleci-build-url", + "ci.provider.name": "circleci", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "circleci-git-commit", + "git.commit_sha": "circleci-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "CIRCLECI": "circleCI", + "CIRCLE_BRANCH": "origin/master", + "CIRCLE_BUILD_NUM": "circleci-pipeline-number", + "CIRCLE_BUILD_URL": "circleci-build-url", + "CIRCLE_PROJECT_REPONAME": "circleci-pipeline-name", + "CIRCLE_REPOSITORY_URL": "sample", + "CIRCLE_SHA1": "circleci-git-commit", + "CIRCLE_WORKFLOW_ID": "circleci-pipeline-id", + "CIRCLE_WORKING_DIRECTORY": "/foo/bar" + }, + { + "ci.job.url": "circleci-build-url", + "ci.pipeline.id": "circleci-pipeline-id", + "ci.pipeline.name": "circleci-pipeline-name", + "ci.pipeline.number": "circleci-pipeline-number", + "ci.pipeline.url": "circleci-build-url", + "ci.provider.name": "circleci", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "circleci-git-commit", + "git.commit_sha": "circleci-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "CIRCLECI": "circleCI", + "CIRCLE_BRANCH": "origin/master", + "CIRCLE_BUILD_NUM": "circleci-pipeline-number", + "CIRCLE_BUILD_URL": "circleci-build-url", + "CIRCLE_PROJECT_REPONAME": "circleci-pipeline-name", + "CIRCLE_REPOSITORY_URL": "sample", + "CIRCLE_SHA1": "circleci-git-commit", + "CIRCLE_WORKFLOW_ID": "circleci-pipeline-id", + "CIRCLE_WORKING_DIRECTORY": "foo/bar" + }, + { + "ci.job.url": "circleci-build-url", + "ci.pipeline.id": "circleci-pipeline-id", + "ci.pipeline.name": "circleci-pipeline-name", + "ci.pipeline.number": "circleci-pipeline-number", + "ci.pipeline.url": "circleci-build-url", + "ci.provider.name": "circleci", + "ci.workspace_path": "foo/bar", + "git.branch": "master", + "git.commit.sha": "circleci-git-commit", + "git.commit_sha": "circleci-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "CIRCLECI": "circleCI", + "CIRCLE_BRANCH": "origin/master", + "CIRCLE_BUILD_NUM": "circleci-pipeline-number", + "CIRCLE_BUILD_URL": "circleci-build-url", + "CIRCLE_PROJECT_REPONAME": "circleci-pipeline-name", + "CIRCLE_REPOSITORY_URL": "sample", + "CIRCLE_SHA1": "circleci-git-commit", + "CIRCLE_WORKFLOW_ID": "circleci-pipeline-id", + "CIRCLE_WORKING_DIRECTORY": "/foo/bar~" + }, + { + "ci.job.url": "circleci-build-url", + "ci.pipeline.id": "circleci-pipeline-id", + "ci.pipeline.name": "circleci-pipeline-name", + "ci.pipeline.number": "circleci-pipeline-number", + "ci.pipeline.url": "circleci-build-url", + "ci.provider.name": "circleci", + "ci.workspace_path": "/foo/bar~", + "git.branch": "master", + "git.commit.sha": "circleci-git-commit", + "git.commit_sha": "circleci-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "CIRCLECI": "circleCI", + "CIRCLE_BRANCH": "origin/master", + "CIRCLE_BUILD_NUM": "circleci-pipeline-number", + "CIRCLE_BUILD_URL": "circleci-build-url", + "CIRCLE_PROJECT_REPONAME": "circleci-pipeline-name", + "CIRCLE_REPOSITORY_URL": "sample", + "CIRCLE_SHA1": "circleci-git-commit", + "CIRCLE_WORKFLOW_ID": "circleci-pipeline-id", + "CIRCLE_WORKING_DIRECTORY": "/foo/~/bar" + }, + { + "ci.job.url": "circleci-build-url", + "ci.pipeline.id": "circleci-pipeline-id", + "ci.pipeline.name": "circleci-pipeline-name", + "ci.pipeline.number": "circleci-pipeline-number", + "ci.pipeline.url": "circleci-build-url", + "ci.provider.name": "circleci", + "ci.workspace_path": "/foo/~/bar", + "git.branch": "master", + "git.commit.sha": "circleci-git-commit", + "git.commit_sha": "circleci-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "CIRCLECI": "circleCI", + "CIRCLE_BRANCH": "origin/master", + "CIRCLE_BUILD_NUM": "circleci-pipeline-number", + "CIRCLE_BUILD_URL": "circleci-build-url", + "CIRCLE_PROJECT_REPONAME": "circleci-pipeline-name", + "CIRCLE_REPOSITORY_URL": "sample", + "CIRCLE_SHA1": "circleci-git-commit", + "CIRCLE_WORKFLOW_ID": "circleci-pipeline-id", + "CIRCLE_WORKING_DIRECTORY": "~/foo/bar", + "HOME": "/not-my-home", + "USERPROFILE": "/not-my-home" + }, + { + "ci.job.url": "circleci-build-url", + "ci.pipeline.id": "circleci-pipeline-id", + "ci.pipeline.name": "circleci-pipeline-name", + "ci.pipeline.number": "circleci-pipeline-number", + "ci.pipeline.url": "circleci-build-url", + "ci.provider.name": "circleci", + "ci.workspace_path": "/not-my-home/foo/bar", + "git.branch": "master", + "git.commit.sha": "circleci-git-commit", + "git.commit_sha": "circleci-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "CIRCLECI": "circleCI", + "CIRCLE_BRANCH": "origin/master", + "CIRCLE_BUILD_NUM": "circleci-pipeline-number", + "CIRCLE_BUILD_URL": "circleci-build-url", + "CIRCLE_PROJECT_REPONAME": "circleci-pipeline-name", + "CIRCLE_REPOSITORY_URL": "sample", + "CIRCLE_SHA1": "circleci-git-commit", + "CIRCLE_WORKFLOW_ID": "circleci-pipeline-id", + "CIRCLE_WORKING_DIRECTORY": "~foo/bar", + "HOME": "/not-my-home", + "USERPROFILE": "/not-my-home" + }, + { + "ci.job.url": "circleci-build-url", + "ci.pipeline.id": "circleci-pipeline-id", + "ci.pipeline.name": "circleci-pipeline-name", + "ci.pipeline.number": "circleci-pipeline-number", + "ci.pipeline.url": "circleci-build-url", + "ci.provider.name": "circleci", + "ci.workspace_path": "~foo/bar", + "git.branch": "master", + "git.commit.sha": "circleci-git-commit", + "git.commit_sha": "circleci-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "CIRCLECI": "circleCI", + "CIRCLE_BRANCH": "origin/master", + "CIRCLE_BUILD_NUM": "circleci-pipeline-number", + "CIRCLE_BUILD_URL": "circleci-build-url", + "CIRCLE_PROJECT_REPONAME": "circleci-pipeline-name", + "CIRCLE_REPOSITORY_URL": "sample", + "CIRCLE_SHA1": "circleci-git-commit", + "CIRCLE_WORKFLOW_ID": "circleci-pipeline-id", + "CIRCLE_WORKING_DIRECTORY": "~", + "HOME": "/not-my-home", + "USERPROFILE": "/not-my-home" + }, + { + "ci.job.url": "circleci-build-url", + "ci.pipeline.id": "circleci-pipeline-id", + "ci.pipeline.name": "circleci-pipeline-name", + "ci.pipeline.number": "circleci-pipeline-number", + "ci.pipeline.url": "circleci-build-url", + "ci.provider.name": "circleci", + "ci.workspace_path": "/not-my-home", + "git.branch": "master", + "git.commit.sha": "circleci-git-commit", + "git.commit_sha": "circleci-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "CIRCLECI": "circleCI", + "CIRCLE_BRANCH": "refs/heads/master", + "CIRCLE_BUILD_NUM": "circleci-pipeline-number", + "CIRCLE_BUILD_URL": "circleci-build-url", + "CIRCLE_PROJECT_REPONAME": "circleci-pipeline-name", + "CIRCLE_REPOSITORY_URL": "sample", + "CIRCLE_SHA1": "circleci-git-commit", + "CIRCLE_WORKFLOW_ID": "circleci-pipeline-id", + "CIRCLE_WORKING_DIRECTORY": "/foo/bar" + }, + { + "ci.job.url": "circleci-build-url", + "ci.pipeline.id": "circleci-pipeline-id", + "ci.pipeline.name": "circleci-pipeline-name", + "ci.pipeline.number": "circleci-pipeline-number", + "ci.pipeline.url": "circleci-build-url", + "ci.provider.name": "circleci", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "circleci-git-commit", + "git.commit_sha": "circleci-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "CIRCLECI": "circleCI", + "CIRCLE_BRANCH": "refs/heads/feature/one", + "CIRCLE_BUILD_NUM": "circleci-pipeline-number", + "CIRCLE_BUILD_URL": "circleci-build-url", + "CIRCLE_PROJECT_REPONAME": "circleci-pipeline-name", + "CIRCLE_REPOSITORY_URL": "sample", + "CIRCLE_SHA1": "circleci-git-commit", + "CIRCLE_WORKFLOW_ID": "circleci-pipeline-id", + "CIRCLE_WORKING_DIRECTORY": "/foo/bar" + }, + { + "ci.job.url": "circleci-build-url", + "ci.pipeline.id": "circleci-pipeline-id", + "ci.pipeline.name": "circleci-pipeline-name", + "ci.pipeline.number": "circleci-pipeline-number", + "ci.pipeline.url": "circleci-build-url", + "ci.provider.name": "circleci", + "ci.workspace_path": "/foo/bar", + "git.branch": "feature/one", + "git.commit.sha": "circleci-git-commit", + "git.commit_sha": "circleci-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "CIRCLECI": "circleCI", + "CIRCLE_BRANCH": "origin/tags/0.1.0", + "CIRCLE_BUILD_NUM": "circleci-pipeline-number", + "CIRCLE_BUILD_URL": "circleci-build-url", + "CIRCLE_PROJECT_REPONAME": "circleci-pipeline-name", + "CIRCLE_REPOSITORY_URL": "sample", + "CIRCLE_SHA1": "circleci-git-commit", + "CIRCLE_TAG": "origin/tags/0.1.0", + "CIRCLE_WORKFLOW_ID": "circleci-pipeline-id", + "CIRCLE_WORKING_DIRECTORY": "/foo/bar" + }, + { + "ci.job.url": "circleci-build-url", + "ci.pipeline.id": "circleci-pipeline-id", + "ci.pipeline.name": "circleci-pipeline-name", + "ci.pipeline.number": "circleci-pipeline-number", + "ci.pipeline.url": "circleci-build-url", + "ci.provider.name": "circleci", + "ci.workspace_path": "/foo/bar", + "git.commit.sha": "circleci-git-commit", + "git.commit_sha": "circleci-git-commit", + "git.repository_url": "sample", + "git.tag": "0.1.0" + } + ], + [ + { + "CIRCLECI": "circleCI", + "CIRCLE_BRANCH": "refs/heads/tags/0.1.0", + "CIRCLE_BUILD_NUM": "circleci-pipeline-number", + "CIRCLE_BUILD_URL": "circleci-build-url", + "CIRCLE_PROJECT_REPONAME": "circleci-pipeline-name", + "CIRCLE_REPOSITORY_URL": "sample", + "CIRCLE_SHA1": "circleci-git-commit", + "CIRCLE_TAG": "refs/heads/tags/0.1.0", + "CIRCLE_WORKFLOW_ID": "circleci-pipeline-id", + "CIRCLE_WORKING_DIRECTORY": "/foo/bar" + }, + { + "ci.job.url": "circleci-build-url", + "ci.pipeline.id": "circleci-pipeline-id", + "ci.pipeline.name": "circleci-pipeline-name", + "ci.pipeline.number": "circleci-pipeline-number", + "ci.pipeline.url": "circleci-build-url", + "ci.provider.name": "circleci", + "ci.workspace_path": "/foo/bar", + "git.commit.sha": "circleci-git-commit", + "git.commit_sha": "circleci-git-commit", + "git.repository_url": "sample", + "git.tag": "0.1.0" + } + ], + [ + { + "CIRCLECI": "circleCI", + "CIRCLE_BRANCH": "origin/master", + "CIRCLE_BUILD_NUM": "circleci-pipeline-number", + "CIRCLE_BUILD_URL": "circleci-build-url", + "CIRCLE_PROJECT_REPONAME": "circleci-pipeline-name", + "CIRCLE_SHA1": "circleci-git-commit", + "CIRCLE_WORKFLOW_ID": "circleci-pipeline-id", + "CIRCLE_WORKING_DIRECTORY": "/foo/bar" + }, + { + "ci.job.url": "circleci-build-url", + "ci.pipeline.id": "circleci-pipeline-id", + "ci.pipeline.name": "circleci-pipeline-name", + "ci.pipeline.number": "circleci-pipeline-number", + "ci.pipeline.url": "circleci-build-url", + "ci.provider.name": "circleci", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "circleci-git-commit", + "git.commit_sha": "circleci-git-commit" + } + ], + [ + { + "CIRCLECI": "circleCI", + "CIRCLE_BRANCH": "origin/master", + "CIRCLE_BUILD_NUM": "circleci-pipeline-number", + "CIRCLE_BUILD_URL": "circleci-build-url", + "CIRCLE_PROJECT_REPONAME": "circleci-pipeline-name", + "CIRCLE_SHA1": "circleci-git-commit", + "CIRCLE_WORKFLOW_ID": "circleci-pipeline-id", + "CIRCLE_WORKING_DIRECTORY": "/foo/bar" + }, + { + "ci.job.url": "circleci-build-url", + "ci.pipeline.id": "circleci-pipeline-id", + "ci.pipeline.name": "circleci-pipeline-name", + "ci.pipeline.number": "circleci-pipeline-number", + "ci.pipeline.url": "circleci-build-url", + "ci.provider.name": "circleci", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "circleci-git-commit", + "git.commit_sha": "circleci-git-commit" + } + ], + [ + { + "CIRCLECI": "circleCI", + "CIRCLE_BRANCH": "origin/master", + "CIRCLE_BUILD_NUM": "circleci-pipeline-number", + "CIRCLE_BUILD_URL": "circleci-build-url", + "CIRCLE_PROJECT_REPONAME": "circleci-pipeline-name", + "CIRCLE_REPOSITORY_URL": "http://hostname.com/repo.git", + "CIRCLE_SHA1": "circleci-git-commit", + "CIRCLE_WORKFLOW_ID": "circleci-pipeline-id", + "CIRCLE_WORKING_DIRECTORY": "/foo/bar" + }, + { + "ci.job.url": "circleci-build-url", + "ci.pipeline.id": "circleci-pipeline-id", + "ci.pipeline.name": "circleci-pipeline-name", + "ci.pipeline.number": "circleci-pipeline-number", + "ci.pipeline.url": "circleci-build-url", + "ci.provider.name": "circleci", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "circleci-git-commit", + "git.commit_sha": "circleci-git-commit", + "git.repository_url": "http://hostname.com/repo.git" + } + ], + [ + { + "CIRCLECI": "circleCI", + "CIRCLE_BRANCH": "origin/master", + "CIRCLE_BUILD_NUM": "circleci-pipeline-number", + "CIRCLE_BUILD_URL": "circleci-build-url", + "CIRCLE_PROJECT_REPONAME": "circleci-pipeline-name", + "CIRCLE_REPOSITORY_URL": "http://user@hostname.com/repo.git", + "CIRCLE_SHA1": "circleci-git-commit", + "CIRCLE_WORKFLOW_ID": "circleci-pipeline-id", + "CIRCLE_WORKING_DIRECTORY": "/foo/bar" + }, + { + "ci.job.url": "circleci-build-url", + "ci.pipeline.id": "circleci-pipeline-id", + "ci.pipeline.name": "circleci-pipeline-name", + "ci.pipeline.number": "circleci-pipeline-number", + "ci.pipeline.url": "circleci-build-url", + "ci.provider.name": "circleci", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "circleci-git-commit", + "git.commit_sha": "circleci-git-commit", + "git.repository_url": "http://hostname.com/repo.git" + } + ], + [ + { + "CIRCLECI": "circleCI", + "CIRCLE_BRANCH": "origin/master", + "CIRCLE_BUILD_NUM": "circleci-pipeline-number", + "CIRCLE_BUILD_URL": "circleci-build-url", + "CIRCLE_PROJECT_REPONAME": "circleci-pipeline-name", + "CIRCLE_REPOSITORY_URL": "http://user%E2%82%AC@hostname.com/repo.git", + "CIRCLE_SHA1": "circleci-git-commit", + "CIRCLE_WORKFLOW_ID": "circleci-pipeline-id", + "CIRCLE_WORKING_DIRECTORY": "/foo/bar" + }, + { + "ci.job.url": "circleci-build-url", + "ci.pipeline.id": "circleci-pipeline-id", + "ci.pipeline.name": "circleci-pipeline-name", + "ci.pipeline.number": "circleci-pipeline-number", + "ci.pipeline.url": "circleci-build-url", + "ci.provider.name": "circleci", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "circleci-git-commit", + "git.commit_sha": "circleci-git-commit", + "git.repository_url": "http://hostname.com/repo.git" + } + ], + [ + { + "CIRCLECI": "circleCI", + "CIRCLE_BRANCH": "origin/master", + "CIRCLE_BUILD_NUM": "circleci-pipeline-number", + "CIRCLE_BUILD_URL": "circleci-build-url", + "CIRCLE_PROJECT_REPONAME": "circleci-pipeline-name", + "CIRCLE_REPOSITORY_URL": "http://user:pwd@hostname.com/repo.git", + "CIRCLE_SHA1": "circleci-git-commit", + "CIRCLE_WORKFLOW_ID": "circleci-pipeline-id", + "CIRCLE_WORKING_DIRECTORY": "/foo/bar" + }, + { + "ci.job.url": "circleci-build-url", + "ci.pipeline.id": "circleci-pipeline-id", + "ci.pipeline.name": "circleci-pipeline-name", + "ci.pipeline.number": "circleci-pipeline-number", + "ci.pipeline.url": "circleci-build-url", + "ci.provider.name": "circleci", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "circleci-git-commit", + "git.commit_sha": "circleci-git-commit", + "git.repository_url": "http://hostname.com/repo.git" + } + ], + [ + { + "CIRCLECI": "circleCI", + "CIRCLE_BRANCH": "origin/master", + "CIRCLE_BUILD_NUM": "circleci-pipeline-number", + "CIRCLE_BUILD_URL": "circleci-build-url", + "CIRCLE_PROJECT_REPONAME": "circleci-pipeline-name", + "CIRCLE_REPOSITORY_URL": "git@hostname.com:org/repo.git", + "CIRCLE_SHA1": "circleci-git-commit", + "CIRCLE_WORKFLOW_ID": "circleci-pipeline-id", + "CIRCLE_WORKING_DIRECTORY": "/foo/bar" + }, + { + "ci.job.url": "circleci-build-url", + "ci.pipeline.id": "circleci-pipeline-id", + "ci.pipeline.name": "circleci-pipeline-name", + "ci.pipeline.number": "circleci-pipeline-number", + "ci.pipeline.url": "circleci-build-url", + "ci.provider.name": "circleci", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "circleci-git-commit", + "git.commit_sha": "circleci-git-commit", + "git.repository_url": "git@hostname.com:org/repo.git" + } + ] +] diff --git a/tests/tracer/fixtures/ci/github_actions.json b/tests/tracer/fixtures/ci/github_actions.json new file mode 100644 index 00000000000..b9a7f17440d --- /dev/null +++ b/tests/tracer/fixtures/ci/github_actions.json @@ -0,0 +1,411 @@ +[ + [ + { + "GITHUB_ACTION": "run", + "GITHUB_REF": "master", + "GITHUB_REPOSITORY": "ghactions-repo", + "GITHUB_RUN_ID": "ghactions-pipeline-id", + "GITHUB_RUN_NUMBER": "ghactions-pipeline-number", + "GITHUB_SHA": "ghactions-commit", + "GITHUB_WORKFLOW": "ghactions-pipeline-name", + "GITHUB_WORKSPACE": "/foo/bar" + }, + { + "ci.job.url": "https://github.com/ghactions-repo/commit/ghactions-commit/checks", + "ci.pipeline.id": "ghactions-pipeline-id", + "ci.pipeline.name": "ghactions-pipeline-name", + "ci.pipeline.number": "ghactions-pipeline-number", + "ci.pipeline.url": "https://github.com/ghactions-repo/commit/ghactions-commit/checks", + "ci.provider.name": "github", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "ghactions-commit", + "git.commit_sha": "ghactions-commit", + "git.repository_url": "https://github.com/ghactions-repo.git" + } + ], + [ + { + "GITHUB_ACTION": "run", + "GITHUB_REF": "master", + "GITHUB_REPOSITORY": "ghactions-repo", + "GITHUB_RUN_ID": "ghactions-pipeline-id", + "GITHUB_RUN_NUMBER": "ghactions-pipeline-number", + "GITHUB_SHA": "ghactions-commit", + "GITHUB_WORKFLOW": "ghactions-pipeline-name", + "GITHUB_WORKSPACE": "/foo/bar" + }, + { + "ci.job.url": "https://github.com/ghactions-repo/commit/ghactions-commit/checks", + "ci.pipeline.id": "ghactions-pipeline-id", + "ci.pipeline.name": "ghactions-pipeline-name", + "ci.pipeline.number": "ghactions-pipeline-number", + "ci.pipeline.url": "https://github.com/ghactions-repo/commit/ghactions-commit/checks", + "ci.provider.name": "github", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "ghactions-commit", + "git.commit_sha": "ghactions-commit", + "git.repository_url": "https://github.com/ghactions-repo.git" + } + ], + [ + { + "GITHUB_ACTION": "run", + "GITHUB_REF": "master", + "GITHUB_REPOSITORY": "ghactions-repo", + "GITHUB_RUN_ID": "ghactions-pipeline-id", + "GITHUB_RUN_NUMBER": "ghactions-pipeline-number", + "GITHUB_SHA": "ghactions-commit", + "GITHUB_WORKFLOW": "ghactions-pipeline-name", + "GITHUB_WORKSPACE": "foo/bar" + }, + { + "ci.job.url": "https://github.com/ghactions-repo/commit/ghactions-commit/checks", + "ci.pipeline.id": "ghactions-pipeline-id", + "ci.pipeline.name": "ghactions-pipeline-name", + "ci.pipeline.number": "ghactions-pipeline-number", + "ci.pipeline.url": "https://github.com/ghactions-repo/commit/ghactions-commit/checks", + "ci.provider.name": "github", + "ci.workspace_path": "foo/bar", + "git.branch": "master", + "git.commit.sha": "ghactions-commit", + "git.commit_sha": "ghactions-commit", + "git.repository_url": "https://github.com/ghactions-repo.git" + } + ], + [ + { + "GITHUB_ACTION": "run", + "GITHUB_REF": "master", + "GITHUB_REPOSITORY": "ghactions-repo", + "GITHUB_RUN_ID": "ghactions-pipeline-id", + "GITHUB_RUN_NUMBER": "ghactions-pipeline-number", + "GITHUB_SHA": "ghactions-commit", + "GITHUB_WORKFLOW": "ghactions-pipeline-name", + "GITHUB_WORKSPACE": "/foo/bar~" + }, + { + "ci.job.url": "https://github.com/ghactions-repo/commit/ghactions-commit/checks", + "ci.pipeline.id": "ghactions-pipeline-id", + "ci.pipeline.name": "ghactions-pipeline-name", + "ci.pipeline.number": "ghactions-pipeline-number", + "ci.pipeline.url": "https://github.com/ghactions-repo/commit/ghactions-commit/checks", + "ci.provider.name": "github", + "ci.workspace_path": "/foo/bar~", + "git.branch": "master", + "git.commit.sha": "ghactions-commit", + "git.commit_sha": "ghactions-commit", + "git.repository_url": "https://github.com/ghactions-repo.git" + } + ], + [ + { + "GITHUB_ACTION": "run", + "GITHUB_REF": "master", + "GITHUB_REPOSITORY": "ghactions-repo", + "GITHUB_RUN_ID": "ghactions-pipeline-id", + "GITHUB_RUN_NUMBER": "ghactions-pipeline-number", + "GITHUB_SHA": "ghactions-commit", + "GITHUB_WORKFLOW": "ghactions-pipeline-name", + "GITHUB_WORKSPACE": "/foo/~/bar" + }, + { + "ci.job.url": "https://github.com/ghactions-repo/commit/ghactions-commit/checks", + "ci.pipeline.id": "ghactions-pipeline-id", + "ci.pipeline.name": "ghactions-pipeline-name", + "ci.pipeline.number": "ghactions-pipeline-number", + "ci.pipeline.url": "https://github.com/ghactions-repo/commit/ghactions-commit/checks", + "ci.provider.name": "github", + "ci.workspace_path": "/foo/~/bar", + "git.branch": "master", + "git.commit.sha": "ghactions-commit", + "git.commit_sha": "ghactions-commit", + "git.repository_url": "https://github.com/ghactions-repo.git" + } + ], + [ + { + "GITHUB_ACTION": "run", + "GITHUB_REF": "master", + "GITHUB_REPOSITORY": "ghactions-repo", + "GITHUB_RUN_ID": "ghactions-pipeline-id", + "GITHUB_RUN_NUMBER": "ghactions-pipeline-number", + "GITHUB_SHA": "ghactions-commit", + "GITHUB_WORKFLOW": "ghactions-pipeline-name", + "GITHUB_WORKSPACE": "~/foo/bar", + "HOME": "/not-my-home", + "USERPROFILE": "/not-my-home" + }, + { + "ci.job.url": "https://github.com/ghactions-repo/commit/ghactions-commit/checks", + "ci.pipeline.id": "ghactions-pipeline-id", + "ci.pipeline.name": "ghactions-pipeline-name", + "ci.pipeline.number": "ghactions-pipeline-number", + "ci.pipeline.url": "https://github.com/ghactions-repo/commit/ghactions-commit/checks", + "ci.provider.name": "github", + "ci.workspace_path": "/not-my-home/foo/bar", + "git.branch": "master", + "git.commit.sha": "ghactions-commit", + "git.commit_sha": "ghactions-commit", + "git.repository_url": "https://github.com/ghactions-repo.git" + } + ], + [ + { + "GITHUB_ACTION": "run", + "GITHUB_REF": "master", + "GITHUB_REPOSITORY": "ghactions-repo", + "GITHUB_RUN_ID": "ghactions-pipeline-id", + "GITHUB_RUN_NUMBER": "ghactions-pipeline-number", + "GITHUB_SHA": "ghactions-commit", + "GITHUB_WORKFLOW": "ghactions-pipeline-name", + "GITHUB_WORKSPACE": "~foo/bar", + "HOME": "/not-my-home", + "USERPROFILE": "/not-my-home" + }, + { + "ci.job.url": "https://github.com/ghactions-repo/commit/ghactions-commit/checks", + "ci.pipeline.id": "ghactions-pipeline-id", + "ci.pipeline.name": "ghactions-pipeline-name", + "ci.pipeline.number": "ghactions-pipeline-number", + "ci.pipeline.url": "https://github.com/ghactions-repo/commit/ghactions-commit/checks", + "ci.provider.name": "github", + "ci.workspace_path": "~foo/bar", + "git.branch": "master", + "git.commit.sha": "ghactions-commit", + "git.commit_sha": "ghactions-commit", + "git.repository_url": "https://github.com/ghactions-repo.git" + } + ], + [ + { + "GITHUB_ACTION": "run", + "GITHUB_REF": "master", + "GITHUB_REPOSITORY": "ghactions-repo", + "GITHUB_RUN_ID": "ghactions-pipeline-id", + "GITHUB_RUN_NUMBER": "ghactions-pipeline-number", + "GITHUB_SHA": "ghactions-commit", + "GITHUB_WORKFLOW": "ghactions-pipeline-name", + "GITHUB_WORKSPACE": "~", + "HOME": "/not-my-home", + "USERPROFILE": "/not-my-home" + }, + { + "ci.job.url": "https://github.com/ghactions-repo/commit/ghactions-commit/checks", + "ci.pipeline.id": "ghactions-pipeline-id", + "ci.pipeline.name": "ghactions-pipeline-name", + "ci.pipeline.number": "ghactions-pipeline-number", + "ci.pipeline.url": "https://github.com/ghactions-repo/commit/ghactions-commit/checks", + "ci.provider.name": "github", + "ci.workspace_path": "/not-my-home", + "git.branch": "master", + "git.commit.sha": "ghactions-commit", + "git.commit_sha": "ghactions-commit", + "git.repository_url": "https://github.com/ghactions-repo.git" + } + ], + [ + { + "GITHUB_ACTION": "run", + "GITHUB_REF": "origin/master", + "GITHUB_REPOSITORY": "ghactions-repo", + "GITHUB_RUN_ID": "ghactions-pipeline-id", + "GITHUB_RUN_NUMBER": "ghactions-pipeline-number", + "GITHUB_SHA": "ghactions-commit", + "GITHUB_WORKFLOW": "ghactions-pipeline-name", + "GITHUB_WORKSPACE": "/foo/bar" + }, + { + "ci.job.url": "https://github.com/ghactions-repo/commit/ghactions-commit/checks", + "ci.pipeline.id": "ghactions-pipeline-id", + "ci.pipeline.name": "ghactions-pipeline-name", + "ci.pipeline.number": "ghactions-pipeline-number", + "ci.pipeline.url": "https://github.com/ghactions-repo/commit/ghactions-commit/checks", + "ci.provider.name": "github", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "ghactions-commit", + "git.commit_sha": "ghactions-commit", + "git.repository_url": "https://github.com/ghactions-repo.git" + } + ], + [ + { + "GITHUB_ACTION": "run", + "GITHUB_REF": "refs/heads/master", + "GITHUB_REPOSITORY": "ghactions-repo", + "GITHUB_RUN_ID": "ghactions-pipeline-id", + "GITHUB_RUN_NUMBER": "ghactions-pipeline-number", + "GITHUB_SHA": "ghactions-commit", + "GITHUB_WORKFLOW": "ghactions-pipeline-name", + "GITHUB_WORKSPACE": "/foo/bar" + }, + { + "ci.job.url": "https://github.com/ghactions-repo/commit/ghactions-commit/checks", + "ci.pipeline.id": "ghactions-pipeline-id", + "ci.pipeline.name": "ghactions-pipeline-name", + "ci.pipeline.number": "ghactions-pipeline-number", + "ci.pipeline.url": "https://github.com/ghactions-repo/commit/ghactions-commit/checks", + "ci.provider.name": "github", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "ghactions-commit", + "git.commit_sha": "ghactions-commit", + "git.repository_url": "https://github.com/ghactions-repo.git" + } + ], + [ + { + "GITHUB_ACTION": "run", + "GITHUB_REF": "refs/heads/feature/one", + "GITHUB_REPOSITORY": "ghactions-repo", + "GITHUB_RUN_ID": "ghactions-pipeline-id", + "GITHUB_RUN_NUMBER": "ghactions-pipeline-number", + "GITHUB_SHA": "ghactions-commit", + "GITHUB_WORKFLOW": "ghactions-pipeline-name", + "GITHUB_WORKSPACE": "/foo/bar" + }, + { + "ci.job.url": "https://github.com/ghactions-repo/commit/ghactions-commit/checks", + "ci.pipeline.id": "ghactions-pipeline-id", + "ci.pipeline.name": "ghactions-pipeline-name", + "ci.pipeline.number": "ghactions-pipeline-number", + "ci.pipeline.url": "https://github.com/ghactions-repo/commit/ghactions-commit/checks", + "ci.provider.name": "github", + "ci.workspace_path": "/foo/bar", + "git.branch": "feature/one", + "git.commit.sha": "ghactions-commit", + "git.commit_sha": "ghactions-commit", + "git.repository_url": "https://github.com/ghactions-repo.git" + } + ], + [ + { + "GITHUB_ACTION": "run", + "GITHUB_REF": "origin/tags/0.1.0", + "GITHUB_REPOSITORY": "ghactions-repo", + "GITHUB_RUN_ID": "ghactions-pipeline-id", + "GITHUB_RUN_NUMBER": "ghactions-pipeline-number", + "GITHUB_SHA": "ghactions-commit", + "GITHUB_WORKFLOW": "ghactions-pipeline-name", + "GITHUB_WORKSPACE": "/foo/bar" + }, + { + "ci.job.url": "https://github.com/ghactions-repo/commit/ghactions-commit/checks", + "ci.pipeline.id": "ghactions-pipeline-id", + "ci.pipeline.name": "ghactions-pipeline-name", + "ci.pipeline.number": "ghactions-pipeline-number", + "ci.pipeline.url": "https://github.com/ghactions-repo/commit/ghactions-commit/checks", + "ci.provider.name": "github", + "ci.workspace_path": "/foo/bar", + "git.commit.sha": "ghactions-commit", + "git.commit_sha": "ghactions-commit", + "git.repository_url": "https://github.com/ghactions-repo.git", + "git.tag": "0.1.0" + } + ], + [ + { + "GITHUB_ACTION": "run", + "GITHUB_REF": "refs/heads/tags/0.1.0", + "GITHUB_REPOSITORY": "ghactions-repo", + "GITHUB_RUN_ID": "ghactions-pipeline-id", + "GITHUB_RUN_NUMBER": "ghactions-pipeline-number", + "GITHUB_SHA": "ghactions-commit", + "GITHUB_WORKFLOW": "ghactions-pipeline-name", + "GITHUB_WORKSPACE": "/foo/bar" + }, + { + "ci.job.url": "https://github.com/ghactions-repo/commit/ghactions-commit/checks", + "ci.pipeline.id": "ghactions-pipeline-id", + "ci.pipeline.name": "ghactions-pipeline-name", + "ci.pipeline.number": "ghactions-pipeline-number", + "ci.pipeline.url": "https://github.com/ghactions-repo/commit/ghactions-commit/checks", + "ci.provider.name": "github", + "ci.workspace_path": "/foo/bar", + "git.commit.sha": "ghactions-commit", + "git.commit_sha": "ghactions-commit", + "git.repository_url": "https://github.com/ghactions-repo.git", + "git.tag": "0.1.0" + } + ], + [ + { + "GITHUB_ACTION": "run", + "GITHUB_HEAD_REF": "origin/other", + "GITHUB_REF": "origin/master", + "GITHUB_REPOSITORY": "ghactions-repo", + "GITHUB_RUN_ID": "ghactions-pipeline-id", + "GITHUB_RUN_NUMBER": "ghactions-pipeline-number", + "GITHUB_SHA": "ghactions-commit", + "GITHUB_WORKFLOW": "ghactions-pipeline-name", + "GITHUB_WORKSPACE": "/foo/bar" + }, + { + "ci.job.url": "https://github.com/ghactions-repo/commit/ghactions-commit/checks", + "ci.pipeline.id": "ghactions-pipeline-id", + "ci.pipeline.name": "ghactions-pipeline-name", + "ci.pipeline.number": "ghactions-pipeline-number", + "ci.pipeline.url": "https://github.com/ghactions-repo/commit/ghactions-commit/checks", + "ci.provider.name": "github", + "ci.workspace_path": "/foo/bar", + "git.branch": "other", + "git.commit.sha": "ghactions-commit", + "git.commit_sha": "ghactions-commit", + "git.repository_url": "https://github.com/ghactions-repo.git" + } + ], + [ + { + "GITHUB_ACTION": "run", + "GITHUB_HEAD_REF": "refs/heads/other", + "GITHUB_REF": "refs/heads/master", + "GITHUB_REPOSITORY": "ghactions-repo", + "GITHUB_RUN_ID": "ghactions-pipeline-id", + "GITHUB_RUN_NUMBER": "ghactions-pipeline-number", + "GITHUB_SHA": "ghactions-commit", + "GITHUB_WORKFLOW": "ghactions-pipeline-name", + "GITHUB_WORKSPACE": "/foo/bar" + }, + { + "ci.job.url": "https://github.com/ghactions-repo/commit/ghactions-commit/checks", + "ci.pipeline.id": "ghactions-pipeline-id", + "ci.pipeline.name": "ghactions-pipeline-name", + "ci.pipeline.number": "ghactions-pipeline-number", + "ci.pipeline.url": "https://github.com/ghactions-repo/commit/ghactions-commit/checks", + "ci.provider.name": "github", + "ci.workspace_path": "/foo/bar", + "git.branch": "other", + "git.commit.sha": "ghactions-commit", + "git.commit_sha": "ghactions-commit", + "git.repository_url": "https://github.com/ghactions-repo.git" + } + ], + [ + { + "GITHUB_ACTION": "run", + "GITHUB_HEAD_REF": "refs/heads/feature/other", + "GITHUB_REF": "refs/heads/feature/one", + "GITHUB_REPOSITORY": "ghactions-repo", + "GITHUB_RUN_ID": "ghactions-pipeline-id", + "GITHUB_RUN_NUMBER": "ghactions-pipeline-number", + "GITHUB_SHA": "ghactions-commit", + "GITHUB_WORKFLOW": "ghactions-pipeline-name", + "GITHUB_WORKSPACE": "/foo/bar" + }, + { + "ci.job.url": "https://github.com/ghactions-repo/commit/ghactions-commit/checks", + "ci.pipeline.id": "ghactions-pipeline-id", + "ci.pipeline.name": "ghactions-pipeline-name", + "ci.pipeline.number": "ghactions-pipeline-number", + "ci.pipeline.url": "https://github.com/ghactions-repo/commit/ghactions-commit/checks", + "ci.provider.name": "github", + "ci.workspace_path": "/foo/bar", + "git.branch": "feature/other", + "git.commit.sha": "ghactions-commit", + "git.commit_sha": "ghactions-commit", + "git.repository_url": "https://github.com/ghactions-repo.git" + } + ] +] diff --git a/tests/tracer/fixtures/ci/gitlab.json b/tests/tracer/fixtures/ci/gitlab.json new file mode 100644 index 00000000000..a1980b25a1a --- /dev/null +++ b/tests/tracer/fixtures/ci/gitlab.json @@ -0,0 +1,567 @@ +[ + [ + { + "CI_COMMIT_BRANCH": "origin/master", + "CI_COMMIT_SHA": "gitlab-git-commit", + "CI_JOB_URL": "gitlab-job-url", + "CI_PIPELINE_ID": "gitlab-pipeline-id", + "CI_PIPELINE_IID": "gitlab-pipeline-number", + "CI_PIPELINE_URL": "https://foo/repo/-/pipelines/1234", + "CI_PROJECT_PATH": "gitlab-pipeline-name", + "CI_REPOSITORY_URL": "sample", + "GITLAB_CI": "gitlab" + }, + { + "ci.job.url": "gitlab-job-url", + "ci.pipeline.id": "gitlab-pipeline-id", + "ci.pipeline.name": "gitlab-pipeline-name", + "ci.pipeline.number": "gitlab-pipeline-number", + "ci.pipeline.url": "https://foo/repo/pipelines/1234", + "ci.provider.name": "gitlab", + "git.branch": "master", + "git.commit.sha": "gitlab-git-commit", + "git.commit_sha": "gitlab-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "CI_COMMIT_BRANCH": "origin/master", + "CI_COMMIT_SHA": "gitlab-git-commit", + "CI_JOB_URL": "gitlab-job-url", + "CI_PIPELINE_ID": "gitlab-pipeline-id", + "CI_PIPELINE_IID": "gitlab-pipeline-number", + "CI_PIPELINE_URL": "https://foo/repo/-/pipelines/1234", + "CI_PROJECT_PATH": "gitlab-pipeline-name", + "CI_REPOSITORY_URL": "sample", + "GITLAB_CI": "gitlab" + }, + { + "ci.job.url": "gitlab-job-url", + "ci.pipeline.id": "gitlab-pipeline-id", + "ci.pipeline.name": "gitlab-pipeline-name", + "ci.pipeline.number": "gitlab-pipeline-number", + "ci.pipeline.url": "https://foo/repo/pipelines/1234", + "ci.provider.name": "gitlab", + "git.branch": "master", + "git.commit.sha": "gitlab-git-commit", + "git.commit_sha": "gitlab-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "CI_COMMIT_BRANCH": "origin/master", + "CI_COMMIT_SHA": "gitlab-git-commit", + "CI_JOB_URL": "gitlab-job-url", + "CI_PIPELINE_ID": "gitlab-pipeline-id", + "CI_PIPELINE_IID": "gitlab-pipeline-number", + "CI_PIPELINE_URL": "https://foo/repo/-/pipelines/1234", + "CI_PROJECT_DIR": "foo/bar", + "CI_PROJECT_PATH": "gitlab-pipeline-name", + "CI_REPOSITORY_URL": "sample", + "GITLAB_CI": "gitlab" + }, + { + "ci.job.url": "gitlab-job-url", + "ci.pipeline.id": "gitlab-pipeline-id", + "ci.pipeline.name": "gitlab-pipeline-name", + "ci.pipeline.number": "gitlab-pipeline-number", + "ci.pipeline.url": "https://foo/repo/pipelines/1234", + "ci.provider.name": "gitlab", + "ci.workspace_path": "foo/bar", + "git.branch": "master", + "git.commit.sha": "gitlab-git-commit", + "git.commit_sha": "gitlab-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "CI_COMMIT_BRANCH": "origin/master", + "CI_COMMIT_SHA": "gitlab-git-commit", + "CI_JOB_URL": "gitlab-job-url", + "CI_PIPELINE_ID": "gitlab-pipeline-id", + "CI_PIPELINE_IID": "gitlab-pipeline-number", + "CI_PIPELINE_URL": "https://foo/repo/-/pipelines/1234", + "CI_PROJECT_DIR": "/foo/bar~", + "CI_PROJECT_PATH": "gitlab-pipeline-name", + "CI_REPOSITORY_URL": "sample", + "GITLAB_CI": "gitlab" + }, + { + "ci.job.url": "gitlab-job-url", + "ci.pipeline.id": "gitlab-pipeline-id", + "ci.pipeline.name": "gitlab-pipeline-name", + "ci.pipeline.number": "gitlab-pipeline-number", + "ci.pipeline.url": "https://foo/repo/pipelines/1234", + "ci.provider.name": "gitlab", + "ci.workspace_path": "/foo/bar~", + "git.branch": "master", + "git.commit.sha": "gitlab-git-commit", + "git.commit_sha": "gitlab-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "CI_COMMIT_BRANCH": "origin/master", + "CI_COMMIT_SHA": "gitlab-git-commit", + "CI_JOB_URL": "gitlab-job-url", + "CI_PIPELINE_ID": "gitlab-pipeline-id", + "CI_PIPELINE_IID": "gitlab-pipeline-number", + "CI_PIPELINE_URL": "https://foo/repo/-/pipelines/1234", + "CI_PROJECT_DIR": "/foo/~/bar", + "CI_PROJECT_PATH": "gitlab-pipeline-name", + "CI_REPOSITORY_URL": "sample", + "GITLAB_CI": "gitlab" + }, + { + "ci.job.url": "gitlab-job-url", + "ci.pipeline.id": "gitlab-pipeline-id", + "ci.pipeline.name": "gitlab-pipeline-name", + "ci.pipeline.number": "gitlab-pipeline-number", + "ci.pipeline.url": "https://foo/repo/pipelines/1234", + "ci.provider.name": "gitlab", + "ci.workspace_path": "/foo/~/bar", + "git.branch": "master", + "git.commit.sha": "gitlab-git-commit", + "git.commit_sha": "gitlab-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "CI_COMMIT_BRANCH": "origin/master", + "CI_COMMIT_SHA": "gitlab-git-commit", + "CI_JOB_URL": "gitlab-job-url", + "CI_PIPELINE_ID": "gitlab-pipeline-id", + "CI_PIPELINE_IID": "gitlab-pipeline-number", + "CI_PIPELINE_URL": "https://foo/repo/-/pipelines/1234", + "CI_PROJECT_DIR": "~/foo/bar", + "CI_PROJECT_PATH": "gitlab-pipeline-name", + "CI_REPOSITORY_URL": "sample", + "GITLAB_CI": "gitlab", + "HOME": "/not-my-home", + "USERPROFILE": "/not-my-home" + }, + { + "ci.job.url": "gitlab-job-url", + "ci.pipeline.id": "gitlab-pipeline-id", + "ci.pipeline.name": "gitlab-pipeline-name", + "ci.pipeline.number": "gitlab-pipeline-number", + "ci.pipeline.url": "https://foo/repo/pipelines/1234", + "ci.provider.name": "gitlab", + "ci.workspace_path": "/not-my-home/foo/bar", + "git.branch": "master", + "git.commit.sha": "gitlab-git-commit", + "git.commit_sha": "gitlab-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "CI_COMMIT_BRANCH": "origin/master", + "CI_COMMIT_SHA": "gitlab-git-commit", + "CI_JOB_URL": "gitlab-job-url", + "CI_PIPELINE_ID": "gitlab-pipeline-id", + "CI_PIPELINE_IID": "gitlab-pipeline-number", + "CI_PIPELINE_URL": "https://foo/repo/-/pipelines/1234", + "CI_PROJECT_DIR": "~foo/bar", + "CI_PROJECT_PATH": "gitlab-pipeline-name", + "CI_REPOSITORY_URL": "sample", + "GITLAB_CI": "gitlab", + "HOME": "/not-my-home", + "USERPROFILE": "/not-my-home" + }, + { + "ci.job.url": "gitlab-job-url", + "ci.pipeline.id": "gitlab-pipeline-id", + "ci.pipeline.name": "gitlab-pipeline-name", + "ci.pipeline.number": "gitlab-pipeline-number", + "ci.pipeline.url": "https://foo/repo/pipelines/1234", + "ci.provider.name": "gitlab", + "ci.workspace_path": "~foo/bar", + "git.branch": "master", + "git.commit.sha": "gitlab-git-commit", + "git.commit_sha": "gitlab-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "CI_COMMIT_BRANCH": "origin/master", + "CI_COMMIT_SHA": "gitlab-git-commit", + "CI_JOB_URL": "gitlab-job-url", + "CI_PIPELINE_ID": "gitlab-pipeline-id", + "CI_PIPELINE_IID": "gitlab-pipeline-number", + "CI_PIPELINE_URL": "https://foo/repo/-/pipelines/1234", + "CI_PROJECT_DIR": "~", + "CI_PROJECT_PATH": "gitlab-pipeline-name", + "CI_REPOSITORY_URL": "sample", + "GITLAB_CI": "gitlab", + "HOME": "/not-my-home", + "USERPROFILE": "/not-my-home" + }, + { + "ci.job.url": "gitlab-job-url", + "ci.pipeline.id": "gitlab-pipeline-id", + "ci.pipeline.name": "gitlab-pipeline-name", + "ci.pipeline.number": "gitlab-pipeline-number", + "ci.pipeline.url": "https://foo/repo/pipelines/1234", + "ci.provider.name": "gitlab", + "ci.workspace_path": "/not-my-home", + "git.branch": "master", + "git.commit.sha": "gitlab-git-commit", + "git.commit_sha": "gitlab-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "CI_COMMIT_BRANCH": "origin/master", + "CI_COMMIT_SHA": "gitlab-git-commit", + "CI_JOB_URL": "gitlab-job-url", + "CI_PIPELINE_ID": "gitlab-pipeline-id", + "CI_PIPELINE_IID": "gitlab-pipeline-number", + "CI_PIPELINE_URL": "https://foo/repo/-/pipelines/1234", + "CI_PROJECT_DIR": "/foo/bar", + "CI_PROJECT_PATH": "gitlab-pipeline-name", + "CI_REPOSITORY_URL": "sample", + "GITLAB_CI": "gitlab" + }, + { + "ci.job.url": "gitlab-job-url", + "ci.pipeline.id": "gitlab-pipeline-id", + "ci.pipeline.name": "gitlab-pipeline-name", + "ci.pipeline.number": "gitlab-pipeline-number", + "ci.pipeline.url": "https://foo/repo/pipelines/1234", + "ci.provider.name": "gitlab", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "gitlab-git-commit", + "git.commit_sha": "gitlab-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "CI_COMMIT_BRANCH": "origin/master", + "CI_COMMIT_SHA": "gitlab-git-commit", + "CI_JOB_URL": "gitlab-job-url", + "CI_PIPELINE_ID": "gitlab-pipeline-id", + "CI_PIPELINE_IID": "gitlab-pipeline-number", + "CI_PROJECT_DIR": "/foo/bar", + "CI_PROJECT_PATH": "gitlab-pipeline-name", + "CI_REPOSITORY_URL": "sample", + "GITLAB_CI": "gitlab" + }, + { + "ci.job.url": "gitlab-job-url", + "ci.pipeline.id": "gitlab-pipeline-id", + "ci.pipeline.name": "gitlab-pipeline-name", + "ci.pipeline.number": "gitlab-pipeline-number", + "ci.provider.name": "gitlab", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "gitlab-git-commit", + "git.commit_sha": "gitlab-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "CI_COMMIT_BRANCH": "origin/master", + "CI_COMMIT_SHA": "gitlab-git-commit", + "CI_JOB_URL": "gitlab-job-url", + "CI_PIPELINE_ID": "gitlab-pipeline-id", + "CI_PIPELINE_IID": "gitlab-pipeline-number", + "CI_PROJECT_DIR": "/foo/bar", + "CI_PROJECT_PATH": "gitlab-pipeline-name", + "CI_REPOSITORY_URL": "sample", + "GITLAB_CI": "gitlab" + }, + { + "ci.job.url": "gitlab-job-url", + "ci.pipeline.id": "gitlab-pipeline-id", + "ci.pipeline.name": "gitlab-pipeline-name", + "ci.pipeline.number": "gitlab-pipeline-number", + "ci.provider.name": "gitlab", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "gitlab-git-commit", + "git.commit_sha": "gitlab-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "CI_COMMIT_BRANCH": "refs/heads/master", + "CI_COMMIT_SHA": "gitlab-git-commit", + "CI_JOB_URL": "gitlab-job-url", + "CI_PIPELINE_ID": "gitlab-pipeline-id", + "CI_PIPELINE_IID": "gitlab-pipeline-number", + "CI_PIPELINE_URL": "https://foo/repo/-/pipelines/1234", + "CI_PROJECT_DIR": "/foo/bar", + "CI_PROJECT_PATH": "gitlab-pipeline-name", + "CI_REPOSITORY_URL": "sample", + "GITLAB_CI": "gitlab" + }, + { + "ci.job.url": "gitlab-job-url", + "ci.pipeline.id": "gitlab-pipeline-id", + "ci.pipeline.name": "gitlab-pipeline-name", + "ci.pipeline.number": "gitlab-pipeline-number", + "ci.pipeline.url": "https://foo/repo/pipelines/1234", + "ci.provider.name": "gitlab", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "gitlab-git-commit", + "git.commit_sha": "gitlab-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "CI_COMMIT_BRANCH": "refs/heads/feature/one", + "CI_COMMIT_SHA": "gitlab-git-commit", + "CI_JOB_URL": "gitlab-job-url", + "CI_PIPELINE_ID": "gitlab-pipeline-id", + "CI_PIPELINE_IID": "gitlab-pipeline-number", + "CI_PIPELINE_URL": "https://foo/repo/-/pipelines/1234", + "CI_PROJECT_DIR": "/foo/bar", + "CI_PROJECT_PATH": "gitlab-pipeline-name", + "CI_REPOSITORY_URL": "sample", + "GITLAB_CI": "gitlab" + }, + { + "ci.job.url": "gitlab-job-url", + "ci.pipeline.id": "gitlab-pipeline-id", + "ci.pipeline.name": "gitlab-pipeline-name", + "ci.pipeline.number": "gitlab-pipeline-number", + "ci.pipeline.url": "https://foo/repo/pipelines/1234", + "ci.provider.name": "gitlab", + "ci.workspace_path": "/foo/bar", + "git.branch": "feature/one", + "git.commit.sha": "gitlab-git-commit", + "git.commit_sha": "gitlab-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "CI_COMMIT_SHA": "gitlab-git-commit", + "CI_COMMIT_TAG": "origin/tags/0.1.0", + "CI_JOB_URL": "gitlab-job-url", + "CI_PIPELINE_ID": "gitlab-pipeline-id", + "CI_PIPELINE_IID": "gitlab-pipeline-number", + "CI_PIPELINE_URL": "https://foo/repo/-/pipelines/1234", + "CI_PROJECT_DIR": "/foo/bar", + "CI_PROJECT_PATH": "gitlab-pipeline-name", + "CI_REPOSITORY_URL": "sample", + "GITLAB_CI": "gitlab" + }, + { + "ci.job.url": "gitlab-job-url", + "ci.pipeline.id": "gitlab-pipeline-id", + "ci.pipeline.name": "gitlab-pipeline-name", + "ci.pipeline.number": "gitlab-pipeline-number", + "ci.pipeline.url": "https://foo/repo/pipelines/1234", + "ci.provider.name": "gitlab", + "ci.workspace_path": "/foo/bar", + "git.commit.sha": "gitlab-git-commit", + "git.commit_sha": "gitlab-git-commit", + "git.repository_url": "sample", + "git.tag": "0.1.0" + } + ], + [ + { + "CI_COMMIT_SHA": "gitlab-git-commit", + "CI_COMMIT_TAG": "refs/heads/tags/0.1.0", + "CI_JOB_URL": "gitlab-job-url", + "CI_PIPELINE_ID": "gitlab-pipeline-id", + "CI_PIPELINE_IID": "gitlab-pipeline-number", + "CI_PIPELINE_URL": "https://foo/repo/-/pipelines/1234", + "CI_PROJECT_DIR": "/foo/bar", + "CI_PROJECT_PATH": "gitlab-pipeline-name", + "CI_REPOSITORY_URL": "sample", + "GITLAB_CI": "gitlab" + }, + { + "ci.job.url": "gitlab-job-url", + "ci.pipeline.id": "gitlab-pipeline-id", + "ci.pipeline.name": "gitlab-pipeline-name", + "ci.pipeline.number": "gitlab-pipeline-number", + "ci.pipeline.url": "https://foo/repo/pipelines/1234", + "ci.provider.name": "gitlab", + "ci.workspace_path": "/foo/bar", + "git.commit.sha": "gitlab-git-commit", + "git.commit_sha": "gitlab-git-commit", + "git.repository_url": "sample", + "git.tag": "0.1.0" + } + ], + [ + { + "CI_COMMIT_SHA": "gitlab-git-commit", + "CI_COMMIT_TAG": "0.1.0", + "CI_JOB_URL": "gitlab-job-url", + "CI_PIPELINE_ID": "gitlab-pipeline-id", + "CI_PIPELINE_IID": "gitlab-pipeline-number", + "CI_PIPELINE_URL": "https://foo/repo/-/pipelines/1234", + "CI_PROJECT_DIR": "/foo/bar", + "CI_PROJECT_PATH": "gitlab-pipeline-name", + "CI_REPOSITORY_URL": "sample", + "GITLAB_CI": "gitlab" + }, + { + "ci.job.url": "gitlab-job-url", + "ci.pipeline.id": "gitlab-pipeline-id", + "ci.pipeline.name": "gitlab-pipeline-name", + "ci.pipeline.number": "gitlab-pipeline-number", + "ci.pipeline.url": "https://foo/repo/pipelines/1234", + "ci.provider.name": "gitlab", + "ci.workspace_path": "/foo/bar", + "git.commit.sha": "gitlab-git-commit", + "git.commit_sha": "gitlab-git-commit", + "git.repository_url": "sample", + "git.tag": "0.1.0" + } + ], + [ + { + "CI_COMMIT_BRANCH": "origin/master", + "CI_COMMIT_SHA": "gitlab-git-commit", + "CI_JOB_URL": "gitlab-job-url", + "CI_PIPELINE_ID": "gitlab-pipeline-id", + "CI_PIPELINE_IID": "gitlab-pipeline-number", + "CI_PIPELINE_URL": "https://foo/repo/-/pipelines/1234", + "CI_PROJECT_DIR": "/foo/bar", + "CI_PROJECT_PATH": "gitlab-pipeline-name", + "CI_REPOSITORY_URL": "http://hostname.com/repo.git", + "GITLAB_CI": "gitlab" + }, + { + "ci.job.url": "gitlab-job-url", + "ci.pipeline.id": "gitlab-pipeline-id", + "ci.pipeline.name": "gitlab-pipeline-name", + "ci.pipeline.number": "gitlab-pipeline-number", + "ci.pipeline.url": "https://foo/repo/pipelines/1234", + "ci.provider.name": "gitlab", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "gitlab-git-commit", + "git.commit_sha": "gitlab-git-commit", + "git.repository_url": "http://hostname.com/repo.git" + } + ], + [ + { + "CI_COMMIT_BRANCH": "origin/master", + "CI_COMMIT_SHA": "gitlab-git-commit", + "CI_JOB_URL": "gitlab-job-url", + "CI_PIPELINE_ID": "gitlab-pipeline-id", + "CI_PIPELINE_IID": "gitlab-pipeline-number", + "CI_PIPELINE_URL": "https://foo/repo/-/pipelines/1234", + "CI_PROJECT_DIR": "/foo/bar", + "CI_PROJECT_PATH": "gitlab-pipeline-name", + "CI_REPOSITORY_URL": "http://user@hostname.com/repo.git", + "GITLAB_CI": "gitlab" + }, + { + "ci.job.url": "gitlab-job-url", + "ci.pipeline.id": "gitlab-pipeline-id", + "ci.pipeline.name": "gitlab-pipeline-name", + "ci.pipeline.number": "gitlab-pipeline-number", + "ci.pipeline.url": "https://foo/repo/pipelines/1234", + "ci.provider.name": "gitlab", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "gitlab-git-commit", + "git.commit_sha": "gitlab-git-commit", + "git.repository_url": "http://hostname.com/repo.git" + } + ], + [ + { + "CI_COMMIT_BRANCH": "origin/master", + "CI_COMMIT_SHA": "gitlab-git-commit", + "CI_JOB_URL": "gitlab-job-url", + "CI_PIPELINE_ID": "gitlab-pipeline-id", + "CI_PIPELINE_IID": "gitlab-pipeline-number", + "CI_PIPELINE_URL": "https://foo/repo/-/pipelines/1234", + "CI_PROJECT_DIR": "/foo/bar", + "CI_PROJECT_PATH": "gitlab-pipeline-name", + "CI_REPOSITORY_URL": "http://user%E2%82%AC@hostname.com/repo.git", + "GITLAB_CI": "gitlab" + }, + { + "ci.job.url": "gitlab-job-url", + "ci.pipeline.id": "gitlab-pipeline-id", + "ci.pipeline.name": "gitlab-pipeline-name", + "ci.pipeline.number": "gitlab-pipeline-number", + "ci.pipeline.url": "https://foo/repo/pipelines/1234", + "ci.provider.name": "gitlab", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "gitlab-git-commit", + "git.commit_sha": "gitlab-git-commit", + "git.repository_url": "http://hostname.com/repo.git" + } + ], + [ + { + "CI_COMMIT_BRANCH": "origin/master", + "CI_COMMIT_SHA": "gitlab-git-commit", + "CI_JOB_URL": "gitlab-job-url", + "CI_PIPELINE_ID": "gitlab-pipeline-id", + "CI_PIPELINE_IID": "gitlab-pipeline-number", + "CI_PIPELINE_URL": "https://foo/repo/-/pipelines/1234", + "CI_PROJECT_DIR": "/foo/bar", + "CI_PROJECT_PATH": "gitlab-pipeline-name", + "CI_REPOSITORY_URL": "http://user:pwd@hostname.com/repo.git", + "GITLAB_CI": "gitlab" + }, + { + "ci.job.url": "gitlab-job-url", + "ci.pipeline.id": "gitlab-pipeline-id", + "ci.pipeline.name": "gitlab-pipeline-name", + "ci.pipeline.number": "gitlab-pipeline-number", + "ci.pipeline.url": "https://foo/repo/pipelines/1234", + "ci.provider.name": "gitlab", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "gitlab-git-commit", + "git.commit_sha": "gitlab-git-commit", + "git.repository_url": "http://hostname.com/repo.git" + } + ], + [ + { + "CI_COMMIT_BRANCH": "origin/master", + "CI_COMMIT_SHA": "gitlab-git-commit", + "CI_JOB_URL": "gitlab-job-url", + "CI_PIPELINE_ID": "gitlab-pipeline-id", + "CI_PIPELINE_IID": "gitlab-pipeline-number", + "CI_PIPELINE_URL": "https://foo/repo/-/pipelines/1234", + "CI_PROJECT_DIR": "/foo/bar", + "CI_PROJECT_PATH": "gitlab-pipeline-name", + "CI_REPOSITORY_URL": "git@hostname.com:org/repo.git", + "GITLAB_CI": "gitlab" + }, + { + "ci.job.url": "gitlab-job-url", + "ci.pipeline.id": "gitlab-pipeline-id", + "ci.pipeline.name": "gitlab-pipeline-name", + "ci.pipeline.number": "gitlab-pipeline-number", + "ci.pipeline.url": "https://foo/repo/pipelines/1234", + "ci.provider.name": "gitlab", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "gitlab-git-commit", + "git.commit_sha": "gitlab-git-commit", + "git.repository_url": "git@hostname.com:org/repo.git" + } + ] +] diff --git a/tests/tracer/fixtures/ci/jenkins.json b/tests/tracer/fixtures/ci/jenkins.json new file mode 100644 index 00000000000..323da4ce08c --- /dev/null +++ b/tests/tracer/fixtures/ci/jenkins.json @@ -0,0 +1,594 @@ +[ + [ + { + "BUILD_NUMBER": "jenkins-pipeline-number", + "BUILD_TAG": "jenkins-pipeline-id", + "BUILD_URL": "jenkins-pipeline-url", + "GIT_BRANCH": "origin/master", + "GIT_COMMIT": "jenkins-git-commit", + "GIT_URL": "sample", + "JENKINS_URL": "jenkins", + "JOB_NAME": "jobName", + "JOB_URL": "jenkins-job-url" + }, + { + "ci.job.url": "jenkins-job-url", + "ci.pipeline.id": "jenkins-pipeline-id", + "ci.pipeline.name": "jobName", + "ci.pipeline.number": "jenkins-pipeline-number", + "ci.pipeline.url": "jenkins-pipeline-url", + "ci.provider.name": "jenkins", + "git.branch": "master", + "git.commit.sha": "jenkins-git-commit", + "git.commit_sha": "jenkins-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "BUILD_NUMBER": "jenkins-pipeline-number", + "BUILD_TAG": "jenkins-pipeline-id", + "BUILD_URL": "jenkins-pipeline-url", + "GIT_BRANCH": "origin/master", + "GIT_COMMIT": "jenkins-git-commit", + "GIT_URL": "sample", + "JENKINS_URL": "jenkins", + "JOB_NAME": "jobName", + "JOB_URL": "jenkins-job-url" + }, + { + "ci.job.url": "jenkins-job-url", + "ci.pipeline.id": "jenkins-pipeline-id", + "ci.pipeline.name": "jobName", + "ci.pipeline.number": "jenkins-pipeline-number", + "ci.pipeline.url": "jenkins-pipeline-url", + "ci.provider.name": "jenkins", + "git.branch": "master", + "git.commit.sha": "jenkins-git-commit", + "git.commit_sha": "jenkins-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "BUILD_NUMBER": "jenkins-pipeline-number", + "BUILD_TAG": "jenkins-pipeline-id", + "BUILD_URL": "jenkins-pipeline-url", + "GIT_BRANCH": "origin/master", + "GIT_COMMIT": "jenkins-git-commit", + "GIT_URL": "sample", + "JENKINS_URL": "jenkins", + "JOB_NAME": "jobName", + "JOB_URL": "jenkins-job-url", + "WORKSPACE": "foo/bar" + }, + { + "ci.job.url": "jenkins-job-url", + "ci.pipeline.id": "jenkins-pipeline-id", + "ci.pipeline.name": "jobName", + "ci.pipeline.number": "jenkins-pipeline-number", + "ci.pipeline.url": "jenkins-pipeline-url", + "ci.provider.name": "jenkins", + "ci.workspace_path": "foo/bar", + "git.branch": "master", + "git.commit.sha": "jenkins-git-commit", + "git.commit_sha": "jenkins-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "BUILD_NUMBER": "jenkins-pipeline-number", + "BUILD_TAG": "jenkins-pipeline-id", + "BUILD_URL": "jenkins-pipeline-url", + "GIT_BRANCH": "origin/master", + "GIT_COMMIT": "jenkins-git-commit", + "GIT_URL": "sample", + "JENKINS_URL": "jenkins", + "JOB_NAME": "jobName", + "JOB_URL": "jenkins-job-url", + "WORKSPACE": "/foo/bar~" + }, + { + "ci.job.url": "jenkins-job-url", + "ci.pipeline.id": "jenkins-pipeline-id", + "ci.pipeline.name": "jobName", + "ci.pipeline.number": "jenkins-pipeline-number", + "ci.pipeline.url": "jenkins-pipeline-url", + "ci.provider.name": "jenkins", + "ci.workspace_path": "/foo/bar~", + "git.branch": "master", + "git.commit.sha": "jenkins-git-commit", + "git.commit_sha": "jenkins-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "BUILD_NUMBER": "jenkins-pipeline-number", + "BUILD_TAG": "jenkins-pipeline-id", + "BUILD_URL": "jenkins-pipeline-url", + "GIT_BRANCH": "origin/master", + "GIT_COMMIT": "jenkins-git-commit", + "GIT_URL": "sample", + "JENKINS_URL": "jenkins", + "JOB_NAME": "jobName", + "JOB_URL": "jenkins-job-url", + "WORKSPACE": "/foo/~/bar" + }, + { + "ci.job.url": "jenkins-job-url", + "ci.pipeline.id": "jenkins-pipeline-id", + "ci.pipeline.name": "jobName", + "ci.pipeline.number": "jenkins-pipeline-number", + "ci.pipeline.url": "jenkins-pipeline-url", + "ci.provider.name": "jenkins", + "ci.workspace_path": "/foo/~/bar", + "git.branch": "master", + "git.commit.sha": "jenkins-git-commit", + "git.commit_sha": "jenkins-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "BUILD_NUMBER": "jenkins-pipeline-number", + "BUILD_TAG": "jenkins-pipeline-id", + "BUILD_URL": "jenkins-pipeline-url", + "GIT_BRANCH": "origin/master", + "GIT_COMMIT": "jenkins-git-commit", + "GIT_URL": "sample", + "HOME": "/not-my-home", + "JENKINS_URL": "jenkins", + "JOB_NAME": "jobName", + "JOB_URL": "jenkins-job-url", + "USERPROFILE": "/not-my-home", + "WORKSPACE": "~/foo/bar" + }, + { + "ci.job.url": "jenkins-job-url", + "ci.pipeline.id": "jenkins-pipeline-id", + "ci.pipeline.name": "jobName", + "ci.pipeline.number": "jenkins-pipeline-number", + "ci.pipeline.url": "jenkins-pipeline-url", + "ci.provider.name": "jenkins", + "ci.workspace_path": "/not-my-home/foo/bar", + "git.branch": "master", + "git.commit.sha": "jenkins-git-commit", + "git.commit_sha": "jenkins-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "BUILD_NUMBER": "jenkins-pipeline-number", + "BUILD_TAG": "jenkins-pipeline-id", + "BUILD_URL": "jenkins-pipeline-url", + "GIT_BRANCH": "origin/master", + "GIT_COMMIT": "jenkins-git-commit", + "GIT_URL": "sample", + "HOME": "/not-my-home", + "JENKINS_URL": "jenkins", + "JOB_NAME": "jobName", + "JOB_URL": "jenkins-job-url", + "USERPROFILE": "/not-my-home", + "WORKSPACE": "~foo/bar" + }, + { + "ci.job.url": "jenkins-job-url", + "ci.pipeline.id": "jenkins-pipeline-id", + "ci.pipeline.name": "jobName", + "ci.pipeline.number": "jenkins-pipeline-number", + "ci.pipeline.url": "jenkins-pipeline-url", + "ci.provider.name": "jenkins", + "ci.workspace_path": "~foo/bar", + "git.branch": "master", + "git.commit.sha": "jenkins-git-commit", + "git.commit_sha": "jenkins-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "BUILD_NUMBER": "jenkins-pipeline-number", + "BUILD_TAG": "jenkins-pipeline-id", + "BUILD_URL": "jenkins-pipeline-url", + "GIT_BRANCH": "origin/master", + "GIT_COMMIT": "jenkins-git-commit", + "GIT_URL": "sample", + "HOME": "/not-my-home", + "JENKINS_URL": "jenkins", + "JOB_NAME": "jobName", + "JOB_URL": "jenkins-job-url", + "USERPROFILE": "/not-my-home", + "WORKSPACE": "~" + }, + { + "ci.job.url": "jenkins-job-url", + "ci.pipeline.id": "jenkins-pipeline-id", + "ci.pipeline.name": "jobName", + "ci.pipeline.number": "jenkins-pipeline-number", + "ci.pipeline.url": "jenkins-pipeline-url", + "ci.provider.name": "jenkins", + "ci.workspace_path": "/not-my-home", + "git.branch": "master", + "git.commit.sha": "jenkins-git-commit", + "git.commit_sha": "jenkins-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "BUILD_NUMBER": "jenkins-pipeline-number", + "BUILD_TAG": "jenkins-pipeline-id", + "BUILD_URL": "jenkins-pipeline-url", + "GIT_BRANCH": "origin/master", + "GIT_COMMIT": "jenkins-git-commit", + "GIT_URL": "sample", + "JENKINS_URL": "jenkins", + "JOB_NAME": "jobName", + "JOB_URL": "jenkins-job-url", + "WORKSPACE": "/foo/bar" + }, + { + "ci.job.url": "jenkins-job-url", + "ci.pipeline.id": "jenkins-pipeline-id", + "ci.pipeline.name": "jobName", + "ci.pipeline.number": "jenkins-pipeline-number", + "ci.pipeline.url": "jenkins-pipeline-url", + "ci.provider.name": "jenkins", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "jenkins-git-commit", + "git.commit_sha": "jenkins-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "BUILD_NUMBER": "jenkins-pipeline-number", + "BUILD_TAG": "jenkins-pipeline-id", + "BUILD_URL": "jenkins-pipeline-url", + "GIT_BRANCH": "refs/heads/master", + "GIT_COMMIT": "jenkins-git-commit", + "GIT_URL": "sample", + "JENKINS_URL": "jenkins", + "JOB_NAME": "jobName/master", + "JOB_URL": "jenkins-job-url", + "WORKSPACE": "/foo/bar" + }, + { + "ci.job.url": "jenkins-job-url", + "ci.pipeline.id": "jenkins-pipeline-id", + "ci.pipeline.name": "jobName", + "ci.pipeline.number": "jenkins-pipeline-number", + "ci.pipeline.url": "jenkins-pipeline-url", + "ci.provider.name": "jenkins", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "jenkins-git-commit", + "git.commit_sha": "jenkins-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "BUILD_NUMBER": "jenkins-pipeline-number", + "BUILD_TAG": "jenkins-pipeline-id", + "BUILD_URL": "jenkins-pipeline-url", + "GIT_BRANCH": "refs/heads/master", + "GIT_COMMIT": "jenkins-git-commit", + "GIT_URL": "sample", + "JENKINS_URL": "jenkins", + "JOB_NAME": "jobName/another", + "JOB_URL": "jenkins-job-url", + "WORKSPACE": "/foo/bar" + }, + { + "ci.job.url": "jenkins-job-url", + "ci.pipeline.id": "jenkins-pipeline-id", + "ci.pipeline.name": "jobName/another", + "ci.pipeline.number": "jenkins-pipeline-number", + "ci.pipeline.url": "jenkins-pipeline-url", + "ci.provider.name": "jenkins", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "jenkins-git-commit", + "git.commit_sha": "jenkins-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "BUILD_NUMBER": "jenkins-pipeline-number", + "BUILD_TAG": "jenkins-pipeline-id", + "BUILD_URL": "jenkins-pipeline-url", + "GIT_BRANCH": "refs/heads/feature/one", + "GIT_COMMIT": "jenkins-git-commit", + "GIT_URL": "sample", + "JENKINS_URL": "jenkins", + "JOB_NAME": "jobName/feature/one", + "JOB_URL": "jenkins-job-url", + "WORKSPACE": "/foo/bar" + }, + { + "ci.job.url": "jenkins-job-url", + "ci.pipeline.id": "jenkins-pipeline-id", + "ci.pipeline.name": "jobName", + "ci.pipeline.number": "jenkins-pipeline-number", + "ci.pipeline.url": "jenkins-pipeline-url", + "ci.provider.name": "jenkins", + "ci.workspace_path": "/foo/bar", + "git.branch": "feature/one", + "git.commit.sha": "jenkins-git-commit", + "git.commit_sha": "jenkins-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "BUILD_NUMBER": "jenkins-pipeline-number", + "BUILD_TAG": "jenkins-pipeline-id", + "BUILD_URL": "jenkins-pipeline-url", + "GIT_BRANCH": "refs/heads/master", + "GIT_COMMIT": "jenkins-git-commit", + "GIT_URL": "sample", + "JENKINS_URL": "jenkins", + "JOB_NAME": "jobName/KEY1=VALUE1,KEY2=VALUE2", + "JOB_URL": "jenkins-job-url", + "WORKSPACE": "/foo/bar" + }, + { + "ci.job.url": "jenkins-job-url", + "ci.pipeline.id": "jenkins-pipeline-id", + "ci.pipeline.name": "jobName", + "ci.pipeline.number": "jenkins-pipeline-number", + "ci.pipeline.url": "jenkins-pipeline-url", + "ci.provider.name": "jenkins", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "jenkins-git-commit", + "git.commit_sha": "jenkins-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "BUILD_NUMBER": "jenkins-pipeline-number", + "BUILD_TAG": "jenkins-pipeline-id", + "BUILD_URL": "jenkins-pipeline-url", + "GIT_BRANCH": "refs/heads/master", + "GIT_COMMIT": "jenkins-git-commit", + "GIT_URL": "sample", + "JENKINS_URL": "jenkins", + "JOB_NAME": "jobName/KEY1=VALUE1,KEY2=VALUE2/master", + "JOB_URL": "jenkins-job-url", + "WORKSPACE": "/foo/bar" + }, + { + "ci.job.url": "jenkins-job-url", + "ci.pipeline.id": "jenkins-pipeline-id", + "ci.pipeline.name": "jobName", + "ci.pipeline.number": "jenkins-pipeline-number", + "ci.pipeline.url": "jenkins-pipeline-url", + "ci.provider.name": "jenkins", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "jenkins-git-commit", + "git.commit_sha": "jenkins-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "BUILD_NUMBER": "jenkins-pipeline-number", + "BUILD_TAG": "jenkins-pipeline-id", + "BUILD_URL": "jenkins-pipeline-url", + "GIT_BRANCH": "refs/heads/master", + "GIT_COMMIT": "jenkins-git-commit", + "GIT_URL": "sample", + "JENKINS_URL": "jenkins", + "JOB_NAME": "jobName/KEY1=VALUE1,KEY2=VALUE2/another-branch", + "JOB_URL": "jenkins-job-url", + "WORKSPACE": "/foo/bar" + }, + { + "ci.job.url": "jenkins-job-url", + "ci.pipeline.id": "jenkins-pipeline-id", + "ci.pipeline.name": "jobName/another-branch", + "ci.pipeline.number": "jenkins-pipeline-number", + "ci.pipeline.url": "jenkins-pipeline-url", + "ci.provider.name": "jenkins", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "jenkins-git-commit", + "git.commit_sha": "jenkins-git-commit", + "git.repository_url": "sample" + } + ], + [ + { + "BUILD_NUMBER": "jenkins-pipeline-number", + "BUILD_TAG": "jenkins-pipeline-id", + "BUILD_URL": "jenkins-pipeline-url", + "GIT_BRANCH": "origin/tags/0.1.0", + "GIT_COMMIT": "jenkins-git-commit", + "GIT_URL": "sample", + "JENKINS_URL": "jenkins", + "JOB_URL": "jenkins-job-url", + "WORKSPACE": "/foo/bar" + }, + { + "ci.job.url": "jenkins-job-url", + "ci.pipeline.id": "jenkins-pipeline-id", + "ci.pipeline.number": "jenkins-pipeline-number", + "ci.pipeline.url": "jenkins-pipeline-url", + "ci.provider.name": "jenkins", + "ci.workspace_path": "/foo/bar", + "git.commit.sha": "jenkins-git-commit", + "git.commit_sha": "jenkins-git-commit", + "git.repository_url": "sample", + "git.tag": "0.1.0" + } + ], + [ + { + "BUILD_NUMBER": "jenkins-pipeline-number", + "BUILD_TAG": "jenkins-pipeline-id", + "BUILD_URL": "jenkins-pipeline-url", + "GIT_BRANCH": "refs/heads/tags/0.1.0", + "GIT_COMMIT": "jenkins-git-commit", + "GIT_URL": "sample", + "JENKINS_URL": "jenkins", + "JOB_URL": "jenkins-job-url", + "WORKSPACE": "/foo/bar" + }, + { + "ci.job.url": "jenkins-job-url", + "ci.pipeline.id": "jenkins-pipeline-id", + "ci.pipeline.number": "jenkins-pipeline-number", + "ci.pipeline.url": "jenkins-pipeline-url", + "ci.provider.name": "jenkins", + "ci.workspace_path": "/foo/bar", + "git.commit.sha": "jenkins-git-commit", + "git.commit_sha": "jenkins-git-commit", + "git.repository_url": "sample", + "git.tag": "0.1.0" + } + ], + [ + { + "BUILD_NUMBER": "jenkins-pipeline-number", + "BUILD_TAG": "jenkins-pipeline-id", + "BUILD_URL": "jenkins-pipeline-url", + "GIT_BRANCH": "origin/master", + "GIT_COMMIT": "jenkins-git-commit", + "GIT_URL": "http://hostname.com/repo.git", + "JENKINS_URL": "jenkins", + "JOB_NAME": "jobName", + "JOB_URL": "jenkins-job-url", + "WORKSPACE": "/foo/bar" + }, + { + "ci.job.url": "jenkins-job-url", + "ci.pipeline.id": "jenkins-pipeline-id", + "ci.pipeline.name": "jobName", + "ci.pipeline.number": "jenkins-pipeline-number", + "ci.pipeline.url": "jenkins-pipeline-url", + "ci.provider.name": "jenkins", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "jenkins-git-commit", + "git.commit_sha": "jenkins-git-commit", + "git.repository_url": "http://hostname.com/repo.git" + } + ], + [ + { + "BUILD_NUMBER": "jenkins-pipeline-number", + "BUILD_TAG": "jenkins-pipeline-id", + "BUILD_URL": "jenkins-pipeline-url", + "GIT_BRANCH": "origin/master", + "GIT_COMMIT": "jenkins-git-commit", + "GIT_URL": "http://user@hostname.com/repo.git", + "JENKINS_URL": "jenkins", + "JOB_NAME": "jobName", + "JOB_URL": "jenkins-job-url", + "WORKSPACE": "/foo/bar" + }, + { + "ci.job.url": "jenkins-job-url", + "ci.pipeline.id": "jenkins-pipeline-id", + "ci.pipeline.name": "jobName", + "ci.pipeline.number": "jenkins-pipeline-number", + "ci.pipeline.url": "jenkins-pipeline-url", + "ci.provider.name": "jenkins", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "jenkins-git-commit", + "git.commit_sha": "jenkins-git-commit", + "git.repository_url": "http://hostname.com/repo.git" + } + ], + [ + { + "BUILD_NUMBER": "jenkins-pipeline-number", + "BUILD_TAG": "jenkins-pipeline-id", + "BUILD_URL": "jenkins-pipeline-url", + "GIT_BRANCH": "origin/master", + "GIT_COMMIT": "jenkins-git-commit", + "GIT_URL": "http://user%E2%82%AC@hostname.com/repo.git", + "JENKINS_URL": "jenkins", + "JOB_NAME": "jobName", + "JOB_URL": "jenkins-job-url", + "WORKSPACE": "/foo/bar" + }, + { + "ci.job.url": "jenkins-job-url", + "ci.pipeline.id": "jenkins-pipeline-id", + "ci.pipeline.name": "jobName", + "ci.pipeline.number": "jenkins-pipeline-number", + "ci.pipeline.url": "jenkins-pipeline-url", + "ci.provider.name": "jenkins", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "jenkins-git-commit", + "git.commit_sha": "jenkins-git-commit", + "git.repository_url": "http://hostname.com/repo.git" + } + ], + [ + { + "BUILD_NUMBER": "jenkins-pipeline-number", + "BUILD_TAG": "jenkins-pipeline-id", + "BUILD_URL": "jenkins-pipeline-url", + "GIT_BRANCH": "origin/master", + "GIT_COMMIT": "jenkins-git-commit", + "GIT_URL": "http://user:pwd@hostname.com/repo.git", + "JENKINS_URL": "jenkins", + "JOB_NAME": "jobName", + "JOB_URL": "jenkins-job-url", + "WORKSPACE": "/foo/bar" + }, + { + "ci.job.url": "jenkins-job-url", + "ci.pipeline.id": "jenkins-pipeline-id", + "ci.pipeline.name": "jobName", + "ci.pipeline.number": "jenkins-pipeline-number", + "ci.pipeline.url": "jenkins-pipeline-url", + "ci.provider.name": "jenkins", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "jenkins-git-commit", + "git.commit_sha": "jenkins-git-commit", + "git.repository_url": "http://hostname.com/repo.git" + } + ], + [ + { + "BUILD_NUMBER": "jenkins-pipeline-number", + "BUILD_TAG": "jenkins-pipeline-id", + "BUILD_URL": "jenkins-pipeline-url", + "GIT_BRANCH": "origin/master", + "GIT_COMMIT": "jenkins-git-commit", + "GIT_URL": "git@hostname.com:org/repo.git", + "JENKINS_URL": "jenkins", + "JOB_NAME": "jobName", + "JOB_URL": "jenkins-job-url", + "WORKSPACE": "/foo/bar" + }, + { + "ci.job.url": "jenkins-job-url", + "ci.pipeline.id": "jenkins-pipeline-id", + "ci.pipeline.name": "jobName", + "ci.pipeline.number": "jenkins-pipeline-number", + "ci.pipeline.url": "jenkins-pipeline-url", + "ci.provider.name": "jenkins", + "ci.workspace_path": "/foo/bar", + "git.branch": "master", + "git.commit.sha": "jenkins-git-commit", + "git.commit_sha": "jenkins-git-commit", + "git.repository_url": "git@hostname.com:org/repo.git" + } + ] +] diff --git a/tests/tracer/fixtures/ci/travis.json b/tests/tracer/fixtures/ci/travis.json index 46a421e05e5..239fe04c1f9 100644 --- a/tests/tracer/fixtures/ci/travis.json +++ b/tests/tracer/fixtures/ci/travis.json @@ -81,7 +81,6 @@ { "TRAVIS": "travisCI", "TRAVIS_BRANCH": "origin/master", - "TRAVIS_BUILD_DIR": "", "TRAVIS_BUILD_ID": "travis-pipeline-id", "TRAVIS_BUILD_NUMBER": "travis-pipeline-number", "TRAVIS_BUILD_WEB_URL": "travis-pipeline-url", @@ -96,7 +95,6 @@ "ci.pipeline.number": "travis-pipeline-number", "ci.pipeline.url": "travis-pipeline-url", "ci.provider.name": "travisci", - "ci.workspace_path": "", "git.branch": "master", "git.commit.sha": "travis-git-commit", "git.commit_sha": "travis-git-commit", @@ -113,7 +111,6 @@ "TRAVIS_BUILD_WEB_URL": "travis-pipeline-url", "TRAVIS_COMMIT": "travis-git-commit", "TRAVIS_JOB_WEB_URL": "travis-job-url", - "TRAVIS_PULL_REQUEST_BRANCH": "", "TRAVIS_REPO_SLUG": "user/repo" }, { @@ -166,7 +163,6 @@ "TRAVIS_BUILD_WEB_URL": "travis-pipeline-url", "TRAVIS_COMMIT": "travis-git-commit", "TRAVIS_JOB_WEB_URL": "travis-job-url", - "TRAVIS_PULL_REQUEST_SLUG": "", "TRAVIS_REPO_SLUG": "user/repo" }, { diff --git a/tests/tracer/test_ext.py b/tests/tracer/test_ext.py index 164407e4c95..2dd6d68dd6a 100644 --- a/tests/tracer/test_ext.py +++ b/tests/tracer/test_ext.py @@ -1,3 +1,4 @@ +import glob import os import json @@ -14,12 +15,12 @@ def test_flatten_dict(): assert aws._flatten_dict(d, sep="_") == e -def _ci_fixtures(*names): +def _ci_fixtures(): basepath = os.path.join(os.path.dirname(__file__), "fixtures", "ci") - for name in names: - with open(os.path.join(basepath, name + ".json")) as fp: - for item in json.load(fp): - yield name, item[0], item[1] + for filename in glob.glob(os.path.join(basepath, '*.json')): + with open(filename) as fp: + for i, item in enumerate(json.load(fp)): + yield os.path.basename(filename)[:-5] + ':' + str(i), item[0], item[1] def _updateenv(monkeypatch, env): @@ -27,7 +28,7 @@ def _updateenv(monkeypatch, env): monkeypatch.setenv(k, v) -@pytest.mark.parametrize("name,environment,tags", _ci_fixtures("appveyor", "azurepipelines", "bitbucket", "travis")) +@pytest.mark.parametrize("name,environment,tags", _ci_fixtures()) def test_ci_providers(monkeypatch, name, environment, tags): _updateenv(monkeypatch, environment) - assert tags == ci.tags(), (name, environment) + assert tags == ci.tags(), "wrong tags in {0} for {1}".format(name, environment) From 2e9e40e4d7c9d6b7f0d0979db328fd9967808f8f Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Tue, 3 Nov 2020 10:47:59 +0100 Subject: [PATCH 28/34] configurable operation name --- ddtrace/contrib/pytest/__init__.py | 7 ++++++- ddtrace/contrib/pytest/plugin.py | 2 +- tests/contrib/pytest/test_pytest.py | 3 +++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ddtrace/contrib/pytest/__init__.py b/ddtrace/contrib/pytest/__init__.py index d2a80a3ca48..51253900411 100644 --- a/ddtrace/contrib/pytest/__init__.py +++ b/ddtrace/contrib/pytest/__init__.py @@ -10,5 +10,10 @@ from ddtrace import config +from ...utils.formats import get_env + # pytest default settings -config._add("pytest", dict(_default_service="pytest")) +config._add("pytest", dict( + _default_service="pytest", + operation_name=get_env('pytest', 'operation_name', default="pytest.test"), +)) diff --git a/ddtrace/contrib/pytest/plugin.py b/ddtrace/contrib/pytest/plugin.py index 47ba0054f31..fba917c4520 100644 --- a/ddtrace/contrib/pytest/plugin.py +++ b/ddtrace/contrib/pytest/plugin.py @@ -68,7 +68,7 @@ def pytest_runtest_protocol(item, nextitem): return with pin.tracer.trace( - SpanTypes.TEST.value, + ddconfig.pytest.operation_name, service=int_service(pin, ddconfig.pytest), resource=item.nodeid, span_type=SpanTypes.TEST.value, diff --git a/tests/contrib/pytest/test_pytest.py b/tests/contrib/pytest/test_pytest.py index 5426d4d2acb..71e9e7b5d78 100644 --- a/tests/contrib/pytest/test_pytest.py +++ b/tests/contrib/pytest/test_pytest.py @@ -145,6 +145,7 @@ def test_service(ddspan): assert len(spans) == 1 assert spans[0].service == "pytest" + assert spans[0].name == "pytest.test" def test_dd_service_name(self): """Test integration service name.""" @@ -170,6 +171,7 @@ def test_dd_pytest_service_name(self): """Test integration service name.""" self.monkeypatch.setenv("DD_SERVICE", "mysvc") self.monkeypatch.setenv("DD_PYTEST_SERVICE", "pymysvc") + self.monkeypatch.setenv("DD_PYTEST_OPERATION_NAME", "mytest") py_file = self.testdir.makepyfile( """ @@ -179,6 +181,7 @@ def test_service(ddspan): assert 'mysvc' == os.getenv('DD_SERVICE') assert 'pymysvc' == os.getenv('DD_PYTEST_SERVICE') assert 'pymysvc' == ddspan.service + assert 'mytest' == ddspan.name """ ) file_name = os.path.basename(py_file.strpath) From 844a86810714b90b94847d7422a77e0f02bba3e1 Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Tue, 3 Nov 2020 11:09:02 +0100 Subject: [PATCH 29/34] black --- ddtrace/contrib/pytest/__init__.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ddtrace/contrib/pytest/__init__.py b/ddtrace/contrib/pytest/__init__.py index 51253900411..9854743e37e 100644 --- a/ddtrace/contrib/pytest/__init__.py +++ b/ddtrace/contrib/pytest/__init__.py @@ -13,7 +13,10 @@ from ...utils.formats import get_env # pytest default settings -config._add("pytest", dict( - _default_service="pytest", - operation_name=get_env('pytest', 'operation_name', default="pytest.test"), -)) +config._add( + "pytest", + dict( + _default_service="pytest", + operation_name=get_env("pytest", "operation_name", default="pytest.test"), + ), +) From 4418e91e14d301a21f3887ae4612ceba5c31f3c8 Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Tue, 3 Nov 2020 19:08:56 +0100 Subject: [PATCH 30/34] document configuration options --- ddtrace/contrib/pytest/__init__.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/ddtrace/contrib/pytest/__init__.py b/ddtrace/contrib/pytest/__init__.py index 9854743e37e..5d64eeff03b 100644 --- a/ddtrace/contrib/pytest/__init__.py +++ b/ddtrace/contrib/pytest/__init__.py @@ -1,4 +1,9 @@ """ +The Pytest ingration traces test executions. + +Enabling +~~~~~~~~ + Enable traced execution of tests using ``pytest`` runner by running ``pytest --ddtrace`` or by modifying any configuration file read by Pytest (``pytest.ini``, ``setup.cfg``, ...):: @@ -6,6 +11,28 @@ [pytest] ddtrace = 1 + +Global Configuration +~~~~~~~~~~~~~~~~~~~~ + +.. py:data:: ddtrace.config.pytest["service"] + + The service name reported by default for pytest traces. + + This option can also be set with the ``DD_PYTEST_SERVICE`` environment + variable. + + Default: ``"pytest"`` + + +.. py:data:: ddtrace.config.pytest["operation_name"] + + The operation name reported by default for pytest traces. + + This option can also be set with the ``DD_PYTEST_OPERATION_NAME`` environment + variable. + + Default: ``"pytest.test"`` """ from ddtrace import config From baf8aa08f404761ca0d64fa8b771f18c25e9b9e7 Mon Sep 17 00:00:00 2001 From: Kyle Verhoog Date: Wed, 4 Nov 2020 11:40:38 -0500 Subject: [PATCH 31/34] add circleci entry --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index bf672221c57..8157a2a12b5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -898,6 +898,7 @@ requires_tests: &requires_tests - pynamodb - pyodbc - pyramid + - pytest - redis - rediscluster - requests From 56a05d886fc704d1376bfe04354dcc1093cbed88 Mon Sep 17 00:00:00 2001 From: Kyle Verhoog Date: Fri, 13 Nov 2020 15:05:16 -0500 Subject: [PATCH 32/34] use pytest 3 for flask and aiohttp --- tox.ini | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tox.ini b/tox.ini index 14cbeb480d5..400aec3581a 100644 --- a/tox.ini +++ b/tox.ini @@ -31,10 +31,10 @@ envlist = # aiobotocore 0.2 and 0.4 do not work because they use async as a reserved keyword aiobotocore_contrib-py{37,38,39}-aiobotocore{03,05,07,08,09,010,011,012} # Python 3.7 needs at least aiohttp 2.3 - aiohttp_contrib-{py35,py36}-aiohttp{12,13,20,21,22}-aiohttp_jinja{012,013}-yarl - aiohttp_contrib-{py35,py36,py37,py38}-aiohttp23-aiohttp_jinja015-yarl10 - aiohttp_contrib-{py35,py36,py37}-aiohttp{30,31,32,33,35,36}-aiohttp_jinja{015}-yarl10 - aiohttp_contrib-py38-aiohttp{30,31,32,33,36}-aiohttp_jinja015-yarl10 + aiohttp_contrib-{py35,py36}-aiohttp{12,13,20,21,22}-aiohttp_jinja{012,013}-yarl-pytest3 + aiohttp_contrib-{py35,py36,py37,py38}-aiohttp23-aiohttp_jinja015-yarl10-pytest3 + aiohttp_contrib-{py35,py36,py37}-aiohttp{30,31,32,33,35,36}-aiohttp_jinja{015}-yarl10-pytest3 + aiohttp_contrib-py38-aiohttp{30,31,32,33,36}-aiohttp_jinja015-yarl10-pytest3 aiopg_contrib-{py35,py36}-aiopg{012,015} aiopg_contrib-py{37,38,39}-aiopg015 algoliasearch_contrib-py{27,35,36,37,38,39}-algoliasearch{1,2,} @@ -68,11 +68,11 @@ envlist = elasticsearch_contrib-{py27,py35,py36}-elasticsearch6{40} falcon_contrib{,_autopatch}-{py27,py35,py36,py37}-falcon{10,11,12,13,14} falcon_contrib{,_autopatch}-{py35,py36,py37}-falcon{20} - flask_contrib{,_autopatch}-{py27,py35,py36}-flask{010,011,012,10}-blinker + flask_contrib{,_autopatch}-{py27,py35,py36}-flask{010,011,012,10}-blinker-pytest3 # Flask <=0.9 does not support Python 3 - flask_contrib{,_autopatch}-{py27}-flask{09}-blinker - flask_cache_contrib-py{27,35,36,37,38,39}-flask{010,011,012}-flaskcache{013}-memcached-redis{210}-blinker - flask_cache_contrib-py27-flask{010,011}-flaskcache{012}-memcached-redis{210}-blinker + flask_contrib{,_autopatch}-{py27}-flask{09}-blinker-pytest3 + flask_cache_contrib-py{27,35,36,37,38,39}-flask{010,011,012}-flaskcache{013}-memcached-redis{210}-blinker-pytest3 + flask_cache_contrib-py27-flask{010,011}-flaskcache{012}-memcached-redis{210}-blinker-pytest3 futures_contrib-py27-futures{30,31,32,} futures_contrib-py{35,36,37,38,39} gevent_contrib-py27-gevent{11,12,13}-sslmodules From ef96a5b210f68c48145f02ed2e8c5034ebee9397 Mon Sep 17 00:00:00 2001 From: Kyle Verhoog Date: Fri, 13 Nov 2020 15:26:33 -0500 Subject: [PATCH 33/34] add pytest to docs --- docs/index.rst | 2 ++ docs/integrations.rst | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/docs/index.rst b/docs/index.rst index cad248e8314..341ad875b95 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -112,6 +112,8 @@ contacting support. +--------------------------------------------------+---------------+----------------+ | :ref:`pyramid` | >= 1.7 | No | +--------------------------------------------------+---------------+----------------+ +| :ref:`pytest` | >= 3.0 | Yes | ++--------------------------------------------------+---------------+----------------+ | :ref:`redis` | >= 2.6 | Yes | +--------------------------------------------------+---------------+----------------+ | :ref:`rediscluster` | >= 1.3.5 | Yes | diff --git a/docs/integrations.rst b/docs/integrations.rst index dee3754a82a..bb5d9b4586d 100644 --- a/docs/integrations.rst +++ b/docs/integrations.rst @@ -256,6 +256,13 @@ Pyramid .. automodule:: ddtrace.contrib.pyramid +.. _pytest: + +pytest +^^^^^^ +.. automodule:: ddtrace.contrib.pytest + + .. _psycopg2: psycopg From f4c0b0d2fa0d051f554116da04548490d16b9ae1 Mon Sep 17 00:00:00 2001 From: Kyle Verhoog Date: Fri, 13 Nov 2020 15:28:25 -0500 Subject: [PATCH 34/34] fix typo --- ddtrace/contrib/pytest/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ddtrace/contrib/pytest/__init__.py b/ddtrace/contrib/pytest/__init__.py index 5d64eeff03b..7922a5455dd 100644 --- a/ddtrace/contrib/pytest/__init__.py +++ b/ddtrace/contrib/pytest/__init__.py @@ -1,12 +1,12 @@ """ -The Pytest ingration traces test executions. +The pytest integration traces test executions. Enabling ~~~~~~~~ Enable traced execution of tests using ``pytest`` runner by running ``pytest --ddtrace`` or by modifying any configuration -file read by Pytest (``pytest.ini``, ``setup.cfg``, ...):: +file read by pytest (``pytest.ini``, ``setup.cfg``, ...):: [pytest] ddtrace = 1