Skip to content

Commit

Permalink
💚 (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
wcandillon authored Sep 5, 2024
1 parent ee1aab0 commit 7d2ef9e
Show file tree
Hide file tree
Showing 15 changed files with 162 additions and 281 deletions.
64 changes: 23 additions & 41 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ on:
branches:
- main
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
branches:
- main
merge_group:
types:
- checks_requested

jobs:
lint:
runs-on: ubuntu-latest
Expand All @@ -27,31 +30,24 @@ jobs:
run: yarn lint

- name: Typecheck files
working-directory: packages/webgpu
run: yarn tsc

test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/webgpu
steps:
- name: Checkout
uses: actions/checkout@v3
# test:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v3

- name: Setup
uses: ./.github/actions/setup
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
# - name: Setup
# uses: ./.github/actions/setup
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}

# - name: Run unit tests
# run: yarn test --maxWorkers=2 --coverage
# - name: Run unit tests
# run: yarn test --maxWorkers=2 --coverage

build-library:
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/webgpu
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -62,10 +58,11 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Build package
working-directory: packages/webgpu
run: yarn prepare

build-android:
runs-on: macos-latest
runs-on: macos-latest-large
env:
TURBO_CACHE_DIR: .turbo/android
steps:
Expand All @@ -83,7 +80,7 @@ jobs:
path: ${{ env.TURBO_CACHE_DIR }}
key: ${{ runner.os }}-turborepo-android-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-turborepo-android-
${{ runner.os }}-turborepo-android
- name: Check turborepo cache for Android
run: |
Expand Down Expand Up @@ -117,7 +114,7 @@ jobs:
- name: Install Android SDK
run: echo "sdk.dir=$ANDROID_HOME" > $GITHUB_WORKSPACE/apps/paper/android/local.properties

- name: Cache Gradle
if: env.turbo_cache_hit != 1
uses: actions/cache@v3
Expand All @@ -133,10 +130,10 @@ jobs:
env:
JAVA_OPTS: "-XX:MaxHeapSize=6g"
run: |
yarn build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}"
yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}"
build-ios:
runs-on: macos-latest
runs-on: macos-latest-large
env:
TURBO_CACHE_DIR: .turbo/ios
steps:
Expand All @@ -148,20 +145,6 @@ jobs:
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Download Dawn Binary Artifacts
uses: dawidd6/action-download-artifact@v2
with:
workflow: "build-dawn.yml"
repo: wcandillon/react-native-webgpu
github_token: ${{secrets.GITHUB_TOKEN}}
path: artifacts
branch: main
name: dawn-libs

- name: Copy Artifacts to libs folder
working-directory: packages/webgpu
run: yarn copy-artifacts

- name: Cache turborepo for iOS
uses: actions/cache@v3
with:
Expand Down Expand Up @@ -190,7 +173,6 @@ jobs:
${{ runner.os }}-cocoapods-
- name: Install cocoapods
if: env.turbo_cache_hit != 1 && steps.cocoapods-cache.outputs.cache-hit != 'true'
run: |
cd apps/paper/ios
pod install
Expand Down
File renamed without changes.
12 changes: 9 additions & 3 deletions apps/paper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
"private": true,
"scripts": {
"lint": "eslint . --ext .ts,.tsx --max-warnings 0 --cache --fix",
"tsc": "tsc --noEmit",
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"build:android": "cd android && ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a",
"build:ios": "cd ios && xcodebuild -workspace WgpuExample.xcworkspace -scheme WgpuExample -configuration Debug -sdk iphonesimulator CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ GCC_OPTIMIZATION_LEVEL=0 GCC_PRECOMPILE_PREFIX_HEADER=YES ASSETCATALOG_COMPILER_OPTIMIZATION=time DEBUG_INFORMATION_FORMAT=dwarf COMPILER_INDEX_STORE_ENABLE=NO | xcpretty"
"build:android": "cd android && ./gradlew assembleDebug --warning-mode all",
"build:ios": "npm run mkdist && react-native bundle --entry-file index.js --platform ios --dev true --bundle-output dist/main.ios.jsbundle --assets-dest dist && react-native build-ios --scheme WgpuExample --mode Debug --extra-params \"-sdk iphonesimulator CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ GCC_OPTIMIZATION_LEVEL=0 GCC_PRECOMPILE_PREFIX_HEADER=YES ASSETCATALOG_COMPILER_OPTIMIZATION=time DEBUG_INFORMATION_FORMAT=dwarf COMPILER_INDEX_STORE_ENABLE=NO\"",
"mkdist": "node -e \"require('node:fs').mkdirSync('dist', { recursive: true, mode: 0o755 })\""
},
"dependencies": {
"@react-navigation/native": "^6.1.17",
Expand All @@ -35,7 +37,11 @@
"@react-native/typescript-config": "0.74.84",
"@types/three": "^0.167.2",
"@webgpu/types": "^0.1.44",
"babel-plugin-module-resolver": "^5.0.0"
"babel-plugin-module-resolver": "^5.0.0",
"eslint": "8",
"eslint-config-react-native-wcandillon": "^3.10.2",
"eslint-plugin-import": "2.27.5",
"typescript": "^5.2.2"
},
"engines": {
"node": ">=18"
Expand Down
5 changes: 1 addition & 4 deletions apps/paper/src/Cube/TexturedCube.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,7 @@ export const TexturedCube = () => {
// Fetch the image and upload it into a GPUTexture.
let cubeTexture: GPUTexture;
{
const response = await fetchAsset(
// eslint-disable-next-line @typescript-eslint/no-var-requires
require("../assets/Di-3d.png"),
);
const response = await fetchAsset(require("../assets/Di-3d.png"));
const imageBitmap = await createImageBitmap(await response.blob());
cubeTexture = device.createTexture({
size: [imageBitmap.width, imageBitmap.height, 1],
Expand Down
1 change: 0 additions & 1 deletion apps/paper/src/Particles/Particles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ export function Particules() {
let numMipLevels = 1;
let texture: GPUTexture;
{
// eslint-disable-next-line @typescript-eslint/no-var-requires
const response = await fetchAsset(require("../assets/react.png"));
const imageBitmap = await createImageBitmap(await response.blob());

Expand Down
2 changes: 0 additions & 2 deletions apps/paper/src/RenderBundles/RenderBundles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ export const RenderBundles = () => {
// Fetch the images and upload them into a GPUTexture.
let planetTexture: GPUTexture;
{
// eslint-disable-next-line @typescript-eslint/no-var-requires
const response = await fetchAsset(require("../assets/saturn.png"));
const imageBitmap = await createImageBitmap(await response.blob());

Expand All @@ -120,7 +119,6 @@ export const RenderBundles = () => {

let moonTexture: GPUTexture;
{
// eslint-disable-next-line @typescript-eslint/no-var-requires
const response = await fetchAsset(require("../assets/moon.png"));
const imageBitmap = await createImageBitmap(await response.blob());

Expand Down
5 changes: 1 addition & 4 deletions apps/paper/src/ReversedZ/ReversedZ.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ const DepthBufferMode = {
Reversed: 1,
};

const depthBufferModes = [
DepthBufferMode.Default,
DepthBufferMode.Reversed,
];
const depthBufferModes = [DepthBufferMode.Default, DepthBufferMode.Reversed];
const depthCompareFuncs = {
[DepthBufferMode.Default]: "less" as GPUCompareFunction,
[DepthBufferMode.Reversed]: "greater" as GPUCompareFunction,
Expand Down
1 change: 0 additions & 1 deletion apps/paper/src/Tests.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable no-eval */

import React, { useEffect, useState } from "react";
Expand Down
1 change: 0 additions & 1 deletion apps/paper/src/ThreeJS/assets/AssetManager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-var-requires */
import * as THREE from "three/webgpu";
import { Image } from "react-native";

Expand Down
1 change: 0 additions & 1 deletion apps/paper/src/components/useAssets.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-var-requires */
import { useEffect, useState } from "react";
import { Image } from "react-native";
import "react-native-wgpu";
Expand Down
11 changes: 2 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,11 @@
"packageManager": "[email protected]",
"scripts": {
"lint": "turbo run lint",
"tsc": "turbo run tsc",
"build:ios": "turbo run build:ios",
"build:android": "turbo run build:android"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^8.3.0",
"@typescript-eslint/parser": "^8.3.0",
"eslint": "8",
"eslint-config-react-native-wcandillon": "^3.10.2",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "^28.8.0",
"eslint-plugin-prettier": "^5.2.1",
"turbo": "^2.1.0",
"typescript": "^5.2.2"
"turbo": "^2.1.0"
}
}
8 changes: 8 additions & 0 deletions packages/webgpu/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "react-native-wcandillon",
"ignorePatterns": ["**/*/components/meshes"],
"rules": {
"no-bitwise": "off",
"@typescript-eslint/no-require-imports": "off"
}
}
11 changes: 9 additions & 2 deletions packages/webgpu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
"scripts": {
"test": "jest -i",
"test:ref": "REFERENCE=true yarn test -i",
"tsc": "tsc --noEmit",
"lint": "eslint . --ext .ts,.tsx --max-warnings 0 --cache --fix",
"tsc": "tsc --noEmit",
"prepare": "bob build",
"build-dawn": "ts-node scripts/build/dawn.ts",
"clean-dawn": "rimraf ./libs && rimraf ../../externals/dawn/out",
Expand Down Expand Up @@ -70,9 +70,16 @@
"@types/react": "^18.2.44",
"@types/seedrandom": "^3.0.8",
"@types/ws": "^8.5.10",
"@typescript-eslint/eslint-plugin": "^8.4.0",
"@typescript-eslint/parser": "^8.4.0",
"@webgpu/types": "^0.1.44",
"clang-format": "^1.8.0",
"del-cli": "^5.1.0",
"eslint": "8",
"eslint-config-react-native-wcandillon": "^3.10.2",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-jest": "^28.8.2",
"eslint-plugin-prettier": "^5.2.1",
"jest": "^29.7.0",
"lodash": "^4.17.21",
"pixelmatch": "5.3.0",
Expand All @@ -87,7 +94,7 @@
"teapot": "^1.0.0",
"ts-morph": "^22.0.0",
"ts-node": "^10.9.2",
"turbo": "^1.10.7",
"typescript": "^5.2.2",
"wgpu-matrix": "^3.0.2",
"ws": "^8.18.0"
},
Expand Down
53 changes: 35 additions & 18 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,51 @@
"$schema": "https://turbo.build/schema.json",
"tasks": {
"build:android": {
"env": ["JAVA_HOME", "ANDROID_NDK", "ANDROID_SDK", "ANDROID_HOME"],
"outputs": [
"apps/*/android",
"!apps/*/android/.gradle",
"!apps/*/android/build",
"!apps/*/android/app/build"
],
"inputs": [
"packages/webgpu/package.json",
"**/*/package.json",
"packages/webgpu/android",
"!packages/webgpu/android/build",
"packages/webgpu/src/*.ts",
"packages/webgpu/src/*.tsx",
"packages/webgpu/example/package.json",
"packages/webgpu/example/android",
"!packages/webgpu/example/android/.gradle",
"!packages/webgpu/example/android/build",
"!packages/webgpu/example/android/app/build"
],
"outputs": []
"apps/*/package.json",
"apps/*/android",
"apps/*/android/app/build.gradle",
"apps/*/android/build.gradle",
"apps/*/android/gradle.properties",
"apps/*/android/local.properties",
"!apps/*/android/.gradle",
"!apps/*/android/build",
"!apps/*/android/app/build"
]
},
"build:ios": {
"outputs": [
"apps/*/ios/build",
"apps/*/ios/Pods"
],
"inputs": [
"packages/webgpu/package.json",
"packages/webgpu/*.podspec",
"packages/webgpu/ios",
"package.json",
"*.podspec",
"ios",
"ios/Podfile",
"ios/*.xcconfig",
"ios/**/*.plist",
"packages/webgpu/src/*.ts",
"packages/webgpu/src/*.tsx",
"packages/webgpu/example/package.json",
"packages/webgpu/example/ios",
"!packages/webgpu/example/ios/build",
"!packages/webgpu/example/ios/Pods"
],
"outputs": []
"apps/*/package.json",
"apps/*/ios",
"!apps/*/ios/build",
"!apps/*/ios/Pods"
]
},
"lint": {}
"lint": {},
"tsc": {}
}
}
Loading

0 comments on commit 7d2ef9e

Please sign in to comment.