Skip to content

Commit 3e8f2b4

Browse files
committed
add: timestamp suffix to binary log files to differentiate between steps
1 parent 40496ea commit 3e8f2b4

File tree

1 file changed

+30
-10
lines changed

1 file changed

+30
-10
lines changed

setup-local/dist/index.js

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,6 +1071,7 @@ const github = __webpack_require__(469);
10711071
const os = __webpack_require__(87);
10721072
const path = __webpack_require__(622);
10731073
const fs = __webpack_require__(747);
1074+
const Utils = __webpack_require__(353);
10741075
const ArtifactsManager = __webpack_require__(513);
10751076
const constants = __webpack_require__(613);
10761077

@@ -1084,6 +1085,9 @@ const {
10841085
ALLOWED_INPUT_VALUES: {
10851086
LOCAL_TESTING,
10861087
},
1088+
ENV_VARS: {
1089+
BROWSERSTACK_LOCAL_LOGS_FILE,
1090+
},
10871091
} = constants;
10881092

10891093
/**
@@ -1126,8 +1130,9 @@ class BinaryControl {
11261130
* Generates logging file name and its path for Local Binary
11271131
*/
11281132
_generateLogFileMetadata() {
1129-
this.logFileName = `${LOCAL_LOG_FILE_PREFIX}_${github.context.job}.log`;
1133+
this.logFileName = process.env[BROWSERSTACK_LOCAL_LOGS_FILE] || `${LOCAL_LOG_FILE_PREFIX}_${github.context.job}_${new Date().toISOString()}.log`;
11301134
this.logFilePath = path.resolve(this.binaryFolder, this.logFileName);
1135+
core.exportVariable(BROWSERSTACK_LOCAL_LOGS_FILE, this.logFileName);
11311136
}
11321137

11331138
/**
@@ -1196,23 +1201,16 @@ class BinaryControl {
11961201
};
11971202
}
11981203

1199-
_binaryExists() {
1200-
const localBinary = tc.findAllVersions(LOCAL_BINARY_NAME);
1201-
return localBinary.length ? true : false;
1202-
}
1203-
12041204
/**
12051205
* Downloads the Local Binary, extracts it and adds it in the PATH variable
12061206
*/
12071207
async downloadBinary() {
12081208
try {
1209-
if (this._binaryExists()) {
1210-
console.log(core.getState('jinga'));
1209+
if (Utils.checkToolInCache(LOCAL_BINARY_NAME)) {
12111210
core.info('BrowserStackLocal binary already exists in cache. Using that instead of downloading again...');
12121211
return;
12131212
}
12141213
await this._makeDirectory();
1215-
core.saveState('jinga', 'lala');
12161214
core.info('Downloading BrowserStackLocal binary...');
12171215
const downloadPath = await tc.downloadTool(this.binaryLink, path.resolve(this.binaryFolder, 'binaryZip'));
12181216
const extractedPath = await tc.extractZip(downloadPath, this.binaryFolder);
@@ -1283,7 +1281,6 @@ class BinaryControl {
12831281
* Uploads BrowserStackLocal generated logs (if the file exists for the job)
12841282
*/
12851283
async uploadLogFilesIfAny() {
1286-
core.saveState
12871284
this._generateLogFileMetadata();
12881285
if (fs.existsSync(this.logFilePath)) {
12891286
await ArtifactsManager.uploadArtifacts(
@@ -1293,6 +1290,7 @@ class BinaryControl {
12931290
);
12941291
await io.rmRF(this.logFilePath);
12951292
}
1293+
Utils.clearEnvironmentVariable(BROWSERSTACK_LOCAL_LOGS_FILE);
12961294
}
12971295
}
12981296

@@ -7178,6 +7176,27 @@ exports.default = void 0;
71787176
var _default = '00000000-0000-0000-0000-000000000000';
71797177
exports.default = _default;
71807178

7179+
/***/ }),
7180+
7181+
/***/ 353:
7182+
/***/ (function(module, __unusedexports, __webpack_require__) {
7183+
7184+
const tc = __webpack_require__(533);
7185+
7186+
class Utils {
7187+
static clearEnvironmentVariable(environmentVariable) {
7188+
delete process.env[environmentVariable];
7189+
}
7190+
7191+
static checkToolInCache(toolName) {
7192+
const toolCache = tc.findAllVersions(toolName);
7193+
return toolCache.length !== 0;
7194+
}
7195+
}
7196+
7197+
module.exports = Utils;
7198+
7199+
71817200
/***/ }),
71827201

71837202
/***/ 357:
@@ -13383,6 +13402,7 @@ module.exports = {
1338313402
ENV_VARS: {
1338413403
BROWSERSTACK_ACCESS_KEY: 'BROWSERSTACK_ACCESS_KEY',
1338513404
BROWSERSTACK_LOCAL_IDENTIFIER: 'BROWSERSTACK_LOCAL_IDENTIFIER',
13405+
BROWSERSTACK_LOCAL_LOGS_FILE: 'BROWSERSTACK_LOCAL_LOGS_FILE',
1338613406
},
1338713407

1338813408
BINARY_LINKS: {

0 commit comments

Comments
 (0)