@azure/microsoft-playwright-testing 1.0.0-alpha.20240911.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/LICENSE +21 -0
  3. package/README.md +151 -0
  4. package/dist/common/constants.d.ts +92 -0
  5. package/dist/common/constants.d.ts.map +1 -0
  6. package/dist/common/constants.js +222 -0
  7. package/dist/common/constants.js.map +1 -0
  8. package/dist/common/customerConfig.d.ts +9 -0
  9. package/dist/common/customerConfig.d.ts.map +1 -0
  10. package/dist/common/customerConfig.js +15 -0
  11. package/dist/common/customerConfig.js.map +1 -0
  12. package/dist/common/entraIdAccessToken.d.ts +12 -0
  13. package/dist/common/entraIdAccessToken.d.ts.map +1 -0
  14. package/dist/common/entraIdAccessToken.js +72 -0
  15. package/dist/common/entraIdAccessToken.js.map +1 -0
  16. package/dist/common/environmentVariables.d.ts +12 -0
  17. package/dist/common/environmentVariables.d.ts.map +1 -0
  18. package/dist/common/environmentVariables.js +17 -0
  19. package/dist/common/environmentVariables.js.map +1 -0
  20. package/dist/common/executor.d.ts +2 -0
  21. package/dist/common/executor.d.ts.map +1 -0
  22. package/dist/common/executor.js +79 -0
  23. package/dist/common/executor.js.map +1 -0
  24. package/dist/common/httpService.d.ts +5 -0
  25. package/dist/common/httpService.d.ts.map +1 -0
  26. package/dist/common/httpService.js +37 -0
  27. package/dist/common/httpService.js.map +1 -0
  28. package/dist/common/logger.d.ts +3 -0
  29. package/dist/common/logger.d.ts.map +1 -0
  30. package/dist/common/logger.js +9 -0
  31. package/dist/common/logger.js.map +1 -0
  32. package/dist/common/messages.d.ts +9 -0
  33. package/dist/common/messages.d.ts.map +1 -0
  34. package/dist/common/messages.js +14 -0
  35. package/dist/common/messages.js.map +1 -0
  36. package/dist/common/multimap.d.ts +16 -0
  37. package/dist/common/multimap.d.ts.map +1 -0
  38. package/dist/common/multimap.js +64 -0
  39. package/dist/common/multimap.js.map +1 -0
  40. package/dist/common/playwrightServiceConfig.d.ts +12 -0
  41. package/dist/common/playwrightServiceConfig.d.ts.map +1 -0
  42. package/dist/common/playwrightServiceConfig.js +39 -0
  43. package/dist/common/playwrightServiceConfig.js.map +1 -0
  44. package/dist/common/types.d.ts +301 -0
  45. package/dist/common/types.d.ts.map +1 -0
  46. package/dist/common/types.js +5 -0
  47. package/dist/common/types.js.map +1 -0
  48. package/dist/core/global/playwright-service-global-setup.d.ts +4 -0
  49. package/dist/core/global/playwright-service-global-setup.d.ts.map +1 -0
  50. package/dist/core/global/playwright-service-global-setup.js +19 -0
  51. package/dist/core/global/playwright-service-global-setup.js.map +1 -0
  52. package/dist/core/global/playwright-service-global-teardown.d.ts +4 -0
  53. package/dist/core/global/playwright-service-global-teardown.d.ts.map +1 -0
  54. package/dist/core/global/playwright-service-global-teardown.js +19 -0
  55. package/dist/core/global/playwright-service-global-teardown.js.map +1 -0
  56. package/dist/core/playwrightService.d.ts +63 -0
  57. package/dist/core/playwrightService.d.ts.map +1 -0
  58. package/dist/core/playwrightService.js +131 -0
  59. package/dist/core/playwrightService.js.map +1 -0
  60. package/dist/core/playwrightServiceEntra.d.ts +16 -0
  61. package/dist/core/playwrightServiceEntra.d.ts.map +1 -0
  62. package/dist/core/playwrightServiceEntra.js +51 -0
  63. package/dist/core/playwrightServiceEntra.js.map +1 -0
  64. package/dist/index.d.ts +10 -0
  65. package/dist/index.d.ts.map +1 -0
  66. package/dist/index.js +19 -0
  67. package/dist/index.js.map +1 -0
  68. package/dist/model/entraTokenDetails.d.ts +5 -0
  69. package/dist/model/entraTokenDetails.d.ts.map +1 -0
  70. package/dist/model/entraTokenDetails.js +9 -0
  71. package/dist/model/entraTokenDetails.js.map +1 -0
  72. package/dist/model/mptTokenDetails.d.ts +11 -0
  73. package/dist/model/mptTokenDetails.d.ts.map +1 -0
  74. package/dist/model/mptTokenDetails.js +14 -0
  75. package/dist/model/mptTokenDetails.js.map +1 -0
  76. package/dist/model/shard.d.ts +41 -0
  77. package/dist/model/shard.d.ts.map +1 -0
  78. package/dist/model/shard.js +24 -0
  79. package/dist/model/shard.js.map +1 -0
  80. package/dist/model/storageUri.d.ts +14 -0
  81. package/dist/model/storageUri.d.ts.map +1 -0
  82. package/dist/model/storageUri.js +22 -0
  83. package/dist/model/storageUri.js.map +1 -0
  84. package/dist/model/testResult.d.ts +40 -0
  85. package/dist/model/testResult.d.ts.map +1 -0
  86. package/dist/model/testResult.js +9 -0
  87. package/dist/model/testResult.js.map +1 -0
  88. package/dist/model/testRun.d.ts +36 -0
  89. package/dist/model/testRun.d.ts.map +1 -0
  90. package/dist/model/testRun.js +12 -0
  91. package/dist/model/testRun.js.map +1 -0
  92. package/dist/reporter/index.d.ts +10 -0
  93. package/dist/reporter/index.d.ts.map +1 -0
  94. package/dist/reporter/index.js +15 -0
  95. package/dist/reporter/index.js.map +1 -0
  96. package/dist/reporter/mptReporter.d.ts +96 -0
  97. package/dist/reporter/mptReporter.d.ts.map +1 -0
  98. package/dist/reporter/mptReporter.js +350 -0
  99. package/dist/reporter/mptReporter.js.map +1 -0
  100. package/dist/tsdoc-metadata.json +11 -0
  101. package/dist/utils/cIInfoProvider.d.ts +25 -0
  102. package/dist/utils/cIInfoProvider.d.ts.map +1 -0
  103. package/dist/utils/cIInfoProvider.js +107 -0
  104. package/dist/utils/cIInfoProvider.js.map +1 -0
  105. package/dist/utils/packageManager.d.ts +15 -0
  106. package/dist/utils/packageManager.d.ts.map +1 -0
  107. package/dist/utils/packageManager.js +54 -0
  108. package/dist/utils/packageManager.js.map +1 -0
  109. package/dist/utils/reporterUtils.d.ts +57 -0
  110. package/dist/utils/reporterUtils.d.ts.map +1 -0
  111. package/dist/utils/reporterUtils.js +547 -0
  112. package/dist/utils/reporterUtils.js.map +1 -0
  113. package/dist/utils/serviceClient.d.ts +23 -0
  114. package/dist/utils/serviceClient.d.ts.map +1 -0
  115. package/dist/utils/serviceClient.js +91 -0
  116. package/dist/utils/serviceClient.js.map +1 -0
  117. package/dist/utils/storageClient.d.ts +6 -0
  118. package/dist/utils/storageClient.d.ts.map +1 -0
  119. package/dist/utils/storageClient.js +41 -0
  120. package/dist/utils/storageClient.js.map +1 -0
  121. package/dist/utils/utils.d.ts +17 -0
  122. package/dist/utils/utils.d.ts.map +1 -0
  123. package/dist/utils/utils.js +143 -0
  124. package/dist/utils/utils.js.map +1 -0
  125. package/package.json +104 -0
  126. package/types/microsoft-playwright-testing.d.ts +352 -0
  127. package/types/reporter/microsoft-playwright-testing.d.ts +146 -0
@@ -0,0 +1,350 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT License.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ const tslib_1 = require("tslib");
6
+ const logger_1 = require("../common/logger");
7
+ const constants_1 = require("../common/constants");
8
+ const environmentVariables_1 = require("../common/environmentVariables");
9
+ const multimap_1 = require("../common/multimap");
10
+ const mptTokenDetails_1 = require("../model/mptTokenDetails");
11
+ const cIInfoProvider_1 = require("../utils/cIInfoProvider");
12
+ const reporterUtils_1 = tslib_1.__importDefault(require("../utils/reporterUtils"));
13
+ const serviceClient_1 = require("../utils/serviceClient");
14
+ const storageClient_1 = require("../utils/storageClient");
15
+ const messages_1 = require("../common/messages");
16
+ /**
17
+ * @public
18
+ *
19
+ * Extends Playwright's Reporter class to enable Microsoft Playwright Testing's Reporting
20
+ * feature to publish test results and related artifacts and
21
+ * view them in the service portal for faster and easier troubleshooting.
22
+ *
23
+ * @example
24
+ *
25
+ * ```
26
+ * import { defineConfig } from "@playwright/test";
27
+ *
28
+ * export default defineConfig({
29
+ * reporter: [["@azure/microsoft-playwright-testing/reporter"]]
30
+ * });
31
+ * ```
32
+ */
33
+ class MPTReporter {
34
+ constructor(config) {
35
+ this.isTokenValid = true;
36
+ this.enableGitHubSummary = true;
37
+ this.isRegionValid = true;
38
+ this.isTestRunStartSuccess = false;
39
+ this.ciInfo = cIInfoProvider_1.CIInfoProvider.getCIInfo();
40
+ this.testRawResults = new multimap_1.MultiMap();
41
+ this._testEndPromises = [];
42
+ this.testResultBatch = new Set();
43
+ this.errorMessages = [];
44
+ this.informationalMessages = [];
45
+ this.processedErrorMessageKeys = [];
46
+ this.uploadMetadata = {
47
+ numTestResults: 0,
48
+ numTotalAttachments: 0,
49
+ sizeTotalAttachments: 0,
50
+ };
51
+ this.numWorkers = -1;
52
+ this.testRunUrl = "";
53
+ this.enableResultPublish = true;
54
+ if ((config === null || config === void 0 ? void 0 : config.enableGitHubSummary) !== undefined) {
55
+ this.enableGitHubSummary = config.enableGitHubSummary;
56
+ }
57
+ if ((config === null || config === void 0 ? void 0 : config.enableResultPublish) !== undefined) {
58
+ this.enableResultPublish = config.enableResultPublish;
59
+ }
60
+ }
61
+ _addError(errorMessage) {
62
+ if (this.errorMessages.length < constants_1.Constants.ERROR_MESSAGES_MAX_LENGTH) {
63
+ this.errorMessages.push(this.reporterUtils.redactAccessToken(errorMessage));
64
+ }
65
+ }
66
+ _addInformationalMessage(message) {
67
+ this.informationalMessages.push(message);
68
+ }
69
+ /**
70
+ * @public
71
+ *
72
+ * Called once before running tests.
73
+ *
74
+ * @param config - Resolved configuration.
75
+ * @param suite - The root suite that contains all projects, files and test cases.
76
+ */
77
+ onBegin(config, suite) {
78
+ if (!this.enableResultPublish)
79
+ return;
80
+ this.initializeMPTReporter();
81
+ this.reporterUtils = new reporterUtils_1.default(this.envVariables, config, suite);
82
+ if (this.isTokenValid && this.isRegionValid) {
83
+ this.serviceClient = new serviceClient_1.ServiceClient(this.envVariables, this.reporterUtils);
84
+ this.promiseOnBegin = this._onBegin();
85
+ }
86
+ }
87
+ /**
88
+ * @public
89
+ *
90
+ * Called after a test has been finished in the worker process.
91
+ *
92
+ * @param test - Test that has been finished.
93
+ * @param result - Result of the test run.
94
+ */
95
+ onTestEnd(test, result) {
96
+ this.numWorkers = Math.max(this.numWorkers, result.parallelIndex + 1);
97
+ this.processTestResult(result);
98
+ if (!this.enableResultPublish)
99
+ return;
100
+ // Process test result
101
+ this._onTestEnd(test, result);
102
+ // Upload the test results batch
103
+ try {
104
+ if (this.testResultBatch.size >= constants_1.Constants.TEST_BATCH_SIZE) {
105
+ const currResultBatch = [...this.testResultBatch];
106
+ if (this.isTestRunStartSuccess) {
107
+ this._testEndPromises.push(this.serviceClient.postTestResults(currResultBatch));
108
+ logger_1.reporterLogger.info(`\nAdded test results batch for upload.`);
109
+ this.testResultBatch.clear();
110
+ }
111
+ }
112
+ }
113
+ catch (err) {
114
+ this._addError(`Name: ${err.name}, Message: ${err.message}, Stack: ${err.stack}`);
115
+ logger_1.reporterLogger.error(`\nError in uploading test results: ${err.message}.`);
116
+ }
117
+ }
118
+ /**
119
+ * @public
120
+ *
121
+ * Called after all tests have been run, or testing has been interrupted. Note that this method may return a [Promise]
122
+ * and Playwright Test will await it. Reporter is allowed to override the status and hence affect the exit code of the
123
+ * test runner.
124
+ *
125
+ * @param result - Result of the full test run, `status` can be one of:
126
+ * - `'passed'` - Everything went as expected.
127
+ * - `'failed'` - Any test has failed.
128
+ * - `'timedout'` - The
129
+ * {@link https://playwright.dev/docs/api/class-testconfig#test-config-global-timeout | testConfig.globalTimeout} has
130
+ * been reached.
131
+ * - `'interrupted'` - Interrupted by the user.
132
+ */
133
+ async onEnd(result) {
134
+ if (this.enableResultPublish) {
135
+ await this._onEnd(result);
136
+ if (!this.isTestRunStartSuccess) {
137
+ this._addError(`\nUnable to initialize test run report.`);
138
+ }
139
+ else {
140
+ let count = 0;
141
+ process.stdout.write("\nUploading test results.");
142
+ await Promise.allSettled(this._testEndPromises).then((values) => {
143
+ values.forEach((value) => {
144
+ if (value.status === "fulfilled") {
145
+ count++;
146
+ this.reporterUtils.progressBar(count, this._testEndPromises.length);
147
+ }
148
+ return value.status;
149
+ });
150
+ logger_1.reporterLogger.info(`\nTest result processing completed.`);
151
+ return values;
152
+ });
153
+ try {
154
+ await this.serviceClient.postTestRunShardEnd(result, this.shard, this.errorMessages, this.uploadMetadata, this.numWorkers);
155
+ logger_1.reporterLogger.info(`\nTest run successfully uploaded.`);
156
+ if (this.enableGitHubSummary) {
157
+ this.reporterUtils.generateMarkdownSummary(this.testRunUrl);
158
+ }
159
+ process.stdout.write(`\nTest report: ${this.testRunUrl}\n`);
160
+ }
161
+ catch (err) {
162
+ this._addError(`Name: ${err.name}, Message: ${err.message}, Stack: ${err.stack}`);
163
+ logger_1.reporterLogger.error(`\nError in completing test run: ${err.message}`);
164
+ process.stdout.write(`\nUnable to complete test results upload.`);
165
+ }
166
+ }
167
+ }
168
+ this.displayAdditionalInformation();
169
+ }
170
+ async _onBegin() {
171
+ process.stdout.write(`\n`);
172
+ try {
173
+ const testRunResponse = await this.serviceClient.patchTestRun(this.ciInfo);
174
+ logger_1.reporterLogger.info(`\nTest run report successfully initialized: ${testRunResponse === null || testRunResponse === void 0 ? void 0 : testRunResponse.displayName}.`);
175
+ process.stdout.write(`Initializing reporting for this test run. You can view the results at: https://playwright.microsoft.com/workspaces/${this.envVariables.accountId}/runs/${this.envVariables.runId}\n`);
176
+ const shardResponse = await this.serviceClient.postTestRunShardStart();
177
+ this.shard = shardResponse;
178
+ // Set test report link as environment variable. If/else to check if environment variable defined or not.
179
+ if (constants_1.Constants.DEFAULT_SERVICE_ENDPOINT &&
180
+ this.envVariables.accountId &&
181
+ this.envVariables.runId) {
182
+ this.testRunUrl = `${constants_1.Constants.DEFAULT_DASHBOARD_ENDPOINT}/workspaces/${encodeURI(this.envVariables.accountId)}/runs/${encodeURI(this.envVariables.runId)}`;
183
+ }
184
+ return true;
185
+ }
186
+ catch (err) {
187
+ this._addError(`Name: ${err.name}, Message: ${err.message}, Stack: ${err.stack}`);
188
+ logger_1.reporterLogger.error(`\nError in initializing test run report: ${err.message}.`);
189
+ return false;
190
+ }
191
+ }
192
+ async _onTestEnd(test, result) {
193
+ try {
194
+ this.isTestRunStartSuccess = await this.promiseOnBegin;
195
+ if (!this.isTestRunStartSuccess) {
196
+ this._addError(`\nUnable to initialize test run report.`);
197
+ return;
198
+ }
199
+ this.uploadMetadata.numTestResults++;
200
+ const testResultObject = this.reporterUtils.getTestResultObject(test, result, this.ciInfo.jobId);
201
+ this.testResultBatch.add(testResultObject);
202
+ // Store test attachments in array
203
+ const testAttachments = [];
204
+ for (const attachment of result.attachments) {
205
+ if (attachment.path !== undefined && attachment.path !== "") {
206
+ testAttachments.push(attachment.path);
207
+ this.uploadMetadata.numTotalAttachments++;
208
+ this.uploadMetadata.sizeTotalAttachments += reporterUtils_1.default.getFileSize(attachment.path);
209
+ }
210
+ }
211
+ // Get raw result object and store it in map
212
+ const rawTestResult = this.reporterUtils.getRawTestResultObject(result);
213
+ this.testRawResults.set(testResultObject.testExecutionId, JSON.stringify(rawTestResult));
214
+ this._testEndPromises.push(this._uploadTestResultAttachments(testResultObject.testExecutionId, testAttachments));
215
+ }
216
+ catch (err) {
217
+ this._addError(`Name: ${err.name}, Message: ${err.message}, Stack: ${err.stack}`);
218
+ logger_1.reporterLogger.error(`\nError in processing test result: ${err.message}.`);
219
+ }
220
+ }
221
+ async _onEnd(_) {
222
+ this.isTestRunStartSuccess = await this.promiseOnBegin;
223
+ if (!this.isTestRunStartSuccess) {
224
+ this._addError(`\nUnable to initialize test run report.`);
225
+ return;
226
+ }
227
+ try {
228
+ // Upload the remaining test results
229
+ if (this.testResultBatch.size > 0) {
230
+ await this.serviceClient.postTestResults([...this.testResultBatch]);
231
+ logger_1.reporterLogger.info(`\nUploaded test results batch successfully.`);
232
+ this.testResultBatch.clear();
233
+ }
234
+ }
235
+ catch (err) {
236
+ this._addError(`Name: ${err.name}, Message: ${err.message}, Stack: ${err.stack}`);
237
+ logger_1.reporterLogger.error(`\nError in uploading test run information: ${err.message}`);
238
+ }
239
+ }
240
+ async _uploadTestResultAttachments(testExecutionId, testAttachments) {
241
+ try {
242
+ this.isTestRunStartSuccess = await this.promiseOnBegin;
243
+ if (!this.isTestRunStartSuccess) {
244
+ this._addError(`\nUnable to initialize test run report.`);
245
+ return;
246
+ }
247
+ for (const attachmentPath of testAttachments) {
248
+ const fileRelativePath = `${testExecutionId}/${reporterUtils_1.default.getFileRelativePath(attachmentPath)}`;
249
+ if (this.sasUri === undefined ||
250
+ !reporterUtils_1.default.isTimeGreaterThanCurrentPlus10Minutes(this.sasUri.expiresAt)) {
251
+ // Renew the sas uri
252
+ this.sasUri = await this.serviceClient.createStorageUri();
253
+ logger_1.reporterLogger.info(`\nFetched SAS URI with validity: ${this.sasUri.expiresAt} and access: ${this.sasUri.accessLevel}.`);
254
+ }
255
+ this.storageClient.uploadFile(this.sasUri.uri, attachmentPath, fileRelativePath);
256
+ }
257
+ const rawTestResult = this.testRawResults.get(testExecutionId);
258
+ if (this.sasUri === undefined ||
259
+ !reporterUtils_1.default.isTimeGreaterThanCurrentPlus10Minutes(this.sasUri.expiresAt)) {
260
+ // Renew the sas uri
261
+ this.sasUri = await this.serviceClient.createStorageUri();
262
+ }
263
+ this.storageClient.uploadBuffer(this.sasUri.uri, rawTestResult[0], `${testExecutionId}/rawTestResult.json`);
264
+ }
265
+ catch (err) {
266
+ this._addError(`Name: ${err.name}, Message: ${err.message}, Stack: ${err.stack}`);
267
+ logger_1.reporterLogger.error(`\nError in uploading test result attachments: ${err.message}`);
268
+ }
269
+ }
270
+ initializeMPTReporter() {
271
+ this.envVariables = new environmentVariables_1.EnvironmentVariables();
272
+ if (process.env[constants_1.InternalEnvironmentVariables.MPT_SETUP_FATAL_ERROR] === "true") {
273
+ this.isTokenValid = false;
274
+ return;
275
+ }
276
+ if (!process.env["PLAYWRIGHT_SERVICE_REPORTING_URL"]) {
277
+ process.stdout.write("\nReporting service url not found.");
278
+ this.isTokenValid = false;
279
+ return;
280
+ }
281
+ logger_1.reporterLogger.info(`Reporting url - ${process.env["PLAYWRIGHT_SERVICE_REPORTING_URL"]}`);
282
+ if (this.envVariables.accessToken === undefined || this.envVariables.accessToken === "") {
283
+ process.stdout.write(`\n${messages_1.ServiceErrorMessageConstants.NO_AUTH_ERROR}`);
284
+ this.isTokenValid = false;
285
+ }
286
+ else if (reporterUtils_1.default.hasAudienceClaim(this.envVariables.accessToken)) {
287
+ const result = reporterUtils_1.default.populateValuesFromServiceUrl();
288
+ this.envVariables.region = result.region;
289
+ this.envVariables.accountId = result.accountId;
290
+ const entraTokenDetails = reporterUtils_1.default.getTokenDetails(this.envVariables.accessToken, mptTokenDetails_1.TokenType.ENTRA);
291
+ this.envVariables.userId = entraTokenDetails.oid;
292
+ this.envVariables.userName = entraTokenDetails.name;
293
+ }
294
+ else {
295
+ const mptTokenDetails = reporterUtils_1.default.getTokenDetails(this.envVariables.accessToken, mptTokenDetails_1.TokenType.MPT);
296
+ this.envVariables.accountId = mptTokenDetails.aid;
297
+ this.envVariables.userId = mptTokenDetails.oid;
298
+ this.envVariables.userName = mptTokenDetails.userName;
299
+ this.envVariables.region = reporterUtils_1.default.getRegionFromAccountID(this.envVariables.accountId);
300
+ }
301
+ this.storageClient = new storageClient_1.StorageClient();
302
+ if (this.envVariables.region &&
303
+ !constants_1.Constants.SupportedRegions.includes(this.envVariables.region) &&
304
+ this.isTokenValid) {
305
+ process.stdout.write(`\nUnsupported region's workspace used to generate the input Access Token; the supported regions are ${constants_1.Constants.SupportedRegions.join(", ")}`);
306
+ this.isRegionValid = false;
307
+ }
308
+ if (this.envVariables.runId === undefined || this.envVariables.runId === "") {
309
+ this.envVariables.runId = reporterUtils_1.default.getRunId(this.ciInfo);
310
+ }
311
+ }
312
+ displayAdditionalInformation() {
313
+ if (this.informationalMessages.length > 0)
314
+ console.info(); // Add a new line before displaying the messages
315
+ this.informationalMessages.forEach((message, index) => {
316
+ console.info(`${index + 1}. ${message}`);
317
+ });
318
+ }
319
+ processTestResult(result) {
320
+ if (process.env[constants_1.InternalEnvironmentVariables.MPT_CLOUD_HOSTED_BROWSER_USED] &&
321
+ result.status !== "passed") {
322
+ result.errors.forEach((error) => {
323
+ constants_1.TestResultErrorConstants.forEach((testResultErrorParseObj) => {
324
+ if (this.processedErrorMessageKeys.includes(testResultErrorParseObj.key)) {
325
+ return;
326
+ }
327
+ const errorMessage = error.message;
328
+ if (!errorMessage)
329
+ return;
330
+ const match = errorMessage.match(testResultErrorParseObj.pattern);
331
+ if (match) {
332
+ this.processedErrorMessageKeys.push(testResultErrorParseObj.key);
333
+ this._addInformationalMessage(testResultErrorParseObj.message);
334
+ }
335
+ });
336
+ });
337
+ }
338
+ }
339
+ /**
340
+ * @public
341
+ *
342
+ * Whether this reporter uses stdio for reporting. When it does not, Playwright Test could add some output to enhance
343
+ * user experience. If your reporter does not print to the terminal, it is strongly recommended to return `false`.
344
+ */
345
+ printsToStdio() {
346
+ return true;
347
+ }
348
+ }
349
+ exports.default = MPTReporter;
350
+ //# sourceMappingURL=mptReporter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mptReporter.js","sourceRoot":"","sources":["../../src/reporter/mptReporter.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAUlC,6CAAkD;AAClD,mDAI6B;AAC7B,yEAAsE;AACtE,iDAA8C;AAE9C,8DAAsE;AAKtE,4DAAiE;AACjE,mFAAmD;AACnD,0DAAuD;AACvD,0DAAuD;AAEvD,iDAAkE;AAElE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW;IA4Bf,YAAY,MAAkC;QA3BtC,iBAAY,GAAY,IAAI,CAAC;QAC7B,wBAAmB,GAAG,IAAI,CAAC;QAC3B,kBAAa,GAAY,IAAI,CAAC;QAE9B,0BAAqB,GAAY,KAAK,CAAC;QACvC,WAAM,GAAW,+BAAc,CAAC,SAAS,EAAE,CAAC;QAK5C,mBAAc,GAAG,IAAI,mBAAQ,EAAkB,CAAC;QAEhD,qBAAgB,GAAoB,EAAE,CAAC;QACvC,oBAAe,GAAuB,IAAI,GAAG,EAAiB,CAAC;QAC/D,kBAAa,GAAa,EAAE,CAAC;QAC7B,0BAAqB,GAAa,EAAE,CAAC;QACrC,8BAAyB,GAAa,EAAE,CAAC;QAEzC,mBAA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,OAAO,CAAC,CAAC,uBAAuB,EAAE,EAAE;oBAC3D,IAAI,IAAI,CAAC,yBAAyB,CAAC,QAAQ,CAAC,uBAAuB,CAAC,GAAG,CAAC,EAAE,CAAC;wBACzE,OAAO;oBACT,CAAC;oBACD,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC;oBACnC,IAAI,CAAC,YAAY;wBAAE,OAAO;oBAC1B,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;oBAClE,IAAI,KAAK,EAAE,CAAC;wBACV,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,uBAAuB,CAAC,GAAG,CAAC,CAAC;wBACjE,IAAI,CAAC,wBAAwB,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;oBACjE,CAAC;gBACH,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,aAAa;QACX,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AACD,kBAAe,WAAW,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n FullResult,\n TestCase,\n TestResult,\n FullConfig,\n Reporter,\n Suite,\n} from \"@playwright/test/reporter\";\nimport { reporterLogger } from \"../common/logger\";\nimport {\n Constants,\n InternalEnvironmentVariables,\n TestResultErrorConstants,\n} from \"../common/constants\";\nimport { EnvironmentVariables } from \"../common/environmentVariables\";\nimport { MultiMap } from \"../common/multimap\";\nimport { EntraTokenDetails } from \"../model/entraTokenDetails\";\nimport { MPTTokenDetails, TokenType } from \"../model/mptTokenDetails\";\nimport { Shard, UploadMetadata } from \"../model/shard\";\nimport { StorageUri } from \"../model/storageUri\";\nimport { TestResult as MPTTestResult, RawTestResult } from \"../model/testResult\";\nimport { TestRun } from \"../model/testRun\";\nimport { CIInfo, CIInfoProvider } from \"../utils/cIInfoProvider\";\nimport ReporterUtils from \"../utils/reporterUtils\";\nimport { ServiceClient } from \"../utils/serviceClient\";\nimport { StorageClient } from \"../utils/storageClient\";\nimport { MPTReporterConfig } from \"../common/types\";\nimport { ServiceErrorMessageConstants } from \"../common/messages\";\n\n/**\n * @public\n *\n * Extends Playwright's Reporter class to enable Microsoft Playwright Testing's Reporting\n * feature to publish test results and related artifacts and\n * view them in the service portal for faster and easier troubleshooting.\n *\n * @example\n *\n * ```\n * import { defineConfig } from \"@playwright/test\";\n *\n * export default defineConfig({\n * reporter: [[\"@azure/microsoft-playwright-testing/reporter\"]]\n * });\n * ```\n */\nclass MPTReporter implements Reporter {\n private isTokenValid: boolean = true;\n private enableGitHubSummary = true;\n private isRegionValid: boolean = true;\n private shard!: Shard;\n private isTestRunStartSuccess: boolean = false;\n private ciInfo: CIInfo = CIInfoProvider.getCIInfo();\n private serviceClient!: ServiceClient;\n private storageClient!: StorageClient;\n private reporterUtils!: ReporterUtils;\n private envVariables!: EnvironmentVariables;\n private testRawResults = new MultiMap<string, string>();\n private promiseOnBegin!: Promise<boolean>;\n private _testEndPromises: Promise<void>[] = [];\n private testResultBatch: Set<MPTTestResult> = new Set<MPTTestResult>();\n private errorMessages: string[] = [];\n private informationalMessages: string[] = [];\n private processedErrorMessageKeys: string[] = [];\n private sasUri!: StorageUri;\n private uploadMetadata: UploadMetadata = {\n numTestResults: 0,\n numTotalAttachments: 0,\n sizeTotalAttachments: 0,\n };\n private numWorkers: number = -1;\n private testRunUrl: string = \"\";\n private enableResultPublish: boolean = true;\n\n constructor(config: Partial<MPTReporterConfig>) {\n if (config?.enableGitHubSummary !== undefined) {\n this.enableGitHubSummary = config.enableGitHubSummary;\n }\n if (config?.enableResultPublish !== undefined) {\n this.enableResultPublish = config.enableResultPublish;\n }\n }\n private _addError(errorMessage: string): void {\n if (this.errorMessages.length < Constants.ERROR_MESSAGES_MAX_LENGTH) {\n this.errorMessages.push(this.reporterUtils.redactAccessToken(errorMessage));\n }\n }\n\n private _addInformationalMessage(message: string): void {\n this.informationalMessages.push(message);\n }\n\n /**\n * @public\n *\n * Called once before running tests.\n *\n * @param config - Resolved configuration.\n * @param suite - The root suite that contains all projects, files and test cases.\n */\n onBegin(config: FullConfig, suite: Suite): void {\n if (!this.enableResultPublish) return;\n this.initializeMPTReporter();\n this.reporterUtils = new ReporterUtils(this.envVariables, config, suite);\n if (this.isTokenValid && this.isRegionValid) {\n this.serviceClient = new ServiceClient(this.envVariables, this.reporterUtils);\n this.promiseOnBegin = this._onBegin();\n }\n }\n\n /**\n * @public\n *\n * Called after a test has been finished in the worker process.\n *\n * @param test - Test that has been finished.\n * @param result - Result of the test run.\n */\n onTestEnd(test: TestCase, result: TestResult): void {\n this.numWorkers = Math.max(this.numWorkers, result.parallelIndex + 1);\n this.processTestResult(result);\n if (!this.enableResultPublish) return;\n // Process test result\n this._onTestEnd(test, result);\n // Upload the test results batch\n try {\n if (this.testResultBatch.size >= Constants.TEST_BATCH_SIZE) {\n const currResultBatch: MPTTestResult[] = [...this.testResultBatch];\n if (this.isTestRunStartSuccess) {\n this._testEndPromises.push(this.serviceClient.postTestResults(currResultBatch));\n reporterLogger.info(`\\nAdded test results batch for upload.`);\n this.testResultBatch.clear();\n }\n }\n } catch (err: any) {\n this._addError(`Name: ${err.name}, Message: ${err.message}, Stack: ${err.stack}`);\n reporterLogger.error(`\\nError in uploading test results: ${err.message}.`);\n }\n }\n\n /**\n * @public\n *\n * Called after all tests have been run, or testing has been interrupted. Note that this method may return a [Promise]\n * and Playwright Test will await it. Reporter is allowed to override the status and hence affect the exit code of the\n * test runner.\n *\n * @param result - Result of the full test run, `status` can be one of:\n * - `'passed'` - Everything went as expected.\n * - `'failed'` - Any test has failed.\n * - `'timedout'` - The\n * {@link https://playwright.dev/docs/api/class-testconfig#test-config-global-timeout | testConfig.globalTimeout} has\n * been reached.\n * - `'interrupted'` - Interrupted by the user.\n */\n async onEnd(result: FullResult): Promise<void> {\n if (this.enableResultPublish) {\n await this._onEnd(result);\n if (!this.isTestRunStartSuccess) {\n this._addError(`\\nUnable to initialize test run report.`);\n } else {\n let count: number = 0;\n process.stdout.write(\"\\nUploading test results.\");\n await Promise.allSettled(this._testEndPromises).then((values) => {\n values.forEach((value) => {\n if (value.status === \"fulfilled\") {\n count++;\n this.reporterUtils.progressBar(count, this._testEndPromises.length);\n }\n return value.status;\n });\n reporterLogger.info(`\\nTest result processing completed.`);\n return values;\n });\n try {\n await this.serviceClient.postTestRunShardEnd(\n result,\n this.shard,\n this.errorMessages,\n this.uploadMetadata,\n this.numWorkers,\n );\n reporterLogger.info(`\\nTest run successfully uploaded.`);\n\n if (this.enableGitHubSummary) {\n this.reporterUtils.generateMarkdownSummary(this.testRunUrl);\n }\n\n process.stdout.write(`\\nTest report: ${this.testRunUrl}\\n`);\n } catch (err: any) {\n this._addError(`Name: ${err.name}, Message: ${err.message}, Stack: ${err.stack}`);\n reporterLogger.error(`\\nError in completing test run: ${err.message}`);\n process.stdout.write(`\\nUnable to complete test results upload.`);\n }\n }\n }\n this.displayAdditionalInformation();\n }\n\n private async _onBegin(): Promise<boolean> {\n process.stdout.write(`\\n`);\n try {\n const testRunResponse: TestRun | undefined = await this.serviceClient.patchTestRun(\n this.ciInfo,\n );\n reporterLogger.info(\n `\\nTest run report successfully initialized: ${testRunResponse?.displayName}.`,\n );\n process.stdout.write(\n `Initializing reporting for this test run. You can view the results at: https://playwright.microsoft.com/workspaces/${this.envVariables.accountId}/runs/${this.envVariables.runId}\\n`,\n );\n const shardResponse = await this.serviceClient.postTestRunShardStart();\n this.shard = shardResponse;\n // Set test report link as environment variable. If/else to check if environment variable defined or not.\n if (\n Constants.DEFAULT_SERVICE_ENDPOINT &&\n this.envVariables.accountId &&\n this.envVariables.runId\n ) {\n this.testRunUrl = `${Constants.DEFAULT_DASHBOARD_ENDPOINT}/workspaces/${encodeURI(\n this.envVariables.accountId,\n )}/runs/${encodeURI(this.envVariables.runId)}`;\n }\n return true;\n } catch (err: any) {\n this._addError(`Name: ${err.name}, Message: ${err.message}, Stack: ${err.stack}`);\n reporterLogger.error(`\\nError in initializing test run report: ${err.message}.`);\n return false;\n }\n }\n\n private async _onTestEnd(test: TestCase, result: TestResult): Promise<undefined> {\n try {\n this.isTestRunStartSuccess = await this.promiseOnBegin;\n if (!this.isTestRunStartSuccess) {\n this._addError(`\\nUnable to initialize test run report.`);\n return;\n }\n this.uploadMetadata.numTestResults++;\n const testResultObject: MPTTestResult = this.reporterUtils.getTestResultObject(\n test,\n result,\n this.ciInfo.jobId!,\n );\n this.testResultBatch.add(testResultObject);\n // Store test attachments in array\n const testAttachments: string[] = [];\n for (const attachment of result.attachments) {\n if (attachment.path !== undefined && attachment.path !== \"\") {\n testAttachments.push(attachment.path);\n this.uploadMetadata.numTotalAttachments++;\n this.uploadMetadata.sizeTotalAttachments += ReporterUtils.getFileSize(attachment.path);\n }\n }\n\n // Get raw result object and store it in map\n const rawTestResult: RawTestResult = this.reporterUtils.getRawTestResultObject(result);\n this.testRawResults.set(testResultObject.testExecutionId, JSON.stringify(rawTestResult));\n this._testEndPromises.push(\n this._uploadTestResultAttachments(testResultObject.testExecutionId, testAttachments),\n );\n } catch (err: any) {\n this._addError(`Name: ${err.name}, Message: ${err.message}, Stack: ${err.stack}`);\n reporterLogger.error(`\\nError in processing test result: ${err.message}.`);\n }\n }\n\n private async _onEnd(_: FullResult): Promise<void> {\n this.isTestRunStartSuccess = await this.promiseOnBegin;\n if (!this.isTestRunStartSuccess) {\n this._addError(`\\nUnable to initialize test run report.`);\n return;\n }\n try {\n // Upload the remaining test results\n if (this.testResultBatch.size > 0) {\n await this.serviceClient.postTestResults([...this.testResultBatch]);\n reporterLogger.info(`\\nUploaded test results batch successfully.`);\n this.testResultBatch.clear();\n }\n } catch (err: any) {\n this._addError(`Name: ${err.name}, Message: ${err.message}, Stack: ${err.stack}`);\n reporterLogger.error(`\\nError in uploading test run information: ${err.message}`);\n }\n }\n\n private async _uploadTestResultAttachments(\n testExecutionId: string,\n testAttachments: string[],\n ): Promise<void> {\n try {\n this.isTestRunStartSuccess = await this.promiseOnBegin;\n if (!this.isTestRunStartSuccess) {\n this._addError(`\\nUnable to initialize test run report.`);\n return;\n }\n for (const attachmentPath of testAttachments) {\n const fileRelativePath = `${testExecutionId}/${ReporterUtils.getFileRelativePath(\n attachmentPath,\n )}`;\n if (\n this.sasUri === undefined ||\n !ReporterUtils.isTimeGreaterThanCurrentPlus10Minutes(this.sasUri.expiresAt)\n ) {\n // Renew the sas uri\n this.sasUri = await this.serviceClient.createStorageUri();\n reporterLogger.info(\n `\\nFetched SAS URI with validity: ${this.sasUri.expiresAt} and access: ${this.sasUri.accessLevel}.`,\n );\n }\n this.storageClient.uploadFile(this.sasUri.uri, attachmentPath, fileRelativePath);\n }\n const rawTestResult = this.testRawResults.get(testExecutionId);\n if (\n this.sasUri === undefined ||\n !ReporterUtils.isTimeGreaterThanCurrentPlus10Minutes(this.sasUri.expiresAt)\n ) {\n // Renew the sas uri\n this.sasUri = await this.serviceClient.createStorageUri();\n }\n this.storageClient.uploadBuffer(\n this.sasUri.uri,\n rawTestResult[0]!,\n `${testExecutionId}/rawTestResult.json`,\n );\n } catch (err: any) {\n this._addError(`Name: ${err.name}, Message: ${err.message}, Stack: ${err.stack}`);\n reporterLogger.error(`\\nError in uploading test result attachments: ${err.message}`);\n }\n }\n\n private initializeMPTReporter(): void {\n this.envVariables = new EnvironmentVariables();\n if (process.env[InternalEnvironmentVariables.MPT_SETUP_FATAL_ERROR] === \"true\") {\n this.isTokenValid = false;\n return;\n }\n if (!process.env[\"PLAYWRIGHT_SERVICE_REPORTING_URL\"]) {\n process.stdout.write(\"\\nReporting service url not found.\");\n this.isTokenValid = false;\n return;\n }\n reporterLogger.info(`Reporting url - ${process.env[\"PLAYWRIGHT_SERVICE_REPORTING_URL\"]}`);\n if (this.envVariables.accessToken === undefined || this.envVariables.accessToken === \"\") {\n process.stdout.write(`\\n${ServiceErrorMessageConstants.NO_AUTH_ERROR}`);\n this.isTokenValid = false;\n } else if (ReporterUtils.hasAudienceClaim(this.envVariables.accessToken)) {\n const result = ReporterUtils.populateValuesFromServiceUrl();\n this.envVariables.region = result!.region;\n this.envVariables.accountId = result!.accountId;\n const entraTokenDetails: EntraTokenDetails = ReporterUtils.getTokenDetails<EntraTokenDetails>(\n this.envVariables.accessToken,\n TokenType.ENTRA,\n );\n this.envVariables.userId = entraTokenDetails.oid;\n this.envVariables.userName = entraTokenDetails.name;\n } else {\n const mptTokenDetails: MPTTokenDetails = ReporterUtils.getTokenDetails<MPTTokenDetails>(\n this.envVariables.accessToken,\n TokenType.MPT,\n );\n this.envVariables.accountId = mptTokenDetails.aid;\n this.envVariables.userId = mptTokenDetails.oid;\n this.envVariables.userName = mptTokenDetails.userName;\n this.envVariables.region = ReporterUtils.getRegionFromAccountID(this.envVariables.accountId!);\n }\n this.storageClient = new StorageClient();\n if (\n this.envVariables.region &&\n !Constants.SupportedRegions.includes(this.envVariables.region!) &&\n this.isTokenValid\n ) {\n process.stdout.write(\n `\\nUnsupported region's workspace used to generate the input Access Token; the supported regions are ${Constants.SupportedRegions.join(\n \", \",\n )}`,\n );\n this.isRegionValid = false;\n }\n if (this.envVariables.runId === undefined || this.envVariables.runId === \"\") {\n this.envVariables.runId = ReporterUtils.getRunId(this.ciInfo);\n }\n }\n\n private displayAdditionalInformation(): void {\n if (this.informationalMessages.length > 0) console.info(); // Add a new line before displaying the messages\n this.informationalMessages.forEach((message, index) => {\n console.info(`${index + 1}. ${message}`);\n });\n }\n\n private processTestResult(result: TestResult): void {\n if (\n process.env[InternalEnvironmentVariables.MPT_CLOUD_HOSTED_BROWSER_USED] &&\n result.status !== \"passed\"\n ) {\n result.errors.forEach((error) => {\n TestResultErrorConstants.forEach((testResultErrorParseObj) => {\n if (this.processedErrorMessageKeys.includes(testResultErrorParseObj.key)) {\n return;\n }\n const errorMessage = error.message;\n if (!errorMessage) return;\n const match = errorMessage.match(testResultErrorParseObj.pattern);\n if (match) {\n this.processedErrorMessageKeys.push(testResultErrorParseObj.key);\n this._addInformationalMessage(testResultErrorParseObj.message);\n }\n });\n });\n }\n }\n\n /**\n * @public\n *\n * Whether this reporter uses stdio for reporting. When it does not, Playwright Test could add some output to enhance\n * user experience. If your reporter does not print to the terminal, it is strongly recommended to return `false`.\n */\n printsToStdio(): boolean {\n return true;\n }\n}\nexport default MPTReporter;\n"]}
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.47.8"
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,25 @@
1
+ export declare enum CI_PROVIDERS {
2
+ GITHUB = "GITHUB",
3
+ ADO = "ADO",
4
+ DEFAULT = "DEFAULT"
5
+ }
6
+ export type CIInfo = {
7
+ provider: CI_PROVIDERS | null;
8
+ repo: string | null;
9
+ branch: string | null;
10
+ author: string | null;
11
+ commitId: string | null;
12
+ revisionUrl: string | null;
13
+ runId: string | null;
14
+ runAttempt: number | null;
15
+ jobId: string | null;
16
+ };
17
+ export declare class CIInfoProvider {
18
+ private static isGitHubActions;
19
+ static getCIProvider(): string | null;
20
+ static getCIInfo(): CIInfo;
21
+ private static isAzureDevOps;
22
+ private static getADORunId;
23
+ private static getGHBranchName;
24
+ }
25
+ //# sourceMappingURL=cIInfoProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cIInfoProvider.d.ts","sourceRoot":"","sources":["../../src/utils/cIInfoProvider.ts"],"names":[],"mappings":"AAGA,oBAAY,YAAY;IACtB,MAAM,WAAW;IACjB,GAAG,QAAQ;IACX,OAAO,YAAY;CAEpB;AAED,MAAM,MAAM,MAAM,GAAG;IACnB,QAAQ,EAAE,YAAY,GAAG,IAAI,CAAC;IAC9B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB,CAAC;AAEF,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAC,eAAe;IAI9B,MAAM,CAAC,aAAa,IAAI,MAAM,GAAG,IAAI;IAUrC,MAAM,CAAC,SAAS,IAAI,MAAM;IAsD1B,OAAO,CAAC,MAAM,CAAC,aAAa;IAM5B,OAAO,CAAC,MAAM,CAAC,WAAW;IAW1B,OAAO,CAAC,MAAM,CAAC,eAAe;CAU/B"}
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT License.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.CIInfoProvider = exports.CI_PROVIDERS = void 0;
6
+ var CI_PROVIDERS;
7
+ (function (CI_PROVIDERS) {
8
+ CI_PROVIDERS["GITHUB"] = "GITHUB";
9
+ CI_PROVIDERS["ADO"] = "ADO";
10
+ CI_PROVIDERS["DEFAULT"] = "DEFAULT";
11
+ // Add more CI providers as needed
12
+ })(CI_PROVIDERS || (exports.CI_PROVIDERS = CI_PROVIDERS = {}));
13
+ class CIInfoProvider {
14
+ static isGitHubActions() {
15
+ return process.env["GITHUB_ACTIONS"] === "true";
16
+ }
17
+ static getCIProvider() {
18
+ if (CIInfoProvider.isGitHubActions()) {
19
+ return CI_PROVIDERS.GITHUB;
20
+ }
21
+ else if (CIInfoProvider.isAzureDevOps()) {
22
+ return CI_PROVIDERS.ADO;
23
+ }
24
+ else {
25
+ return CI_PROVIDERS.DEFAULT;
26
+ }
27
+ }
28
+ static getCIInfo() {
29
+ var _a, _b, _c, _d, _e, _f, _g, _h;
30
+ const ciProvider = CIInfoProvider.getCIProvider();
31
+ if (ciProvider === CI_PROVIDERS.GITHUB) {
32
+ // Logic to get GitHub Actions CIInfo
33
+ return {
34
+ provider: CI_PROVIDERS.GITHUB,
35
+ repo: process.env["GITHUB_REPOSITORY_ID"] || null,
36
+ branch: this.getGHBranchName() || null,
37
+ author: process.env["GITHUB_ACTOR"] || null,
38
+ commitId: process.env["GITHUB_SHA"] || null,
39
+ revisionUrl: process.env["GITHUB_SERVER_URL"]
40
+ ? `${process.env["GITHUB_SERVER_URL"]}/${process.env["GITHUB_REPOSITORY"]}/commit/${process.env["GITHUB_SHA"]}`
41
+ : null,
42
+ runId: process.env["GITHUB_RUN_ID"] || null,
43
+ runAttempt: process.env["GITHUB_RUN_ATTEMPT"]
44
+ ? parseInt(process.env["GITHUB_RUN_ATTEMPT"], 10)
45
+ : null,
46
+ jobId: process.env["GITHUB_JOB"] || null,
47
+ };
48
+ }
49
+ else if (ciProvider === CI_PROVIDERS.ADO) {
50
+ // Logic to get Azure DevOps CIInfo
51
+ return {
52
+ provider: CI_PROVIDERS.ADO,
53
+ repo: process.env["BUILD_REPOSITORY_ID"] || null,
54
+ branch: process.env["BUILD_SOURCEBRANCH"] || null,
55
+ author: process.env["BUILD_REQUESTEDFOR"] || null,
56
+ commitId: process.env["BUILD_SOURCEVERSION"] || null,
57
+ revisionUrl: process.env["SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"]
58
+ ? `${process.env["SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"]}${process.env["SYSTEM_TEAMPROJECT"]}/_git/${process.env["BUILD_REPOSITORY_NAME"]}/commit/${process.env["BUILD_SOURCEVERSION"]}`
59
+ : null,
60
+ runId: this.getADORunId() || null,
61
+ runAttempt: process.env["RELEASE_ATTEMPTNUMBER"]
62
+ ? parseInt(process.env["RELEASE_ATTEMPTNUMBER"], 10)
63
+ : parseInt((_a = process.env["SYSTEM_JOBATTEMPT"]) !== null && _a !== void 0 ? _a : "", 10),
64
+ jobId: process.env["RELEASE_DEPLOYMENTID"]
65
+ ? process.env["RELEASE_DEPLOYMENTID"]
66
+ : process.env["SYSTEM_JOBID"] || null,
67
+ };
68
+ }
69
+ else {
70
+ // Handle unsupported CI provider
71
+ return {
72
+ provider: CI_PROVIDERS.DEFAULT,
73
+ repo: (_b = process.env["REPO"]) !== null && _b !== void 0 ? _b : "",
74
+ branch: (_c = process.env["BRANCH"]) !== null && _c !== void 0 ? _c : "",
75
+ author: (_d = process.env["AUTHOR"]) !== null && _d !== void 0 ? _d : "",
76
+ commitId: (_e = process.env["COMMIT_ID"]) !== null && _e !== void 0 ? _e : "",
77
+ revisionUrl: (_f = process.env["REVISION_URL"]) !== null && _f !== void 0 ? _f : "",
78
+ runId: (_g = process.env["RUN_ID"]) !== null && _g !== void 0 ? _g : "",
79
+ runAttempt: process.env["RUN_ATTEMPT"] ? parseInt(process.env["RUN_ATTEMPT"], 10) : null,
80
+ jobId: (_h = process.env["JOB_ID"]) !== null && _h !== void 0 ? _h : "",
81
+ };
82
+ }
83
+ }
84
+ static isAzureDevOps() {
85
+ return (process.env["AZURE_HTTP_USER_AGENT"] !== undefined && process.env["TF_BUILD"] !== undefined);
86
+ }
87
+ static getADORunId() {
88
+ if (process.env["RELEASE_DEFINITIONID"] !== null &&
89
+ process.env["RELEASE_DEPLOYMENTID"] !== null) {
90
+ return `${process.env["RELEASE_DEFINITIONID"]}-${process.env["RELEASE_DEPLOYMENTID"]}`;
91
+ }
92
+ else {
93
+ return `${process.env["SYSTEM_DEFINITIONID"]}-${process.env["SYSTEM_JOBID"]}`;
94
+ }
95
+ }
96
+ static getGHBranchName() {
97
+ if (process.env["GITHUB_EVENT_NAME"] === "pull_request" ||
98
+ process.env["GITHUB_EVENT_NAME"] === "pull_request_target") {
99
+ return process.env["GITHUB_HEAD_REF"];
100
+ }
101
+ else {
102
+ return process.env["GITHUB_REF_NAME"];
103
+ }
104
+ }
105
+ }
106
+ exports.CIInfoProvider = CIInfoProvider;
107
+ //# sourceMappingURL=cIInfoProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cIInfoProvider.js","sourceRoot":"","sources":["../../src/utils/cIInfoProvider.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,iCAAiB,CAAA;IACjB,2BAAW,CAAA;IACX,mCAAmB,CAAA;IACnB,kCAAkC;AACpC,CAAC,EALW,YAAY,4BAAZ,YAAY,QAKvB;AAcD,MAAa,cAAc;IACjB,MAAM,CAAC,eAAe;QAC5B,OAAO,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,KAAK,MAAM,CAAC;IAClD,CAAC;IAED,MAAM,CAAC,aAAa;QAClB,IAAI,cAAc,CAAC,eAAe,EAAE,EAAE,CAAC;YACrC,OAAO,YAAY,CAAC,MAAM,CAAC;QAC7B,CAAC;aAAM,IAAI,cAAc,CAAC,aAAa,EAAE,EAAE,CAAC;YAC1C,OAAO,YAAY,CAAC,GAAG,CAAC;QAC1B,CAAC;aAAM,CAAC;YACN,OAAO,YAAY,CAAC,OAAO,CAAC;QAC9B,CAAC;IACH,CAAC;IAED,MAAM,CAAC,SAAS;;QACd,MAAM,UAAU,GAAG,cAAc,CAAC,aAAa,EAAE,CAAC;QAClD,IAAI,UAAU,KAAK,YAAY,CAAC,MAAM,EAAE,CAAC;YACvC,qCAAqC;YACrC,OAAO;gBACL,QAAQ,EAAE,YAAY,CAAC,MAAM;gBAC7B,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,IAAI,IAAI;gBACjD,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,IAAI,IAAI;gBACtC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,IAAI;gBAC3C,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,IAAI;gBAC3C,WAAW,EAAE,OAA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EAAE,MAAA,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,mCAAI,EAAE;aACnC,CAAC;QACJ,CAAC;IACH,CAAC;IAEO,MAAM,CAAC,aAAa;QAC1B,OAAO,CACL,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,KAAK,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,SAAS,CAC5F,CAAC;IACJ,CAAC;IAEO,MAAM,CAAC,WAAW;QACxB,IACE,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,KAAK,IAAI;YAC5C,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,KAAK,IAAI,EAC5C,CAAC;YACD,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,EAAE,CAAC;QACzF,CAAC;aAAM,CAAC;YACN,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC;QAChF,CAAC;IACH,CAAC;IAEO,MAAM,CAAC,eAAe;QAC5B,IACE,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,KAAK,cAAc;YACnD,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,KAAK,qBAAqB,EAC1D,CAAC;YACD,OAAO,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAE,CAAC;QACzC,CAAC;aAAM,CAAC;YACN,OAAO,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAE,CAAC;QACzC,CAAC;IACH,CAAC;CACF;AAhGD,wCAgGC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport enum CI_PROVIDERS {\n GITHUB = \"GITHUB\",\n ADO = \"ADO\",\n DEFAULT = \"DEFAULT\",\n // Add more CI providers as needed\n}\n\nexport type CIInfo = {\n provider: CI_PROVIDERS | null;\n repo: string | null;\n branch: string | null;\n author: string | null;\n commitId: string | null;\n revisionUrl: string | null;\n runId: string | null;\n runAttempt: number | null;\n jobId: string | null;\n};\n\nexport class CIInfoProvider {\n private static isGitHubActions(): boolean {\n return process.env[\"GITHUB_ACTIONS\"] === \"true\";\n }\n\n static getCIProvider(): string | null {\n if (CIInfoProvider.isGitHubActions()) {\n return CI_PROVIDERS.GITHUB;\n } else if (CIInfoProvider.isAzureDevOps()) {\n return CI_PROVIDERS.ADO;\n } else {\n return CI_PROVIDERS.DEFAULT;\n }\n }\n\n static getCIInfo(): CIInfo {\n const ciProvider = CIInfoProvider.getCIProvider();\n if (ciProvider === CI_PROVIDERS.GITHUB) {\n // Logic to get GitHub Actions CIInfo\n return {\n provider: CI_PROVIDERS.GITHUB,\n repo: process.env[\"GITHUB_REPOSITORY_ID\"] || null,\n branch: this.getGHBranchName() || null,\n author: process.env[\"GITHUB_ACTOR\"] || null,\n commitId: process.env[\"GITHUB_SHA\"] || null,\n revisionUrl: process.env[\"GITHUB_SERVER_URL\"]\n ? `${process.env[\"GITHUB_SERVER_URL\"]}/${process.env[\"GITHUB_REPOSITORY\"]}/commit/${process.env[\"GITHUB_SHA\"]}`\n : null,\n runId: process.env[\"GITHUB_RUN_ID\"] || null,\n runAttempt: process.env[\"GITHUB_RUN_ATTEMPT\"]\n ? parseInt(process.env[\"GITHUB_RUN_ATTEMPT\"], 10)\n : null,\n jobId: process.env[\"GITHUB_JOB\"] || null,\n };\n } else if (ciProvider === CI_PROVIDERS.ADO) {\n // Logic to get Azure DevOps CIInfo\n return {\n provider: CI_PROVIDERS.ADO,\n repo: process.env[\"BUILD_REPOSITORY_ID\"] || null,\n branch: process.env[\"BUILD_SOURCEBRANCH\"] || null,\n author: process.env[\"BUILD_REQUESTEDFOR\"] || null,\n commitId: process.env[\"BUILD_SOURCEVERSION\"] || null,\n revisionUrl: process.env[\"SYSTEM_TEAMFOUNDATIONCOLLECTIONURI\"]\n ? `${process.env[\"SYSTEM_TEAMFOUNDATIONCOLLECTIONURI\"]}${process.env[\"SYSTEM_TEAMPROJECT\"]}/_git/${process.env[\"BUILD_REPOSITORY_NAME\"]}/commit/${process.env[\"BUILD_SOURCEVERSION\"]}`\n : null,\n runId: this.getADORunId() || null,\n runAttempt: process.env[\"RELEASE_ATTEMPTNUMBER\"]\n ? parseInt(process.env[\"RELEASE_ATTEMPTNUMBER\"], 10)\n : parseInt(process.env[\"SYSTEM_JOBATTEMPT\"] ?? \"\", 10),\n jobId: process.env[\"RELEASE_DEPLOYMENTID\"]\n ? process.env[\"RELEASE_DEPLOYMENTID\"]\n : process.env[\"SYSTEM_JOBID\"] || null,\n };\n } else {\n // Handle unsupported CI provider\n return {\n provider: CI_PROVIDERS.DEFAULT,\n repo: process.env[\"REPO\"] ?? \"\",\n branch: process.env[\"BRANCH\"] ?? \"\",\n author: process.env[\"AUTHOR\"] ?? \"\",\n commitId: process.env[\"COMMIT_ID\"] ?? \"\",\n revisionUrl: process.env[\"REVISION_URL\"] ?? \"\",\n runId: process.env[\"RUN_ID\"] ?? \"\",\n runAttempt: process.env[\"RUN_ATTEMPT\"] ? parseInt(process.env[\"RUN_ATTEMPT\"], 10) : null,\n jobId: process.env[\"JOB_ID\"] ?? \"\",\n };\n }\n }\n\n private static isAzureDevOps(): boolean {\n return (\n process.env[\"AZURE_HTTP_USER_AGENT\"] !== undefined && process.env[\"TF_BUILD\"] !== undefined\n );\n }\n\n private static getADORunId(): string {\n if (\n process.env[\"RELEASE_DEFINITIONID\"] !== null &&\n process.env[\"RELEASE_DEPLOYMENTID\"] !== null\n ) {\n return `${process.env[\"RELEASE_DEFINITIONID\"]}-${process.env[\"RELEASE_DEPLOYMENTID\"]}`;\n } else {\n return `${process.env[\"SYSTEM_DEFINITIONID\"]}-${process.env[\"SYSTEM_JOBID\"]}`;\n }\n }\n\n private static getGHBranchName(): string {\n if (\n process.env[\"GITHUB_EVENT_NAME\"] === \"pull_request\" ||\n process.env[\"GITHUB_EVENT_NAME\"] === \"pull_request_target\"\n ) {\n return process.env[\"GITHUB_HEAD_REF\"]!;\n } else {\n return process.env[\"GITHUB_REF_NAME\"]!;\n }\n }\n}\n"]}
@@ -0,0 +1,15 @@
1
+ import { PackageManager } from "../common/types";
2
+ export declare class NPM implements PackageManager {
3
+ runCommand: (command: string, args: string) => string;
4
+ getVersionFromStdout: (stdout: string) => string;
5
+ }
6
+ export declare class PNPM implements PackageManager {
7
+ runCommand: (command: string, args: string) => string;
8
+ getVersionFromStdout: (stdout: string) => string;
9
+ }
10
+ export declare class Yarn implements PackageManager {
11
+ runCommand: (command: string, args: string) => string;
12
+ getVersionFromStdout: (stdout: string) => string;
13
+ }
14
+ export declare const getPackageManager: () => PackageManager;
15
+ //# sourceMappingURL=packageManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"packageManager.d.ts","sourceRoot":"","sources":["../../src/utils/packageManager.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,qBAAa,GAAI,YAAW,cAAc;IACxC,UAAU,YAAa,MAAM,QAAQ,MAAM,KAAG,MAAM,CAElD;IACF,oBAAoB,WAAY,MAAM,KAAG,MAAM,CAG7C;CACH;AAED,qBAAa,IAAK,YAAW,cAAc;IACzC,UAAU,YAAa,MAAM,QAAQ,MAAM,KAAG,MAAM,CAElD;IACF,oBAAoB,WAAY,MAAM,KAAG,MAAM,CAG7C;CACH;AAED,qBAAa,IAAK,YAAW,cAAc;IACzC,UAAU,YAAa,MAAM,QAAQ,MAAM,KAAG,MAAM,CAElD;IACF,oBAAoB,WAAY,MAAM,KAAG,MAAM,CAG7C;CACH;AAGD,eAAO,MAAM,iBAAiB,QAAO,cAOpC,CAAC"}