diff --git a/.github/actions/expo-prebuild/action.yml b/.github/actions/expo-prebuild/action.yml index 70cf0e1..bf2388d 100644 --- a/.github/actions/expo-prebuild/action.yml +++ b/.github/actions/expo-prebuild/action.yml @@ -4,21 +4,38 @@ inputs: platform: description: Should be android or ios required: true - cache-key: - description: Cache prebuild folder if set + key: + description: Artifact key required: false +outputs: + artifact-name: + description: Artifact name + value: ${{ steps.artifact-name.outputs.name }} runs: using: 'composite' steps: - - name: Expo prebuild cache - uses: actions/cache@v4 - if: ${{ inputs.cache-key != '' }} + - name: Define artifact name + id: artifact-name + shell: bash + run: echo "name=${{ inputs.platform }}-prebuild-${{ inputs.key }}" >> $GITHUB_OUTPUT + - name: Check artifact existance + id: artifact-check + uses: LIT-Protocol/artifact-exists-action@v0 with: - path: ./example/${{ inputs.platform }} - key: ${{ inputs.cache-key }} + name: ${{ steps.artifact-name.outputs.name }} - name: Expo prebuild + if: ${{ steps.artifact-check.outputs.exists != 'true' }} env: PLATFORM: ${{ inputs.platform }} working-directory: ./example shell: bash run: npm run prebuild -- --no-install --platform $PLATFORM + - name: Create artifact + if: ${{ inputs.key != '' && steps.artifact-check.outputs.exists != 'true' }} + uses: actions/upload-artifact@v4 + with: + name: ${{ steps.artifact-name.outputs.name }} + path: ./example/${{ inputs.platform }} + if-no-files-found: error + retention-days: 90 + overwrite: true diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 3f139f4..6475d87 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,13 +1,9 @@ -name: CI +name: Continuous integration on: pull_request: branches: [main] -env: - DEVELOPER_DIR: /Applications/Xcode_15.4.app/Contents/Developer - CP_HOME_DIR: ${{ github.workspace }}/.cocoapods - concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: ${{ github.ref != 'main' }} @@ -35,105 +31,3 @@ jobs: - uses: actions/checkout@v4 - uses: ./.github/actions/npm-install - run: npm run build - expo_fingerprint: - name: Calculate fingerprint - runs-on: ubuntu-latest - needs: [npm_install] - outputs: - fingerprint: ${{ steps.expo-fingerprint.outputs.fingerprint }} - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/npm-install - - uses: ./.github/actions/expo-fingerprint - id: expo-fingerprint - prebuild_android: - name: Expo prebuild Android - runs-on: ubuntu-latest - needs: [expo_fingerprint] - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/npm-install - - uses: ./.github/actions/expo-prebuild - with: - cache-key: prebuild-android-${{ needs.expo_fingerprint.outputs.fingerprint }} - platform: android - prebuild_ios: - name: Expo prebuild iOS - runs-on: ubuntu-latest - needs: [expo_fingerprint] - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/npm-install - - uses: ./.github/actions/expo-prebuild - with: - cache-key: prebuild-ios-${{ needs.expo_fingerprint.outputs.fingerprint }} - platform: ios - test_android: - name: Test Android - # Can't run on macos-latest: https://github.com/ReactiveCircus/android-emulator-runner/issues/392 - runs-on: macos-13 - needs: [expo_fingerprint, prebuild_android] - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/npm-install - - uses: actions/cache/restore@v4 - with: - path: ./example/android - key: prebuild-android-${{ needs.expo_fingerprint.outputs.fingerprint }} - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: '17' - - name: Cache Gradle packages - uses: actions/cache@v4 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-gradle- - - name: Test Android Module - uses: reactivecircus/android-emulator-runner@v2 - with: - api-level: 34 - force-avd-creation: false - emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none - target: google_apis - arch: x86_64 - working-directory: ./example/android - script: ./gradlew expo-signature:connectedAndroidTest - disable-animations: true - test_ios: - name: Test iOS - runs-on: macos-latest - needs: [expo_fingerprint, prebuild_ios] - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/npm-install - - name: Cache CocoaPods - id: cocoapods-cache - uses: actions/cache@v4 - with: - path: ${{ env.CP_HOME_DIR }} - key: ${{ runner.os }}-pods - - uses: actions/cache/restore@v4 - with: - path: ./example/ios - key: prebuild-ios-${{ needs.expo_fingerprint.outputs.fingerprint }} - - uses: irgaly/xcode-cache@v1 - with: - key: xcode-cache-deriveddata-${{ github.workflow }}-${{ github.sha }} - restore-keys: xcode-cache-deriveddata-${{ github.workflow }}- - - uses: ./.github/actions/npm-install - - name: Pod install - working-directory: ./example/ios - run: pod install - - name: Test iOS Module - working-directory: ./example - run: | - xcodebuild test \ - -workspace ios/exposignatureexample.xcworkspace \ - -scheme SignatureModule-Unit-Tests \ - -destination 'platform=iOS Simulator,name=iPhone 15 Pro,OS=latest' diff --git a/.github/workflows/CD.yml b/.github/workflows/release.yml similarity index 96% rename from .github/workflows/CD.yml rename to .github/workflows/release.yml index 7a66b33..645f40d 100644 --- a/.github/workflows/CD.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: CD +name: Release new package version on: push: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..1a9d2b9 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,128 @@ +name: Test native + +on: + push: + pull_request: + branches: [main] + paths: + - 'android/**' + - 'ios/**' + workflow_dispatch: + +env: + DEVELOPER_DIR: /Applications/Xcode_15.4.app/Contents/Developer + CP_HOME_DIR: ${{ github.workspace }}/.cocoapods + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'main' }} + +jobs: + expo_fingerprint: + name: Calculate fingerprint + runs-on: ubuntu-latest + outputs: + fingerprint: ${{ steps.expo-fingerprint.outputs.fingerprint }} + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/npm-install + - uses: ./.github/actions/expo-fingerprint + id: expo-fingerprint + prebuild_android: + name: Expo prebuild Android + runs-on: ubuntu-latest + needs: [expo_fingerprint] + outputs: + artifact-name: ${{ steps.prebuild.outputs.artifact-name }} + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/npm-install + - uses: ./.github/actions/expo-prebuild + id: prebuild + with: + key: ${{ needs.expo_fingerprint.outputs.fingerprint }} + platform: android + prebuild_ios: + name: Expo prebuild iOS + runs-on: ubuntu-latest + needs: [expo_fingerprint] + outputs: + artifact-name: ${{ steps.prebuild.outputs.artifact-name }} + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/npm-install + - uses: ./.github/actions/expo-prebuild + id: prebuild + with: + key: ${{ needs.expo_fingerprint.outputs.fingerprint }} + platform: ios + test_android: + name: Test Android + # Can't run on macos-latest: https://github.com/ReactiveCircus/android-emulator-runner/issues/392 + runs-on: macos-13 + needs: [prebuild_android] + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/npm-install + - uses: actions/download-artifact@v4 + with: + path: ./example/android + name: ${{ needs.prebuild_android.outputs.artifact-name }} + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: '17' + - name: Cache Gradle packages + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + - name: Test Android Module + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: 34 + force-avd-creation: false + emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none + target: google_apis + arch: x86_64 + working-directory: ./example/android + script: ./gradlew expo-signature:connectedAndroidTest + disable-animations: true + test_ios: + name: Test iOS + runs-on: macos-latest + needs: [prebuild_ios] + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/npm-install + - name: Cache CocoaPods + id: cocoapods-cache + uses: actions/cache@v4 + with: + path: ${{ env.CP_HOME_DIR }} + key: ${{ runner.os }}-pods + - uses: actions/download-artifact@v4 + with: + path: ./example/ios + name: ${{ needs.prebuild_ios.outputs.artifact-name }} + - uses: irgaly/xcode-cache@v1 + with: + key: xcode-cache-deriveddata-${{ github.workflow }}-${{ github.sha }} + restore-keys: xcode-cache-deriveddata-${{ github.workflow }}- + - uses: ./.github/actions/npm-install + - name: Pod install + working-directory: ./example/ios + run: pod install + - name: Test iOS Module + working-directory: ./example + run: | + xcodebuild test \ + -workspace ios/exposignatureexample.xcworkspace \ + -scheme SignatureModule-Unit-Tests \ + -destination 'platform=iOS Simulator,name=iPhone 15 Pro,OS=latest'