@sentinelqa/uploader 0.1.2 → 0.1.5
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/dist/cli.js +35 -5
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -218,10 +218,21 @@ const detectGitLabEnv = () => {
|
|
|
218
218
|
provider: "gitlab",
|
|
219
219
|
commit: {
|
|
220
220
|
sha: readEnv("CI_COMMIT_SHA"),
|
|
221
|
-
branch: readEnv("CI_COMMIT_BRANCH") || readEnv("CI_COMMIT_REF_NAME")
|
|
221
|
+
branch: readEnv("CI_COMMIT_BRANCH") || readEnv("CI_COMMIT_REF_NAME"),
|
|
222
|
+
message: readEnv("CI_COMMIT_MESSAGE"),
|
|
223
|
+
author: readEnv("GITLAB_USER_NAME") || readEnv("GITLAB_USER_LOGIN")
|
|
224
|
+
},
|
|
225
|
+
workflow: {
|
|
226
|
+
id: readEnv("CI_PIPELINE_ID"),
|
|
227
|
+
name: readEnv("CI_PIPELINE_SOURCE")
|
|
228
|
+
},
|
|
229
|
+
job: {
|
|
230
|
+
id: readEnv("CI_JOB_ID"),
|
|
231
|
+
name: readEnv("CI_JOB_NAME")
|
|
222
232
|
},
|
|
223
233
|
ci: {
|
|
224
|
-
url: readEnv("CI_JOB_URL") || readEnv("CI_PIPELINE_URL")
|
|
234
|
+
url: readEnv("CI_JOB_URL") || readEnv("CI_PIPELINE_URL"),
|
|
235
|
+
pipelineUrl: readEnv("CI_PIPELINE_URL")
|
|
225
236
|
}
|
|
226
237
|
};
|
|
227
238
|
};
|
|
@@ -238,8 +249,21 @@ const detectGitHubEnv = () => {
|
|
|
238
249
|
const url = serverUrl && repo && runId ? `${serverUrl}/${repo}/actions/runs/${runId}` : null;
|
|
239
250
|
return {
|
|
240
251
|
provider: "github",
|
|
241
|
-
commit: {
|
|
242
|
-
|
|
252
|
+
commit: {
|
|
253
|
+
sha,
|
|
254
|
+
branch,
|
|
255
|
+
message: readEnv("GITHUB_COMMIT_MESSAGE") || null,
|
|
256
|
+
author: readEnv("GITHUB_ACTOR")
|
|
257
|
+
},
|
|
258
|
+
workflow: {
|
|
259
|
+
id: runId,
|
|
260
|
+
name: readEnv("GITHUB_WORKFLOW")
|
|
261
|
+
},
|
|
262
|
+
job: {
|
|
263
|
+
id: readEnv("GITHUB_RUN_ATTEMPT"),
|
|
264
|
+
name: readEnv("GITHUB_JOB")
|
|
265
|
+
},
|
|
266
|
+
ci: { url, pipelineUrl: url }
|
|
243
267
|
};
|
|
244
268
|
};
|
|
245
269
|
const getArtifacts = (rootDir, typeOverride, runId, s3Prefix) => {
|
|
@@ -348,6 +372,8 @@ const main = async () => {
|
|
|
348
372
|
fail("Commit branch is required.");
|
|
349
373
|
if (!ci.ci.url)
|
|
350
374
|
fail("CI run URL is required.");
|
|
375
|
+
if (!ci.workflow.id)
|
|
376
|
+
fail("Workflow ID is required.");
|
|
351
377
|
const appUrl = readEnv("SENTINEL_URL") || readEnv("APP_URL") || DEFAULT_APP_URL;
|
|
352
378
|
const createRes = await withRetry(() => fetch(`${appUrl}/api/runs`, {
|
|
353
379
|
method: "POST",
|
|
@@ -358,6 +384,8 @@ const main = async () => {
|
|
|
358
384
|
body: JSON.stringify({
|
|
359
385
|
provider: ci.provider,
|
|
360
386
|
commit: ci.commit,
|
|
387
|
+
workflow: ci.workflow,
|
|
388
|
+
job: ci.job,
|
|
361
389
|
ci: ci.ci
|
|
362
390
|
})
|
|
363
391
|
}), "POST /api/runs");
|
|
@@ -456,7 +484,9 @@ const main = async () => {
|
|
|
456
484
|
headers: {
|
|
457
485
|
"content-type": artifact.contentType
|
|
458
486
|
},
|
|
459
|
-
body
|
|
487
|
+
body,
|
|
488
|
+
// Required by Node.js fetch when streaming a request body
|
|
489
|
+
duplex: "half"
|
|
460
490
|
});
|
|
461
491
|
if (!res.ok) {
|
|
462
492
|
throw new Error(`Upload failed (${res.status}) for ${artifact.objectKey}`);
|