diff --git a/.circleci/config.yml b/.circleci/config.yml index a5c5f41418e29c..27e9ccbecdb154 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,41 +1,35 @@ aliases: - &restore-node-cache keys: - - v1-dependencies-{{ arch }}-{{ .Branch }}-{{ checksum "package.json" }} + - v1-dependencies-{{ arch }}-{{ checksum "package.json" }} # Fallback in case checksum fails - - v1-dependencies-{{ arch }}-{{ .Branch }}- + - v1-dependencies-{{ arch }}- - &save-node-cache paths: - node_modules - key: v1-dependencies-{{ arch }}-{{ .Branch }}-{{ checksum "package.json" }} + key: v1-dependencies-{{ arch }}-{{ checksum "package.json" }} - &restore-cache-analysis keys: - - v1-analysis-dependencies-{{ arch }}-{{ .Branch }}-{{ checksum "package.json" }}{{ checksum "danger/package.json" }} + - v1-analysis-dependencies-{{ arch }}-{{ checksum "package.json" }}{{ checksum "danger/package.json" }} # Fallback in case checksum fails - - v1-analysis-dependencies-{{ arch }}-{{ .Branch }}- + - v1-analysis-dependencies-{{ arch }}- - &save-cache-analysis paths: - danger/node_modules - node_modules - key: v1-analysis-dependencies-{{ arch }}-{{ .Branch }}-{{ checksum "package.json" }}{{ checksum "danger/package.json" }} + key: v1-analysis-dependencies-{{ arch }}-{{ checksum "package.json" }}{{ checksum "danger/package.json" }} - &restore-cache-android-packages keys: - - v1-android-sdkmanager-packages-{{ arch }}-{{ checksum "scripts/circle-ci-android-setup.sh" }} + - v2-android-sdkmanager-packages-{{ arch }}-{{ checksum "scripts/circle-ci-android-setup.sh" }} # Fallback in case checksum fails - - v1-android-sdkmanager-packages-{{ arch }}- + - v2-android-sdkmanager-packages-{{ arch }}- - &save-cache-android-packages paths: - - /opt/android/sdk/system-images/android-23 - - /opt/android/sdk/system-images/android-19 - - /opt/android/sdk/platforms/android-26 - - /opt/android/sdk/platforms/android-23 - - /opt/android/sdk/platforms/android-19 - - /opt/android/sdk/build-tools/23.0.1 - - /opt/android/sdk/add-ons/addon-google_apis-google-23 - key: v1-android-sdkmanager-packages-{{ arch }}-{{ checksum "scripts/circle-ci-android-setup.sh" }} + - /opt/android/sdk + key: v2-android-sdkmanager-packages-{{ arch }}-{{ checksum "scripts/circle-ci-android-setup.sh" }} - &restore-cache-ndk keys: @@ -50,23 +44,13 @@ aliases: - /opt/ndk key: v1-android-ndk-{{ arch }}-r10e-32-64 - - &restore-cache-buck-downloads - keys: - - v1-buck-downloads-{{ arch }}-{{ .Branch }}-{{ checksum "ReactAndroid/build.gradle" }} - # Fallback in case checksum fails - - v1-buck-downloads-{{ arch }}-{{ .Branch }}- - - &save-cache-buck-downloads - paths: - - "ReactAndroid/build/downloads" - key: v1-buck-downloads-{{ arch }}-{{ .Branch }}-{{ checksum "ReactAndroid/build.gradle" }} - - &restore-cache-buck keys: - - v1-buck-{{ arch }}-v2017.11.16.01 + - v2-buck-{{ arch }}-v2017.11.16.01 - &save-cache-buck paths: - ~/buck - key: v1-buck-{{ arch }}-v2017.11.16.01 + key: v2-buck-{{ arch }}-v2017.11.16.01 - &restore-cache-watchman keys: @@ -83,7 +67,7 @@ aliases: - &install-buck | if [[ ! -e ~/buck ]]; then - git clone https://github.com/facebook/buck.git ~/buck --branch v2017.09.04.02 --depth=1 + git clone https://github.com/facebook/buck.git ~/buck --branch v2017.11.16.01 --depth=1 fi cd ~/buck && ant buck --version @@ -151,14 +135,45 @@ aliases: sudo apt-get update -y sudo apt-get install ant autoconf automake g++ gcc libqt5widgets5 lib32z1 lib32stdc++6 make maven python-dev python3-dev qml-module-qtquick-controls qtdeclarative5-dev file -y - - &install-android-app-dependencies - | - buck fetch ReactAndroid/src/test/java/com/facebook/react/modules - buck fetch ReactAndroid/src/main/java/com/facebook/react - buck fetch ReactAndroid/src/main/java/com/facebook/react/shell - buck fetch ReactAndroid/src/test/... - buck fetch ReactAndroid/src/androidTest/... - ./gradlew :ReactAndroid:downloadBoost :ReactAndroid:downloadDoubleConversion :ReactAndroid:downloadFolly :ReactAndroid:downloadGlog :ReactAndroid:downloadJSCHeaders + - &build-android-app + name: Build Android App + command: | + buck build ReactAndroid/src/main/java/com/facebook/react + buck build ReactAndroid/src/main/java/com/facebook/react/shell + + - &wait-for-avd + name: Wait for Android Virtual Device + command: source scripts/circle-ci-android-setup.sh && waitForAVD + + - &check-js-bundle + name: Check for JavaScript Bundle + command: | + if [[ ! -e ReactAndroid/src/androidTest/assets/AndroidTestBundle.js ]]; then + echo "JavaScript bundle missing, verify build-js-bundle step"; exit 1; + else + echo "JavaScript bundle found."; + fi + + - &compile-native-libs + name: Compile Native Libs for Unit and Integration Tests + command: ./gradlew :ReactAndroid:packageReactNdkLibsForBuck -Pjobs=$BUILD_THREADS -Pcom.android.build.threadPoolSize=1 + no_output_timeout: 6m + + - &run-android-unit-tests + name: Unit Tests + command: buck test ReactAndroid/src/test/... --config build.threads=$BUILD_THREADS + + - &run-android-integration-tests + name: Build and Install Test APK + command: source scripts/circle-ci-android-setup.sh && NO_BUCKD=1 retry3 buck install ReactAndroid/src/androidTest/buck-runner:instrumentation-tests --config build.threads=$BUILD_THREADS + + - &collect-android-test-results + name: Collect Test Results + command: | + mkdir -p ~/junit/ + find . -type f -regex ".*/build/test-results/debug/.*xml" -exec cp {} ~/junit/ \; + find . -type f -regex ".*/outputs/androidTest-results/connected/.*xml" -exec cp {} ~/junit/ \; + when: always defaults: &defaults working_directory: ~/react-native @@ -295,9 +310,12 @@ jobs: - restore-cache: *restore-node-cache - run: *install-node-dependencies - save-cache: *save-node-cache - - restore-cache: *restore-cache-buck-downloads - - run: *install-android-app-dependencies - - save-cache: *save-cache-buck-downloads + - run: buck fetch ReactAndroid/src/test/java/com/facebook/react/modules + - run: buck fetch ReactAndroid/src/main/java/com/facebook/react + - run: buck fetch ReactAndroid/src/main/java/com/facebook/react/shell + - run: buck fetch ReactAndroid/src/test/... + - run: buck fetch ReactAndroid/src/androidTest/... + - run: ./gradlew :ReactAndroid:downloadBoost :ReactAndroid:downloadDoubleConversion :ReactAndroid:downloadFolly :ReactAndroid:downloadGlog :ReactAndroid:downloadJSCHeaders - run: name: Publish React Native Package @@ -359,63 +377,42 @@ jobs: - restore-cache: *restore-cache-ndk - run: *install-ndk - save-cache: *save-cache-ndk + - restore-cache: *restore-cache-buck - run: *install-buck - save-cache: *save-cache-buck + - run: *install-node + - restore-cache: *restore-node-cache - run: *install-node-dependencies - save-cache: *save-node-cache - - restore-cache: *restore-cache-buck-downloads - - run: *install-android-app-dependencies - - save-cache: *save-cache-buck-downloads - - run: - name: Build Android App - command: | - buck build ReactAndroid/src/main/java/com/facebook/react - buck build ReactAndroid/src/main/java/com/facebook/react/shell - - # Wait for AVD to finish booting before running tests - - run: - name: Wait for Android Virtual Device - command: source scripts/circle-ci-android-setup.sh && waitForAVD - + - run: buck fetch ReactAndroid/src/test/java/com/facebook/react/modules + - run: buck fetch ReactAndroid/src/main/java/com/facebook/react + - run: buck fetch ReactAndroid/src/main/java/com/facebook/react/shell + - run: buck fetch ReactAndroid/src/test/... + - run: buck fetch ReactAndroid/src/androidTest/... + - run: ./gradlew :ReactAndroid:downloadBoost :ReactAndroid:downloadDoubleConversion :ReactAndroid:downloadFolly :ReactAndroid:downloadGlog :ReactAndroid:downloadJSCHeaders + + - run: *build-android-app + - run: *compile-native-libs + # The JavaScript Bundle is built as part of the build-js-bundle workflow, # and is required for instrumentation tests. - attach_workspace: at: ReactAndroid/src/androidTest/assets/ - - run: - name: Check for JavaScript Bundle - command: | - if [[ ! -e ReactAndroid/src/androidTest/assets/AndroidTestBundle.js ]]; then - echo "JavaScript bundle missing, verify build-js-bundle step"; exit 1; - else - echo "JavaScript bundle found."; - fi - + - run: *check-js-bundle + + # Wait for AVD to finish booting before running tests + - run: *wait-for-avd + # Tests - - run: - name: Compile Native Libs for Unit and Integration Tests - command: ./gradlew :ReactAndroid:packageReactNdkLibsForBuck -Pjobs=$BUILD_THREADS -Pcom.android.build.threadPoolSize=1 - no_output_timeout: 6m - - run: - name: Unit Tests - command: buck test ReactAndroid/src/test/... --config build.threads=$BUILD_THREADS - - # Integration Tests - - run: - name: Build and Install Test APK - command: source scripts/circle-ci-android-setup.sh && NO_BUCKD=1 retry3 buck install ReactAndroid/src/androidTest/buck-runner:instrumentation-tests --config build.threads=$BUILD_THREADS + - run: *run-android-unit-tests + - run: *run-android-integration-tests # post (always runs) - - run: - name: Collect Test Results - command: | - mkdir -p ~/junit/ - find . -type f -regex ".*/build/test-results/debug/.*xml" -exec cp {} ~/junit/ \; - find . -type f -regex ".*/outputs/androidTest-results/connected/.*xml" -exec cp {} ~/junit/ \; - when: always + - run: *collect-android-test-results - store_test_results: path: ~/junit - store_artifacts: @@ -457,7 +454,8 @@ jobs: else echo "Skipping code analysis." fi - + when: always + # Workflows enables us to run multiple jobs in parallel workflows: version: 2 diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 45740eb85de6bd..b9d084bf849cf8 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,5 +1,3 @@ -docs/* @hramos -blog/* @hramos Libraries/Animated/* @janicduplessis Libraries/NativeAnimation/* @janicduplessis Libraries/Image/* @shergin @@ -9,6 +7,7 @@ React/Views/* @shergin React/Modules/* @shergin React/CxxBridge/* @mhorowitz ReactAndroid/src/main/java/com/facebook/react/animated/* @janicduplessis +**/*.md @hramos package.json @hramos local-cli/core/* @grabbou @kureev local-cli/link/* @grabbou @kureev diff --git a/ContainerShip/Dockerfile.android b/ContainerShip/Dockerfile.android index 605bb33104d0d1..adb361ab58f79c 100644 --- a/ContainerShip/Dockerfile.android +++ b/ContainerShip/Dockerfile.android @@ -1,7 +1,7 @@ -FROM containership/android-base:latest +FROM hramos/android-base:latest # set default environment variables -ENV GRADLE_OPTS="-Dorg.gradle.jvmargs=\"-Xmx512m -XX:+HeapDumpOnOutOfMemoryError\"" +ENV GRADLE_OPTS="-Dorg.gradle.daemon=false -Dorg.gradle.jvmargs=\"-Xmx512m -XX:+HeapDumpOnOutOfMemoryError\"" ENV JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF8" # add ReactAndroid directory @@ -46,9 +46,5 @@ RUN cd $(npm root -g)/npm && npm install fs-extra && sed -i -e s/graceful-fs/fs- # build node dependencies RUN npm install -RUN npm install github@0.2.4 - -WORKDIR /app/website -RUN npm install WORKDIR /app diff --git a/ContainerShip/Dockerfile.android-base b/ContainerShip/Dockerfile.android-base index d83bddf5606263..05caa480f3c827 100644 --- a/ContainerShip/Dockerfile.android-base +++ b/ContainerShip/Dockerfile.android-base @@ -1,8 +1,8 @@ FROM library/ubuntu:16.04 # set default build arguments -ARG ANDROID_VERSION=25.2.3 -ARG BUCK_VERSION=f3452a6a7ab15a60e94c962e686293acbe677473 +ARG ANDROID_TOOLS_VERSION=25.2.5 +ARG BUCK_VERSION=v2017.11.16.01 ARG NDK_VERSION=10e ARG NODE_VERSION=6.2.0 ARG WATCHMAN_VERSION=4.7.0 @@ -12,7 +12,7 @@ ENV ADB_INSTALL_TIMEOUT=10 ENV PATH=${PATH}:/opt/buck/bin/ ENV ANDROID_HOME=/opt/android ENV ANDROID_SDK_HOME=${ANDROID_HOME} -ENV PATH=${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools +ENV PATH=${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/platform-tools ENV ANDROID_NDK=/opt/ndk/android-ndk-r$NDK_VERSION ENV PATH=${PATH}:${ANDROID_NDK} @@ -28,9 +28,8 @@ RUN npm install n -g RUN n $NODE_VERSION # download buck -RUN git clone https://github.com/facebook/buck.git /opt/buck +RUN git clone https://github.com/facebook/buck.git /opt/buck --branch $BUCK_VERSION --depth=1 WORKDIR /opt/buck -RUN git checkout $BUCK_VERSION # build buck RUN ant @@ -46,10 +45,11 @@ RUN ./configure RUN make RUN make install +# Full reference at https://dl.google.com/android/repository/repository2-1.xml # download and unpack android RUN mkdir /opt/android WORKDIR /opt/android -RUN curl --silent https://dl.google.com/android/repository/tools_r$ANDROID_VERSION-linux.zip > android.zip +RUN curl --silent https://dl.google.com/android/repository/tools_r$ANDROID_TOOLS_VERSION-linux.zip > android.zip RUN unzip android.zip RUN rm android.zip @@ -63,39 +63,15 @@ RUN unzip ndk.zip RUN rm ndk.zip # Add android SDK tools - -# Android SDK Platform-tools, revision 25.0.4 -RUN echo "y" | android update sdk -u -a -t $(android list sdk -a | grep "Android SDK Platform-tools, revision 25.0.4" | awk '{ print $1 }' | sed 's/.$//') - -# Android SDK Build-tools, revision 23.0.1 -RUN echo "y" | android update sdk -u -a -t $(android list sdk -a | grep "Android SDK Build-tools, revision 23.0.1" | awk '{ print $1 }' | sed 's/.$//') - -# SDK Platform Android 6.0, API 23, revision 3 -RUN echo "y" | android update sdk -u -a -t $(android list sdk -a | grep "SDK Platform Android 6.0, API 23" | awk '{ print $1 }' | sed 's/.$//') - -# SDK Platform Android 4.4.2, API 19, revision 4 -RUN echo "y" | android update sdk -u -a -t $(android list sdk -a | grep "SDK Platform Android 4.4.2, API 19, revision 4" | awk '{ print $1 }' | sed 's/.$//') - -# ARM EABI v7a System Image, Android API 19, revision 5 -RUN echo "y" | android update sdk -u -a -t $(android list sdk -a | grep "ARM EABI v7a System Image, Android API 19, revision 5" | awk '{ print $1 }' | sed 's/.$//') - -# Intel x86 Atom System Image, Android API 19, revision 5 -RUN echo "y" | android update sdk -u -a -t $(android list sdk -a | grep "Intel x86 Atom System Image, Android API 19, revision 5" | awk '{ print $1 }' | sed 's/.$//') - -# Google APIs, Android API 23, revision 1 -RUN echo "y" | android update sdk -u -a -t $(android list sdk -a | grep "Google APIs, Android API 23, revision 1" | awk '{ print $1 }' | sed 's/.$//') - -# Android Support Repository, revision 45 -RUN echo "y" | android update sdk -u -a -t $(android list sdk -a | grep "Android Support Repository" | awk '{ print $1 }' | sed 's/.$//') +RUN echo "y" | sdkmanager "system-images;android-19;google_apis;armeabi-v7a" +RUN echo "y" | sdkmanager "platforms;android-23" +RUN echo "y" | sdkmanager "platforms;android-19" +RUN echo "y" | sdkmanager "build-tools;23.0.1" +RUN echo "y" | sdkmanager "add-ons;addon-google_apis-google-23" +RUN echo "y" | sdkmanager "extras;android;m2repository" # Link adb executable RUN ln -s /opt/android/platform-tools/adb /usr/bin/adb -# Install google-chrome -RUN curl -fsSL https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \ - && echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list \ - && apt-get update \ - && apt-get install -y google-chrome-stable - # clean up unnecessary directories RUN rm -rf /opt/android/system-images/android-19/default/x86 diff --git a/Libraries/Lists/VirtualizeUtils.js b/Libraries/Lists/VirtualizeUtils.js index b665bd2d28ad8d..c43b13251eb3c3 100644 --- a/Libraries/Lists/VirtualizeUtils.js +++ b/Libraries/Lists/VirtualizeUtils.js @@ -25,17 +25,19 @@ function elementsThatOverlapOffsets( getFrameMetrics: (index: number) => {length: number, offset: number}, ): Array { const out = []; + let outLength = 0; for (let ii = 0; ii < itemCount; ii++) { const frame = getFrameMetrics(ii); const trailingOffset = frame.offset + frame.length; for (let kk = 0; kk < offsets.length; kk++) { if (out[kk] == null && trailingOffset >= offsets[kk]) { out[kk] = ii; + outLength++; if (kk === offsets.length - 1) { invariant( - out.length === offsets.length, - 'bad offsets input, should be in increasing order ' + - JSON.stringify(offsets), + outLength === offsets.length, + 'bad offsets input, should be in increasing order: %s', + JSON.stringify(offsets), ); return out; } diff --git a/Libraries/Lists/VirtualizedList.js b/Libraries/Lists/VirtualizedList.js index 77c01bd6c1747f..83b31ee7a56a47 100644 --- a/Libraries/Lists/VirtualizedList.js +++ b/Libraries/Lists/VirtualizedList.js @@ -535,6 +535,11 @@ class VirtualizedList extends React.PureComponent { 'to support native onScroll events with useNativeDriver', ); + invariant( + props.windowSize > 0, + 'VirtualizedList: The windowSize prop must be present and set to a value greater than 0.', + ); + this._fillRateHelper = new FillRateHelper(this._getFrameMetrics); this._updateCellsToRenderBatcher = new Batchinator( this._updateCellsToRender, diff --git a/Libraries/Lists/__tests__/VirtualizeUtils-test.js b/Libraries/Lists/__tests__/VirtualizeUtils-test.js index 482574c12a4c2f..3e8b2c9433f592 100644 --- a/Libraries/Lists/__tests__/VirtualizeUtils-test.js +++ b/Libraries/Lists/__tests__/VirtualizeUtils-test.js @@ -81,4 +81,15 @@ describe('elementsThatOverlapOffsets', function() { elementsThatOverlapOffsets(offsets, frames.length, ii => frames[ii]), ).toEqual([1]); }); + it('errors on non-increasing offsets', function() { + const offsets = [150, 50]; + const frames = [ + {offset: 0, length: 50}, + {offset: 50, length: 150}, + {offset: 250, length: 100}, + ]; + expect(() => { + elementsThatOverlapOffsets(offsets, frames.length, ii => frames[ii]); + }).toThrowErrorMatchingSnapshot(); + }); }); diff --git a/Libraries/Lists/__tests__/__snapshots__/VirtualizeUtils-test.js.snap b/Libraries/Lists/__tests__/__snapshots__/VirtualizeUtils-test.js.snap new file mode 100644 index 00000000000000..6daafe6961fd72 --- /dev/null +++ b/Libraries/Lists/__tests__/__snapshots__/VirtualizeUtils-test.js.snap @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`elementsThatOverlapOffsets errors on non-increasing offsets 1`] = `"bad offsets input, should be in increasing order: [150,50]"`; diff --git a/ReactAndroid/DEFS b/ReactAndroid/DEFS index 9c268a4cda5ed9..0b5843026b3805 100644 --- a/ReactAndroid/DEFS +++ b/ReactAndroid/DEFS @@ -86,7 +86,7 @@ def rn_robolectric_test(name, srcs, vm_args = None, *args, **kwargs): '-XX:MaxPermSize=620m', '-Drobolectric.offline=true', ] - if os.path.isdir("/dev/shm") and not os.environ['CIRCLECI']: + if os.path.isdir("/dev/shm") and 'CIRCLECI' not in os.environ: extra_vm_args.append('-Djava.io.tmpdir=/dev/shm') else: extra_vm_args.append( @@ -108,6 +108,6 @@ def rn_robolectric_test(name, srcs, vm_args = None, *args, **kwargs): vm_args = vm_args + extra_vm_args, *args, **kwargs) -original_cxx_library = cxx_library -def cxx_library(allow_jni_merging=None, **kwargs): - original_cxx_library(**kwargs) + +def fb_xplat_cxx_library(allow_jni_merging=None, **kwargs): + cxx_library(*args, **kwargs) diff --git a/ReactCommon/yoga/BUCK b/ReactCommon/yoga/BUCK index 65bfdf418530a4..bd4dddd12aa543 100644 --- a/ReactCommon/yoga/BUCK +++ b/ReactCommon/yoga/BUCK @@ -1,3 +1,5 @@ +include_defs("//ReactAndroid/DEFS") + fb_xplat_cxx_library( name = "yoga", srcs = glob(["yoga/*.cpp"]), diff --git a/ReactCommon/yoga/yoga/YGNode.cpp b/ReactCommon/yoga/yoga/YGNode.cpp index 70f0f46ab6106a..14c072fb1a120e 100644 --- a/ReactCommon/yoga/yoga/YGNode.cpp +++ b/ReactCommon/yoga/yoga/YGNode.cpp @@ -34,15 +34,11 @@ YGBaselineFunc YGNode::getBaseline() const { return baseline_; } -YGStyle YGNode::getStyle() const { +YGStyle& YGNode::getStyle() { return style_; } -YGLayout YGNode::getLayout() const { - return layout_; -} - -YGLayout& YGNode::getLayoutRef() { +YGLayout& YGNode::getLayout() { return layout_; } @@ -248,21 +244,21 @@ YGNode::YGNode() resolvedDimensions_({{YGValueUndefined, YGValueUndefined}}) {} YGNode::YGNode(const YGNode& node) - : context_(node.getContext()), - print_(node.getPrintFunc()), - hasNewLayout_(node.getHasNewLayout()), - nodeType_(node.getNodeType()), - measure_(node.getMeasure()), - baseline_(node.getBaseline()), - style_(node.getStyle()), - layout_(node.getLayout()), - lineIndex_(node.getLineIndex()), - parent_(node.getParent()), - children_(node.getChildren()), - nextChild_(node.getNextChild()), - config_(node.getConfig()), - isDirty_(node.isDirty()), - resolvedDimensions_(node.getResolvedDimensions()) {} + : context_(node.context_), + print_(node.print_), + hasNewLayout_(node.hasNewLayout_), + nodeType_(node.nodeType_), + measure_(node.measure_), + baseline_(node.baseline_), + style_(node.style_), + layout_(node.layout_), + lineIndex_(node.lineIndex_), + parent_(node.parent_), + children_(node.children_), + nextChild_(node.nextChild_), + config_(node.config_), + isDirty_(node.isDirty_), + resolvedDimensions_(node.resolvedDimensions_) {} YGNode::YGNode(const YGConfigRef newConfig) : YGNode() { config_ = newConfig; @@ -315,8 +311,8 @@ YGNode& YGNode::operator=(const YGNode& node) { nodeType_ = node.getNodeType(); measure_ = node.getMeasure(); baseline_ = node.getBaseline(); - style_ = node.getStyle(); - layout_ = node.getLayout(); + style_ = node.style_; + layout_ = node.layout_; lineIndex_ = node.getLineIndex(); parent_ = node.getParent(); children_ = node.getChildren(); @@ -330,28 +326,28 @@ YGNode& YGNode::operator=(const YGNode& node) { YGValue YGNode::marginLeadingValue(const YGFlexDirection axis) const { if (YGFlexDirectionIsRow(axis) && - getStyle().margin[YGEdgeStart].unit != YGUnitUndefined) { - return getStyle().margin[YGEdgeStart]; + style_.margin[YGEdgeStart].unit != YGUnitUndefined) { + return style_.margin[YGEdgeStart]; } else { - return getStyle().margin[leading[axis]]; + return style_.margin[leading[axis]]; } } YGValue YGNode::marginTrailingValue(const YGFlexDirection axis) const { if (YGFlexDirectionIsRow(axis) && - getStyle().margin[YGEdgeEnd].unit != YGUnitUndefined) { - return getStyle().margin[YGEdgeEnd]; + style_.margin[YGEdgeEnd].unit != YGUnitUndefined) { + return style_.margin[YGEdgeEnd]; } else { - return getStyle().margin[trailing[axis]]; + return style_.margin[trailing[axis]]; } } YGValue YGNode::resolveFlexBasisPtr() const { - YGValue flexBasis = getStyle().flexBasis; + YGValue flexBasis = style_.flexBasis; if (flexBasis.unit != YGUnitAuto && flexBasis.unit != YGUnitUndefined) { return flexBasis; } - if (!YGFloatIsUndefined(getStyle().flex) && getStyle().flex > 0.0f) { + if (!YGFloatIsUndefined(style_.flex) && style_.flex > 0.0f) { return config_->useWebDefaults ? YGValueAuto : YGValueZero; } return YGValueAuto; @@ -361,10 +357,10 @@ void YGNode::resolveDimension() { for (uint32_t dim = YGDimensionWidth; dim < YGDimensionCount; dim++) { if (getStyle().maxDimensions[dim].unit != YGUnitUndefined && YGValueEqual( - getStyle().maxDimensions[dim], getStyle().minDimensions[dim])) { - resolvedDimensions_[dim] = getStyle().maxDimensions[dim]; + getStyle().maxDimensions[dim], style_.minDimensions[dim])) { + resolvedDimensions_[dim] = style_.maxDimensions[dim]; } else { - resolvedDimensions_[dim] = getStyle().dimensions[dim]; + resolvedDimensions_[dim] = style_.dimensions[dim]; } } } diff --git a/ReactCommon/yoga/yoga/YGNode.h b/ReactCommon/yoga/yoga/YGNode.h index a5062bdb850211..4e76b35b2924ac 100644 --- a/ReactCommon/yoga/yoga/YGNode.h +++ b/ReactCommon/yoga/yoga/YGNode.h @@ -60,9 +60,10 @@ struct YGNode { YGNodeType getNodeType() const; YGMeasureFunc getMeasure() const; YGBaselineFunc getBaseline() const; - YGStyle getStyle() const; - YGLayout getLayout() const; - YGLayout& getLayoutRef(); // TODO remove its use + // For Perfomance reasons passing as reference. + YGStyle& getStyle(); + // For Perfomance reasons passing as reference. + YGLayout& getLayout(); uint32_t getLineIndex() const; YGNodeRef getParent() const; YGVector getChildren() const; diff --git a/ReactCommon/yoga/yoga/Yoga.cpp b/ReactCommon/yoga/yoga/Yoga.cpp index 188354db85a988..6f6b2f6f0d7a2d 100644 --- a/ReactCommon/yoga/yoga/Yoga.cpp +++ b/ReactCommon/yoga/yoga/Yoga.cpp @@ -1803,7 +1803,7 @@ static bool YGNodeFixedSizeSetMeasuredDimensions(const YGNodeRef node, } static void YGZeroOutLayoutRecursivly(const YGNodeRef node) { - memset(&(node->getLayoutRef()), 0, sizeof(YGLayout)); + memset(&(node->getLayout()), 0, sizeof(YGLayout)); node->setHasNewLayout(true); YGCloneChildrenIfNeeded(node); const uint32_t childCount = YGNodeGetChildCount(node); @@ -3341,7 +3341,7 @@ bool YGLayoutNodeInternal(const YGNodeRef node, const bool performLayout, const char *reason, const YGConfigRef config) { - YGLayout* layout = &node->getLayoutRef(); + YGLayout* layout = &node->getLayout(); gDepth++; diff --git a/danger/dangerfile.js b/danger/dangerfile.js index d38ccdd6b4db74..034798bfafdaeb 100644 --- a/danger/dangerfile.js +++ b/danger/dangerfile.js @@ -15,41 +15,6 @@ const minimatch = require('minimatch'); import { danger, fail, markdown, message, warn } from 'danger'; -const isDocsFile = path => includes(path, 'docs/'); -const editsDocs = danger.git.modified_files.filter(isDocsFile).length > 0; -const addsDocs = danger.git.created_files.filter(isDocsFile).length > 0; -if (addsDocs || editsDocs) { - // Note, this does not yet cover edits to the autogenerated docs - // (e.g. comments within JS source files) - const title = ':page_facing_up: Docs'; - const idea = 'Thanks for your contribution to the docs!'; - message(`${title} - ${idea}`); - - // Add the Documentation label via bot, as @facebook-open-source-bot does not have write privileges on the repo. - markdown('@facebook-github-bot label Documentation'); -} - -const isBlogFile = path => includes(path, 'blog/'); - -// Flags new blog posts. Note that mentions will not be parsed as the access token we're using does -// not belong to the Facebook org (on purpose) -const addsBlogPost = danger.git.created_files.filter(isBlogFile).length > 0; -if (addsBlogPost) { - const title = ':memo: Blog post'; - const idea = 'This PR appears to add a new blog post, ' + - 'and may require further review from the React Native team.'; - warn(`${title} - ${idea}`); -} - -// Flags edits to blog posts -const editsBlogPost = danger.git.modified_files.filter(isBlogFile).length > 0; -if (editsBlogPost) { - const title = ':memo: Blog post'; - const idea = 'This PR appears to edit an existing blog post, ' + - 'and may require further review from the React Native team.'; - warn(`${title} - ${idea}`); -} - // Fails if the description is too short. if (!danger.github.pr.body || danger.github.pr.body.length < 10) { fail(':grey_question: This pull request needs a description.'); @@ -74,19 +39,8 @@ if (packageChanged) { } // Warns if a test plan is missing. -const gettingStartedChanged = includes(danger.git.modified_files, 'docs/GettingStarted.md'); const includesTestPlan = danger.github.pr.body && danger.github.pr.body.toLowerCase().includes('test plan'); - -// Warns if a test plan is missing, when editing the Getting Started guide. This page needs to be -// tested in all its permutations. -if (!includesTestPlan && gettingStartedChanged) { - const title = ':clipboard: Test Plan'; - const idea = 'This PR appears to be missing a Test Plan.'; - warn(`${title} - ${idea}`); - markdown('@facebook-github-bot label Needs more information'); -} -// Doc edits rarely require a test plan. We'll trust the reviewer to push back if one is needed. -if (!includesTestPlan && !editsDocs) { +if (!includesTestPlan) { const title = ':clipboard: Test Plan'; const idea = 'This PR appears to be missing a Test Plan.'; warn(`${title} - ${idea}`); diff --git a/danger/package.json b/danger/package.json index 2b9ec69565dac7..6646a6c7fbb7c1 100644 --- a/danger/package.json +++ b/danger/package.json @@ -4,7 +4,7 @@ "danger": "node ./node_modules/.bin/danger" }, "devDependencies": { - "danger": "^1.2.0", + "danger": "^2.1.6", "lodash.includes": "^4.3.0", "minimatch": "^3.0.4" } diff --git a/local-cli/__tests__/fs-mock-test.js b/local-cli/__tests__/fs-mock-test.js index 4852106c61b7ed..175ebcaccc9ae8 100644 --- a/local-cli/__tests__/fs-mock-test.js +++ b/local-cli/__tests__/fs-mock-test.js @@ -17,6 +17,8 @@ declare var jest: any; declare var describe: any; +declare var beforeEach: any; +declare var expect: any; declare var it: any; jest.mock('fs'); diff --git a/local-cli/dependencies/dependencies.js b/local-cli/dependencies/dependencies.js index b6f4166d170661..31a127a53b4a24 100644 --- a/local-cli/dependencies/dependencies.js +++ b/local-cli/dependencies/dependencies.js @@ -52,7 +52,7 @@ function dependencies(argv, config, args, packagerInstance) { platform: args.platform, entryFile: relativePath, dev: args.dev, - minify: !args.dev, + minify: false, generateSourceMaps: !args.dev, }; diff --git a/local-cli/runAndroid/runAndroid.js b/local-cli/runAndroid/runAndroid.js index 0b27f58b0e4857..22f0a627ae9ac4 100644 --- a/local-cli/runAndroid/runAndroid.js +++ b/local-cli/runAndroid/runAndroid.js @@ -226,7 +226,7 @@ function runOnAllDevices(args, cmd, packageNameWithSuffix, packageName, adbPath) 'Could not install the app on the device, read the error above for details.\n' + 'Make sure you have an Android emulator running or a device connected and have\n' + 'set up your Android development environment:\n' + - 'https://facebook.github.io/react-native/docs/android-setup.html' + 'https://facebook.github.io/react-native/docs/getting-started.html' )); // stderr is automatically piped from the gradle process, so the user // should see the error already, there is no need to do diff --git a/package.json b/package.json index 66e2b2d66902c9..0415ee1395b895 100644 --- a/package.json +++ b/package.json @@ -126,7 +126,8 @@ "lint": "eslint .", "prettier": "find . -name node_modules -prune -or -name '*.js' -print | xargs prettier --write", "start": "/usr/bin/env bash -c './scripts/packager.sh \"$@\" || true' --", - "test-android-setup": "docker pull containership/android-base:latest", + "test-android-setup": "docker pull hramos/android-base:latest", + "test-android-build-base": "docker build -t hramos/android-base -f ContainerShip/Dockerfile.android-base .", "test-android-build": "docker build -t react/android -f ContainerShip/Dockerfile.android .", "test-android-run-instrumentation": "docker run --cap-add=SYS_ADMIN -it react/android bash ContainerShip/scripts/run-android-docker-instrumentation-tests.sh", "test-android-run-unit": "docker run --cap-add=SYS_ADMIN -it react/android bash ContainerShip/scripts/run-android-docker-unit-tests.sh",