@empiricalrun/test-gen 0.23.11 → 0.23.13
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.
- package/CHANGELOG.md +17 -0
- package/dist/reporter/index.d.ts.map +1 -1
- package/dist/reporter/index.js +2 -2
- package/dist/uploader/index.d.ts.map +1 -1
- package/dist/uploader/index.js +3 -3
- package/package.json +3 -2
- package/dist/uploader/r2.d.ts +0 -11
- package/dist/uploader/r2.d.ts.map +0 -1
- package/dist/uploader/r2.js +0 -138
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @empiricalrun/test-gen
|
|
2
2
|
|
|
3
|
+
## 0.23.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [51b7e11]
|
|
8
|
+
- @empiricalrun/r2-uploader@0.1.1
|
|
9
|
+
|
|
10
|
+
## 0.23.12
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 6a1288a: feat: create r2 uploader package and support for retry
|
|
15
|
+
- Updated dependencies [bff7e8b]
|
|
16
|
+
- Updated dependencies [6a1288a]
|
|
17
|
+
- @empiricalrun/reporter@0.17.10
|
|
18
|
+
- @empiricalrun/r2-uploader@0.1.0
|
|
19
|
+
|
|
3
20
|
## 0.23.11
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/reporter/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/reporter/index.ts"],"names":[],"mappings":"AACA,OAAO,EAA4B,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAa5E,KAAK,kBAAkB,GAAG;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAKF,wBAAgB,WAAW,IAAI,QAAQ,GAAG,SAAS,CAUlD;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAGlE;AAED,qBAAa,sBAAsB;;IAE3B,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK1C,eAAe,CAAC,EACpB,eAAe,EACf,QAAQ,GACT,EAAE;QACD,eAAe,EAAE,MAAM,CAAC;QACxB,QAAQ,EAAE,MAAM,CAAC;KAClB;IAkCK,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA2B9C,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAUlD"}
|
package/dist/reporter/index.js
CHANGED
|
@@ -4,12 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.TestGenUpdatesReporter = exports.setReporterConfig = exports.getReporter = void 0;
|
|
7
|
+
const r2_uploader_1 = require("@empiricalrun/r2-uploader");
|
|
7
8
|
const reporter_1 = require("@empiricalrun/reporter");
|
|
8
9
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
9
10
|
const path_1 = __importDefault(require("path"));
|
|
10
11
|
const logger_1 = require("../bin/logger");
|
|
11
12
|
const uploader_1 = require("../uploader");
|
|
12
|
-
const r2_1 = require("../uploader/r2");
|
|
13
13
|
let reporterInstance = undefined;
|
|
14
14
|
let reporterConfig = undefined;
|
|
15
15
|
function getReporter() {
|
|
@@ -80,7 +80,7 @@ class TestGenUpdatesReporter {
|
|
|
80
80
|
await promises_1.default.mkdir((process.cwd(), "gen-assets"));
|
|
81
81
|
await promises_1.default.writeFile(path_1.default.join(process.cwd(), "gen-assets", `current-view-${Date.now()}.png`), buffer);
|
|
82
82
|
const uploadDir = (0, uploader_1.getUploadPathForRun)(reporterConfig?.projectRepoName);
|
|
83
|
-
const files = await (0,
|
|
83
|
+
const files = await (0, r2_uploader_1.uploadDirectory)({
|
|
84
84
|
sourceDir: path_1.default.join(process.cwd(), "gen-assets"),
|
|
85
85
|
destinationDir: uploadDir,
|
|
86
86
|
uploadBucket: uploader_1.UPLOAD_BUCKET,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/uploader/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/uploader/index.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,aAAa,gBAAgB,CAAC;AAC3C,eAAO,MAAM,aAAa,kCAAkC,CAAC;AAG7D,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,UAUpE;AAED;;;;;;;;;GASG;AACH,wBAAsB,6BAA6B,CAAC,EAClD,eAAe,EACf,QAAQ,GACT,EAAE;IACD,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,OAAO,CAAC;IACV,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC,CAmED;AAED,wBAAgB,mBAAmB,CAAC,eAAe,EAAE,MAAM,UAM1D;AAED,wBAAgB,2BAA2B,uBAQ1C"}
|
package/dist/uploader/index.js
CHANGED
|
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.checkIfResultsUploadAllowed = exports.getUploadPathForRun = exports.uploadTestResultsUsingPrjRepo = exports.getFullUploadPath = exports.UPLOAD_DOMAIN = exports.UPLOAD_BUCKET = void 0;
|
|
7
|
+
const r2_uploader_1 = require("@empiricalrun/r2-uploader");
|
|
7
8
|
const reporter_1 = require("@empiricalrun/reporter");
|
|
8
9
|
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const r2_1 = require("./r2");
|
|
10
10
|
// json summary of test results
|
|
11
11
|
// originally we used to upload test results directory for this
|
|
12
12
|
// but now we have our test results (per testcase artifacts) inside playwright-report/data
|
|
@@ -40,14 +40,14 @@ async function uploadTestResultsUsingPrjRepo({ projectRepoName, testName, }) {
|
|
|
40
40
|
// test-generation/<project-name>/<random-uuid>
|
|
41
41
|
const uploadDir = getUploadPathForRun(projectRepoName);
|
|
42
42
|
// upload test assets
|
|
43
|
-
const files = await (0,
|
|
43
|
+
const files = await (0, r2_uploader_1.uploadDirectory)({
|
|
44
44
|
// ~/source-repo/playwright-report -> has index.html, data, trace(they are assets for index.html, not sure why they are called trace), and summary.json
|
|
45
45
|
sourceDir: path_1.default.join(process.cwd(), PLAYWRIGHT_REPORT_DATA), // upload data dir
|
|
46
46
|
destinationDir: uploadDir,
|
|
47
47
|
uploadBucket: exports.UPLOAD_BUCKET,
|
|
48
48
|
});
|
|
49
49
|
// upload summary.json
|
|
50
|
-
await (0,
|
|
50
|
+
await (0, r2_uploader_1.uploadDirectory)({
|
|
51
51
|
// ~/source-repo/playwright-report -> has index.html, data, trace(they are assets for index.html, not sure why they are called trace), and summary.json
|
|
52
52
|
sourceDir: path_1.default.join(process.cwd(), "playwright-report"), // upload data dir
|
|
53
53
|
fileList: [path_1.default.join(process.cwd(), "playwright-report", "summary.json")],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empiricalrun/test-gen",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.13",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -42,7 +42,8 @@
|
|
|
42
42
|
"tsx": "^4.16.2",
|
|
43
43
|
"typescript": "^5.3.3",
|
|
44
44
|
"@empiricalrun/llm": "^0.8.3",
|
|
45
|
-
"@empiricalrun/
|
|
45
|
+
"@empiricalrun/r2-uploader": "^0.1.1",
|
|
46
|
+
"@empiricalrun/reporter": "^0.17.10"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
49
|
"@types/detect-port": "^1.3.5",
|
package/dist/uploader/r2.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
interface FileMap {
|
|
2
|
-
[file: string]: string;
|
|
3
|
-
}
|
|
4
|
-
export declare function uploadDirectory({ sourceDir, fileList, destinationDir, uploadBucket, }: {
|
|
5
|
-
sourceDir: string;
|
|
6
|
-
fileList?: string[];
|
|
7
|
-
destinationDir: string;
|
|
8
|
-
uploadBucket: string;
|
|
9
|
-
}): Promise<FileMap>;
|
|
10
|
-
export {};
|
|
11
|
-
//# sourceMappingURL=r2.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"r2.d.ts","sourceRoot":"","sources":["../../src/uploader/r2.ts"],"names":[],"mappings":"AAsBA,UAAU,OAAO;IACf,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB;AA2GD,wBAAsB,eAAe,CAAC,EACpC,SAAS,EACT,QAAQ,EACR,cAAc,EACd,YAAY,GACb,EAAE;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,OAAO,CAAC,CAYnB"}
|
package/dist/uploader/r2.js
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.uploadDirectory = void 0;
|
|
30
|
-
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
31
|
-
const s3_request_presigner_1 = require("@aws-sdk/s3-request-presigner");
|
|
32
|
-
const fs = __importStar(require("fs"));
|
|
33
|
-
const md5_1 = __importDefault(require("md5"));
|
|
34
|
-
const path_1 = __importDefault(require("path"));
|
|
35
|
-
const getFileList = (dir) => {
|
|
36
|
-
let files = [];
|
|
37
|
-
const items = fs.readdirSync(dir, {
|
|
38
|
-
withFileTypes: true,
|
|
39
|
-
});
|
|
40
|
-
for (const item of items) {
|
|
41
|
-
const isDir = item.isDirectory();
|
|
42
|
-
const absolutePath = `${dir}/${item.name}`;
|
|
43
|
-
if (isDir) {
|
|
44
|
-
files = [...files, ...getFileList(absolutePath)];
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
files.push(absolutePath);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return files;
|
|
51
|
-
};
|
|
52
|
-
const run = async (config) => {
|
|
53
|
-
const map = new Map();
|
|
54
|
-
const urls = {};
|
|
55
|
-
const S3 = new client_s3_1.S3Client({
|
|
56
|
-
region: "auto",
|
|
57
|
-
endpoint: `https://${config.accountId}.r2.cloudflarestorage.com`,
|
|
58
|
-
credentials: {
|
|
59
|
-
accessKeyId: config.accessKeyId,
|
|
60
|
-
secretAccessKey: config.secretAccessKey,
|
|
61
|
-
},
|
|
62
|
-
});
|
|
63
|
-
let files;
|
|
64
|
-
if (config.fileList) {
|
|
65
|
-
console.log("uploading single file: ", config.fileList[0]);
|
|
66
|
-
files = config.fileList;
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
files = getFileList(config.sourceDir);
|
|
70
|
-
}
|
|
71
|
-
await Promise.all(files.map(async (file) => {
|
|
72
|
-
console.log(file);
|
|
73
|
-
const fileStream = fs.readFileSync(file);
|
|
74
|
-
console.log(config.sourceDir);
|
|
75
|
-
console.log(config.destinationDir);
|
|
76
|
-
//const fileName = file.replace(/^.*[\\\/]/, "");
|
|
77
|
-
const fileName = file.replace(config.sourceDir, "");
|
|
78
|
-
const fileKey = path_1.default.join(config.destinationDir !== "" ? config.destinationDir : config.sourceDir, fileName);
|
|
79
|
-
if (fileKey.includes(".gitkeep"))
|
|
80
|
-
return;
|
|
81
|
-
console.log(fileKey);
|
|
82
|
-
let mimeType = "application/octet-stream";
|
|
83
|
-
try {
|
|
84
|
-
const mime = (await import("mime")).default;
|
|
85
|
-
mimeType = mime.getType(file) || "application/octet-stream";
|
|
86
|
-
}
|
|
87
|
-
catch (err) {
|
|
88
|
-
console.warn("Failed to get mime type for file", file, err);
|
|
89
|
-
}
|
|
90
|
-
const uploadParams = {
|
|
91
|
-
Bucket: config.bucket,
|
|
92
|
-
Key: fileKey,
|
|
93
|
-
Body: fileStream,
|
|
94
|
-
ContentLength: fs.statSync(file).size,
|
|
95
|
-
ContentType: mimeType ?? "application/octet-stream",
|
|
96
|
-
};
|
|
97
|
-
const cmd = new client_s3_1.PutObjectCommand(uploadParams);
|
|
98
|
-
const digest = (0, md5_1.default)(fileStream);
|
|
99
|
-
cmd.middlewareStack.add((next) => async (args) => {
|
|
100
|
-
args.request.headers["if-none-match"] = `"${digest}"`;
|
|
101
|
-
return await next(args);
|
|
102
|
-
}, {
|
|
103
|
-
step: "build",
|
|
104
|
-
name: "addETag",
|
|
105
|
-
});
|
|
106
|
-
try {
|
|
107
|
-
const data = await S3.send(cmd);
|
|
108
|
-
console.log(`R2 Success - ${file}`);
|
|
109
|
-
map.set(file, data);
|
|
110
|
-
const fileUrl = await (0, s3_request_presigner_1.getSignedUrl)(S3, cmd);
|
|
111
|
-
urls[file] = fileUrl;
|
|
112
|
-
}
|
|
113
|
-
catch (err) {
|
|
114
|
-
const error = err;
|
|
115
|
-
if (error["$metadata"]) {
|
|
116
|
-
if (error.$metadata.httpStatusCode !== 412)
|
|
117
|
-
// If-None-Match
|
|
118
|
-
throw error;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return;
|
|
122
|
-
}));
|
|
123
|
-
return urls;
|
|
124
|
-
};
|
|
125
|
-
async function uploadDirectory({ sourceDir, fileList, destinationDir, uploadBucket, }) {
|
|
126
|
-
let config = {
|
|
127
|
-
accountId: process.env.R2_ACCOUNT_ID,
|
|
128
|
-
accessKeyId: process.env.R2_ACCESS_KEY_ID,
|
|
129
|
-
secretAccessKey: process.env.R2_SECRET_ACCESS_KEY,
|
|
130
|
-
bucket: uploadBucket,
|
|
131
|
-
sourceDir,
|
|
132
|
-
destinationDir,
|
|
133
|
-
fileList,
|
|
134
|
-
};
|
|
135
|
-
const uploadedFiles = await run(config);
|
|
136
|
-
return uploadedFiles;
|
|
137
|
-
}
|
|
138
|
-
exports.uploadDirectory = uploadDirectory;
|