From c547f783c440019a4a87ba55b668b3af5ff8fc91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ramos?= Date: Thu, 21 Dec 2017 17:19:52 -0800 Subject: [PATCH 01/12] Update Docker images to latest Android SDK, Buck Summary: Test Plan Rebuilt Docker images locally, confirmed successful image build. Can later be reproed with ``` npm run test-android-setup npm run test-android-build npm run test-android-run-unit-tests ``` Note that unit tests are failing in master, but in this PR we can repro the same failure. Closes https://github.com/facebook/react-native/pull/17313 Differential Revision: D6624899 Pulled By: hramos fbshipit-source-id: 42b8cd708ec2a02399bb6ef30fd73faba2646f79 --- ContainerShip/Dockerfile.android | 7 ++-- ContainerShip/Dockerfile.android-base | 48 +++++++-------------------- ReactAndroid/DEFS | 2 +- 3 files changed, 15 insertions(+), 42 deletions(-) diff --git a/ContainerShip/Dockerfile.android b/ContainerShip/Dockerfile.android index 605bb33104d0d1..df71885cafeb3e 100644 --- a/ContainerShip/Dockerfile.android +++ b/ContainerShip/Dockerfile.android @@ -1,7 +1,7 @@ FROM containership/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 @@ -38,6 +38,7 @@ RUN ./gradlew :ReactAndroid:downloadBoost :ReactAndroid:downloadDoubleConversion RUN ./gradlew :ReactAndroid:packageReactNdkLibsForBuck -Pjobs=1 -Pcom.android.build.threadPoolSize=1 # add all react-native code +# How does this work? ADD . /app WORKDIR /app @@ -46,9 +47,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/ReactAndroid/DEFS b/ReactAndroid/DEFS index 9c268a4cda5ed9..45fb8ab9e352f7 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( From 3559e42c55366bacd9bb5178ecab64f95e9a8ea7 Mon Sep 17 00:00:00 2001 From: Logan Daniels Date: Thu, 21 Dec 2017 18:13:04 -0800 Subject: [PATCH 02/12] Make sure VirtualizedList's windowSize is greater than 0 Summary: Setting `windowSize = 0` doesn't make sense. Let's make sure we catch this problem in the constructor so that it doesn't cause inexplicable list behavior. Also fixed an invariant in `VirtualizeUtils` that is meant to prohibit non-monotonically-increasing offset arrays. As written, the invariant condition can never actually be violated. Reviewed By: sahrens Differential Revision: D6625302 fbshipit-source-id: b2a983cbe7bb5fbe0aed7c5d59e69a8a00672993 --- Libraries/Lists/VirtualizeUtils.js | 8 +++++--- Libraries/Lists/VirtualizedList.js | 5 +++++ Libraries/Lists/__tests__/VirtualizeUtils-test.js | 11 +++++++++++ .../__snapshots__/VirtualizeUtils-test.js.snap | 3 +++ 4 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 Libraries/Lists/__tests__/__snapshots__/VirtualizeUtils-test.js.snap 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]"`; From a163f70f875dff4428eebd989bfaf28dda6551bf Mon Sep 17 00:00:00 2001 From: Pritesh Nandgaonkar Date: Fri, 22 Dec 2017 06:43:32 -0800 Subject: [PATCH 03/12] Optimize the performance of Origami Reviewed By: emilsjolander Differential Revision: D6619293 fbshipit-source-id: c1632efd97f47696b7f8bb1b3e763de92c707287 --- ReactCommon/yoga/yoga/YGNode.cpp | 64 +++++++++++++++----------------- ReactCommon/yoga/yoga/YGNode.h | 7 ++-- ReactCommon/yoga/yoga/Yoga.cpp | 4 +- 3 files changed, 36 insertions(+), 39 deletions(-) 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++; From 077c3ab34952f4b442abdd7a47ab54ca4bd0ba2e Mon Sep 17 00:00:00 2001 From: Taras Tsugrii Date: Fri, 22 Dec 2017 08:41:01 -0800 Subject: [PATCH 04/12] Define internal FB macro for OSS builds. Reviewed By: hramos Differential Revision: D6626785 fbshipit-source-id: bb7c89499bc7c72e24dabd82899c3d9c49874101 --- ReactAndroid/DEFS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ReactAndroid/DEFS b/ReactAndroid/DEFS index 45fb8ab9e352f7..f55e59a8945845 100644 --- a/ReactAndroid/DEFS +++ b/ReactAndroid/DEFS @@ -111,3 +111,7 @@ def rn_robolectric_test(name, srcs, vm_args = None, *args, **kwargs): original_cxx_library = cxx_library def cxx_library(allow_jni_merging=None, **kwargs): original_cxx_library(**kwargs) + + +def fb_xplat_cxx_library(*args, **kwargs): + cxx_library(*args, **kwargs) From b750e3b21bc5c135773e8de53c5663bdf6266951 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ramos?= Date: Fri, 22 Dec 2017 09:47:06 -0800 Subject: [PATCH 05/12] Update to Danger 2.0 Summary: See #17234 for discussion. Closes https://github.com/facebook/react-native/pull/17310 Differential Revision: D6627914 Pulled By: hramos fbshipit-source-id: 3d72fc69fe03c53706d2076ecf7b5321a00d1642 --- danger/dangerfile.js | 48 +------------------------------------------- danger/package.json | 2 +- 2 files changed, 2 insertions(+), 48 deletions(-) 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" } From 4e767013ed73fb89f69f2e59626d6dcf3bb77684 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ramos?= <165856+hramos@users.noreply.github.com> Date: Fri, 22 Dec 2017 11:07:48 -0800 Subject: [PATCH 06/12] Fix buck failures on master Summary: WIP. Closes https://github.com/facebook/react-native/pull/17295 Differential Revision: D6628523 Pulled By: hramos fbshipit-source-id: ac2833e99de9e94340b8027469cc74a5b7379962 --- .circleci/config.yml | 164 ++++++++++++++-------------- local-cli/__tests__/fs-mock-test.js | 2 + 2 files changed, 83 insertions(+), 83 deletions(-) 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/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'); From 33da6047a3650e5724bb4a063ccb7ccceeaf3be9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ramos?= Date: Fri, 22 Dec 2017 14:25:21 -0800 Subject: [PATCH 07/12] Include OSS defs in Yoga BUCK Reviewed By: ttsugriy Differential Revision: D6630280 fbshipit-source-id: 6355d4b64a39feb000d5a104f39733a90fc5a31e --- ReactCommon/yoga/BUCK | 2 ++ 1 file changed, 2 insertions(+) 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"]), From 6661633390276f707faa60509b2805a83929e747 Mon Sep 17 00:00:00 2001 From: Mack Solomon Date: Fri, 22 Dec 2017 15:13:08 -0800 Subject: [PATCH 08/12] use working getting started url Summary: android-setup.html does not seem to exist. https://facebook.github.io/react-native/docs/android-setup.html (404) Closes https://github.com/facebook/react-native/pull/17324 Differential Revision: D6630732 Pulled By: hramos fbshipit-source-id: c1bd4750e3b72a0b1542a75f50d404807eabb8f1 --- local-cli/runAndroid/runAndroid.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 85ff264445aa4b9cf0b91aaca5764bb56caba997 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ramos?= <165856+hramos@users.noreply.github.com> Date: Fri, 22 Dec 2017 15:23:23 -0800 Subject: [PATCH 09/12] Update CODEOWNERS Summary: (Write your motivation here.) (Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Bonus points for screenshots and videos!) (If this PR adds or changes functionality, please take some time to update the docs at https://github.com/facebook/react-native-website, and link to your PR here.) Closes https://github.com/facebook/react-native/pull/17326 Differential Revision: D6630825 Pulled By: hramos fbshipit-source-id: f2c0369e3dc5b279aba96c8307b742693be1494c --- .github/CODEOWNERS | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 From 4fbfbe6bb0e0eaaf12ec713888bf2c6a347f0f96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ramos?= Date: Fri, 22 Dec 2017 20:18:43 -0800 Subject: [PATCH 10/12] Update image Summary: Use newer Docker image and add script that rebuilds the image locally Rebuilding should be rarely needed, but in this case we did need a newer BUCK version To run tests locally: ``` npm run test-android-setup npm run test-android-build npm run test-android-run-unit-test ``` If a newer android-base image is needed, just run `npm run test-android-build-base` to rebuild the image locally. Ping hramos if the Docker hub image is too out of date. Closes https://github.com/facebook/react-native/pull/17325 Differential Revision: D6630793 Pulled By: hramos fbshipit-source-id: ec76ec86aec0debf914649b7ec5fdafccf28fec7 --- ContainerShip/Dockerfile.android | 3 +-- package.json | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ContainerShip/Dockerfile.android b/ContainerShip/Dockerfile.android index df71885cafeb3e..adb361ab58f79c 100644 --- a/ContainerShip/Dockerfile.android +++ b/ContainerShip/Dockerfile.android @@ -1,4 +1,4 @@ -FROM containership/android-base:latest +FROM hramos/android-base:latest # set default environment variables ENV GRADLE_OPTS="-Dorg.gradle.daemon=false -Dorg.gradle.jvmargs=\"-Xmx512m -XX:+HeapDumpOnOutOfMemoryError\"" @@ -38,7 +38,6 @@ RUN ./gradlew :ReactAndroid:downloadBoost :ReactAndroid:downloadDoubleConversion RUN ./gradlew :ReactAndroid:packageReactNdkLibsForBuck -Pjobs=1 -Pcom.android.build.threadPoolSize=1 # add all react-native code -# How does this work? ADD . /app WORKDIR /app 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", From 4a1bb8fe8dfd36ea207c0683d683bb8b22a282a5 Mon Sep 17 00:00:00 2001 From: Rafael Oleza Date: Sat, 23 Dec 2017 09:07:07 -0800 Subject: [PATCH 11/12] Do not set minify=true when calculating the list of dependencies Reviewed By: davidaurelio Differential Revision: D6633160 fbshipit-source-id: ce45cae413959c232cb18b4b5ad51f04a52410a4 --- local-cli/dependencies/dependencies.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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, }; From a6a66c5b3943443e4016f32407e4a4f8d707e387 Mon Sep 17 00:00:00 2001 From: Taras Tsugrii Date: Sat, 23 Dec 2017 19:14:45 -0800 Subject: [PATCH 12/12] Remove last usages of cxx_library. Reviewed By: mzlee Differential Revision: D6632262 fbshipit-source-id: 1ec3ba232e573b9cbc892f23827f9a7c5df34106 --- ReactAndroid/DEFS | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/ReactAndroid/DEFS b/ReactAndroid/DEFS index f55e59a8945845..0b5843026b3805 100644 --- a/ReactAndroid/DEFS +++ b/ReactAndroid/DEFS @@ -108,10 +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(*args, **kwargs): +def fb_xplat_cxx_library(allow_jni_merging=None, **kwargs): cxx_library(*args, **kwargs)