react-native-community / react-native-circleci-orb

A CircleCI Orb to Simplify Testing your React Native App
MIT License
174 stars 81 forks source link

ADB Start Stop fails /bin/bash: adb: command not found #195

Closed maaxg closed 1 month ago

maaxg commented 1 month ago

Orb version

rn: react-native-community/react-native@8.0.0

What happened

Build's working fine but when the rn/android_test job starts, it breaks in the "ADB Start Stop" step with the following error

/bin/bash: adb: command not found
Exited with code exit status 127

Here's my Config.yml file

version: 2.1
orbs:
  node: circleci/node@5.2.0
  android: circleci/android@2.5.0
  rn: react-native-community/react-native@8.0.0
  ruby: circleci/ruby@2.1.3

commands:
  detox_build_ios:
    steps:
      - restore_cache:
          keys:
            - ios-build-cache-{{ arch }}-{{ checksum "~/.tmp/checksumfiles/package.json" }}
      - run: |
          yarn add -g detox-cli react-native-cli
          detox build --configuration ios.sim.release
      - save_cache:
          key: ios-build-cache-{{ arch }}-{{ checksum "~/.tmp/checksumfiles/package.json" }}
          paths:
            - ios/build/Build

  detox_build_android:
    steps:
      - android/restore-gradle-cache
      - run: |
          yarn add -g detox-cli react-native-cli
          detox build --configuration android.emu.release
      - android/save-gradle-cache

executors:
  node:
    docker:
      - image: cimg/node:18.12
jobs:
  build:
    executor: rn/linux_js
    steps:
      - checkout
      - node/install-packages:
          pkg-manager: yarn
  test:
    executor: rn/linux_js
    steps:
      - checkout
      - node/install-packages:
          pkg-manager: yarn
      - run:
          name: Test application
          command: yarn run test:summary
      - store_artifacts:
          path: __tests__/coverage
  deploy_production:
    executor: node
    steps:
      - checkout
      - add_ssh_keys:
          fingerprints:
            - "00:00:00:00"
      - run:
          name: Create tag
          command: |
            git config --global user.email "email@email.com"
            git config --global user.name "app"
            export PACKAGE_VERSION=$(node -p -e "require('./package.json').version")
            git tag -a ${PACKAGE_VERSION} -m "release ${PACKAGE_VERSION}"
            git push origin master --tags
  analyse_js:
    executor: node
    steps:
      - attach_workspace:
          at: .
      - rn/yarn_install
  checkout_code:
      executor:
        name: rn/linux_js
        node_version: '18.12'
      steps:
        - checkout
        - persist_to_workspace:
            paths: .
            root: .

workflows:
  production_build_and_deploy:
    jobs:
      - build:
          filters:
            branches:
              only: master
      - test:
          requires:
            - build
      - deploy_production:
          context: production
          requires:
            - build
  e2e_tests:
    jobs:
      - checkout_code
      - analyse_js:
          requires:
            - checkout_code
      - rn/android_build:
          build_type: release
          name: build_android_release
          project_path: android
          checkout: true
          yarn_cache: true
          build_image_version: v13.1
          resource_class: large
          requires:
            - checkout_code
            - analyse_js
      - rn/android_test:
          node_version: '18.12'
          detox_configuration: android.emu.release
          resource_class: macos.m1.medium.gen1
          xcode_version: '15.1.0'
          homebrew_update: false
          homebrew_cache: true
          requires:
            - build_android_release

Any idea of what is wrong?

Expected behavior

Ideally, the "ADB Start Stop" should not return an error

fotos commented 1 month ago

@maaxg have you tried re-running the failed job with SSH and ssh'ing into the instance? Is adb installed? Maybe the PATH is incorrectly setup?

Unfortunately I don't have a working example with the rn/android_test job (source), as we are using an android machine executor and the commands directly in order to speed up things.

Here is how our setup looks like:

version: 2.1

aliases:
  - &android_machine_image 2023.09.1
  - &android_platform_version android-28
  - &android_device Pixel_4_API_28

orbs:
  android: circleci/android@2.0.0
  rn: react-native-community/react-native@7.4.0

jobs:
  # […]

  android_test:
    executor:
      name: android/android-machine
      tag: *android_machine_image
      resource-class: large
    parameters:
      device:
        description: The type of device you want to test on.
        type: string
        default: *android_device
      platform_version:
        description: The version of Android to run on the emulator.
        type: string
        default: *android_platform_version
      detox_configuration:
        description: The Detox configuration to test.
        type: string
        default: android.emu.release
    steps:
      - attach_workspace:
          at: .
      - run:
          name: Install Yarn
          command: npm install --global yarn
      - run:
          name: Install Detox
          command: npm install --global detox-cli
      - rn/yarn_install:
          cache_folder: ~/.cache/yarn
      - android/create-avd:
          avd-name: <<parameters.device>>
          system-image: system-images;<<parameters.platform_version>>;default;x86_64
          install: true
          additional-args: -d pixel
      - android/start-emulator:
          avd-name: <<parameters.device>>
          gpu: auto
          memory: 1024
          additional-args: -accel on -logcat *:W | grep -i 'ReactNative\|com.reactnativecommunity'
          restore-gradle-cache-post-emulator-launch: false
          post-emulator-launch-assemble-command: ''
      - rn/detox_test:
          configuration: <<parameters.detox_configuration>>

workflows:
  ci:
    jobs:
     # […]
      - android_test:
          name: android:test
          requires:
            - android:build

Hopefully that helps!

Alternatively, I suggest creating an example project on GH and I can try to take a closer look.

maaxg commented 1 month ago

@fotos Hi! Thanks for your response. I didn't try re-running with SSH, I will give it a shot with your configuration and change my executor also, maybe that will do the trick for running it in circle ci.

I've opted to run the Detox tests on GitHub Actions, but it's a temporary solution until I figure out how to run it on Circle ci.

I've opened the issue thinking that would probably be a problem with the orb but since it's not, I think we can close this issue

Thank you for your time :)

fotos commented 1 month ago

Cool – I'll close the issue with the assumption that what you experience is not a problem with the orb.

If it is, and you have a repo that replicates the problem, feel free to re-open and I'll take a closer look.