Skip to content

Instantly share code, notes, and snippets.

@batazo
Forked from transitive-bullshit/.gitlab-ci.yml
Created January 24, 2024 00:33
Show Gist options
  • Save batazo/8377941851fd3387c41be65e5e30394f to your computer and use it in GitHub Desktop.
Save batazo/8377941851fd3387c41be65e5e30394f to your computer and use it in GitHub Desktop.
GitLab CI Detox React Native Example
stages:
- E2E
.ios_base:
tags:
- macOS
- swiftlint
cache:
paths:
- node_modules
- ios/vendor
before_script:
- npm i
- cd ios
- bundle install --without=documentation --deployment
Detox:
extends: .ios_base
stage: Detox
variables:
E2E: "true"
tags:
- macOS
- simulator
only:
- merge_requests
before_script:
- xcodebuild -version
- node --version
- brew tap wix/brew > /dev/null 2>&1
- brew install applesimutils > /dev/null 2>&1
- npm i -g npx > /dev/null 2>&1
- rm -rf $TMPDIR/metro-* && rm -rf $TMPDIR/react-* && rm -rf $TMPDIR/haste-*
- rm -rf ios/build
- killall node || echo
- xcrun simctl shutdown all
script:
- E2E=true npm start -- --port 8081 &
- npx detox build > /dev/null 2>&1
- npx detox test --cleanup --loglevel info
- kill -9 $(lsof -n -i4TCP:8081)
after_script:
- xcrun simctl shutdown all
- (if [ "$(lsof -n -i4TCP:8081)" != "" ]; then kill -9 $(lsof -n -i4TCP:8081); else echo "Cleaned"; exit 33; fi);
@batazo
Copy link
Author

batazo commented Jan 24, 2024

Some extra useful bits for anyone working on this:

  • brew install jq > /dev/null 2>&1
  • xcrun simctl boot $(applesimutils --list --byName 'iPhone X' | jq -r '.[0].udid')
  • open -a Simulator.app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment