From 786ef9a55b9508ec164c7ef675f9850e4dc1f5a2 Mon Sep 17 00:00:00 2001 From: codepushr <1425202+codepushr@users.noreply.github.com> Date: Thu, 26 Sep 2024 13:32:16 +0200 Subject: [PATCH] build: streamline actions into setup scripts --- .../capacitor-setup-android/action.yml | 51 +++++++++++ .../actions/capacitor-setup-ios/action.yml | 43 +++++++++ .../actions/capacitor-setup-web/action.yml | 18 ++++ .github/workflows/build.yml | 88 ++----------------- .github/workflows/test.yml | 86 +----------------- 5 files changed, 122 insertions(+), 164 deletions(-) create mode 100644 .github/actions/capacitor-setup-android/action.yml create mode 100644 .github/actions/capacitor-setup-ios/action.yml create mode 100644 .github/actions/capacitor-setup-web/action.yml diff --git a/.github/actions/capacitor-setup-android/action.yml b/.github/actions/capacitor-setup-android/action.yml new file mode 100644 index 0000000..5f6c431 --- /dev/null +++ b/.github/actions/capacitor-setup-android/action.yml @@ -0,0 +1,51 @@ +name: 'capacitor-setup-android' +description: '' +runs: + using: 'composite' + steps: + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: lts/* + - name: Install JDK + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + - name: Install Android SDK + uses: android-actions/setup-android@v3 + - name: Enable KVM + run: | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules + sudo udevadm control --reload-rules + sudo udevadm trigger --name-match=kvm + - name: Cache node_modules + id: node-modules + uses: actions/cache@v4 + with: + path: | + node_modules + key: node-modules + - name: Cache Gradle + uses: actions/cache@v4 + with: + path: | + android/.gradle + ~/.gradle/caches + key: gradle + - name: Cache Android SDK + id: aandroid-sdk + uses: actions/cache@v4 + with: + path: ~/Android/Sdk + key: android-sdk + - name: Cache AVD + uses: actions/cache@v4 + id: avd-cache + with: + path: | + ~/.android/avd/* + ~/.android/adb* + key: avd-29 + - name: Npm Install + run: npm i diff --git a/.github/actions/capacitor-setup-ios/action.yml b/.github/actions/capacitor-setup-ios/action.yml new file mode 100644 index 0000000..53e8194 --- /dev/null +++ b/.github/actions/capacitor-setup-ios/action.yml @@ -0,0 +1,43 @@ +name: 'capacitor-setup-ios' +description: '' +runs: + using: 'composite' + steps: + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: lts/* + - name: Install Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.3' + bundler-cache: true + - name: Install Swift + uses: SwiftyLab/setup-swift@latest + with: + swift-version: '5.10.0' + - name: Cache node_modules + id: node-modules + uses: actions/cache@v4 + with: + path: | + node_modules + key: node-modules + - name: Cache Pods + id: pods + uses: actions/cache@v4 + with: + path: | + ios/Pods + key: pods + - name: Cache Xcode + uses: irgaly/xcode-cache@v1.7.2 + with: + key: xcode-deriveddata + restore-keys: xcode-deriveddata + - name: Npm Install + shell: bash + run: npm i + - name: Pod Install + shell: bash + run: cd ios; pod install; cd - diff --git a/.github/actions/capacitor-setup-web/action.yml b/.github/actions/capacitor-setup-web/action.yml new file mode 100644 index 0000000..2e32fbf --- /dev/null +++ b/.github/actions/capacitor-setup-web/action.yml @@ -0,0 +1,18 @@ +name: 'capacitor-setup-web' +description: '' +runs: + using: 'composite' + steps: + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: lts/* + - name: Cache node_modules + id: node-modules + uses: actions/cache@v4 + with: + path: | + node_modules + key: node-modules + - name: Npm Install + run: npm i diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index eb13994..d7128b6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,61 +9,16 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Install Node.js - uses: actions/setup-node@v4 - with: - node-version: lts/* - - name: Cache node_modules - id: node-modules - uses: actions/cache@v4 - with: - path: | - node_modules - key: node-modules - - name: Npm Install - run: npm i + - name: Setup Capacitor iOS + uses: ./.github/actions/capacitor-setup-web - name: Run Build run: npm run verify:web build_ios: runs-on: macos-latest steps: - uses: actions/checkout@v4 - - name: Install Node.js - uses: actions/setup-node@v4 - with: - node-version: lts/* - - name: Install Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: '3.3' - bundler-cache: true - - name: Install Swift - uses: SwiftyLab/setup-swift@latest - with: - swift-version: '5.10.0' - - name: Cache node_modules - id: node-modules - uses: actions/cache@v4 - with: - path: | - node_modules - key: node-modules - - name: Cache Pods - id: pods - uses: actions/cache@v4 - with: - path: | - ios/Pods - key: pods - - name: Cache Xcode - uses: irgaly/xcode-cache@v1.7.2 - with: - key: xcode-deriveddata - restore-keys: xcode-deriveddata - - name: Npm Install - run: npm i - - name: Pod Install - run: cd ios; pod install; cd - + - name: Setup Capacitor iOS + uses: ./.github/actions/capacitor-setup-ios - name: Run Build env: DEVELOPER_DIR: /Applications/Xcode_15.4.app @@ -78,38 +33,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Install Node.js - uses: actions/setup-node@v4 - with: - node-version: lts/* - - name: Install JDK - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'temurin' - - name: Install Android SDK - uses: android-actions/setup-android@v3 - - name: Cache node_modules - id: node-modules - uses: actions/cache@v4 - with: - path: | - node_modules - key: node-modules - - name: Cache Gradle - uses: actions/cache@v4 - with: - path: | - android/.gradle - ~/.gradle/caches - key: gradle - - name: Cache Android SDK - id: aandroid-sdk - uses: actions/cache@v4 - with: - path: ~/Android/Sdk - key: android-sdk - - name: Npm Install - run: npm i + - name: Setup Capacitor Android + uses: ./.github/actions/capacitor-setup-android - name: Run Build run: npm run verify:android diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f4b4612..74796ba 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,42 +9,8 @@ jobs: runs-on: macos-latest steps: - uses: actions/checkout@v4 - - name: Install Node.js - uses: actions/setup-node@v4 - with: - node-version: lts/* - - name: Install Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: '3.3' - bundler-cache: true - - name: Install Swift - uses: SwiftyLab/setup-swift@latest - with: - swift-version: '5.10.0' - - name: Cache node_modules - id: node-modules - uses: actions/cache@v4 - with: - path: | - node_modules - key: node-modules - - name: Cache Pods - id: pods - uses: actions/cache@v4 - with: - path: | - ios/Pods - key: pods - - name: Cache Xcode - uses: irgaly/xcode-cache@v1.7.2 - with: - key: xcode-deriveddata - restore-keys: xcode-deriveddata - - name: Npm Install - run: npm i - - name: Pod Install - run: cd ios; pod install; cd - + - name: Setup Capacitor iOS + uses: ./.github/actions/capacitor-setup-ios - name: Run Tests env: DEVELOPER_DIR: /Applications/Xcode_15.4.app @@ -61,52 +27,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Install Node.js - uses: actions/setup-node@v4 - with: - node-version: lts/* - - name: Install JDK - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'temurin' - - name: Install Android SDK - uses: android-actions/setup-android@v3 - - name: Enable KVM - run: | - echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules - sudo udevadm control --reload-rules - sudo udevadm trigger --name-match=kvm - - name: Cache node_modules - id: node-modules - uses: actions/cache@v4 - with: - path: | - node_modules - key: node-modules - - name: Cache Gradle - uses: actions/cache@v4 - with: - path: | - android/.gradle - ~/.gradle/caches - key: gradle - - name: Cache Android SDK - id: aandroid-sdk - uses: actions/cache@v4 - with: - path: ~/Android/Sdk - key: android-sdk - - name: Cache AVD - uses: actions/cache@v4 - id: avd-cache - with: - path: | - ~/.android/avd/* - ~/.android/adb* - key: avd-29 - - name: Npm Install - run: npm i + - name: Setup Capacitor Android + uses: ./.github/actions/capacitor-setup-android - name: Run Tests uses: reactivecircus/android-emulator-runner@v2 with: