Skip to content

Commit

Permalink
🐙 add github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
wcandillon authored Jun 17, 2024
2 parents 3602d8f + 75ffcd7 commit 73f1785
Show file tree
Hide file tree
Showing 5 changed files with 390 additions and 0 deletions.
182 changes: 182 additions & 0 deletions .github/workflows/build-android.yml
Original file line number Diff line number Diff line change
@@ -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

45 changes: 45 additions & 0 deletions .github/workflows/build-dawn.yml
Original file line number Diff line number Diff line change
@@ -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
101 changes: 101 additions & 0 deletions .github/workflows/build-ios.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: 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
48 changes: 48 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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;
14 changes: 14 additions & 0 deletions .github/workflows/cpplint.yml
Original file line number Diff line number Diff line change
@@ -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=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

0 comments on commit 73f1785

Please sign in to comment.