From 608027cdc43862f7a4f2b1d3ae9a3c3df417a6d5 Mon Sep 17 00:00:00 2001 From: William Candillon Date: Mon, 17 Jun 2024 22:11:14 +0200 Subject: [PATCH 1/7] Create build-dawn.yml --- .github/workflows/build-dawn.yml | 45 ++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/build-dawn.yml diff --git a/.github/workflows/build-dawn.yml b/.github/workflows/build-dawn.yml new file mode 100644 index 000000000..c0966a097 --- /dev/null +++ b/.github/workflows/build-dawn.yml @@ -0,0 +1,45 @@ +name: Build Dawn +on: workflow_dispatch +jobs: + build: + runs-on: macos-latest + env: + WORKING_DIRECTORY: ./package + steps: + - name: checkout + uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Setup Android NDK + id: setup-ndk + uses: nttld/setup-ndk@v1 + with: + ndk-version: r22b + + - name: Setup Ninja + uses: seanmiddleditch/gha-setup-ninja@master + + - name: Setup Nodejs and npm + uses: actions/setup-node@v3 + with: + cache: yarn + + - name: Install root node dependencies + run: yarn + + - name: Build Dawn + working-directory: ${{ env.WORKING_DIRECTORY }}/ + env: + ANDROID_NDK: ${{ steps.setup-ndk.outputs.ndk-path }} + run: yarn build-dawn + + - name: Upload artifacts - Dawn Library Files + if: github.ref == 'refs/heads/main' + uses: actions/upload-artifact@v2 + with: + name: dawn-libs + path: | + ${{ env.WORKING_DIRECTORY }}/libs + ${{ env.WORKING_DIRECTORY }}/cpp/dawn + ${{ env.WORKING_DIRECTORY }}/cpp/webgpu From c6aacebfe58a2a8bc2e571f9c97920cb1fa15655 Mon Sep 17 00:00:00 2001 From: William Candillon Date: Mon, 17 Jun 2024 22:12:38 +0200 Subject: [PATCH 2/7] Create build-android.yml --- .github/workflows/build-android.yml | 182 ++++++++++++++++++++++++++++ 1 file changed, 182 insertions(+) create mode 100644 .github/workflows/build-android.yml diff --git a/.github/workflows/build-android.yml b/.github/workflows/build-android.yml new file mode 100644 index 000000000..5e5089926 --- /dev/null +++ b/.github/workflows/build-android.yml @@ -0,0 +1,182 @@ +name: Android + +on: + push: + branches: + - main + pull_request: + +jobs: + build: + runs-on: macos-12 + strategy: + matrix: + working-directory: [package/example] + timeout-minutes: 55 + concurrency: + group: android-example-${{ matrix.working-directory }}-${{ github.ref }} + cancel-in-progress: true + steps: + - name: checkout + uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: '11' + + - name: Install NDK + uses: nttld/setup-ndk@v1 + id: setup-ndk + with: + ndk-version: r21d + + - name: Set ANDROID_NDK + run: echo "ANDROID_NDK=$ANDROID_HOME/ndk-bundle" >> $GITHUB_ENV + + - name: Download Skia Binary Artifacts + uses: dawidd6/action-download-artifact@v2 + with: + workflow: "build-skia.yml" + repo: shopify/react-native-skia + path: artifacts + branch: main + + - name: Download Dawn Binary Artifacts + uses: dawidd6/action-download-artifact@v2 + with: + workflow: "build-dawn.yml" + repo: wcandillon/react-native-webgpu + path: artifacts + branch: main + + - name: Install Package + working-directory: package + run: yarn install --frozen-lockfile + + - name: Copy Artifacts to libs folder + working-directory: package + run: yarn copy-artifacts + + - name: SDKs - accept licenses + run: y | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses + + - name: Cache hermes build + uses: actions/cache@v3 + env: + cache-name: cache-rn-hermes-engine + with: + path: ${{ matrix.working-directory }}/node_modules/react-native + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.working-directory }}-${{ hashFiles('**/react-native/package.json') }} + + - name: Cache android libraries + uses: actions/cache@v3 + env: + cache-name: cache-rn + with: + path: ${{ matrix.working-directory }}/android/app/build + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.working-directory }}-${{ hashFiles('**/react-native/package.json') }} + + - name: Build Android app + working-directory: ${{ matrix.working-directory }}/android + run: ./gradlew assembleDebug + + - name: Cache apk + uses: actions/cache/save@v3 + env: + cache-name: cache-apk + with: + path: ${{ matrix.working-directory }}/android/app/build/outputs/apk/debug/app-debug.apk + key: apk-${{ github.sha }} + # test: + # needs: build + # runs-on: macos-12 + # strategy: + # matrix: + # working-directory: [example, fabricexample] + # concurrency: + # group: android-example-${{ matrix.working-directory }}-${{ github.ref }} + # cancel-in-progress: true + # steps: + # - name: checkout + # uses: actions/checkout@v3 + # with: + # submodules: recursive + + # - uses: actions/setup-node@v3 + # with: + # node-version: 16 + # cache: 'yarn' + + # - name: Install root dependencies + # run: yarn bootstrap + + # - name: Restore APK + # id: cache-apk + # uses: actions/cache/restore@v3 + # with: + # path: ${{ matrix.working-directory }}/android/app/build/outputs/apk/debug/app-debug.apk + # key: apk-${{ github.sha }} + + # - name: SKDs - download required images + # run: $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager "system-images;android-30;default;x86_64" + + # - name: Emulator - Create + # run: $ANDROID_HOME/cmdline-tools/latest/bin/avdmanager create avd -n Pixel_API_30 --device 'Nexus 5X' --package "system-images;android-30;default;x86_64" --sdcard 512M + + # - name: Emulator - Boot + # run: $ANDROID_HOME/emulator/emulator -memory 4096 -avd Pixel_API_30 -wipe-data -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim & + + # - name: ADB Wait For Device + # run: adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;' + # timeout-minutes: 10 + + # - name: Reverse TCP + # working-directory: ${{ matrix.working-directory }} + # run: yarn android-reverse-tcp + + # - name: Start Package Manager + # working-directory: ${{ matrix.working-directory }} + # run: E2E=true yarn start & + + # - name: Check APK existence + # uses: andstor/file-existence-action@v2 + # with: + # files: ${{ matrix.working-directory }}/android/app/build/outputs/apk/debug/app-debug.apk + # fail: true + + # - name: Install APK + # run: adb install -r ${{ matrix.working-directory }}/android/app/build/outputs/apk/debug/app-debug.apk + + # # - name: Set up environment + # # run: echo "PACKAGE_NAME=${{ env.PACKAGE_NAME }}" >> $GITHUB_ENV + # - name: Launch APK + # env: + # PACKAGE_NAME: ${{ matrix.working-directory == 'fabricexample' && 'com.fabricexample' || 'com.rnskia' }} + # run: adb shell monkey -p ${{ env.PACKAGE_NAME }} 1 + + # # On fabric, the system fonts are slightly different + # # so wont run the paragraph tests there for now + # - name: Run e2e Tests + # working-directory: package + # run: | + # if [ "${{ matrix.working-directory }}" = "example" ]; then + # CI=true yarn e2e + # elif [ "${{ matrix.working-directory }}" = "fabricexample" ]; then + # CI=true yarn e2e --testPathIgnorePatterns Paragraphs + # fi + + # - uses: actions/upload-artifact@v2 + # if: failure() + # with: + # path: package/src/__tests__/snapshots/ + # name: ${{ matrix.working-directory }}-snapshots-screenshots + + # - uses: actions/upload-artifact@v2 + # if: failure() + # with: + # path: docs/static + # name: ${{ matrix.working-directory }}-docs-screenshots + From 12c3104e442db9cc9127938d032d6eaa841aabfa Mon Sep 17 00:00:00 2001 From: William Candillon Date: Mon, 17 Jun 2024 22:13:03 +0200 Subject: [PATCH 3/7] Create build-ios.yml --- .github/workflows/build-ios.yml | 101 ++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 .github/workflows/build-ios.yml diff --git a/.github/workflows/build-ios.yml b/.github/workflows/build-ios.yml new file mode 100644 index 000000000..9ea396c2c --- /dev/null +++ b/.github/workflows/build-ios.yml @@ -0,0 +1,101 @@ +name: Test iOS build +on: + pull_request: + paths: + - 'package/ios/**' + - 'package/cpp/**' + - 'package/example/package.json' + - '.github/workflows/**' + push: + branches: + - main + +jobs: + build: + runs-on: macos-12 + strategy: + matrix: + working-directory: [package/example] + concurrency: + group: ios-example-${{ matrix.working-directory }}-${{ github.ref }} + cancel-in-progress: true + steps: + - name: checkout + uses: actions/checkout@v3 + with: + submodules: recursive + + - uses: actions/setup-node@v3 + with: + cache: 'yarn' + + - name: Download Dawn Binary Artifacts + uses: dawidd6/action-download-artifact@v2 + with: + workflow: "build-dawn.yml" + repo: wcandillon/react-native-webgpu + path: artifacts + branch: main + + - name: Install Package + working-directory: package + run: yarn install --frozen-lockfile + + - name: Copy Artifacts to libs folder + working-directory: package + run: yarn copy-artifacts + + + - name: Restore Pods from cache + uses: actions/cache@v3 + with: + path: | + ${{ matrix.working-directory }}/ios/Pods + ~/Library/Caches/CocoaPods + ~/.cocoapods + key: ${{ runner.os }}-pods-${{ matrix.working-directory }}-${{ hashFiles(format('{0}/ios/Podfile.lock', matrix.working-directory)) }} + + - name: Install Pods + working-directory: ${{ matrix.working-directory }}/ios + run: pod install + + - name: Check if Podfile.lock has changed + working-directory: ${{ matrix.working-directory }}/ios + run: | + # Use git diff to get differences, excluding lines for 'COCOAPODS:' and filtering out 'React-RCTAppDelegate:' + # Right now we also exclude changes to React-RCTAppDelegate because of + # https://github.com/facebook/react-native/issues/39971 + if git diff --ignore-all-space -I 'COCOAPODS:' -I "React-RCTAppDelegate" HEAD -- example/ios/Podfile.lock | grep -q .; then + echo "Podfile.lock has local changes, please update it." + # Display diff, but exclude 'React-RCTAppDelegate:' changes for clarity + git diff --ignore-all-space -I 'COCOAPODS:' -I "React-RCTAppDelegate" HEAD -- example/ios/Podfile.lock | grep -q .; + exit 1 + else + echo "Podfile.lock is up to date." + fi + + - name: Restore build artifacts from cache + uses: actions/cache@v3 + with: + path: ~/Library/Developer/Xcode/DerivedData + key: ${{ runner.os }}-ios-derived-data-${{ hashFiles(format('{0}/ios/Podfile.lock', matrix.working-directory)) }} + + - name: Build app + working-directory: ${{ matrix.working-directory }} + run: CI=true yarn ios --simulator 'iPhone 14 Pro' + + # - name: Run e2e tests + # working-directory: package + # run: yarn e2e + + # - name: Start package manager + # working-directory: example + # run: E2E=true yarn start & + + # - name: Take screenshot + # run: xcrun simctl io booted screenshot screenshot.png + + # - uses: actions/upload-artifact@v2 + # with: + # path: screenshot.png + # name: Download-screenshots From def39593bfc2c64d7fffa16e43a1e89725026482 Mon Sep 17 00:00:00 2001 From: William Candillon Date: Mon, 17 Jun 2024 22:13:22 +0200 Subject: [PATCH 4/7] Create ci.yml --- .github/workflows/ci.yml | 48 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..2a8eb40c8 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,48 @@ +name: Tests +on: + push: + branches: + - main + pull_request: +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + include: + - directory: "package/example" + env: + WORKING_DIRECTORY: ./ + concurrency: + group: tests-${{ matrix.directory }}-${{ github.ref }} + cancel-in-progress: true + steps: + - name: checkout + uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Install clang-format + run: sudo apt-get install -y clang-format + + - name: Run clang-format-ios + run: yarn clang-format-ios --dry-run --Werror + + - name: Run clang-format-android + run: yarn clang-format-android --dry-run --Werror + + - name: Run clang-format-common + run: yarn clang-format-common --dry-run --Werror + + - uses: actions/setup-node@v3 + with: + cache: 'yarn' + + - name: Install Package + run: cd package; yarn install --frozen-lockfile + + - name: Lint Package + run: cd package; yarn lint; + + - name: TypeScript Package + run: cd package; yarn tsc; From 0281e356e122c5c5a7f1bdb51f7cd619358b2178 Mon Sep 17 00:00:00 2001 From: William Candillon Date: Mon, 17 Jun 2024 22:13:46 +0200 Subject: [PATCH 5/7] Create cpplint.yml --- .github/workflows/cpplint.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .github/workflows/cpplint.yml diff --git a/.github/workflows/cpplint.yml b/.github/workflows/cpplint.yml new file mode 100644 index 000000000..5ae7b99c4 --- /dev/null +++ b/.github/workflows/cpplint.yml @@ -0,0 +1,14 @@ +name: cpplint +on: + push: + branches: + - main + pull_request: +jobs: + cpplint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-python@v1 + - run: pip install cpplint + - run: cpplint --linelength=230 --filter=-legal/copyright,-whitespace/indent,-whitespace/comments,-whitespace/ending_newline,-build/include_order,-runtime/references,-readability/todo,-whitespace/blank_line,-whitespace/todo,-runtime/int,-build/c++11,-whitespace/parens --exclude=example --exclude=android/.cxx --exclude=cpp/webgpu --exclude=cpp/dawn --exclude=ios --exclude=android/build --exclude=node_modules --recursive package From d77674715be6f4ef2076da6dc57b3e2e070853b8 Mon Sep 17 00:00:00 2001 From: William Candillon Date: Mon, 17 Jun 2024 22:15:51 +0200 Subject: [PATCH 6/7] =?UTF-8?q?=F0=9F=92=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cpplint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cpplint.yml b/.github/workflows/cpplint.yml index 5ae7b99c4..cd8233621 100644 --- a/.github/workflows/cpplint.yml +++ b/.github/workflows/cpplint.yml @@ -11,4 +11,4 @@ jobs: - uses: actions/checkout@v1 - uses: actions/setup-python@v1 - run: pip install cpplint - - run: cpplint --linelength=230 --filter=-legal/copyright,-whitespace/indent,-whitespace/comments,-whitespace/ending_newline,-build/include_order,-runtime/references,-readability/todo,-whitespace/blank_line,-whitespace/todo,-runtime/int,-build/c++11,-whitespace/parens --exclude=example --exclude=android/.cxx --exclude=cpp/webgpu --exclude=cpp/dawn --exclude=ios --exclude=android/build --exclude=node_modules --recursive package + - run: cpplint --linelength=230 --filter=-legal/copyright,-whitespace/indent,-whitespace/comments,-whitespace/ending_newline,-build/include_order,-runtime/references,-readability/todo,-whitespace/blank_line,-whitespace/todo,-runtime/int,-build/c++11,-whitespace/parens --exclude=package/example --exclude=package/android/.cxx --exclude=package/cpp/webgpu --exclude=package/cpp/dawn --exclude=package/ios --exclude=package/android/build --exclude=package/node_modules --recursive package From 75ffcd7b76a89de022958a4f2b6390c9e2a830cd Mon Sep 17 00:00:00 2001 From: William Candillon Date: Mon, 17 Jun 2024 22:16:50 +0200 Subject: [PATCH 7/7] =?UTF-8?q?=F0=9F=92=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-ios.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-ios.yml b/.github/workflows/build-ios.yml index 9ea396c2c..7bddd3175 100644 --- a/.github/workflows/build-ios.yml +++ b/.github/workflows/build-ios.yml @@ -1,4 +1,4 @@ -name: Test iOS build +name: iOS build on: pull_request: paths: