Skip to content

Commit

Permalink
Revert "Merge branch 'master' into nacho/SendUserAgentHeaderAsStringT…
Browse files Browse the repository at this point in the history
…oTheWAF"

This reverts commit 6a20ad4, reversing
changes made to 4091dea.
  • Loading branch information
NachoEchevarria committed Oct 11, 2024
1 parent 6a20ad4 commit 4e46f13
Show file tree
Hide file tree
Showing 10 changed files with 1 addition and 831 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,6 @@ public string? GitSearchFolder

public string[]? NodeLabels { get; protected set; }

public string? HeadCommit { get; protected set; }

public string? PrBaseCommit { get; protected set; }

public string? PrBaseBranch { get; protected set; }

public CodeOwners? CodeOwners { get; protected set; }

public Dictionary<string, string?>? VariablesToBypass { get; protected set; }
Expand Down Expand Up @@ -528,8 +522,6 @@ internal sealed class Constants
public const string GitHubRunNumber = "GITHUB_RUN_NUMBER";
public const string GitHubWorkflow = "GITHUB_WORKFLOW";
public const string GitHubJob = "GITHUB_JOB";
public const string GitHubEventPath = "GITHUB_EVENT_PATH";
public const string GitHubBaseRef = "GITHUB_BASE_REF";

// Teamcity CI Environment variables
public const string TeamCityVersion = "TEAMCITY_VERSION";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
// </copyright>
#nullable enable

using System;
using System.Collections.Generic;
using System.IO;
using Datadog.Trace.Vendors.Newtonsoft.Json.Linq;

namespace Datadog.Trace.Ci.CiEnvironment;

Expand Down Expand Up @@ -80,51 +77,5 @@ protected override void OnInitialize(GitInfo gitInfo)
return kvp.Value;
});

// Load github-event.json
LoadGithubEventJson();
if (string.IsNullOrEmpty(PrBaseBranch))
{
PrBaseBranch = ValueProvider.GetValue(Constants.GitHubBaseRef);
}
}

private void LoadGithubEventJson()
{
// Load github-event.json
try
{
var githubEventPath = ValueProvider.GetValue(Constants.GitHubEventPath);
if (!string.IsNullOrWhiteSpace(githubEventPath))
{
var githubEvent = File.ReadAllText(githubEventPath);
var githubEventObject = JObject.Parse(githubEvent);
var pullRequestObject = githubEventObject["pull_request"];
if (pullRequestObject is not null)
{
var prHeadSha = pullRequestObject["head"]?["sha"]?.Value<string>();
if (!string.IsNullOrWhiteSpace(prHeadSha))
{
HeadCommit = prHeadSha;
}

var prBaseSha = pullRequestObject["base"]?["sha"]?.Value<string>();
if (!string.IsNullOrWhiteSpace(prBaseSha))
{
PrBaseCommit = prBaseSha;
}

var prBaseRef = pullRequestObject["base"]?["ref"]?.Value<string>();
if (!string.IsNullOrWhiteSpace(prBaseRef))
{
PrBaseBranch = prBaseRef;
}
}
}
}
catch (Exception ex)
{
CIVisibility.Log.Warning(ex, "Error loading the github-event.json");
}
}
}
12 changes: 0 additions & 12 deletions tracer/src/Datadog.Trace/Ci/Tagging/TestSessionSpanTags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,6 @@ public TestSessionSpanTags()
[Metric(CommonTags.LogicalCpuCount)]
public double? LogicalCpuCount { get; }

[Tag(CommonTags.GitHeadCommit)]
public string GitHeadCommit { get; set; }

[Tag(CommonTags.GitPrBaseCommit)]
public string GitPrBaseCommit { get; set; }

[Tag(CommonTags.GitPrBaseBranch)]
public string GitPrBaseBranch { get; set; }

public void SetCIEnvironmentValues(CIEnvironmentValues environmentValues)
{
if (environmentValues is not null)
Expand All @@ -153,9 +144,6 @@ public void SetCIEnvironmentValues(CIEnvironmentValues environmentValues)
GitCommitCommitterEmail = environmentValues.CommitterEmail;
GitCommitMessage = environmentValues.Message;
BuildSourceRoot = environmentValues.SourceRoot;
GitHeadCommit = environmentValues.HeadCommit;
GitPrBaseCommit = environmentValues.PrBaseCommit;
GitPrBaseBranch = environmentValues.PrBaseBranch;

if (environmentValues.VariablesToBypass is { } variablesToBypass)
{
Expand Down
15 changes: 0 additions & 15 deletions tracer/src/Datadog.Trace/Ci/Tags/CommonTags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,19 +189,4 @@ internal static class CommonTags
/// Logical CPU count
/// </summary>
public const string LogicalCpuCount = "_dd.host.vcpu_count";

/// <summary>
/// GIT Head commit hash
/// </summary>
public const string GitHeadCommit = "git.commit.head_sha";

/// <summary>
/// GIT PR Base commit hash
/// </summary>
public const string GitPrBaseCommit = "git.pull_request.base_branch_sha";

/// <summary>
/// GIT PR Base branch name
/// </summary>
public const string GitPrBaseBranch = "git.pull_request.base_branch";
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,6 @@ partial class TestSessionSpanTags
private static ReadOnlySpan<byte> EarlyFlakeDetectionTestEnabledBytes => new byte[] { 184, 116, 101, 115, 116, 46, 101, 97, 114, 108, 121, 95, 102, 108, 97, 107, 101, 46, 101, 110, 97, 98, 108, 101, 100 };
// EarlyFlakeDetectionTestAbortReasonBytes = MessagePack.Serialize("test.early_flake.abort_reason");
private static ReadOnlySpan<byte> EarlyFlakeDetectionTestAbortReasonBytes => new byte[] { 189, 116, 101, 115, 116, 46, 101, 97, 114, 108, 121, 95, 102, 108, 97, 107, 101, 46, 97, 98, 111, 114, 116, 95, 114, 101, 97, 115, 111, 110 };
// GitHeadCommitBytes = MessagePack.Serialize("git.commit.head_sha");
private static ReadOnlySpan<byte> GitHeadCommitBytes => new byte[] { 179, 103, 105, 116, 46, 99, 111, 109, 109, 105, 116, 46, 104, 101, 97, 100, 95, 115, 104, 97 };
// GitPrBaseCommitBytes = MessagePack.Serialize("git.pull_request.base_branch_sha");
private static ReadOnlySpan<byte> GitPrBaseCommitBytes => new byte[] { 217, 32, 103, 105, 116, 46, 112, 117, 108, 108, 95, 114, 101, 113, 117, 101, 115, 116, 46, 98, 97, 115, 101, 95, 98, 114, 97, 110, 99, 104, 95, 115, 104, 97 };
// GitPrBaseBranchBytes = MessagePack.Serialize("git.pull_request.base_branch");
private static ReadOnlySpan<byte> GitPrBaseBranchBytes => new byte[] { 188, 103, 105, 116, 46, 112, 117, 108, 108, 95, 114, 101, 113, 117, 101, 115, 116, 46, 98, 97, 115, 101, 95, 98, 114, 97, 110, 99, 104 };

public override string? GetTag(string key)
{
Expand Down Expand Up @@ -120,9 +114,6 @@ partial class TestSessionSpanTags
"test.itr.tests_skipping.type" => IntelligentTestRunnerSkippingType,
"test.early_flake.enabled" => EarlyFlakeDetectionTestEnabled,
"test.early_flake.abort_reason" => EarlyFlakeDetectionTestAbortReason,
"git.commit.head_sha" => GitHeadCommit,
"git.pull_request.base_branch_sha" => GitPrBaseCommit,
"git.pull_request.base_branch" => GitPrBaseBranch,
_ => base.GetTag(key),
};
}
Expand Down Expand Up @@ -221,15 +212,6 @@ public override void SetTag(string key, string value)
case "test.early_flake.abort_reason":
EarlyFlakeDetectionTestAbortReason = value;
break;
case "git.commit.head_sha":
GitHeadCommit = value;
break;
case "git.pull_request.base_branch_sha":
GitPrBaseCommit = value;
break;
case "git.pull_request.base_branch":
GitPrBaseBranch = value;
break;
case "library_version":
Logger.Value.Warning("Attempted to set readonly tag {TagName} on {TagType}. Ignoring.", key, nameof(TestSessionSpanTags));
break;
Expand Down Expand Up @@ -396,21 +378,6 @@ public override void EnumerateTags<TProcessor>(ref TProcessor processor)
processor.Process(new TagItem<string>("test.early_flake.abort_reason", EarlyFlakeDetectionTestAbortReason, EarlyFlakeDetectionTestAbortReasonBytes));
}

if (GitHeadCommit is not null)
{
processor.Process(new TagItem<string>("git.commit.head_sha", GitHeadCommit, GitHeadCommitBytes));
}

if (GitPrBaseCommit is not null)
{
processor.Process(new TagItem<string>("git.pull_request.base_branch_sha", GitPrBaseCommit, GitPrBaseCommitBytes));
}

if (GitPrBaseBranch is not null)
{
processor.Process(new TagItem<string>("git.pull_request.base_branch", GitPrBaseBranch, GitPrBaseBranchBytes));
}

base.EnumerateTags(ref processor);
}

Expand Down Expand Up @@ -633,27 +600,6 @@ protected override void WriteAdditionalTags(System.Text.StringBuilder sb)
.Append(',');
}

if (GitHeadCommit is not null)
{
sb.Append("git.commit.head_sha (tag):")
.Append(GitHeadCommit)
.Append(',');
}

if (GitPrBaseCommit is not null)
{
sb.Append("git.pull_request.base_branch_sha (tag):")
.Append(GitPrBaseCommit)
.Append(',');
}

if (GitPrBaseBranch is not null)
{
sb.Append("git.pull_request.base_branch (tag):")
.Append(GitPrBaseBranch)
.Append(',');
}

base.WriteAdditionalTags(sb);
}
public override double? GetMetric(string key)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,6 @@ partial class TestSessionSpanTags
private static ReadOnlySpan<byte> EarlyFlakeDetectionTestEnabledBytes => new byte[] { 184, 116, 101, 115, 116, 46, 101, 97, 114, 108, 121, 95, 102, 108, 97, 107, 101, 46, 101, 110, 97, 98, 108, 101, 100 };
// EarlyFlakeDetectionTestAbortReasonBytes = MessagePack.Serialize("test.early_flake.abort_reason");
private static ReadOnlySpan<byte> EarlyFlakeDetectionTestAbortReasonBytes => new byte[] { 189, 116, 101, 115, 116, 46, 101, 97, 114, 108, 121, 95, 102, 108, 97, 107, 101, 46, 97, 98, 111, 114, 116, 95, 114, 101, 97, 115, 111, 110 };
// GitHeadCommitBytes = MessagePack.Serialize("git.commit.head_sha");
private static ReadOnlySpan<byte> GitHeadCommitBytes => new byte[] { 179, 103, 105, 116, 46, 99, 111, 109, 109, 105, 116, 46, 104, 101, 97, 100, 95, 115, 104, 97 };
// GitPrBaseCommitBytes = MessagePack.Serialize("git.pull_request.base_branch_sha");
private static ReadOnlySpan<byte> GitPrBaseCommitBytes => new byte[] { 217, 32, 103, 105, 116, 46, 112, 117, 108, 108, 95, 114, 101, 113, 117, 101, 115, 116, 46, 98, 97, 115, 101, 95, 98, 114, 97, 110, 99, 104, 95, 115, 104, 97 };
// GitPrBaseBranchBytes = MessagePack.Serialize("git.pull_request.base_branch");
private static ReadOnlySpan<byte> GitPrBaseBranchBytes => new byte[] { 188, 103, 105, 116, 46, 112, 117, 108, 108, 95, 114, 101, 113, 117, 101, 115, 116, 46, 98, 97, 115, 101, 95, 98, 114, 97, 110, 99, 104 };

public override string? GetTag(string key)
{
Expand Down Expand Up @@ -120,9 +114,6 @@ partial class TestSessionSpanTags
"test.itr.tests_skipping.type" => IntelligentTestRunnerSkippingType,
"test.early_flake.enabled" => EarlyFlakeDetectionTestEnabled,
"test.early_flake.abort_reason" => EarlyFlakeDetectionTestAbortReason,
"git.commit.head_sha" => GitHeadCommit,
"git.pull_request.base_branch_sha" => GitPrBaseCommit,
"git.pull_request.base_branch" => GitPrBaseBranch,
_ => base.GetTag(key),
};
}
Expand Down Expand Up @@ -221,15 +212,6 @@ public override void SetTag(string key, string value)
case "test.early_flake.abort_reason":
EarlyFlakeDetectionTestAbortReason = value;
break;
case "git.commit.head_sha":
GitHeadCommit = value;
break;
case "git.pull_request.base_branch_sha":
GitPrBaseCommit = value;
break;
case "git.pull_request.base_branch":
GitPrBaseBranch = value;
break;
case "library_version":
Logger.Value.Warning("Attempted to set readonly tag {TagName} on {TagType}. Ignoring.", key, nameof(TestSessionSpanTags));
break;
Expand Down Expand Up @@ -396,21 +378,6 @@ public override void EnumerateTags<TProcessor>(ref TProcessor processor)
processor.Process(new TagItem<string>("test.early_flake.abort_reason", EarlyFlakeDetectionTestAbortReason, EarlyFlakeDetectionTestAbortReasonBytes));
}

if (GitHeadCommit is not null)
{
processor.Process(new TagItem<string>("git.commit.head_sha", GitHeadCommit, GitHeadCommitBytes));
}

if (GitPrBaseCommit is not null)
{
processor.Process(new TagItem<string>("git.pull_request.base_branch_sha", GitPrBaseCommit, GitPrBaseCommitBytes));
}

if (GitPrBaseBranch is not null)
{
processor.Process(new TagItem<string>("git.pull_request.base_branch", GitPrBaseBranch, GitPrBaseBranchBytes));
}

base.EnumerateTags(ref processor);
}

Expand Down Expand Up @@ -633,27 +600,6 @@ protected override void WriteAdditionalTags(System.Text.StringBuilder sb)
.Append(',');
}

if (GitHeadCommit is not null)
{
sb.Append("git.commit.head_sha (tag):")
.Append(GitHeadCommit)
.Append(',');
}

if (GitPrBaseCommit is not null)
{
sb.Append("git.pull_request.base_branch_sha (tag):")
.Append(GitPrBaseCommit)
.Append(',');
}

if (GitPrBaseBranch is not null)
{
sb.Append("git.pull_request.base_branch (tag):")
.Append(GitPrBaseBranch)
.Append(',');
}

base.WriteAdditionalTags(sb);
}
public override double? GetMetric(string key)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,6 @@ partial class TestSessionSpanTags
private static ReadOnlySpan<byte> EarlyFlakeDetectionTestEnabledBytes => new byte[] { 184, 116, 101, 115, 116, 46, 101, 97, 114, 108, 121, 95, 102, 108, 97, 107, 101, 46, 101, 110, 97, 98, 108, 101, 100 };
// EarlyFlakeDetectionTestAbortReasonBytes = MessagePack.Serialize("test.early_flake.abort_reason");
private static ReadOnlySpan<byte> EarlyFlakeDetectionTestAbortReasonBytes => new byte[] { 189, 116, 101, 115, 116, 46, 101, 97, 114, 108, 121, 95, 102, 108, 97, 107, 101, 46, 97, 98, 111, 114, 116, 95, 114, 101, 97, 115, 111, 110 };
// GitHeadCommitBytes = MessagePack.Serialize("git.commit.head_sha");
private static ReadOnlySpan<byte> GitHeadCommitBytes => new byte[] { 179, 103, 105, 116, 46, 99, 111, 109, 109, 105, 116, 46, 104, 101, 97, 100, 95, 115, 104, 97 };
// GitPrBaseCommitBytes = MessagePack.Serialize("git.pull_request.base_branch_sha");
private static ReadOnlySpan<byte> GitPrBaseCommitBytes => new byte[] { 217, 32, 103, 105, 116, 46, 112, 117, 108, 108, 95, 114, 101, 113, 117, 101, 115, 116, 46, 98, 97, 115, 101, 95, 98, 114, 97, 110, 99, 104, 95, 115, 104, 97 };
// GitPrBaseBranchBytes = MessagePack.Serialize("git.pull_request.base_branch");
private static ReadOnlySpan<byte> GitPrBaseBranchBytes => new byte[] { 188, 103, 105, 116, 46, 112, 117, 108, 108, 95, 114, 101, 113, 117, 101, 115, 116, 46, 98, 97, 115, 101, 95, 98, 114, 97, 110, 99, 104 };

public override string? GetTag(string key)
{
Expand Down Expand Up @@ -120,9 +114,6 @@ partial class TestSessionSpanTags
"test.itr.tests_skipping.type" => IntelligentTestRunnerSkippingType,
"test.early_flake.enabled" => EarlyFlakeDetectionTestEnabled,
"test.early_flake.abort_reason" => EarlyFlakeDetectionTestAbortReason,
"git.commit.head_sha" => GitHeadCommit,
"git.pull_request.base_branch_sha" => GitPrBaseCommit,
"git.pull_request.base_branch" => GitPrBaseBranch,
_ => base.GetTag(key),
};
}
Expand Down Expand Up @@ -221,15 +212,6 @@ public override void SetTag(string key, string value)
case "test.early_flake.abort_reason":
EarlyFlakeDetectionTestAbortReason = value;
break;
case "git.commit.head_sha":
GitHeadCommit = value;
break;
case "git.pull_request.base_branch_sha":
GitPrBaseCommit = value;
break;
case "git.pull_request.base_branch":
GitPrBaseBranch = value;
break;
case "library_version":
Logger.Value.Warning("Attempted to set readonly tag {TagName} on {TagType}. Ignoring.", key, nameof(TestSessionSpanTags));
break;
Expand Down Expand Up @@ -396,21 +378,6 @@ public override void EnumerateTags<TProcessor>(ref TProcessor processor)
processor.Process(new TagItem<string>("test.early_flake.abort_reason", EarlyFlakeDetectionTestAbortReason, EarlyFlakeDetectionTestAbortReasonBytes));
}

if (GitHeadCommit is not null)
{
processor.Process(new TagItem<string>("git.commit.head_sha", GitHeadCommit, GitHeadCommitBytes));
}

if (GitPrBaseCommit is not null)
{
processor.Process(new TagItem<string>("git.pull_request.base_branch_sha", GitPrBaseCommit, GitPrBaseCommitBytes));
}

if (GitPrBaseBranch is not null)
{
processor.Process(new TagItem<string>("git.pull_request.base_branch", GitPrBaseBranch, GitPrBaseBranchBytes));
}

base.EnumerateTags(ref processor);
}

Expand Down Expand Up @@ -633,27 +600,6 @@ protected override void WriteAdditionalTags(System.Text.StringBuilder sb)
.Append(',');
}

if (GitHeadCommit is not null)
{
sb.Append("git.commit.head_sha (tag):")
.Append(GitHeadCommit)
.Append(',');
}

if (GitPrBaseCommit is not null)
{
sb.Append("git.pull_request.base_branch_sha (tag):")
.Append(GitPrBaseCommit)
.Append(',');
}

if (GitPrBaseBranch is not null)
{
sb.Append("git.pull_request.base_branch (tag):")
.Append(GitPrBaseBranch)
.Append(',');
}

base.WriteAdditionalTags(sb);
}
public override double? GetMetric(string key)
Expand Down
Loading

0 comments on commit 4e46f13

Please sign in to comment.