Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 79 additions & 8 deletions .github/workflows/doc-examples-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,85 @@
# (C) 2024 GoodData Corporation
# (C) 2025 GoodData Corporation

# Deploy of ui sdk examples from rel/9.9 branch
name: Doc ~ Examples deploy
on:
workflow_dispatch:

jobs:
release-ui-sdk-examples-deploy:
secrets: inherit
permissions:
contents: write
id-token: write
uses: ./.github/workflows/rw-doc-examples-deploy.yml
warm-up-cache:
runs-on:
group: infra1-runners-arc
labels: runners-cxa-xlarge
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Git config user
uses: snow-actions/[email protected]
with:
name: git-action
email: [email protected]
- name: Warmup rush
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
uses: ./.github/actions/rush/warm-up-rush
build:
needs: [warm-up-cache]
runs-on:
group: infra1-runners-arc
labels: runners-rxa-xlarge
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Git config user
uses: snow-actions/[email protected]
with:
name: git-action
email: [email protected]
- name: Debug
run: git log -1
- name: Setup rush
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
uses: ./.github/actions/rush/set-up-rush
- name: Rush build
run: node common/scripts/install-run-rush.js build --to @gooddata/sdk-ui-tests

e2e-backstop:
needs: [warm-up-cache,build]
runs-on:
group: infra1-runners-arc
labels: runners-mxa-2xlarge # bigger runner as backstop sometimes cannot launch the browser
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Git config user
uses: snow-actions/[email protected]
with:
name: git-action
email: [email protected]
- name: Setup rush
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
uses: ./.github/actions/rush/set-up-rush
- name: Rush build
run: |
node common/scripts/install-run-rush.js build --to @gooddata/sdk-ui-tests
- name: Run backstop tests
run: |
export EXECUTOR_NUMBER=$GH_RUN_ID
./common/scripts/ci/run_backstop_tests.sh
env:
GH_RUN_ID: ${{ github.run_id }}
- name: Cleanup backstop artifacts
if: ${{ !cancelled() && failure() }}
run: |
node libs/sdk-ui-tests/backstop/backstop-write-all-artifacts.cjs
- name: Archive the cypress test artifacts
uses: actions/upload-artifact@v4
if: ${{ !cancelled() && failure() }}
with:
name: backstop-test-artifacts-failed
path: |
libs/sdk-ui-tests/backstop/output/**/*
68 changes: 68 additions & 0 deletions libs/sdk-ui-tests/backstop/backstop-write-all-artifacts.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/**
* Process backstop output results.
*
* Adjust config so that the html report is correctly displayed and contains all tests.
*
**/
const fs = require("fs");
const path = require("path");

const currentDir = __dirname;
const references = "reference";

console.log(`Storing all artifacts from ${currentDir}/output`);

const outputPath = path.join(currentDir, "output");
const htmlReportPath = path.join(outputPath, "html-report");
const outputConfig = path.join(htmlReportPath, "config.js");

if (!fs.existsSync(outputConfig)) {
console.log("No backstop output, skipping cleanup of test artifacts");
process.exit(1);
}

// this will be the newly added directory to output, to which we copy
// reference screenshots for failed tests
const referenceDirectory = path.join(outputPath, references);
fs.mkdirSync(referenceDirectory, { recursive: true });

const configData = fs.readFileSync(outputConfig, "utf8");

// the config json we're interested in is wrapped with report({...});
const configJson = configData.slice("report(".length, -2);
const data = JSON.parse(configJson);

data.tests.forEach((test) => {
if (test.status === "pass" || test.status === "fail") {
const referenceFile = test.pair?.reference;
const referencePath = path.join(htmlReportPath, referenceFile);
const baseReferenceFilename = path.basename(referencePath);
const destReference = path.join(referenceDirectory, baseReferenceFilename);

if (fs.existsSync(referencePath)) {
fs.copyFileSync(referencePath, destReference);
}
} else {
console.log(`Processing "${test.pair?.label}", unrecognized test status: "${test.status}"`);
}
});

const updatedTests = data.tests
.filter((test) => test.status === "fail")
.map((test) => ({
...test,
pair: {
...test.pair,
reference: test.pair?.reference?.replace(`../../${references}`, `../${references}`),
},
}));

const replacedConfig = {
...data,
tests: updatedTests,
};
const stringified = JSON.stringify(replacedConfig, null, 2);

// replace original config with adjusted one
const result = `report(${stringified});`;
fs.writeFileSync(outputConfig, result, "utf8");