-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move Detox.framework compilation to postinstall (#373)
* Move Detox.framework compilation to postinstall rather than driver prepare to attemp to fix #356 (Timeouts while running detox.init()). * fixed postinstall issues * only build iOS source package on mac
- Loading branch information
Showing
11 changed files
with
99 additions
and
65 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env node | ||
|
||
const path = require('path'); | ||
const cp = require('child_process'); | ||
|
||
cp.execSync(path.join(__dirname, '../scripts/build_framework.ios.sh'), {stdio: 'inherit'}); |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,42 @@ | ||
#!/bin/bash -e | ||
|
||
if [ $# -ne 2 ]; then | ||
echo "usage: build_framework_ios.sh detoxIosSourceTarballDirPath detoxFrameworkDirPath" | ||
exit 1 | ||
fi | ||
|
||
detoxIosSourceTarballDirPath="${1}" | ||
detoxFrameworkDirPath="${2}" | ||
detoxVersion=`node -p "require('./package.json').version"` | ||
detoxIosSourceTarballDirPath="$(dirname $(dirname ${0}))" | ||
sha1=`(echo "${detoxVersion}" && xcodebuild -version) | shasum | awk '{print $1}' #"${2}"` | ||
detoxFrameworkDirPath="$HOME/Library/Detox/ios/${sha1}" | ||
detoxFrameworkPath="${detoxFrameworkDirPath}/Detox.framework" | ||
detoxSourcePath="${detoxIosSourceTarballDirPath}"/ios_src | ||
|
||
function buildFramework { | ||
echo "Extracting Detox sources..." | ||
|
||
echo "###############################" | ||
echo "Extracting Detox sources..." | ||
mkdir -p "${detoxSourcePath}" | ||
tar -xjf "${detoxIosSourceTarballDirPath}"/Detox-ios-src.tbz -C "${detoxSourcePath}" | ||
|
||
mkdir -p "${detoxSourcePath}" | ||
tar -xjf "${detoxIosSourceTarballDirPath}"/Detox-ios-src.tbz -C "${detoxSourcePath}" | ||
echo "Building Detox.framework..." | ||
|
||
echo "###############################" | ||
mkdir -p "${detoxFrameworkDirPath}" | ||
xcodebuild build -project "${detoxSourcePath}"/Detox.xcodeproj -scheme DetoxFramework -configuration Release -derivedDataPath "${detoxFrameworkDirPath}"/DetoxBuild BUILD_DIR="${detoxFrameworkDirPath}"/DetoxBuild/Build/Products &> "${detoxFrameworkDirPath}"/detox_ios.log | ||
mv "${detoxFrameworkDirPath}"/DetoxBuild/Build/Products/Release-universal/Detox.framework "${detoxFrameworkDirPath}" | ||
rm -fr "${detoxFrameworkDirPath}"/DetoxBuild | ||
|
||
echo "Done" | ||
} | ||
|
||
echo "###############################" | ||
echo "Extracting Detox sources..." | ||
|
||
mkdir -p "${detoxFrameworkDirPath}" | ||
xcodebuild build -project "${detoxSourcePath}"/Detox.xcodeproj -scheme DetoxFramework -configuration Release -derivedDataPath "${detoxFrameworkDirPath}"/DetoxBuild BUILD_DIR="${detoxFrameworkDirPath}"/DetoxBuild/Build/Products &> "${detoxFrameworkDirPath}"/detox_ios.log | ||
mv "${detoxFrameworkDirPath}"/DetoxBuild/Build/Products/Release-universal/Detox.framework "${detoxFrameworkDirPath}" | ||
rm -fr "${detoxFrameworkDirPath}"/DetoxBuild | ||
function main { | ||
if [ -d "${detoxFrameworkDirPath}" ]; then | ||
if [ ! -d "${detoxFrameworkPath}" ]; then | ||
echo "${detoxFrameworkDirPath} was found, but could not find Detox.framework inside it. This means that the Detox framework build process was interrupted. | ||
deleting ${detoxFrameworkDirPath} and trying to rebuild." | ||
rm -rf "${detoxFrameworkDirPath}" | ||
buildFramework | ||
else | ||
echo "Detox.framework was previously compiled, skipping..." | ||
fi | ||
else | ||
buildFramework | ||
fi | ||
} | ||
|
||
echo "###############################" | ||
main |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash -e | ||
|
||
if [ "$__DETOX_DEV" = true ]; then | ||
echo "Running postinstall for detox dev mode, exiting" | ||
exit 0 | ||
fi | ||
|
||
if [ `uname` == "Darwin" ]; then | ||
source "$(dirname ${0})/build_framework.ios.sh" | ||
fi |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,6 @@ | ||
# Contributing to detox | ||
|
||
### Clone detox and submodules | ||
|
||
```sh | ||
git clone [email protected]:wix/detox.git | ||
cd detox | ||
git submodule update --init --recursive | ||
``` | ||
(this makes sure all git submodule dependencies are properly checked out) | ||
# Contributing to Detox | ||
|
||
## Prerequisites | ||
|
||
### Install `node` v7.6 or higher (to support async-await natively) | ||
|
||
|
@@ -30,10 +22,24 @@ For all the internal projects (detox, detox-server, detox-cli, demos, test) `ler | |
```sh | ||
gem install xcpretty | ||
``` | ||
### Installing | ||
|
||
Alternatively, run `scripts/install.ios.sh` / `scripts/android.sh` to install all prerequisites. | ||
|
||
## Detox | ||
|
||
### Clone Detox and submodules | ||
|
||
```sh | ||
lerna bootstrap | ||
git clone [email protected]:wix/detox.git | ||
cd detox | ||
git submodule update --init --recursive | ||
``` | ||
(this makes sure all git submodule dependencies are properly checked out) | ||
|
||
### Installing and linking internal projects | ||
|
||
```sh | ||
scripts/bootstrap.sh | ||
``` | ||
|
||
### Building | ||
|
@@ -66,8 +72,8 @@ cd detox | |
open coverage/lcov-report/index.html | ||
``` | ||
|
||
### Running detox e2e covarage tests | ||
Detox has a suite of e2e tests to test its own API while developing (and for regression). The way we do is is by maintaining a special application that is "tested" against detox's API, but essentially, it's the API that is tested, not the app. | ||
### Running Detox e2e covarage tests | ||
Detox has a suite of e2e tests to test its own API while developing (and for regression). The way we do is is by maintaining a special application that is "tested" against Detox's API, but essentially, it's the API that is tested, not the app. | ||
To run the e2e tests, go to `detox/detox/test` | ||
|
||
```sh | ||
|
@@ -83,14 +89,11 @@ npm run build | |
To run the e2e tests, after the application was built. | ||
|
||
```sh | ||
npm run e2e | ||
npm run build:ios | ||
npm run e2e:ios | ||
``` | ||
|
||
### Native Tests | ||
|
||
We got native tests for our client code, here is how you execute it | ||
|
||
#### Android | ||
### Android Native tests | ||
|
||
0. Install Java and Android SDK 25 | ||
1. In `detox/android` run `./gradlew install` | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash -e | ||
|
||
# Detox package runs a postinstall script when installed as a dependency in order to compile Detox.framework (iOS). | ||
# In order to install it, the framework sources must be already packaged in Detox-ios-src.tbz. An issue arises when developing Detox, | ||
# since postinstall runs before prepublish, causing the compilation script to start running before the sources are available, | ||
# so we had to add a hack :( to the dev process, skipping postinstall and then manually triggering it. | ||
__DETOX_DEV=true lerna bootstrap | ||
npm run postinstall --prefix detox |
This file contains 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