Skip to content

Commit 48f2269

Browse files
chore: define WF to get reference images even for passed tests
Some tests are passing even their references are outdated, but change is too small. WF to get references even for those tests. risk: low
1 parent edeaeb3 commit 48f2269

File tree

2 files changed

+147
-8
lines changed

2 files changed

+147
-8
lines changed
Lines changed: 79 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,85 @@
1-
# (C) 2024 GoodData Corporation
1+
# (C) 2025 GoodData Corporation
22

3-
# Deploy of ui sdk examples from rel/9.9 branch
43
name: Doc ~ Examples deploy
54
on:
65
workflow_dispatch:
76

87
jobs:
9-
release-ui-sdk-examples-deploy:
10-
secrets: inherit
11-
permissions:
12-
contents: write
13-
id-token: write
14-
uses: ./.github/workflows/rw-doc-examples-deploy.yml
8+
warm-up-cache:
9+
runs-on:
10+
group: infra1-runners-arc
11+
labels: runners-cxa-xlarge
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 2
16+
- name: Git config user
17+
uses: snow-actions/git-config-user@v1.0.0
18+
with:
19+
name: git-action
20+
email: git-action@gooddata.com
21+
- name: Warmup rush
22+
env:
23+
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
24+
uses: ./.github/actions/rush/warm-up-rush
25+
build:
26+
needs: [warm-up-cache]
27+
runs-on:
28+
group: infra1-runners-arc
29+
labels: runners-rxa-xlarge
30+
steps:
31+
- uses: actions/checkout@v4
32+
with:
33+
fetch-depth: 2
34+
- name: Git config user
35+
uses: snow-actions/git-config-user@v1.0.0
36+
with:
37+
name: git-action
38+
email: git-action@gooddata.com
39+
- name: Debug
40+
run: git log -1
41+
- name: Setup rush
42+
env:
43+
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
44+
uses: ./.github/actions/rush/set-up-rush
45+
- name: Rush build
46+
run: node common/scripts/install-run-rush.js build --to @gooddata/sdk-ui-tests
47+
48+
e2e-backstop:
49+
needs: [warm-up-cache,build]
50+
runs-on:
51+
group: infra1-runners-arc
52+
labels: runners-mxa-2xlarge # bigger runner as backstop sometimes cannot launch the browser
53+
steps:
54+
- uses: actions/checkout@v4
55+
with:
56+
fetch-depth: 2
57+
- name: Git config user
58+
uses: snow-actions/git-config-user@v1.0.0
59+
with:
60+
name: git-action
61+
email: git-action@gooddata.com
62+
- name: Setup rush
63+
env:
64+
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
65+
uses: ./.github/actions/rush/set-up-rush
66+
- name: Rush build
67+
run: |
68+
node common/scripts/install-run-rush.js build --to @gooddata/sdk-ui-tests
69+
- name: Run backstop tests
70+
run: |
71+
export EXECUTOR_NUMBER=$GH_RUN_ID
72+
./common/scripts/ci/run_backstop_tests.sh
73+
env:
74+
GH_RUN_ID: ${{ github.run_id }}
75+
- name: Cleanup backstop artifacts
76+
if: ${{ !cancelled() && failure() }}
77+
run: |
78+
node libs/sdk-ui-tests/backstop/backstop-write-all-artifacts.cjs
79+
- name: Archive the cypress test artifacts
80+
uses: actions/upload-artifact@v4
81+
if: ${{ !cancelled() && failure() }}
82+
with:
83+
name: backstop-test-artifacts-failed
84+
path: |
85+
libs/sdk-ui-tests/backstop/output/**/*
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/**
2+
* Process backstop output results.
3+
*
4+
* Adjust config so that the html report is correctly displayed and contains all tests.
5+
*
6+
**/
7+
const fs = require("fs");
8+
const path = require("path");
9+
10+
const currentDir = __dirname;
11+
const references = "reference";
12+
13+
console.log(`Storing all artifacts from ${currentDir}/output`);
14+
15+
const outputPath = path.join(currentDir, "output");
16+
const htmlReportPath = path.join(outputPath, "html-report");
17+
const outputConfig = path.join(htmlReportPath, "config.js");
18+
19+
if (!fs.existsSync(outputConfig)) {
20+
console.log("No backstop output, skipping cleanup of test artifacts");
21+
process.exit(1);
22+
}
23+
24+
// this will be the newly added directory to output, to which we copy
25+
// reference screenshots for failed tests
26+
const referenceDirectory = path.join(outputPath, references);
27+
fs.mkdirSync(referenceDirectory, { recursive: true });
28+
29+
const configData = fs.readFileSync(outputConfig, "utf8");
30+
31+
// the config json we're interested in is wrapped with report({...});
32+
const configJson = configData.slice("report(".length, -2);
33+
const data = JSON.parse(configJson);
34+
35+
data.tests.forEach((test) => {
36+
if (test.status === "pass" || test.status === "fail") {
37+
const referenceFile = test.pair?.reference;
38+
const referencePath = path.join(htmlReportPath, referenceFile);
39+
const baseReferenceFilename = path.basename(referencePath);
40+
const destReference = path.join(referenceDirectory, baseReferenceFilename);
41+
42+
if (fs.existsSync(referencePath)) {
43+
fs.copyFileSync(referencePath, destReference);
44+
}
45+
} else {
46+
console.log(`Processing "${test.pair?.label}", unrecognized test status: "${test.status}"`);
47+
}
48+
});
49+
50+
const updatedTests = data.tests
51+
.filter((test) => test.status === "fail")
52+
.map((test) => ({
53+
...test,
54+
pair: {
55+
...test.pair,
56+
reference: test.pair?.reference?.replace(`../../${references}`, `../${references}`),
57+
},
58+
}));
59+
60+
const replacedConfig = {
61+
...data,
62+
tests: updatedTests,
63+
};
64+
const stringified = JSON.stringify(replacedConfig, null, 2);
65+
66+
// replace original config with adjusted one
67+
const result = `report(${stringified});`;
68+
fs.writeFileSync(outputConfig, result, "utf8");

0 commit comments

Comments
 (0)