Skip to content

Commit 5497087

Browse files
refactor and fix ci
Signed-off-by: Nikita Korolev <nikita.korolev@flant.com>
1 parent a45446c commit 5497087

4 files changed

Lines changed: 67 additions & 3 deletions

File tree

.github/scripts/js/e2e/report/cluster-report.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,9 @@ async function buildClusterReport({ core, context }) {
346346
}
347347

348348
const effectiveStageInfo =
349-
stageInfo.reportKind === "tests" && parsedReport.source === "empty"
349+
stageInfo.status === "success" &&
350+
stageInfo.reportKind === "tests" &&
351+
parsedReport.source === "empty"
350352
? buildArtifactMissingDescriptor(config.storageType)
351353
: stageInfo;
352354

.github/scripts/js/e2e/report/cluster-report.test.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,4 +335,44 @@ describe("cluster-report", () => {
335335
expect(report.failedStageLabel).toBe("TEST REPORTS NOT FOUND");
336336
expect(report.status).toBe("missing");
337337
}));
338+
339+
test("keeps cancelled test stage when no reports were found", async () =>
340+
withTempDir(async (tempDir) => {
341+
const reportFile = path.join(tempDir, "report.json");
342+
setStageEnv({
343+
E2E_REPORT_DIR: tempDir,
344+
REPORT_FILE: reportFile,
345+
E2E_TEST_RESULT: "cancelled",
346+
});
347+
348+
const report = await buildClusterReport({
349+
core: createCore(),
350+
context: createContext(),
351+
});
352+
353+
expect(report.reportKind).toBe("tests");
354+
expect(report.failedStage).toBe("e2e-test");
355+
expect(report.failedStageLabel).toBe("E2E TEST");
356+
expect(report.status).toBe("cancelled");
357+
}));
358+
359+
test("keeps failed test stage when no reports were found", async () =>
360+
withTempDir(async (tempDir) => {
361+
const reportFile = path.join(tempDir, "report.json");
362+
setStageEnv({
363+
E2E_REPORT_DIR: tempDir,
364+
REPORT_FILE: reportFile,
365+
E2E_TEST_RESULT: "failure",
366+
});
367+
368+
const report = await buildClusterReport({
369+
core: createCore(),
370+
context: createContext(),
371+
});
372+
373+
expect(report.reportKind).toBe("tests");
374+
expect(report.failedStage).toBe("e2e-test");
375+
expect(report.failedStageLabel).toBe("E2E TEST");
376+
expect(report.status).toBe("failure");
377+
}));
338378
});

.github/workflows/e2e-matrix.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,17 @@ jobs:
477477
steps:
478478
- uses: actions/checkout@v4
479479

480+
- name: Setup Node.js for report scripts
481+
uses: actions/setup-node@v6
482+
with:
483+
node-version: "20"
484+
cache: npm
485+
cache-dependency-path: .github/scripts/js/package-lock.json
486+
487+
- name: Install report script dependencies
488+
working-directory: .github/scripts/js
489+
run: npm ci
490+
480491
- name: Download E2E report artifacts
481492
uses: actions/download-artifact@v5
482493
continue-on-error: true
@@ -497,13 +508,13 @@ jobs:
497508
REPORT_FALLBACK_REPLICATED_FAILED_STAGE: ${{ needs.e2e-replicated.outputs.failed_stage }}
498509
REPORT_FALLBACK_REPLICATED_FAILED_STAGE_LABEL: ${{ needs.e2e-replicated.outputs.failed_stage_label }}
499510
REPORT_FALLBACK_REPLICATED_WORKFLOW_RUN_URL: ${{ needs.e2e-replicated.outputs.workflow_run_url }}
500-
REPORT_FALLBACK_REPLICATED_BRANCH: ${{ needs.e2e-replicated.outputs.branch }}
511+
REPORT_FALLBACK_REPLICATED_BRANCH: ${{ needs.e2e-replicated.outputs.branch || github.ref_name }}
501512
REPORT_FALLBACK_NFS_REPORT_KIND: ${{ needs.e2e-nfs.outputs.report_kind }}
502513
REPORT_FALLBACK_NFS_STATUS: ${{ needs.e2e-nfs.outputs.status }}
503514
REPORT_FALLBACK_NFS_FAILED_STAGE: ${{ needs.e2e-nfs.outputs.failed_stage }}
504515
REPORT_FALLBACK_NFS_FAILED_STAGE_LABEL: ${{ needs.e2e-nfs.outputs.failed_stage_label }}
505516
REPORT_FALLBACK_NFS_WORKFLOW_RUN_URL: ${{ needs.e2e-nfs.outputs.workflow_run_url }}
506-
REPORT_FALLBACK_NFS_BRANCH: ${{ needs.e2e-nfs.outputs.branch }}
517+
REPORT_FALLBACK_NFS_BRANCH: ${{ needs.e2e-nfs.outputs.branch || github.ref_name }}
507518
LOOP_API_BASE_URL: ${{ secrets.LOOP_API_BASE_URL }}
508519
LOOP_CHANNEL_ID: ${{ secrets.LOOP_CHANNEL_ID }}
509520
LOOP_TOKEN: ${{ secrets.LOOP_TOKEN }}

.github/workflows/e2e-reusable-pipeline.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,6 +1348,17 @@ jobs:
13481348
steps:
13491349
- uses: actions/checkout@v4
13501350

1351+
- name: Setup Node.js for report scripts
1352+
uses: actions/setup-node@v6
1353+
with:
1354+
node-version: "20"
1355+
cache: npm
1356+
cache-dependency-path: .github/scripts/js/package-lock.json
1357+
1358+
- name: Install report script dependencies
1359+
working-directory: .github/scripts/js
1360+
run: npm ci
1361+
13511362
- name: Download E2E test results if available
13521363
uses: actions/download-artifact@v5
13531364
continue-on-error: true

0 commit comments

Comments
 (0)