Skip to content

Commit eafe052

Browse files
authored
build: Add Dockerfile for easily updating snapshots (#1071)
- Updated README to include new instructions on how to update snapshots - Add snapshots for mac that weren't previously included - Tested on M1 MacBook Pro - Fixes #960
1 parent e15c125 commit eafe052

32 files changed

Lines changed: 165 additions & 69 deletions

File tree

.dockerignore

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Just copy the .gitignore file for files we don't want to copy to the docker image
2+
3+
# dependencies
4+
/node_modules
5+
6+
# testing
7+
/coverage
8+
9+
# production
10+
/build
11+
/dist
12+
13+
# misc
14+
.vscode/*
15+
!.vscode/settings.json
16+
!.vscode/tasks.json
17+
!.vscode/launch.json
18+
!.vscode/extensions.json
19+
!.vscode/*.code-snippets
20+
.DS_Store
21+
.env.local
22+
.env.development.local
23+
.env.test.local
24+
.env.production.local
25+
.project
26+
.settings/
27+
.eslintcache
28+
.stylelintcache
29+
lerna-debug.log
30+
Lerna-Profile-*.json
31+
32+
/public/vs
33+
34+
npm-debug.log*
35+
yarn-debug.log*
36+
yarn-error.log*
37+
38+
src/**/*.css
39+
40+
tsconfig.tsbuildinfo
41+
packages/*/package-lock.json
42+
/test-results/
43+
/playwright-report/
44+
/playwright/.cache/
45+
46+
# Ignore Dockerfile as well, since we don't need to copy that into the snapshot container
47+
Dockerfile
48+
49+
# Tests are copied to the docker container, as it modifies them
50+
/tests

README.md

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -114,45 +114,6 @@ npx source-map-explorer 'packages/code-studio/build/static/js/*.js'
114114

115115
## Updating Snapshots
116116

117-
Snapshots are used by end-to-end tests to visually verify the output. Sometimes changes are made requiring snapshots to be updated. Since snapshots are platform dependent, you may need to use a docker image to [update snapshots for CI](https://playwright.dev/docs/test-snapshots). You mount the current directory into a docker image and re-run the tests from there.
117+
Snapshots are used by end-to-end tests to visually verify the output. Sometimes changes are made requiring snapshots to be updated. Run snapshots locally to update first, by running `npm run e2e:update-snapshots`.
118118

119-
First start with a clean repo. `node_modules` and some other build output is platform dependent.
120-
121-
```
122-
npm run clean
123-
```
124-
125-
Next, start the docker image and open a bash shell inside of it:
126-
127-
```
128-
docker run --rm --network host -v $(pwd):/work/ -w /work/ -it mcr.microsoft.com/playwright:v1.28.1-focal /bin/bash
129-
```
130-
131-
Within the docker image shell, install some build tools that are not included with the image:
132-
133-
```
134-
apt-get update
135-
apt-get install build-essential --yes
136-
```
137-
138-
Next, use nvm to install and use the correct version of node:
139-
140-
```
141-
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash
142-
export NVM_DIR="$HOME/.nvm"
143-
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
144-
nvm install
145-
```
146-
147-
Install npm dependencies and build the production app, pointing to an API running on your machine:
148-
149-
```
150-
npm ci
151-
VITE_CORE_API_URL=http://host.docker.internal:10000/jsapi npm run build
152-
```
153-
154-
Next, run the tests and update the snapshots:
155-
156-
```
157-
npm run e2e:update-snapshots
158-
```
119+
Once you are satisfied with the snapshots and everything is passing locally, you need to use a docker image to [update snapshots for CI](https://playwright.dev/docs/test-snapshots) (unless you are running the same platform as CI (Ubuntu)). Run `npm run e2e:update-ci-snapshots` to mount the current directory into a docker image and re-run the tests from there. **Note:** You must have [Docker installed](https://docs.docker.com/get-docker/), and `deephaven-core` must already be running on port 10000 on your local machine.

package-lock.json

Lines changed: 24 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"npm": ">=8"
1111
},
1212
"scripts": {
13-
"postinstall": "run-s build:necessary",
13+
"postinstall": "node ./skip.js || run-s build:necessary",
1414
"clean:build": "rimraf packages/*/dist packages/*/build",
1515
"postclean:build": "npm run clean:types",
1616
"clean:cache": "run-s clean:cache:*",
@@ -49,7 +49,8 @@
4949
"e2e:codegen": "playwright codegen http://localhost:4000",
5050
"e2e:headed": "playwright test --project=chromium --headed --debug",
5151
"e2e:update-snapshots": "playwright test --update-snapshots",
52-
"version-bump": "lerna version --conventional-commits --create-release github"
52+
"version-bump": "lerna version --conventional-commits --create-release github",
53+
"e2e:update-ci-snapshots": "docker build --tag web-client-ui-ci-snapshots --file ./tests/update-ci-snapshots/Dockerfile . && docker run --rm --network host --volume $(pwd)/tests:/work/tests/ web-client-ui-ci-snapshots npm run e2e:update-snapshots -- --config=playwright-ci.config.ts"
5354
},
5455
"repository": "https://github.com/deephaven/web-client-ui",
5556
"devDependencies": {
@@ -67,7 +68,7 @@
6768
"@deephaven/stylelint-config": "file:../stylelint-config",
6869
"@deephaven/tsconfig": "file:../tsconfig",
6970
"@fortawesome/fontawesome-common-types": "^6.1.1",
70-
"@playwright/test": "^1.28.1",
71+
"@playwright/test": "^1.30.0",
7172
"@testing-library/jest-dom": "^5.16.4",
7273
"@testing-library/react": "^12.1.3",
7374
"@testing-library/user-event": "^14.4.3",
@@ -119,7 +120,7 @@
119120
"karma-jasmine": "~0.1.5",
120121
"lerna": "^6.4.1",
121122
"npm-run-all": "^4.1.5",
122-
"playwright": "^1.28.1",
123+
"playwright": "^1.30.0",
123124
"prettier": "2.2.1",
124125
"react": "^17.0.2",
125126
"react-dom": "^17.0.2",

playwright-ci.config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import DefaultConfig from './playwright.config';
2+
3+
const config: PlaywrightTestConfig = {
4+
...DefaultConfig,
5+
snapshotDir: '/tests',
6+
};
7+
8+
export default config;

skip.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Script will skip the postinstall script if `SKIP_POSTINSTALL` env variable is set
2+
if (process.env.SKIP_POSTINSTALL) {
3+
process.exit(0);
4+
} else {
5+
process.exit(1);
6+
}
6.36 KB
Loading
18.7 KB
Loading
9.08 KB
Loading
63.5 KB
Loading

0 commit comments

Comments
 (0)