Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI configuration example for Github Actions #2617

Closed
olexandr13 opened this issue Jan 31, 2021 · 8 comments
Closed

CI configuration example for Github Actions #2617

olexandr13 opened this issue Jan 31, 2021 · 8 comments

Comments

@olexandr13
Copy link

It would be great to see the CI configuration example for Github Actions.

@yungkittty
Copy link

@olexandr13 these are my github actions for both android and ios :

e2e_android.yml

name: E2E (Android)

on:
  pull_request:
    branches: [master]

jobs:
  build:
    name: E2E (Android)
    runs-on: macOS-latest

    steps:
      - uses: actions/checkout@v1

      - name: Install Node
        uses: actions/setup-node@v1
        with:
          node-version: '12'

      - name: Install Yarn Dependencies
        run: yarn install

      - name: Install Java JDK
        uses: joschi/setup-jdk@v1
        with:
          java-version: 'openjdk8'
          architecture: 'x64'
        env:
          # https://github.com/actions/toolkit/issues/641#issuecomment-728963957
          ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'

      - name: Run Unit Test(s)
        run: yarn test

      - name: Run Detox Build
        run: yarn e2e:build android.emu.release

      - name: Run Detox Test(s)
        uses: reactivecircus/android-emulator-runner@v2
        with:
          api-level: 29
          target: default
          arch: x86_64
          profile: pixel
          avd-name: Pixel_API_29_AOSP
          script: bash ${{ github.workspace }}/scripts/run-e2e-android-release.sh

e2e_ios.yml

name: E2E (iOS)

on:
  pull_request:
    branches: [master]

jobs:
  build:
    name: E2E (iOS)
    runs-on: macOS-latest

    steps:
      - uses: actions/checkout@v1

      - name: Install Node
        uses: actions/setup-node@v1
        with:
          node-version: '12'

      - name: Install Yarn Dependencies
        run: yarn install

      - name: Install Pod Dependencies
        run: cd ./ios && pod install && cd ..

      - name: Install Detox Dependencies
        run: |
          brew tap wix/brew
          brew install applesimutils

      - name: Run Unit Test(s)
        run: yarn test

      - name: Run Detox Build
        run: yarn e2e:build ios.sim.release

      - name: Run Detox Test(s)
        run: bash ${{ github.workspace }}/scripts/run-e2e-ios-release.sh

run-e2e-android-release.sh

#!/bin/bash

yarn start &

METRO_BUNDLER_PID=$!

yarn e2e:test android.emu.release --headless

DETOX_EXIT_CODE=$?

kill $METRO_BUNDLER_PID

exit $DETOX_EXIT_CODE

run-e2e-ios-release.sh

#!/bin/bash

yarn start &

METRO_BUNDLER_PID=$!

yarn e2e:test ios.sim.release

DETOX_EXIT_CODE=$?

kill $METRO_BUNDLER_PID

exit $DETOX_EXIT_CODE

package.json

...
    "e2e:build": "detox build --configuration",
    "e2e:test": "detox test --configuration",
...

.detoxrc.json

{
  "testRunner": "jest",
  "runnerConfig": XXXX,
  "configurations": {
    "ios.sim.debug": {
      "type": "ios.simulator",
      "binaryPath": XXXX,
      "build": XXXX,
      "device": {
        "type": "iPhone 8",
        "OS": "iOS 14.4"
      }
    },
    "ios.sim.release": {
      "type": "ios.simulator",
      "binaryPath": XXXX,
      "build": XXXX,
      "device": {
        "type": "iPhone 8"
      }
    },
    "android.emu.debug": {
      "type": "android.emulator",
      "binaryPath": XXXX,
      "utilBinaryPaths": ["./cache/test-butler-app.apk"],
      "build": XXXX,
      "device": {
        "avdName": "Pixel_API_29_AOSP"
      }
    },
    "android.emu.release": {
      "type": "android.emulator",
      "binaryPath": XXXX,
      "utilBinaryPaths": ["./cache/test-butler-app.apk"],
      "build": XXXX,
      "device": {
        "avdName": "Pixel_API_29_AOSP"
      }
    }
  }
}

Also, make sure to use Test Butler (I don't know if it works without it), else remove utilBinaryPaths from .detoxrc.json.

This might help you to setup Test Butler.

@ferdicus
Copy link
Contributor

@yungkittty , should definitely open a PR with that 🙇🏿 👏🏿

@olexandr13
Copy link
Author

@yungkittty thank you a lot for your solution!

I have configured the tests similar to your code but got error
Error: ENOENT: no such file or directory, open 'undefined/licenses/android-sdk-arm-dbt-license'
Did not find solution for now... Setting android_home did not help.

@yungkittty
Copy link

@ferdicus I'll try to do that when I've some free time. @olexandr13 I don't remember having a similar error, I'd say to double check that the configuration is exactly the same, especially on the action that installs java and the android emulator. I can't help you much more, sorry 🤷‍♂️

@olexandr13
Copy link
Author

@yungkittty looks like this issue does not depend on configuration.
Your code works great! Thanks )
Will try to fix by myself, don't spend time on it. And thank you again )

@stale
Copy link

stale bot commented Apr 14, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this reporsitory, read this discussion.

@stale stale bot added the 🏚 stale label Apr 14, 2021
@stale
Copy link

stale bot commented Apr 21, 2021

The issue has been closed for inactivity.

@laisvitoria
Copy link

@yungkittty Hello! I implemented your example, but I got this error: "No instrumentation runner found on device {{emulatorName}} for package {{packageName}}". Did you have this problem too?

remarkablemark added a commit to remarkablemark/react-native-cli-quickstart that referenced this issue Feb 17, 2023
remarkablemark added a commit to remarkablemark/react-native-cli-quickstart that referenced this issue Feb 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants