Skip to content

Commit

Permalink
cached + parallel tests (#25)
Browse files Browse the repository at this point in the history
* wip 1

* wip2

* simplify

* no tty

* intermediate docker image

* fix stdio

* tweaks

* test.sh

* packages/e2e

* concurrency 1

* macos-14

* runs-on: ubuntu-latest

* remove set -ex

* -container.image

* doc

* default concurrency

* playwright rejection

* -test.sh

* test.sh out.sh

* rn e2e-{test,build}

* -dependsOn

* doc
  • Loading branch information
abernier authored Jul 29, 2024
1 parent dad2072 commit 2657fe3
Show file tree
Hide file tree
Showing 179 changed files with 502 additions and 331 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ jobs:
group: ${{ github.event_name != 'pull_request' && 'group-pushmain' || github.run_id }}
cancel-in-progress: ${{ github.event_name != 'pull_request' }}

container:
image: ghcr.io/pmndrs/playwright:main
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# container:
# image: ghcr.io/pmndrs/playwright:main
# credentials:
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}

steps:
# Build
Expand All @@ -43,7 +43,7 @@ jobs:
BASE_PATH: ${{ steps.configurepages.outputs.base_path }}

# Tests (only for PRs)
- run: npm test
- run: ./test.sh
if: github.event_name == 'pull_request'
env:
BASE_PATH: ${{ steps.configurepages.outputs.base_path }}
Expand Down
37 changes: 33 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ This will:

- a `--base` set to `${BASE_PATH}/${app_name}`
- a custom vite `--config`, whith a `monkey()` plugin that will:
- [`deterministic`](packages/examples/src/deterministic.js) script into `src/index.jsx`
- monkeypatch the `<Canvas>` with [`CheesyCanvas`](packages/examples/src/CheesyCanvas.jsx) for setting up the scene for playwright screenshots
- [`deterministic`](packages/e2e/src/deterministic.js) script into `src/index.jsx`
- monkeypatch the `<Canvas>` with [`CheesyCanvas`](packages/e2e/src/CheesyCanvas.jsx) for setting up the scene for playwright screenshots

2. build the Next.js `apps/website`
3. copy final result into `out` folder
Expand All @@ -58,12 +58,41 @@ Pre-requisites:
- [build](#build)
> [!WARNING]
> Do not forget to (re-)[build]() first!
```sh
$ docker run --init --rm -v $(pwd):/app -w /app ghcr.io/pmndrs/playwright:main npm test
$ npm test
```
To update the snapshots: `npm test -- -- --update-snapshots`
> [!IMPORTANT]
> If running on mac m-series, you'll need to add `--platform linux/arm64` to the docker command.
> If you built the project with eg. `BASE_PATH=/examples` you'll need to:
>
> ```sh
> $ BASE_PATH=/examples npm test
> ```
## Docker
For generating reproductible snapshots, we still build static `out/` folder locally, but use dockerised environment to run playwright tests against:
```sh
$ ./test.sh
```
> [!NOTE]
> A `-v "$(pwd)":/app` volume is mounted to the container, so any snapshot will be written to the host machine.
To update the snapshots: `./test.sh --update`
> [!IMPORTANT]
> If you built the project with eg. `BASE_PATH=/examples` you'll need to:
>
> ```sh
> $ BASE_PATH=/examples ./test.sh
> ```
# Colophon
Expand Down
5 changes: 3 additions & 2 deletions demos/aquarium/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
"scripts": {
"dev": "vite --host --open",
"build": "tsc && vite build",
"build2": "tsc && vite-build $npm_package_name",
"preview": "vite preview"
"build2": "tsc && e2e-build $npm_package_name",
"preview": "vite preview",
"test": "e2e-test $npm_package_name"
},
"browserslist": [
">0.2%",
Expand Down
2 changes: 1 addition & 1 deletion demos/arkanoid-under-60-loc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"scripts": {
"dev": "vite --host --open",
"build": "tsc && vite build",
"build2": "tsc && vite-build $npm_package_name",
"build2": "tsc && e2e-build $npm_package_name",
"preview": "vite preview"
},
"browserslist": [
Expand Down
2 changes: 1 addition & 1 deletion demos/arkanoid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"scripts": {
"dev": "vite --host --open",
"build": "tsc && vite build",
"build2": "tsc && vite-build $npm_package_name",
"build2": "tsc && e2e-build $npm_package_name",
"preview": "vite preview"
},
"browserslist": [
Expand Down
2 changes: 1 addition & 1 deletion demos/audio-analyser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"scripts": {
"dev": "vite --host --open",
"build": "tsc && vite build",
"build2": "tsc && vite-build $npm_package_name",
"build2": "tsc && e2e-build $npm_package_name",
"preview": "vite preview"
},
"browserslist": [
Expand Down
2 changes: 1 addition & 1 deletion demos/backdrop-and-cables/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"scripts": {
"dev": "vite --host --open",
"build": "tsc && vite build",
"build2": "tsc && vite-build $npm_package_name",
"build2": "tsc && e2e-build $npm_package_name",
"preview": "vite preview"
},
"browserslist": [
Expand Down
5 changes: 3 additions & 2 deletions demos/baking-soft-shadows/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
"scripts": {
"dev": "vite --host --open",
"build": "tsc && vite build",
"build2": "tsc && vite-build $npm_package_name",
"preview": "vite preview"
"build2": "tsc && e2e-build $npm_package_name",
"preview": "vite preview",
"test": "e2e-test $npm_package_name"
},
"browserslist": [
">0.2%",
Expand Down
2 changes: 1 addition & 1 deletion demos/basic-ballpit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"scripts": {
"dev": "vite --host --open",
"build": "tsc && vite build",
"build2": "tsc && vite-build $npm_package_name",
"build2": "tsc && e2e-build $npm_package_name",
"preview": "vite preview"
},
"browserslist": [
Expand Down
2 changes: 1 addition & 1 deletion demos/basic-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"scripts": {
"dev": "vite --host --open",
"build": "tsc && vite build",
"build2": "tsc && vite-build $npm_package_name",
"build2": "tsc && e2e-build $npm_package_name",
"preview": "vite preview"
},
"browserslist": [
Expand Down
2 changes: 1 addition & 1 deletion demos/bestservedbold-christmas-baubles/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"scripts": {
"dev": "vite --host --open",
"build": "tsc && vite build",
"build2": "tsc && vite-build $npm_package_name",
"build2": "tsc && e2e-build $npm_package_name",
"preview": "vite preview"
},
"browserslist": [
Expand Down
2 changes: 1 addition & 1 deletion demos/bezier-curves-and-nodes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"scripts": {
"dev": "vite --host --open",
"build": "tsc && vite build",
"build2": "tsc && vite-build $npm_package_name",
"build2": "tsc && e2e-build $npm_package_name",
"preview": "vite preview"
},
"browserslist": [
Expand Down
2 changes: 1 addition & 1 deletion demos/bloom-hdr-workflow-gltf/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"scripts": {
"dev": "vite --host --open",
"build": "tsc && vite build",
"build2": "tsc && vite-build $npm_package_name",
"build2": "tsc && e2e-build $npm_package_name",
"preview": "vite preview"
},
"browserslist": [
Expand Down
2 changes: 1 addition & 1 deletion demos/bouncy-watch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"scripts": {
"dev": "vite --host --open",
"build": "tsc && vite build",
"build2": "tsc && vite-build $npm_package_name",
"build2": "tsc && e2e-build $npm_package_name",
"preview": "vite preview"
},
"browserslist": [
Expand Down
2 changes: 1 addition & 1 deletion demos/bounds-and-makedefault/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"scripts": {
"dev": "vite --host --open",
"build": "tsc && vite build",
"build2": "tsc && vite-build $npm_package_name",
"build2": "tsc && e2e-build $npm_package_name",
"preview": "vite preview"
},
"browserslist": [
Expand Down
2 changes: 1 addition & 1 deletion demos/bruno-simons-20k-challenge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"scripts": {
"dev": "vite --host --open",
"build": "tsc && vite build",
"build2": "tsc && vite-build $npm_package_name",
"build2": "tsc && e2e-build $npm_package_name",
"preview": "vite preview"
},
"browserslist": [
Expand Down
2 changes: 1 addition & 1 deletion demos/building-dynamic-envmaps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"scripts": {
"dev": "vite --host --open",
"build": "tsc && vite build",
"build2": "tsc && vite-build $npm_package_name",
"build2": "tsc && e2e-build $npm_package_name",
"preview": "vite preview"
},
"browserslist": [
Expand Down
2 changes: 1 addition & 1 deletion demos/building-live-envmaps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"scripts": {
"dev": "vite --host --open",
"build": "tsc && vite build",
"build2": "tsc && vite-build $npm_package_name",
"build2": "tsc && e2e-build $npm_package_name",
"preview": "vite preview"
},
"browserslist": [
Expand Down
2 changes: 1 addition & 1 deletion demos/bvh/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"scripts": {
"dev": "vite --host --open",
"build": "tsc && vite build",
"bbuild2": "tsc && vite-build $npm_package_name",
"bbuild2": "tsc && e2e-build $npm_package_name",
"preview": "vite preview"
},
"browserslist": [
Expand Down
2 changes: 1 addition & 1 deletion demos/camera-scroll/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"scripts": {
"dev": "vite --host --open",
"build": "tsc && vite build",
"build2": "tsc && vite-build $npm_package_name",
"build2": "tsc && e2e-build $npm_package_name",
"preview": "vite preview"
},
"browserslist": [
Expand Down
2 changes: 1 addition & 1 deletion demos/camera-shake/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"scripts": {
"dev": "vite --host --open",
"build": "tsc && vite build",
"build2": "tsc && vite-build $npm_package_name",
"build2": "tsc && e2e-build $npm_package_name",
"preview": "vite preview"
},
"browserslist": [
Expand Down
2 changes: 1 addition & 1 deletion demos/canvas-text/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"scripts": {
"dev": "vite --host --open",
"build": "tsc && vite build",
"build2": "tsc && vite-build $npm_package_name",
"build2": "tsc && e2e-build $npm_package_name",
"preview": "vite preview"
},
"browserslist": [
Expand Down
2 changes: 1 addition & 1 deletion demos/cards-with-border-radius/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"scripts": {
"dev": "vite --host --open",
"build": "tsc && vite build",
"build2": "tsc && vite-build $npm_package_name",
"build2": "tsc && e2e-build $npm_package_name",
"preview": "vite preview"
},
"browserslist": [
Expand Down
2 changes: 1 addition & 1 deletion demos/cards/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"scripts": {
"dev": "vite --host --open",
"build": "tsc && vite build",
"build2": "tsc && vite-build $npm_package_name",
"build2": "tsc && e2e-build $npm_package_name",
"preview": "vite preview"
},
"browserslist": [
Expand Down
2 changes: 1 addition & 1 deletion demos/caustics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"scripts": {
"dev": "vite --host --open",
"build": "tsc && vite build",
"build2": "tsc && vite-build $npm_package_name",
"build2": "tsc && e2e-build $npm_package_name",
"preview": "vite preview"
},
"browserslist": [
Expand Down
2 changes: 1 addition & 1 deletion demos/cell-fracture/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"scripts": {
"dev": "vite --host --open",
"build": "tsc && vite build",
"build2": "tsc && vite-build $npm_package_name",
"build2": "tsc && e2e-build $npm_package_name",
"preview": "vite preview"
},
"browserslist": [
Expand Down
2 changes: 1 addition & 1 deletion demos/clones/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"scripts": {
"dev": "vite --host --open",
"build": "tsc && vite build",
"build2": "tsc && vite-build $npm_package_name",
"build2": "tsc && e2e-build $npm_package_name",
"preview": "vite preview"
},
"browserslist": [
Expand Down
2 changes: 1 addition & 1 deletion demos/clouds/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"scripts": {
"dev": "vite --host --open",
"build": "tsc && vite build",
"build2": "tsc && vite-build $npm_package_name",
"build2": "tsc && e2e-build $npm_package_name",
"preview": "vite preview"
},
"eslintConfig": {
Expand Down
2 changes: 1 addition & 1 deletion demos/color-grading/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"scripts": {
"dev": "vite --host --open",
"build": "tsc && vite build",
"build2": "tsc && vite-build $npm_package_name",
"build2": "tsc && e2e-build $npm_package_name",
"preview": "vite preview"
},
"browserslist": [
Expand Down
2 changes: 1 addition & 1 deletion demos/confetti/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"scripts": {
"dev": "vite --host --open",
"build": "tsc && vite build",
"build2": "tsc && vite-build $npm_package_name",
"build2": "tsc && e2e-build $npm_package_name",
"preview": "vite preview"
},
"browserslist": [
Expand Down
2 changes: 1 addition & 1 deletion demos/csg-bunny-usegroups/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"scripts": {
"dev": "vite --host --open",
"build": "tsc && vite build",
"build2": "tsc && vite-build $npm_package_name",
"build2": "tsc && e2e-build $npm_package_name",
"preview": "vite preview"
},
"browserslist": [
Expand Down
2 changes: 1 addition & 1 deletion demos/csg-house/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"scripts": {
"dev": "vite --host --open",
"build": "tsc && vite build",
"build2": "tsc && vite-build $npm_package_name",
"build2": "tsc && e2e-build $npm_package_name",
"preview": "vite preview"
},
"browserslist": [
Expand Down
2 changes: 1 addition & 1 deletion demos/csg-operations-rapier-physics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"scripts": {
"dev": "vite --host --open",
"build": "tsc && vite build",
"build2": "tsc && vite-build $npm_package_name",
"build2": "tsc && e2e-build $npm_package_name",
"preview": "vite preview"
},
"browserslist": [
Expand Down
2 changes: 1 addition & 1 deletion demos/dbismut-furniture/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"scripts": {
"dev": "vite --host --open",
"build": "tsc && vite build",
"build2": "tsc && vite-build $npm_package_name",
"build2": "tsc && e2e-build $npm_package_name",
"preview": "vite preview"
},
"browserslist": [
Expand Down
2 changes: 1 addition & 1 deletion demos/diamond-refraction/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"scripts": {
"dev": "vite --host --open",
"build": "tsc && vite build",
"build2": "tsc && vite-build $npm_package_name",
"build2": "tsc && e2e-build $npm_package_name",
"preview": "vite preview"
},
"browserslist": [
Expand Down
2 changes: 1 addition & 1 deletion demos/diamond-ring/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"scripts": {
"dev": "vite --host --open",
"build": "tsc && vite build",
"build2": "tsc && vite-build $npm_package_name",
"build2": "tsc && e2e-build $npm_package_name",
"preview": "vite preview"
},
"browserslist": [
Expand Down
Loading

0 comments on commit 2657fe3

Please sign in to comment.