Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(playwrighttesting): Added runName feature #47062

Merged
merged 7 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ public class ServiceEnvironmentVariable
/// The environment variable for the Playwright service run ID.
/// </summary>
public static readonly string PlaywrightServiceRunId = "PLAYWRIGHT_SERVICE_RUN_ID";

/// <summary>
/// The environment variable for the Playwright service run Name.
/// </summary>
public static readonly string PlaywrightServiceRunName = "PLAYWRIGHT_SERVICE_RUN_NAME";
kashish2508 marked this conversation as resolved.
Show resolved Hide resolved
};

/// <summary>
Expand Down Expand Up @@ -180,6 +185,11 @@ public class RunSettingKey
/// Enable Result publish.
/// </summary>
public static readonly string EnableResultPublish = "EnableResultPublish";

/// <summary>
/// The run nam setting key.
kashish2508 marked this conversation as resolved.
Show resolved Hide resolved
/// </summary>
public static readonly string RunName = "RunName";
}

internal class Constants
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ internal class CloudRunMetadata
{
internal string? WorkspaceId { get; set; }
internal string? RunId { get; set; }
internal string? RunName { get; set; }
internal Uri? BaseUri { get; set; }
internal string? PortalUrl
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ private void InitializePlaywrightReporter(string xmlSettings)
runParameters.TryGetValue(RunSettingKey.ManagedIdentityClientId, out var managedIdentityClientId);
runParameters.TryGetValue(RunSettingKey.EnableGitHubSummary, out var enableGithubSummary);
runParameters.TryGetValue(RunSettingKey.EnableResultPublish, out var enableResultPublish);
runParameters.TryGetValue(RunSettingKey.RunName, out var runName);
if (!string.IsNullOrEmpty(runName?.ToString()))
Environment.SetEnvironmentVariable(ServiceEnvironmentVariable.PlaywrightServiceRunName, runName!.ToString());
kashish2508 marked this conversation as resolved.
Show resolved Hide resolved
string? enableGithubSummaryString = enableGithubSummary?.ToString();
string? enableResultPublishString = enableResultPublish?.ToString();

Expand All @@ -113,6 +116,7 @@ private void InitializePlaywrightReporter(string xmlSettings)
#pragma warning restore AZC0102 // Do not use GetAwaiter().GetResult(). Use the TaskExtensions.EnsureCompleted() extension method instead.

var cloudRunId = Environment.GetEnvironmentVariable(ServiceEnvironmentVariable.PlaywrightServiceRunId);
var customRunName = Environment.GetEnvironmentVariable(ServiceEnvironmentVariable.PlaywrightServiceRunName);
string baseUrl = Environment.GetEnvironmentVariable(ReporterConstants.s_pLAYWRIGHT_SERVICE_REPORTING_URL);
string accessToken = Environment.GetEnvironmentVariable(ServiceEnvironmentVariable.PlaywrightServiceAccessToken);
if (string.IsNullOrEmpty(baseUrl))
Expand All @@ -134,6 +138,7 @@ private void InitializePlaywrightReporter(string xmlSettings)
var cloudRunMetadata = new CloudRunMetadata
{
RunId = cloudRunId,
RunName = customRunName,
kashish2508 marked this conversation as resolved.
Show resolved Hide resolved
WorkspaceId = workspaceId,
BaseUri = baseUri,
EnableResultPublish = _enableResultPublish,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public TestRunDto GetTestRun()
{
var startTime = _cloudRunMetadata.TestRunStartTime.ToString("yyyy-MM-ddTHH:mm:ssZ");
var gitBasedRunName = ReporterUtils.GetRunName(CiInfoProvider.GetCIInfo())?.Trim();
string runName = string.IsNullOrEmpty(gitBasedRunName) ? _cloudRunMetadata.RunId! : gitBasedRunName!;
string runName = !string.IsNullOrEmpty(_cloudRunMetadata.RunName) ? _cloudRunMetadata.RunName! : string.IsNullOrEmpty(gitBasedRunName) ? _cloudRunMetadata.RunId! : gitBasedRunName!;
kashish2508 marked this conversation as resolved.
Show resolved Hide resolved
var run = new TestRunDto
{
TestRunId = _cloudRunMetadata.RunId!,
Expand Down
Loading