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

e2e #9

Merged
merged 21 commits into from
Jul 25, 2024
Merged
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
62 changes: 62 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: CI

on:
push:
branches:
- main
pull_request: {}
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

jobs:
build-job:
runs-on: ubuntu-latest

# Cancel multiple runs when pushing to main
concurrency:
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 }}

steps:
# Build
- uses: actions/checkout@v4
- uses: actions/configure-pages@v5
- uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- run: npm ci
- uses: rharkor/[email protected]
- run: npm run build

# Tests (only for PRs)
- run: npm test
if: github.event_name == 'pull_request'

# Upload artifact (only for pushes on main)
- uses: actions/upload-pages-artifact@v3
if: github.event_name != 'pull_request'
with:
path: ./out/examples

deploy-job:
# only for pushes on main
if: github.event_name != 'pull_request'
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build-job
steps:
- id: deployment
uses: actions/deploy-pages@v4
59 changes: 0 additions & 59 deletions .github/workflows/pages.yml

This file was deleted.

6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ node_modules

# Testing
coverage
test-results

# Turbo
.turbo
Expand All @@ -35,7 +36,4 @@ yarn-error.log*

# Misc
.DS_Store
*.pem

tmp
copy.sh
*.pem
48 changes: 45 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ https://docs.pmnd.rs/react-three-fiber/getting-started/examples

index: [apps](apps)

To use a given [`basic-demo`](apps/basic-demo) as a template for a `new-project`:

```sh
$ npx -y degit pmndrs/examples/apps/basic-demo new-project
$ code new-project
```

# INSTALL

```sh
Expand All @@ -16,9 +23,44 @@ $ npm ci
$ npm run -w apps/cards-with-border-radius dev
```

To use a given [`basic-demo`](apps/basic-demo) as a template for a `new-project`:
# build

```sh
$ npx degit pmndrs/examples/apps/basic-demo new-project
$ code new-project
$ npm run build
```

<details>

This will execute `^build2` which will `vite build` each app with:

- a `--base` set to `/examples/${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

</details>

Then `npx serve out`.

<details>

You can build a specific app thanks to [`--filter`](https://turbo.build/repo/docs/reference/run#--filter-string):

```sh
$ npm run build -- --filter aquarium
```

</details>

# test

Pre-requisites:

- [build](#build)

```sh
$ docker run --init --rm -v $(pwd):/app -w /app ghcr.io/pmndrs/playwright:main npm test
```

> [!IMPORTANT]
> If running on mac m-series, you'll need to add `--platform linux/arm64` to the docker command.
1 change: 0 additions & 1 deletion apps/aquarium/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { Lightformer, Environment, RandomizedLight, AccumulativeShadows, MeshTra
import shapesModel from './shapes-transformed.glb?url'
import turtleModel from './model_52a_-_kemps_ridley_sea_turtle_no_id-transformed.glb?url'

console.log('cpoucou')
export default function App({ spheres }) {
return (
<Canvas shadows camera={{ position: [30, 0, -3], fov: 35, near: 1, far: 50 }}>
Expand Down
13 changes: 13 additions & 0 deletions copy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

DST="out/examples"

for app in apps/*; do
if [ -d "$app/dist" ]; then
app_name=$(basename "$app")
mkdir -p "$DST/$app_name"
cp -r "$app/dist/"* "$DST/$app_name/"

echo "Copied $app/dist to $DST/$app_name"
fi
done
Loading