@empiricalrun/playwright-utils 0.37.0 → 0.38.0
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 +12 -0
- package/dist/reporter/uploader.d.ts +6 -1
- package/dist/reporter/uploader.d.ts.map +1 -1
- package/dist/reporter/uploader.js +40 -15
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @empiricalrun/playwright-utils
|
|
2
2
|
|
|
3
|
+
## 0.38.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 1967ac3: feat: support iam creds for s3 uploads
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [1967ac3]
|
|
12
|
+
- @empiricalrun/r2-uploader@0.9.0
|
|
13
|
+
- @empiricalrun/test-gen@0.78.7
|
|
14
|
+
|
|
3
15
|
## 0.37.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -1,15 +1,20 @@
|
|
|
1
|
+
import { StorageCredentials } from "@empiricalrun/r2-uploader";
|
|
1
2
|
export interface UploaderConfig {
|
|
2
3
|
projectName: string;
|
|
3
4
|
runId: string;
|
|
4
5
|
baseUrl?: string;
|
|
5
6
|
uploadBucket?: string;
|
|
7
|
+
credentials: StorageCredentials;
|
|
6
8
|
}
|
|
7
9
|
export declare class Uploader {
|
|
8
10
|
private _baseUrl;
|
|
9
11
|
private _uploadBucket;
|
|
10
12
|
private _destinationDir;
|
|
13
|
+
private _credentials;
|
|
11
14
|
constructor(config: UploaderConfig);
|
|
12
|
-
private static
|
|
15
|
+
private static _getR2Credentials;
|
|
16
|
+
private static _getS3Credentials;
|
|
17
|
+
static getCredentialsFromEnv(enableS3: boolean): StorageCredentials | null;
|
|
13
18
|
get isEnabled(): boolean;
|
|
14
19
|
get baseUrl(): string;
|
|
15
20
|
get destinationDir(): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uploader.d.ts","sourceRoot":"","sources":["../../src/reporter/uploader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"uploader.d.ts","sourceRoot":"","sources":["../../src/reporter/uploader.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,kBAAkB,EAGnB,MAAM,2BAA2B,CAAC;AAKnC,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,kBAAkB,CAAC;CACjC;AAED,qBAAa,QAAQ;IACnB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,YAAY,CAAqB;gBAE7B,MAAM,EAAE,cAAc;IAWlC,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAgBhC,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAUhC,MAAM,CAAC,qBAAqB,CAAC,QAAQ,EAAE,OAAO,GAAG,kBAAkB,GAAG,IAAI;IAO1E,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,IAAI,cAAc,IAAI,MAAM,CAE3B;IAED,IAAI,SAAS,IAAI,MAAM,CAEtB;IAEK,UAAU,CACd,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IA6BnB,eAAe,CACnB,SAAS,EAAE,MAAM,EACjB,iBAAiB,EAAE,MAAM,GACxB,OAAO,CAAC,IAAI,CAAC;IAiBV,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;CAGtC;AAED,wBAAgB,cAAc,IAAI,QAAQ,GAAG,IAAI,CAyBhD"}
|
|
@@ -12,19 +12,44 @@ class Uploader {
|
|
|
12
12
|
_baseUrl;
|
|
13
13
|
_uploadBucket;
|
|
14
14
|
_destinationDir;
|
|
15
|
+
_credentials;
|
|
15
16
|
constructor(config) {
|
|
16
17
|
this._baseUrl = config.baseUrl || "https://reports.empirical.run";
|
|
17
18
|
this._uploadBucket = config.uploadBucket || "test-report";
|
|
18
19
|
this._destinationDir = `${config.projectName}/${config.runId}`;
|
|
19
|
-
|
|
20
|
+
this._credentials = config.credentials;
|
|
21
|
+
logger_1.logger.debug(`[Uploader] Initialized with destination: ${this._destinationDir}, provider: ${this._credentials.provider}`);
|
|
20
22
|
}
|
|
21
|
-
static
|
|
22
|
-
|
|
23
|
+
static _getR2Credentials() {
|
|
24
|
+
if (process.env.R2_ACCOUNT_ID &&
|
|
23
25
|
process.env.R2_ACCESS_KEY_ID &&
|
|
24
|
-
process.env.R2_SECRET_ACCESS_KEY)
|
|
26
|
+
process.env.R2_SECRET_ACCESS_KEY) {
|
|
27
|
+
return {
|
|
28
|
+
provider: "r2",
|
|
29
|
+
accountId: process.env.R2_ACCOUNT_ID,
|
|
30
|
+
accessKeyId: process.env.R2_ACCESS_KEY_ID,
|
|
31
|
+
secretAccessKey: process.env.R2_SECRET_ACCESS_KEY,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
static _getS3Credentials() {
|
|
37
|
+
if (process.env.S3_REGION && process.env.S3_UPLOAD_BUCKET) {
|
|
38
|
+
return {
|
|
39
|
+
provider: "s3-iam",
|
|
40
|
+
region: process.env.S3_REGION,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
static getCredentialsFromEnv(enableS3) {
|
|
46
|
+
if (enableS3) {
|
|
47
|
+
return Uploader._getS3Credentials();
|
|
48
|
+
}
|
|
49
|
+
return Uploader._getR2Credentials();
|
|
25
50
|
}
|
|
26
51
|
get isEnabled() {
|
|
27
|
-
return
|
|
52
|
+
return true;
|
|
28
53
|
}
|
|
29
54
|
get baseUrl() {
|
|
30
55
|
return this._baseUrl;
|
|
@@ -36,10 +61,6 @@ class Uploader {
|
|
|
36
61
|
return `${this._baseUrl}/${this._destinationDir}`;
|
|
37
62
|
}
|
|
38
63
|
async uploadFile(filePath, destinationPath) {
|
|
39
|
-
if (!this.isEnabled) {
|
|
40
|
-
logger_1.logger.debug("[Uploader] R2 credentials not found, skipping upload");
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
64
|
try {
|
|
44
65
|
const fullDestinationPath = path_1.default.join(this._destinationDir, destinationPath);
|
|
45
66
|
const sourceDir = path_1.default.dirname(filePath);
|
|
@@ -49,6 +70,7 @@ class Uploader {
|
|
|
49
70
|
destinationDir: path_1.default.dirname(fullDestinationPath),
|
|
50
71
|
uploadBucket: this._uploadBucket,
|
|
51
72
|
baseUrl: this._baseUrl,
|
|
73
|
+
credentials: this._credentials,
|
|
52
74
|
});
|
|
53
75
|
const result = await (0, r2_uploader_1.sendTaskToQueue)(uploadTask);
|
|
54
76
|
if (result) {
|
|
@@ -63,16 +85,13 @@ class Uploader {
|
|
|
63
85
|
}
|
|
64
86
|
}
|
|
65
87
|
async uploadDirectory(sourceDir, destinationPrefix) {
|
|
66
|
-
if (!this.isEnabled) {
|
|
67
|
-
logger_1.logger.debug("[Uploader] R2 credentials not found, skipping upload");
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
88
|
const fullDestinationDir = path_1.default.join(this._destinationDir, destinationPrefix);
|
|
71
89
|
const uploadTask = (0, r2_uploader_1.createUploadTask)({
|
|
72
90
|
sourceDir,
|
|
73
91
|
destinationDir: fullDestinationDir,
|
|
74
92
|
uploadBucket: this._uploadBucket,
|
|
75
93
|
baseUrl: this._baseUrl,
|
|
94
|
+
credentials: this._credentials,
|
|
76
95
|
});
|
|
77
96
|
await (0, r2_uploader_1.sendTaskToQueue)(uploadTask);
|
|
78
97
|
}
|
|
@@ -86,12 +105,18 @@ function createUploader() {
|
|
|
86
105
|
logger_1.logger.debug("[Uploader] PROJECT_NAME and TEST_RUN_GITHUB_ACTION_ID must be set");
|
|
87
106
|
return null;
|
|
88
107
|
}
|
|
89
|
-
|
|
90
|
-
|
|
108
|
+
const enableS3 = process.env.ENABLE_S3_UPLOADS === "true";
|
|
109
|
+
const credentials = Uploader.getCredentialsFromEnv(enableS3);
|
|
110
|
+
if (!credentials) {
|
|
111
|
+
const storageType = enableS3 ? "S3" : "R2";
|
|
112
|
+
logger_1.logger.debug(`[Uploader] ${storageType} credentials not found`);
|
|
91
113
|
return null;
|
|
92
114
|
}
|
|
115
|
+
const uploadBucket = enableS3 ? process.env.S3_UPLOAD_BUCKET : "test-report";
|
|
93
116
|
return new Uploader({
|
|
94
117
|
projectName: process.env.PROJECT_NAME,
|
|
95
118
|
runId: process.env.TEST_RUN_GITHUB_ACTION_ID,
|
|
119
|
+
uploadBucket,
|
|
120
|
+
credentials,
|
|
96
121
|
});
|
|
97
122
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empiricalrun/playwright-utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.38.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"puppeteer-extra-plugin-recaptcha": "^3.6.8",
|
|
44
44
|
"rimraf": "^6.0.1",
|
|
45
45
|
"@empiricalrun/llm": "^0.25.1",
|
|
46
|
-
"@empiricalrun/r2-uploader": "^0.
|
|
47
|
-
"@empiricalrun/test-gen": "^0.78.
|
|
46
|
+
"@empiricalrun/r2-uploader": "^0.9.0",
|
|
47
|
+
"@empiricalrun/test-gen": "^0.78.7"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"dev": "tsc --build --watch",
|