@@ -41299,7 +41299,7 @@ async function run() {
4129941299 pollingInterval
4130041300 );
4130141301
41302- await ReportProcessor.processReport(reportData, buildName );
41302+ await ReportProcessor.processReport(reportData);
4130341303 } catch (error) {
4130441304 core.setFailed(`Action failed: ${error.message}`);
4130541305 }
@@ -41766,10 +41766,10 @@ module.exports = new MockReportService(); // Export singleton instance
4176641766
4176741767
4176841768const core = __nccwpck_require__(7484);
41769- const ArtifactManager = __nccwpck_require__(197 );
41769+ const UploadFileForArtifact = __nccwpck_require__(8751 );
4177041770
4177141771class ReportProcessor {
41772- static async processReport(reportData, buildName ) {
41772+ static async processReport(reportData) {
4177341773 try {
4177441774 const summary = core.summary;
4177541775 await summary.addHeading('BrowserStack Test Report');
@@ -41783,10 +41783,10 @@ class ReportProcessor {
4178341783 summary.write();
4178441784 if(reportData?.report?.rich_html) {
4178541785 const report = `<!DOCTYPE html> <html><head><style>${reportData?.report?.rich_css}</style></head> ${reportData?.report?.rich_html}</html>`;
41786- await ArtifactManager.saveReportAsArtifact (report, buildName );
41786+ await UploadFileForArtifact.saveReportInFile (report);
4178741787 }
4178841788 } catch (error) {
41789- await core.info(`Error processing report: ${JSON.stringify(error)}`);
41789+ core.info(`Error processing report: ${JSON.stringify(error)}`);
4179041790 await core.summary
4179141791 .addRaw('❌ Error processing report')
4179241792 .write();
@@ -41904,7 +41904,31 @@ module.exports = ReportService;
4190441904
4190541905/***/ }),
4190641906
41907- /***/ 197:
41907+ /***/ 933:
41908+ /***/ ((module) => {
41909+
41910+ "use strict";
41911+
41912+
41913+ class TimeoutManager {
41914+ constructor(timeoutSeconds) {
41915+ this.timeoutMs = timeoutSeconds * 1000;
41916+ this.startTime = Date.now();
41917+ }
41918+
41919+ check() {
41920+ if (Date.now() - this.startTime >= this.timeoutMs) {
41921+ throw new Error(`Operation timed out after ${this.timeoutMs / 1000} seconds`);
41922+ }
41923+ }
41924+ }
41925+
41926+ module.exports = TimeoutManager;
41927+
41928+
41929+ /***/ }),
41930+
41931+ /***/ 8751:
4190841932/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
4190941933
4191041934"use strict";
@@ -41915,98 +41939,31 @@ const path = __nccwpck_require__(6928);
4191541939const core = __nccwpck_require__(7484);
4191641940const artifact = __nccwpck_require__(7884);
4191741941
41918- class ArtifactManager {
41919- static async saveReportAsArtifact(report, buildName ) {
41942+ class UploadFileForArtifact {
41943+ static async saveReportAsArtifact(report) {
4192041944 if (!report) {
4192141945 core.debug('No HTML content available to save as artifact');
4192241946 return '';
4192341947 }
4192441948
4192541949 try {
41950+ const pathName = "browserstack-reports-atifact"
41951+ const fileName = `bstack-report.html`;
4192641952 // Create artifacts directory
41927- const artifactDir = path.join(process.cwd(), 'browserstack-artifacts');
41928- fs.mkdirSync("browserstack-artifacts", { recursive: true });
41929-
41930- // Create HTML file
41931- const fileName = `report.html`;
41932- const filePath = path.join(artifactDir, fileName);
41953+ fs.mkdirSync(pathName, { recursive: true });
41954+ //save path in a env variable
41955+ core.exportVariable('BROWSERSTACK_REPORT_PATH', pathName);
4193341956
4193441957 // Write content
41935- fs.writeFileSync(`browserstack-artifacts/${fileName}`, report);
41936- const fileStat = fs.statSync(filePath);
41937- const content = fs.readFileSync(`browserstack-artifacts/${fileName}`, 'utf8');
41938- core.info(`Successfully read file: ${filePath} (${content.length} bytes)`);
41939- core.exportVariable('BROWSERSTACK_REPORT_PATH', filePath);
41940- core.setOutput('fileStat', fileStat);
41941- core.setOutput('report_file_path', filePath);
41942- core.setOutput('report_dir', artifactDir);
41943-
41944- const dirContents = fs.readdirSync(artifactDir);
41945- core.info(`Directory contents of ${artifactDir}: ${dirContents.join(', ')}`);
41946-
41947- // Upload as artifact
41948- let artifactClient;
41949- if (typeof artifact.create === 'function') {
41950- artifactClient = artifact.create();
41951- core.info('Created artifact client using create() function');
41952- } else if (typeof artifact.default === 'function') {
41953- artifactClient = artifact.default();
41954- core.info('Created artifact client using default() function');
41955- } else if (typeof artifact === 'function') {
41956- artifactClient = artifact();
41957- core.info('Created artifact client using artifact as function');
41958- } else {
41959- // Just save the file locally and return
41960- core.warning('Artifact API not available. Report saved locally only.');
41961- return `File saved locally at: ${filePath}`;
41962- }
41963- const artifactName = `browserstack_results`;
41964- const uploadResult = await artifactClient.uploadArtifact(
41965- artifactName,
41966- [filePath],
41967- artifactDir,
41968- { continueOnError: true }
41969- );
41970-
41971- if (uploadResult.failedItems.length > 0) {
41972- core.warning(`Failed to upload artifacts: ${uploadResult.failedItems.join(', ')}`);
41973- return '';
41974- }
41975-
41976- core.info(`Report saved as artifact: ${artifactName}`);
41977- return `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}/artifacts/${uploadResult.artifactId}`;
41958+ fs.writeFileSync(path.join(pathName,fileName), report);
4197841959 } catch (error) {
41979- core.warning(`Failed to save artifact : ${error.message}`);
41960+ core.warning(`Failed to save file : ${error.message}`);
4198041961 return '';
4198141962 }
4198241963 }
4198341964}
4198441965
41985- module.exports = ArtifactManager;
41986-
41987-
41988- /***/ }),
41989-
41990- /***/ 933:
41991- /***/ ((module) => {
41992-
41993- "use strict";
41994-
41995-
41996- class TimeoutManager {
41997- constructor(timeoutSeconds) {
41998- this.timeoutMs = timeoutSeconds * 1000;
41999- this.startTime = Date.now();
42000- }
42001-
42002- check() {
42003- if (Date.now() - this.startTime >= this.timeoutMs) {
42004- throw new Error(`Operation timed out after ${this.timeoutMs / 1000} seconds`);
42005- }
42006- }
42007- }
42008-
42009- module.exports = TimeoutManager;
41966+ module.exports = UploadFileForArtifact;
4201041967
4201141968
4201241969/***/ }),
0 commit comments