Skip to content

Commit 92cbc57

Browse files
committed
try visual regression action
1 parent 0f07f76 commit 92cbc57

File tree

5 files changed

+148
-43
lines changed

5 files changed

+148
-43
lines changed

.circleci/config.yml

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -42,28 +42,6 @@ jobs:
4242
paths:
4343
- node_modules
4444

45-
visual regression:
46-
<<: *ramdisk
47-
docker:
48-
- image: buildkite/puppeteer:latest
49-
user: node
50-
environment:
51-
COSMOS_HOST: localhost
52-
COSMOS_PORT: 5001
53-
parallelism: 4
54-
steps:
55-
- checkout
56-
- *restore_node_modules_cache
57-
- run:
58-
command: yarn cosmos
59-
background: true
60-
- run:
61-
command: sleep 5 && yarn run visual-regression:exec
62-
environment:
63-
PUPPETEER_EXECUTABLE_PATH: /usr/bin/google-chrome
64-
- store_artifacts:
65-
path: src/panel/__image_snapshots__/__diff_output__/
66-
6745
build:
6846
<<: *node_env
6947
<<: *ramdisk
@@ -149,12 +127,6 @@ workflows:
149127
filters:
150128
tags:
151129
only: /.*/
152-
- visual regression:
153-
requires:
154-
- install
155-
filters:
156-
tags:
157-
only: /.*/
158130
- build:
159131
requires:
160132
- install
@@ -179,7 +151,6 @@ workflows:
179151
requires:
180152
- install
181153
- build
182-
- visual regression
183154
- lint firefox
184155
- verify version
185156
filters:
@@ -191,7 +162,6 @@ workflows:
191162
requires:
192163
- install
193164
- build
194-
- visual regression
195165
- lint firefox
196166
- verify version
197167
filters:
@@ -203,7 +173,6 @@ workflows:
203173
requires:
204174
- install
205175
- build
206-
- visual regression
207176
- lint firefox
208177
- verify version
209178
filters:

.github/workflows/ci.yml

Lines changed: 69 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,10 @@ jobs:
4848
steps.node-modules-cache.outputs.cache-hit != 'true'
4949
run: yarn install --prefer-offline --frozen-lockfile --non-interactive --silent
5050

51-
## currently has an issue with graphql
52-
## - name: TypeScript
53-
## run: yarn run type-check
51+
- name: TypeScript
52+
run: yarn run type-check
5453

55-
- name: Linting
54+
- name: Lint
5655
run: yarn run lint
5756

5857
## TODO: consolidate in linting step
@@ -61,3 +60,69 @@ jobs:
6160

6261
- name: Unit Tests
6362
run: TZ=Europe/London yarn run test --coverage
63+
64+
- name: Build
65+
run: yarn build && yarn bundle
66+
67+
- name: Lint FireFox
68+
run: yarn run lint:firefox
69+
70+
visual-regression:
71+
name: Visual Regression
72+
runs-on: ubuntu-latest
73+
timeout-minutes: 10
74+
steps:
75+
- name: Checkout Repo
76+
uses: actions/checkout@v3
77+
with:
78+
fetch-depth: 0
79+
80+
- name: Setup Node
81+
uses: actions/setup-node@v3
82+
with:
83+
node-version: '16'
84+
85+
- name: Get Yarn cache directory
86+
id: yarn-cache-dir-path
87+
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
88+
89+
- name: Use Yarn cache
90+
uses: actions/cache@v3
91+
id: yarn-cache
92+
with:
93+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
94+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
95+
restore-keys: |
96+
${{ runner.os }}-yarn-
97+
98+
- name: Use node_modules cache
99+
id: node-modules-cache
100+
uses: actions/cache@v3
101+
with:
102+
path: node_modules
103+
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }}
104+
105+
- name: Install Dependencies
106+
if: |
107+
steps.yarn-cache.outputs.cache-hit != 'true' ||
108+
steps.node-modules-cache.outputs.cache-hit != 'true'
109+
run: yarn install --prefer-offline --frozen-lockfile --non-interactive --silent
110+
111+
- name: Run Cosmos
112+
run: yarn run cosmos &
113+
114+
- name: Wait for Cosmos to boot
115+
run: yarn wait-on http://localhost:5001
116+
117+
- name: Run Puppeteer
118+
run: yarn run visual-regression:exec
119+
env:
120+
COSMOS_HOST: locahost
121+
COSMOS_PORT: 5000
122+
123+
- name: Store image diffs
124+
uses: actions/upload-artifact@v2
125+
if: ${{ failure() }}
126+
with:
127+
name: image-snapshots
128+
path: src/panel/__image_snapshots__/__diff_output__/

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@
142142
"terser-webpack-plugin": "^4.2.2",
143143
"ts-jest": "^26.3.0",
144144
"typescript": "^4.9.3",
145+
"wait-on": "^6.0.1",
145146
"web-ext": "^5.1.0",
146147
"webpack": "^4.44.1",
147148
"webpack-cli": "^3.3.12",

src/panel/visual-regression.test.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,9 @@ import { detectCosmosConfig, getFixtures2, FixtureApi } from "react-cosmos";
22
import { toMatchImageSnapshot } from "jest-image-snapshot";
33
expect.extend({ toMatchImageSnapshot });
44

5-
const fixtures = getFixtures2({
6-
...detectCosmosConfig(),
7-
hostname: process.env.COSMOS_HOST,
8-
port: Number(process.env.COSMOS_PORT),
9-
}).reduce<[string, FixtureApi][]>(
10-
(p, c) => [...p, [`${c.fileName} - ${c.name}`, c]],
11-
[]
12-
);
5+
const fixtures = getFixtures2(detectCosmosConfig()).reduce<
6+
[string, FixtureApi][]
7+
>((p, c) => [...p, [`${c.fileName} - ${c.name}`, c]], []);
138

149
beforeAll(async () => {
1510
jest.retryTimes(5);

yarn.lock

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,6 +1370,18 @@
13701370
resolved "https://registry.yarnpkg.com/@graphql-typed-document-node/core/-/core-3.1.1.tgz#076d78ce99822258cf813ecc1e7fa460fa74d052"
13711371
integrity sha512-NQ17ii0rK1b34VZonlmT2QMJFI70m0TRwbknO/ihlbatXyaktDhN/98vBiUU6kNBPljqGqyIrl2T4nY2RpFANg==
13721372

1373+
"@hapi/hoek@^9.0.0":
1374+
version "9.3.0"
1375+
resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-9.3.0.tgz#8368869dcb735be2e7f5cb7647de78e167a251fb"
1376+
integrity sha512-/c6rf4UJlmHlC9b5BaNvzAcFv7HZ2QHaV0D4/HNlBdvFnvQq8RI4kYdhyPCl7Xj+oWvTWQ8ujhqS53LIgAe6KQ==
1377+
1378+
"@hapi/topo@^5.0.0":
1379+
version "5.1.0"
1380+
resolved "https://registry.yarnpkg.com/@hapi/topo/-/topo-5.1.0.tgz#dc448e332c6c6e37a4dc02fd84ba8d44b9afb012"
1381+
integrity sha512-foQZKJig7Ob0BMAYBfcJk8d77QtOe7Wo4ox7ff1lQYoNNAb6jwcY1ncdoy2e9wQZzvNy7ODZCYJkK8kzmcAnAg==
1382+
dependencies:
1383+
"@hapi/hoek" "^9.0.0"
1384+
13731385
"@istanbuljs/load-nyc-config@^1.0.0":
13741386
version "1.1.0"
13751387
resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz#fd3db1d59ecf7cf121e80650bb86712f9b55eced"
@@ -1723,6 +1735,23 @@
17231735
dependencies:
17241736
mkdirp "^1.0.4"
17251737

1738+
"@sideway/address@^4.1.3":
1739+
version "4.1.4"
1740+
resolved "https://registry.yarnpkg.com/@sideway/address/-/address-4.1.4.tgz#03dccebc6ea47fdc226f7d3d1ad512955d4783f0"
1741+
integrity sha512-7vwq+rOHVWjyXxVlR76Agnvhy8I9rpzjosTESvmhNeXOXdZZB15Fl+TI9x1SiHZH5Jv2wTGduSxFDIaq0m3DUw==
1742+
dependencies:
1743+
"@hapi/hoek" "^9.0.0"
1744+
1745+
"@sideway/formula@^3.0.0":
1746+
version "3.0.0"
1747+
resolved "https://registry.yarnpkg.com/@sideway/formula/-/formula-3.0.0.tgz#fe158aee32e6bd5de85044be615bc08478a0a13c"
1748+
integrity sha512-vHe7wZ4NOXVfkoRb8T5otiENVlT7a3IAiw7H5M2+GO+9CDgcVUUsX1zalAztCmwyOr2RUTGJdgB+ZvSVqmdHmg==
1749+
1750+
"@sideway/pinpoint@^2.0.0":
1751+
version "2.0.0"
1752+
resolved "https://registry.yarnpkg.com/@sideway/pinpoint/-/pinpoint-2.0.0.tgz#cff8ffadc372ad29fd3f78277aeb29e632cc70df"
1753+
integrity sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ==
1754+
17261755
"@sindresorhus/is@^0.14.0":
17271756
version "0.14.0"
17281757
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea"
@@ -3109,6 +3138,13 @@ aws4@^1.8.0:
31093138
resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.10.0.tgz#a17b3a8ea811060e74d47d306122400ad4497ae2"
31103139
integrity sha512-3YDiu347mtVtjpyV3u5kVqQLP242c06zwDOgpeRnybmXlYYsLbtTrUBUm8i8srONt+FWobl5aibnU1030PeeuA==
31113140

3141+
axios@^0.25.0:
3142+
version "0.25.0"
3143+
resolved "https://registry.yarnpkg.com/axios/-/axios-0.25.0.tgz#349cfbb31331a9b4453190791760a8d35b093e0a"
3144+
integrity sha512-cD8FOb0tRH3uuEe6+evtAbgJtfxr7ly3fQjYcMcuPlgkwVS9xboaVIpcDV+cYQe+yGykgwZCs1pzjntcGa6l5g==
3145+
dependencies:
3146+
follow-redirects "^1.14.7"
3147+
31123148
babel-jest@^26.3.0:
31133149
version "26.3.0"
31143150
resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-26.3.0.tgz#10d0ca4b529ca3e7d1417855ef7d7bd6fc0c3463"
@@ -6110,6 +6146,11 @@ follow-redirects@^1.0.0:
61106146
dependencies:
61116147
debug "^3.0.0"
61126148

6149+
follow-redirects@^1.14.7:
6150+
version "1.15.2"
6151+
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13"
6152+
integrity sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==
6153+
61136154
for-each@^0.3.3:
61146155
version "0.3.3"
61156156
resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.3.tgz#69b447e88a0a5d32c3e7084f3f1710034b21376e"
@@ -8119,6 +8160,17 @@ [email protected]:
81198160
resolved "https://registry.yarnpkg.com/jetpack-id/-/jetpack-id-1.0.0.tgz#2cf9fbae46d8074fc16b7de0071c8efebca473a6"
81208161
integrity sha1-LPn7rkbYB0/Ba33gBxyO/rykc6Y=
81218162

8163+
joi@^17.6.0:
8164+
version "17.7.0"
8165+
resolved "https://registry.yarnpkg.com/joi/-/joi-17.7.0.tgz#591a33b1fe1aca2bc27f290bcad9b9c1c570a6b3"
8166+
integrity sha512-1/ugc8djfn93rTE3WRKdCzGGt/EtiYKxITMO4Wiv6q5JL1gl9ePt4kBsl1S499nbosspfctIQTpYIhSmHA3WAg==
8167+
dependencies:
8168+
"@hapi/hoek" "^9.0.0"
8169+
"@hapi/topo" "^5.0.0"
8170+
"@sideway/address" "^4.1.3"
8171+
"@sideway/formula" "^3.0.0"
8172+
"@sideway/pinpoint" "^2.0.0"
8173+
81228174
js-select@~0.6.0:
81238175
version "0.6.0"
81248176
resolved "https://registry.yarnpkg.com/js-select/-/js-select-0.6.0.tgz#c284e22824d5927aec962dcdf247174aefb0d190"
@@ -11043,6 +11095,13 @@ rxjs@^6.6.2:
1104311095
dependencies:
1104411096
tslib "^1.9.0"
1104511097

11098+
rxjs@^7.5.4:
11099+
version "7.5.7"
11100+
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-7.5.7.tgz#2ec0d57fdc89ece220d2e702730ae8f1e49def39"
11101+
integrity sha512-z9MzKh/UcOqB3i20H6rtrlaE/CgjLOvheWK/9ILrbhROGTweAi1BaFsTT9FbwZi5Trr1qNRs+MXkhmR06awzQA==
11102+
dependencies:
11103+
tslib "^2.1.0"
11104+
1104611105
[email protected], safe-buffer@~5.1.0, safe-buffer@~5.1.1:
1104711106
version "5.1.2"
1104811107
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d"
@@ -12378,6 +12437,11 @@ tslib@^1.10.0, tslib@^1.8.1, tslib@^1.9.0:
1237812437
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.13.0.tgz#c881e13cc7015894ed914862d276436fa9a47043"
1237912438
integrity sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==
1238012439

12440+
tslib@^2.1.0:
12441+
version "2.4.1"
12442+
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.1.tgz#0d0bfbaac2880b91e22df0768e55be9753a5b17e"
12443+
integrity sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA==
12444+
1238112445
tsutils@^3.17.1:
1238212446
version "3.17.1"
1238312447
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.17.1.tgz#ed719917f11ca0dee586272b2ac49e015a2dd759"
@@ -12829,6 +12893,17 @@ w3c-xmlserializer@^2.0.0:
1282912893
dependencies:
1283012894
xml-name-validator "^3.0.0"
1283112895

12896+
wait-on@^6.0.1:
12897+
version "6.0.1"
12898+
resolved "https://registry.yarnpkg.com/wait-on/-/wait-on-6.0.1.tgz#16bbc4d1e4ebdd41c5b4e63a2e16dbd1f4e5601e"
12899+
integrity sha512-zht+KASY3usTY5u2LgaNqn/Cd8MukxLGjdcZxT2ns5QzDmTFc4XoWBgC+C/na+sMRZTuVygQoMYwdcVjHnYIVw==
12900+
dependencies:
12901+
axios "^0.25.0"
12902+
joi "^17.6.0"
12903+
lodash "^4.17.21"
12904+
minimist "^1.2.5"
12905+
rxjs "^7.5.4"
12906+
1283212907
walker@^1.0.7, walker@~1.0.5:
1283312908
version "1.0.7"
1283412909
resolved "https://registry.yarnpkg.com/walker/-/walker-1.0.7.tgz#2f7f9b8fd10d677262b18a884e28d19618e028fb"

0 commit comments

Comments
 (0)