How to run within Gitlab-CI?

Following https://github.com/expo/expo/issues/6639

I am not able to run expo build:ios or expo build:ios with --non-interactive successfully within Gitlab-CI.

For some reason, the metro process fail to stop the first time and all following attempt fail :

Android

[23:25:31] › Stopping Metro bundler
Error: spawn ps ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
    at onErrorNT (internal/child_process.js:469:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)

iOS

> expo build:ios --apple-id "${EXPO_APPLE_ID}" --release-channel staging -t simulator --non-interactive

- Making sure project is set up correctly...
[23:25:43] Checking if there is a build in progress...

[23:25:47] Unable to find an existing Expo CLI instance for this directory, starting a new one...
Error: spawn ps ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
    at onErrorNT (internal/child_process.js:469:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)

This is my .gitlab-ci.yml:

# Publish expo
staging-native:
  stage: publish-native
  script:
    - npm i
    - expo build:android --non-interactive --release-channel staging || echo skip
    - expo build:ios   --apple-id ${EXPO_APPLE_ID} -t simulator --non-interactive --release-channel staging  || echo skip
    - expo publish  --non-interactive --release-channel staging --max-workers 1  || echo skip
    - npx expo url:apk || echo skip
    - npx expo url:ipa || echo skip
    - curl -o app-${CI_COMMIT_TAG}.apk "$(npx expo url:apk --non-interactive)" || echo skip
    - curl -o app-${CI_COMMIT_TAG}.ipa "$(npx expo url:ipa --non-interactive)" || echo skip
    - ls -altr || echo skip
  only:
    - tags
  tags:
    - docker

expo diagnostics:

  Expo CLI 3.11.3 environment info:
    System:
      OS: Linux 5.3 Debian GNU/Linux 10 (buster) 10 (buster)
      Shell: 5.0.3 - /bin/bash
    Binaries:
      Node: 13.5.0 - ~/.nvm/versions/node/v13.5.0/bin/node
      npm: 6.13.4 - ~/.nvm/versions/node/v13.5.0/bin/npm
    npmPackages:
      expo: ~36.0.2 => 36.0.2 
      react: ~16.12.0 => 16.12.0 
      react-native: https://github.com/expo/react-native/archive/sdk-36.0.0.tar.gz => 0.61.4 
    npmGlobalPackages:
      expo-cli: 3.11.3

I am still finding a way how to use the CI for continuous delivery with expo. Any idea would be much appreciated. (perhaps starts metro in the background, how ?)

If I run the ios build before the android build, then the error swap, this make me understand that the failure of shutdown of metro was causing the second error.

I solved it by doing a background process with expo start & before running the build, my job look like this:

# Publish expo
staging-native:
  stage: publish-native
  artifacts:
    name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME-staging"
    paths:
      - icimatin-${CI_BUILD_TAG}-staging.apk
      - icimatin-${CI_BUILD_TAG}-staging.ipa
    expire_in: 1 week
  script:
    - npm i
    - npx expo start &
    - EXPO_PID=$(echo $!)
    - expo build:ios --release-channel staging --non-interactive
    - expo build:android --release-channel staging --non-interactive
    - expo publish --release-channel staging -- --max-workers 1 --non-interactive
    - curl -o myapp-${CI_BUILD_TAG}-staging.apk "$(npx expo url:apk --non-interactive)" || echo skip
    - curl -o myapp-${CI_BUILD_TAG}-staging.ipa "$(npx expo url:ipa --non-interactive)" || echo skip
    - kill -9 $EXPO_PID
  only:
    - tags
  tags:
    - docker

By the way, why do you run expo sometimes and npx expo other times?

Doing npx expo start is equivalent to npm run start in my project since npm i was called, expo-cli is set in my devDependencies and package.json is having expo start in scripts:

{
  "scripts": {
    "start": "expo start"
  },
  "devDependencies": {
    "expo-cli": "^3.11.3"
  }
}

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.