Skip to content

Commit

Permalink
update CI provider specs;
Browse files Browse the repository at this point in the history
use filter_basic_auth method from Datadog::Core available since ddtrace 1.21
  • Loading branch information
anmarchenko committed Mar 18, 2024
1 parent afd5482 commit 02d3024
Show file tree
Hide file tree
Showing 16 changed files with 541 additions and 336 deletions.
5 changes: 3 additions & 2 deletions lib/datadog/ci/ext/environment/extractor.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# frozen_string_literal: true

require "datadog/core/utils/url"

require_relative "../git"
require_relative "../../utils/git"
require_relative "../../utils/url"
require_relative "providers"

module Datadog
Expand Down Expand Up @@ -76,7 +77,7 @@ def normalize_git!

@tags[Git::TAG_TAG] = Utils::Git.normalize_ref(@tags[Git::TAG_TAG])
@tags[Git::TAG_BRANCH] = Utils::Git.normalize_ref(@tags[Git::TAG_BRANCH])
@tags[Git::TAG_REPOSITORY_URL] = Utils::Url.filter_sensitive_info(
@tags[Git::TAG_REPOSITORY_URL] = Datadog::Core::Utils::Url.filter_basic_auth(
@tags[Git::TAG_REPOSITORY_URL]
)
end
Expand Down
5 changes: 3 additions & 2 deletions lib/datadog/ci/ext/environment/providers/github_actions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

require "json"

require "datadog/core/utils/url"

require_relative "base"
require_relative "../../../utils/url"

module Datadog
module CI
Expand Down Expand Up @@ -79,7 +80,7 @@ def ci_env_vars
def github_server_url
return @github_server_url if defined?(@github_server_url)

@github_server_url ||= Utils::Url.filter_sensitive_info(env["GITHUB_SERVER_URL"])
@github_server_url ||= Datadog::Core::Utils::Url.filter_basic_auth(env["GITHUB_SERVER_URL"])
end
end
end
Expand Down
15 changes: 0 additions & 15 deletions lib/datadog/ci/utils/url.rb

This file was deleted.

9 changes: 0 additions & 9 deletions sig/datadog/ci/utils/url.rbs

This file was deleted.

70 changes: 64 additions & 6 deletions spec/support/fixtures/ci/azurepipelines.json
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,64 @@
"git.tag": "0.0.2"
}
],
[
{
"BUILD_BUILDID": "azure-pipelines-build-id",
"BUILD_DEFINITIONNAME": "azure-pipelines-name",
"BUILD_REPOSITORY_URI": "https://dev.azure.com/fabrikamfiber/repo",
"BUILD_REQUESTEDFOREMAIL": "[email protected]",
"BUILD_REQUESTEDFORID": "azure-pipelines-commit-author",
"BUILD_SOURCEVERSIONMESSAGE": "azure-pipelines-commit-message",
"DD_TEST_CASE_NAME": "http-repository-url-no-git-suffix",
"SYSTEM_JOBID": "azure-pipelines-job-id",
"SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id",
"SYSTEM_TEAMFOUNDATIONSERVERURI": "https://azure-pipelines-server-uri.com/",
"SYSTEM_TEAMPROJECTID": "azure-pipelines-project-id",
"TF_BUILD": "True"
},
{
"_dd.ci.env_vars": "{\"SYSTEM_TEAMPROJECTID\":\"azure-pipelines-project-id\",\"BUILD_BUILDID\":\"azure-pipelines-build-id\",\"SYSTEM_JOBID\":\"azure-pipelines-job-id\"}",
"ci.job.url": "https://azure-pipelines-server-uri.com/azure-pipelines-project-id/_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": "https://azure-pipelines-server-uri.com/azure-pipelines-project-id/_build/results?buildId=azure-pipelines-build-id",
"ci.provider.name": "azurepipelines",
"git.commit.author.email": "[email protected]",
"git.commit.author.name": "azure-pipelines-commit-author",
"git.commit.message": "azure-pipelines-commit-message",
"git.repository_url": "https://dev.azure.com/fabrikamfiber/repo"
}
],
[
{
"BUILD_BUILDID": "azure-pipelines-build-id",
"BUILD_DEFINITIONNAME": "azure-pipelines-name",
"BUILD_REPOSITORY_URI": "ssh://host.xz:54321/path/to/repo/",
"BUILD_REQUESTEDFOREMAIL": "[email protected]",
"BUILD_REQUESTEDFORID": "azure-pipelines-commit-author",
"BUILD_SOURCEVERSIONMESSAGE": "azure-pipelines-commit-message",
"DD_TEST_CASE_NAME": "ssh-repository-url-no-git-suffix",
"SYSTEM_JOBID": "azure-pipelines-job-id",
"SYSTEM_TASKINSTANCEID": "azure-pipelines-task-id",
"SYSTEM_TEAMFOUNDATIONSERVERURI": "https://azure-pipelines-server-uri.com/",
"SYSTEM_TEAMPROJECTID": "azure-pipelines-project-id",
"TF_BUILD": "True"
},
{
"_dd.ci.env_vars": "{\"SYSTEM_TEAMPROJECTID\":\"azure-pipelines-project-id\",\"BUILD_BUILDID\":\"azure-pipelines-build-id\",\"SYSTEM_JOBID\":\"azure-pipelines-job-id\"}",
"ci.job.url": "https://azure-pipelines-server-uri.com/azure-pipelines-project-id/_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": "https://azure-pipelines-server-uri.com/azure-pipelines-project-id/_build/results?buildId=azure-pipelines-build-id",
"ci.provider.name": "azurepipelines",
"git.commit.author.email": "[email protected]",
"git.commit.author.name": "azure-pipelines-commit-author",
"git.commit.message": "azure-pipelines-commit-message",
"git.repository_url": "ssh://host.xz:54321/path/to/repo/"
}
],
[
{
"BUILD_BUILDID": "azure-pipelines-build-id",
Expand Down Expand Up @@ -794,7 +852,7 @@
{
"BUILD_BUILDID": "azure-pipelines-build-id",
"BUILD_DEFINITIONNAME": "azure-pipelines-name",
"BUILD_REPOSITORY_URI": "ssh://[email protected]:port/path/to/repo.git/",
"BUILD_REPOSITORY_URI": "ssh://[email protected]:54321/path/to/repo.git/",
"BUILD_REQUESTEDFOREMAIL": "[email protected]",
"BUILD_REQUESTEDFORID": "azure-pipelines-commit-author",
"BUILD_SOURCEVERSIONMESSAGE": "azure-pipelines-commit-message",
Expand All @@ -815,14 +873,14 @@
"git.commit.author.email": "[email protected]",
"git.commit.author.name": "azure-pipelines-commit-author",
"git.commit.message": "azure-pipelines-commit-message",
"git.repository_url": "ssh://host.xz:port/path/to/repo.git/"
"git.repository_url": "ssh://host.xz:54321/path/to/repo.git/"
}
],
[
{
"BUILD_BUILDID": "azure-pipelines-build-id",
"BUILD_DEFINITIONNAME": "azure-pipelines-name",
"BUILD_REPOSITORY_URI": "ssh://user:[email protected]:port/path/to/repo.git/",
"BUILD_REPOSITORY_URI": "ssh://user:[email protected]:54321/path/to/repo.git/",
"BUILD_REQUESTEDFOREMAIL": "[email protected]",
"BUILD_REQUESTEDFORID": "azure-pipelines-commit-author",
"BUILD_SOURCEVERSIONMESSAGE": "azure-pipelines-commit-message",
Expand All @@ -843,14 +901,14 @@
"git.commit.author.email": "[email protected]",
"git.commit.author.name": "azure-pipelines-commit-author",
"git.commit.message": "azure-pipelines-commit-message",
"git.repository_url": "ssh://host.xz:port/path/to/repo.git/"
"git.repository_url": "ssh://host.xz:54321/path/to/repo.git/"
}
],
[
{
"BUILD_BUILDID": "azure-pipelines-build-id",
"BUILD_DEFINITIONNAME": "azure-pipelines-name",
"BUILD_REPOSITORY_URI": "ssh://user:[email protected]:port/path/to/repo.git/",
"BUILD_REPOSITORY_URI": "ssh://user:[email protected]:54321/path/to/repo.git/",
"BUILD_REQUESTEDFOREMAIL": "[email protected]",
"BUILD_REQUESTEDFORID": "azure-pipelines-commit-author",
"BUILD_SOURCEVERSIONMESSAGE": "azure-pipelines-commit-message",
Expand All @@ -871,7 +929,7 @@
"git.commit.author.email": "[email protected]",
"git.commit.author.name": "azure-pipelines-commit-author",
"git.commit.message": "azure-pipelines-commit-message",
"git.repository_url": "ssh://1.1.1.1:port/path/to/repo.git/"
"git.repository_url": "ssh://1.1.1.1:54321/path/to/repo.git/"
}
]
]
48 changes: 44 additions & 4 deletions spec/support/fixtures/ci/bitbucket.json
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,46 @@
"git.tag": "0.0.2"
}
],
[
{
"BITBUCKET_BUILD_NUMBER": "bitbucket-build-num",
"BITBUCKET_COMMIT": "b9f0fb3fdbb94c9d24b2c75b49663122a529e123",
"BITBUCKET_GIT_HTTP_ORIGIN": "https://bitbucket.org/DataDog/dogweb",
"BITBUCKET_PIPELINE_UUID": "{bitbucket-uuid}",
"BITBUCKET_REPO_FULL_NAME": "bitbucket-repo",
"DD_TEST_CASE_NAME": "http-repository-url-no-git-suffix"
},
{
"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",
"git.commit.sha": "b9f0fb3fdbb94c9d24b2c75b49663122a529e123",
"git.repository_url": "https://bitbucket.org/DataDog/dogweb"
}
],
[
{
"BITBUCKET_BUILD_NUMBER": "bitbucket-build-num",
"BITBUCKET_COMMIT": "b9f0fb3fdbb94c9d24b2c75b49663122a529e123",
"BITBUCKET_GIT_HTTP_ORIGIN": "ssh://host.xz:54321/path/to/repo/",
"BITBUCKET_PIPELINE_UUID": "{bitbucket-uuid}",
"BITBUCKET_REPO_FULL_NAME": "bitbucket-repo",
"DD_TEST_CASE_NAME": "ssh-repository-url-no-git-suffix"
},
{
"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",
"git.commit.sha": "b9f0fb3fdbb94c9d24b2c75b49663122a529e123",
"git.repository_url": "ssh://host.xz:54321/path/to/repo/"
}
],
[
{
"BITBUCKET_BUILD_NUMBER": "bitbucket-build-num",
Expand Down Expand Up @@ -518,7 +558,7 @@
{
"BITBUCKET_BUILD_NUMBER": "bitbucket-build-num",
"BITBUCKET_COMMIT": "b9f0fb3fdbb94c9d24b2c75b49663122a529e123",
"BITBUCKET_GIT_HTTP_ORIGIN": "ssh://[email protected]:port/path/to/repo.git/",
"BITBUCKET_GIT_HTTP_ORIGIN": "ssh://[email protected]:54321/path/to/repo.git/",
"BITBUCKET_PIPELINE_UUID": "{bitbucket-uuid}",
"BITBUCKET_REPO_FULL_NAME": "bitbucket-repo"
},
Expand All @@ -530,14 +570,14 @@
"ci.pipeline.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num",
"ci.provider.name": "bitbucket",
"git.commit.sha": "b9f0fb3fdbb94c9d24b2c75b49663122a529e123",
"git.repository_url": "ssh://host.xz:port/path/to/repo.git/"
"git.repository_url": "ssh://host.xz:54321/path/to/repo.git/"
}
],
[
{
"BITBUCKET_BUILD_NUMBER": "bitbucket-build-num",
"BITBUCKET_COMMIT": "b9f0fb3fdbb94c9d24b2c75b49663122a529e123",
"BITBUCKET_GIT_HTTP_ORIGIN": "ssh://user:[email protected]:port/path/to/repo.git/",
"BITBUCKET_GIT_HTTP_ORIGIN": "ssh://user:[email protected]:54321/path/to/repo.git/",
"BITBUCKET_PIPELINE_UUID": "{bitbucket-uuid}",
"BITBUCKET_REPO_FULL_NAME": "bitbucket-repo"
},
Expand All @@ -549,7 +589,7 @@
"ci.pipeline.url": "https://bitbucket.org/bitbucket-repo/addon/pipelines/home#!/results/bitbucket-build-num",
"ci.provider.name": "bitbucket",
"git.commit.sha": "b9f0fb3fdbb94c9d24b2c75b49663122a529e123",
"git.repository_url": "ssh://host.xz:port/path/to/repo.git/"
"git.repository_url": "ssh://host.xz:54321/path/to/repo.git/"
}
]
]
52 changes: 48 additions & 4 deletions spec/support/fixtures/ci/bitrise.json
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,50 @@
"git.tag": "0.0.2"
}
],
[
{
"BITRISE_BUILD_NUMBER": "bitrise-pipeline-number",
"BITRISE_BUILD_SLUG": "bitrise-pipeline-id",
"BITRISE_BUILD_URL": "https://bitrise-build-url.com//",
"BITRISE_GIT_MESSAGE": "bitrise-git-commit-message",
"BITRISE_TRIGGERED_WORKFLOW_ID": "bitrise-pipeline-name",
"DD_TEST_CASE_NAME": "http-repository-url-no-git-suffix",
"GIT_CLONE_COMMIT_HASH": "b9f0fb3fdbb94c9d24b2c75b49663122a529e123",
"GIT_REPOSITORY_URL": "https://github.com/DataDog/dogweb"
},
{
"ci.pipeline.id": "bitrise-pipeline-id",
"ci.pipeline.name": "bitrise-pipeline-name",
"ci.pipeline.number": "bitrise-pipeline-number",
"ci.pipeline.url": "https://bitrise-build-url.com//",
"ci.provider.name": "bitrise",
"git.commit.message": "bitrise-git-commit-message",
"git.commit.sha": "b9f0fb3fdbb94c9d24b2c75b49663122a529e123",
"git.repository_url": "https://github.com/DataDog/dogweb"
}
],
[
{
"BITRISE_BUILD_NUMBER": "bitrise-pipeline-number",
"BITRISE_BUILD_SLUG": "bitrise-pipeline-id",
"BITRISE_BUILD_URL": "https://bitrise-build-url.com//",
"BITRISE_GIT_MESSAGE": "bitrise-git-commit-message",
"BITRISE_TRIGGERED_WORKFLOW_ID": "bitrise-pipeline-name",
"DD_TEST_CASE_NAME": "ssh-repository-url-no-git-suffix",
"GIT_CLONE_COMMIT_HASH": "b9f0fb3fdbb94c9d24b2c75b49663122a529e123",
"GIT_REPOSITORY_URL": "ssh://host.xz:54321/path/to/repo/"
},
{
"ci.pipeline.id": "bitrise-pipeline-id",
"ci.pipeline.name": "bitrise-pipeline-name",
"ci.pipeline.number": "bitrise-pipeline-number",
"ci.pipeline.url": "https://bitrise-build-url.com//",
"ci.provider.name": "bitrise",
"git.commit.message": "bitrise-git-commit-message",
"git.commit.sha": "b9f0fb3fdbb94c9d24b2c75b49663122a529e123",
"git.repository_url": "ssh://host.xz:54321/path/to/repo/"
}
],
[
{
"BITRISE_BUILD_NUMBER": "bitrise-pipeline-number",
Expand Down Expand Up @@ -613,7 +657,7 @@
"BITRISE_GIT_MESSAGE": "bitrise-git-commit-message",
"BITRISE_TRIGGERED_WORKFLOW_ID": "bitrise-pipeline-name",
"GIT_CLONE_COMMIT_HASH": "b9f0fb3fdbb94c9d24b2c75b49663122a529e123",
"GIT_REPOSITORY_URL": "ssh://[email protected]:port/path/to/repo.git/"
"GIT_REPOSITORY_URL": "ssh://[email protected]:54321/path/to/repo.git/"
},
{
"ci.pipeline.id": "bitrise-pipeline-id",
Expand All @@ -623,7 +667,7 @@
"ci.provider.name": "bitrise",
"git.commit.message": "bitrise-git-commit-message",
"git.commit.sha": "b9f0fb3fdbb94c9d24b2c75b49663122a529e123",
"git.repository_url": "ssh://host.xz:port/path/to/repo.git/"
"git.repository_url": "ssh://host.xz:54321/path/to/repo.git/"
}
],
[
Expand All @@ -634,7 +678,7 @@
"BITRISE_GIT_MESSAGE": "bitrise-git-commit-message",
"BITRISE_TRIGGERED_WORKFLOW_ID": "bitrise-pipeline-name",
"GIT_CLONE_COMMIT_HASH": "b9f0fb3fdbb94c9d24b2c75b49663122a529e123",
"GIT_REPOSITORY_URL": "ssh://user:[email protected]:port/path/to/repo.git/"
"GIT_REPOSITORY_URL": "ssh://user:[email protected]:54321/path/to/repo.git/"
},
{
"ci.pipeline.id": "bitrise-pipeline-id",
Expand All @@ -644,7 +688,7 @@
"ci.provider.name": "bitrise",
"git.commit.message": "bitrise-git-commit-message",
"git.commit.sha": "b9f0fb3fdbb94c9d24b2c75b49663122a529e123",
"git.repository_url": "ssh://host.xz:port/path/to/repo.git/"
"git.repository_url": "ssh://host.xz:54321/path/to/repo.git/"
}
]
]
Loading

0 comments on commit 02d3024

Please sign in to comment.