Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Try to add visual-test results to CI #3419

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
b903a9f
Try to add a non-blocking visual-test
rlingineni Feb 9, 2024
f4e14fd
Update visual-test.yml
rlingineni Feb 9, 2024
0057cb1
tweak multi-line output
rlingineni Feb 9, 2024
33446f8
try multi-line output
rlingineni Feb 9, 2024
2d1e808
Update visual-test.yml
rlingineni Feb 9, 2024
230c395
try again
rlingineni Feb 9, 2024
d987185
change to dot reporter
rlingineni Feb 9, 2024
f0ff0a9
remove ssr for chartgraph
rlingineni Feb 9, 2024
4b078e4
change multi-line strat
rlingineni Feb 9, 2024
f4e3d1e
fix more
rlingineni Feb 9, 2024
686db29
add new line
rlingineni Feb 9, 2024
b5af9f4
Update visual-test.yml
rlingineni Feb 9, 2024
b347895
try other command
rlingineni Feb 9, 2024
75c3b37
Update visual-test.yml
rlingineni Feb 10, 2024
548efe8
try to run on fail
rlingineni Feb 12, 2024
4d76b90
add perms
rlingineni Feb 12, 2024
3db983e
more perms
rlingineni Feb 12, 2024
167e56d
update the GH token for test results
rlingineni Feb 14, 2024
9b12074
add custom reporter
rlingineni Feb 15, 2024
fde7426
just try commenting first
rlingineni Feb 15, 2024
9e4c6c9
Update visual-test.yml
rlingineni Feb 15, 2024
d1d0027
Update visual-test.yml
rlingineni Feb 15, 2024
9b0a7d6
Update visual-test.yml
rlingineni Feb 15, 2024
334c697
fix - this wont work in a PR
rlingineni Feb 15, 2024
147486b
try proxy
rlingineni Feb 15, 2024
7e49082
retry
rlingineni Feb 15, 2024
6c71c8d
Update visual-test.yml
rlingineni Feb 15, 2024
790b184
one more time
rlingineni Feb 15, 2024
f4ac008
fix api
rlingineni Feb 15, 2024
7ef8469
fix logging
rlingineni Feb 15, 2024
19fbc17
Update visual-test.yml
rlingineni Feb 15, 2024
4d6f2b5
test
rlingineni Feb 15, 2024
a97db0f
fix
rlingineni Feb 15, 2024
4b15be4
one last time (final)
rlingineni Feb 15, 2024
b4221a0
progress
rlingineni Feb 15, 2024
17611eb
Update visual-test.yml
rlingineni Feb 15, 2024
28d2bf9
Update visual-test.yml
rlingineni Feb 15, 2024
2b9c539
add visual-test-results
rlingineni Feb 15, 2024
2b85ee5
update reporting
rlingineni Feb 15, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
jobs:
test:
name: Tests
runs-on: ubuntu-latest
runs-on: ubuntu-latest-large
strategy:
matrix:
node_version: [16, 18]
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/visual-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Visual Test Results
permissions:
contents: write
pull-requests: write
issues: write
on:
pull_request:
branches:
- master
push:
branches:
- master
jobs:
playwright-run:
name: Visual Test
timeout-minutes: 60
runs-on: macos-latest-xlarge
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '16'
cache: 'yarn'
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Install Playwright
run: npx playwright install --with-deps chromium
- name: Build
run: yarn build
- name: Run your tests
id: results
uses: mathiasvr/[email protected]
with:
run: npx playwright test playwright/visual-test --config=playwright/playwright.config.js --workers=2 --retries=2 --quiet --reporter='playwright/reporters/reporter.js' || true
- name: Comment PR with execution number
uses: mshick/add-pr-comment@v2
with:
message: |
${{ steps.results.outputs.stdout }}
message-id: visual-test
proxy-url: https://ravi-gh-comment-proxy.deno.dev
67 changes: 39 additions & 28 deletions docs/pages/visual-test/ChartGraph-dark.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,48 @@
// @flow strict
import { type Node as ReactNode } from 'react';
import dynamic from 'next/dynamic';
import { Box, ColorSchemeProvider } from 'gestalt';
import { ChartGraph } from 'gestalt-charts';

function NoSsr(props: { children: ReactNode }) {
return <div> {props.children} </div>;
}

const NoSSR = dynamic(() => Promise.resolve(NoSsr), {
ssr: false,
});

export default function Snapshot(): ReactNode {
return (
<ColorSchemeProvider colorScheme="dark">
<Box width={200}>
<ChartGraph
accessibilityLabel="Example of Bar chart"
visualPatternSelected="default"
onVisualPatternChange={() => {}}
type="bar"
title="Title"
description="Description"
legend="auto"
data={[
{
name: 'A',
'Series_01': 100,
},
{
name: 'B',
'Series_01': 200,
},
{
name: 'C',
'Series_01': 300,
},
]}
elements={[{ type: 'bar', id: 'Series_01' }]}
/>
</Box>
</ColorSchemeProvider>
<NoSSR>
<ColorSchemeProvider colorScheme="dark">
<Box width={200}>
<ChartGraph
accessibilityLabel="Example of Bar chart"
visualPatternSelected="default"
onVisualPatternChange={() => {}}
type="bar"
title="Title"
description="Description"
legend="auto"
data={[
{
name: 'A',
'Series_01': 100,
},
{
name: 'B',
'Series_01': 200,
},
{
name: 'C',
'Series_01': 300,
},
]}
elements={[{ type: 'bar', id: 'Series_01' }]}
/>
</Box>
</ColorSchemeProvider>
</NoSSR>
);
}
67 changes: 39 additions & 28 deletions docs/pages/visual-test/ChartGraph-light.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,48 @@
// @flow strict
import { type Node as ReactNode } from 'react';
import dynamic from 'next/dynamic';
import { Box, ColorSchemeProvider } from 'gestalt';
import { ChartGraph } from 'gestalt-charts';

function NoSsr(props: { children: ReactNode }) {
return <div> {props.children} </div>;
}

const NoSSR = dynamic(() => Promise.resolve(NoSsr), {
ssr: false,
});

export default function Snapshot(): ReactNode {
return (
<ColorSchemeProvider colorScheme="light">
<Box width={200}>
<ChartGraph
accessibilityLabel="Example of Bar chart"
visualPatternSelected="default"
onVisualPatternChange={() => {}}
type="bar"
title="Title"
description="Description"
legend="auto"
data={[
{
name: 'A',
'Series_01': 100,
},
{
name: 'B',
'Series_01': 200,
},
{
name: 'C',
'Series_01': 300,
},
]}
elements={[{ type: 'bar', id: 'Series_01' }]}
/>
</Box>
</ColorSchemeProvider>
<NoSSR>
<ColorSchemeProvider colorScheme="light">
<Box width={200}>
<ChartGraph
accessibilityLabel="Example of Bar chart"
visualPatternSelected="default"
onVisualPatternChange={() => {}}
type="bar"
title="Title"
description="Description"
legend="auto"
data={[
{
name: 'A',
'Series_01': 100,
},
{
name: 'B',
'Series_01': 200,
},
{
name: 'C',
'Series_01': 300,
},
]}
elements={[{ type: 'bar', id: 'Series_01' }]}
/>
</Box>
</ColorSchemeProvider>
</NoSSR>
);
}
65 changes: 65 additions & 0 deletions playwright/reporters/reporter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/* eslint-disable eslint-comments/disable-enable-pair */
/* eslint-disable class-methods-use-this */
/* eslint-disable flowtype/require-valid-file-annotation */

const FailedRuns = {};
let startTime = 0;
class MyReporter {
onBegin(config, suite) {
console.log(`This is an automated test report`);
console.log(`Running ${suite.allTests().length} tests`);
startTime = new Date().getTime();
}

onTestBegin() {}

onTestEnd(test, result) {
if (result.status === 'failed') {
// get the first word of the test title
const title = test.title.split(' ')[0];
FailedRuns[title] = test;
}
}

onEnd() {
// duration
const endTime = new Date().getTime();
const duration = endTime - startTime;
// get duration in minutes and seconds
const minutes = Math.floor(duration / 60000);
const seconds = ((duration % 60000) / 1000).toFixed(0);

if (Object.keys(FailedRuns).length > 0) {
console.log(`### Failed Visual Snapshots ❌`);
console.log('-----------------------------------');
console.log(
'Note: These test failures may or may not be related to your changes. They are not blocking.',
);

console.log('');
console.log(Object.keys(FailedRuns).length, ' failed visual tests:');

Object.keys(FailedRuns).forEach((title) => {
console.log(`- ${title}`);
});

console.log(`To see the failed tests, run the following command locally:`);
console.log(`\`yarn run playwright:visual-test test --ui\``);

console.log('');
console.log('');

console.log(`To update failed tests, run`);
console.log(`\`yarn run playwright:visual-test --update-snapshots\``);

console.log('');

console.log(`Total Test Run Time: ${minutes}m ${seconds}s`);
} else {
console.log(`All visual tests passed ✅`);
console.log(`Total Test Run Time: ${minutes}m ${seconds}s`);
}
}
}

export default MyReporter;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading