CI: Add blank app fixture runner and appium tests #15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test Blank React Native app | |
| on: | |
| pull_request: | |
| types: [opened, synchronize] | |
| workflow_dispatch: | |
| inputs: | |
| platform: | |
| description: 'Project Type' | |
| required: true | |
| type: choice | |
| options: | |
| - 'React Native' | |
| - 'Expo' | |
| default: 'React Native' | |
| version: | |
| description: 'Version (RN e.g. 0.80.2 OR Expo SDK e.g. 52.0.0)' | |
| required: true | |
| default: '0.80.2' | |
| run_ios: | |
| description: 'Test iOS' | |
| type: boolean | |
| default: true | |
| run_android: | |
| description: 'Test Android' | |
| type: boolean | |
| default: true | |
| permissions: | |
| contents: read | |
| env: | |
| NODE_VERSION: 20 | |
| ANDROID_API_LEVEL: 35 | |
| IOS_DEVICE_NAME: "iPhone 17" | |
| IOS_VERSION: "26.1" | |
| APP_DIR: "tested_app" | |
| jobs: | |
| # ==================================================== | |
| # JOB 1: Setup Fixture | |
| # ==================================================== | |
| setup: | |
| name: Setup Fixture | |
| runs-on: ubuntu-latest | |
| outputs: | |
| platform: ${{ steps.vars.outputs.platform }} | |
| version: ${{ steps.vars.outputs.version }} | |
| run_ios: ${{ steps.vars.outputs.run_ios }} | |
| run_android: ${{ steps.vars.outputs.run_android }} | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Resolve Inputs | |
| id: vars | |
| shell: bash | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| PLATFORM="${{ github.event.inputs.platform }}" | |
| VERSION="${{ github.event.inputs.version }}" | |
| RUN_IOS="${{ github.event.inputs.run_ios }}" | |
| RUN_ANDROID="${{ github.event.inputs.run_android }}" | |
| else | |
| PLATFORM="React Native" | |
| VERSION="0.80.2" | |
| RUN_IOS="true" | |
| RUN_ANDROID="true" | |
| fi | |
| echo "platform=$PLATFORM" >> "$GITHUB_OUTPUT" | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| echo "run_ios=$RUN_IOS" >> "$GITHUB_OUTPUT" | |
| echo "run_android=$RUN_ANDROID" >> "$GITHUB_OUTPUT" | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'yarn' | |
| - name: Build Library | |
| run: | | |
| yarn | |
| yarn prepare | |
| rm -f adyen-react-native-*.tgz | |
| npm pack | |
| mv adyen-react-native-*.tgz adyen-react-native.tgz | |
| - name: Generate Fixture | |
| run: | | |
| if [ "${{ steps.vars.outputs.platform }}" == "Expo" ]; then | |
| FLAG="-e" | |
| else | |
| FLAG="-r" | |
| fi | |
| bash ./scripts/fixture_setup.sh $FLAG "${{ steps.vars.outputs.version }}" | |
| - name: Upload Fixture | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: fixture | |
| path: ${{ env.APP_DIR }} | |
| retention-days: 1 | |
| # ==================================================== | |
| # JOB 2: iOS Build & Test | |
| # ==================================================== | |
| ios-test: | |
| name: iOS Test | |
| needs: setup | |
| if: ${{ needs.setup.outputs.run_ios == 'true' }} | |
| runs-on: macos-15 | |
| timeout-minutes: 45 | |
| env: | |
| ADYEN_CLIENT_KEY: ${{ secrets.ADYEN_CLIENT_KEY }} | |
| ADYEN_PUBLIC_KEY: ${{ secrets.ADYEN_PUBLIC_KEY }} | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'yarn' | |
| - name: Setup Ruby & Cocoapods | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: '3.2' | |
| bundler-cache: true | |
| - name: Download Fixture | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: fixture | |
| path: ${{ env.APP_DIR }} | |
| - name: Install Dependencies | |
| working-directory: ${{ env.APP_DIR }} | |
| run: | | |
| yarn install | |
| - name: Setup Appium | |
| run: | | |
| npm i -g appium | |
| appium driver install xcuitest | |
| - name: Start Appium | |
| run: | | |
| appium --port 4723 --log-level error & | |
| for i in {1..30}; do | |
| nc -z 127.0.0.1 4723 && exit 0 | |
| sleep 1 | |
| done | |
| exit 1 | |
| - name: Inject Secrets | |
| if: ${{ env.ADYEN_CLIENT_KEY != '' && env.ADYEN_PUBLIC_KEY != '' }} | |
| run: | | |
| bash ./scripts/inject_secrets.sh "$APP_DIR" | |
| - name: Run iOS Test | |
| run: | | |
| bash ./scripts/fixture_ios.sh "$APP_DIR" "${{ needs.setup.outputs.platform }}" "${{ env.IOS_DEVICE_NAME }}" "${{ env.IOS_VERSION }}" | |
| # ==================================================== | |
| # JOB 3: Android Build & Test | |
| # ==================================================== | |
| android-test: | |
| name: Android Test | |
| needs: setup | |
| if: ${{ needs.setup.outputs.run_android == 'true' }} | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 45 | |
| env: | |
| ADYEN_CLIENT_KEY: ${{ secrets.ADYEN_CLIENT_KEY }} | |
| ADYEN_PUBLIC_KEY: ${{ secrets.ADYEN_PUBLIC_KEY }} | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'yarn' | |
| - name: Setup Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'zulu' | |
| java-version: '17' | |
| - name: Enable KVM (Linux Acceleration) | |
| 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: Download Fixture | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: fixture | |
| path: ${{ env.APP_DIR }} | |
| - name: Install Dependencies | |
| working-directory: ${{ env.APP_DIR }} | |
| run: | | |
| yarn install | |
| - name: Setup Appium | |
| run: | | |
| npm i -g appium | |
| appium driver install uiautomator2 | |
| - name: Start Appium | |
| run: | | |
| appium --port 4723 --log-level error & | |
| for i in {1..30}; do | |
| nc -z 127.0.0.1 4723 && exit 0 | |
| sleep 1 | |
| done | |
| exit 1 | |
| - name: Inject Secrets | |
| if: ${{ env.ADYEN_CLIENT_KEY != '' && env.ADYEN_PUBLIC_KEY != '' }} | |
| run: | | |
| bash ./scripts/inject_secrets.sh "$APP_DIR" | |
| - name: Run Android Test | |
| uses: reactivecircus/android-emulator-runner@v2 | |
| with: | |
| api-level: ${{ env.ANDROID_API_LEVEL }} | |
| target: google_apis | |
| arch: x86_64 | |
| script: | | |
| bash ./scripts/fixture_android.sh "$APP_DIR" "${{ needs.setup.outputs.platform }}" "${{ env.ANDROID_API_LEVEL }}" |