Skip to content

Commit

Permalink
Clear cache to resolve iOS, tvOS workflow
Browse files Browse the repository at this point in the history
Summary:
tvOS and iOS workflows were flaky, apparently due to a stale cache that contained a problematic version of the Metro dependency. Thanks to motiz88 for identifying the potential cause of flakiness in react-native-community/releases#2 (comment).

https://circleci.com/workflow-run/440180a2-e888-4f27-bec9-b8e5d9be6708

[GENERAL] [MINOR] [CI] - Resolve iOS, tvOS failures in Circle
Closes #18304

Differential Revision: D7220150

Pulled By: hramos

fbshipit-source-id: 0f5e68c779dfce44e6deb8b813a3ac9e25a2ab97
  • Loading branch information
hramos authored and facebook-github-bot committed Mar 9, 2018
1 parent 3e9a371 commit c9d7562
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 23 deletions.
50 changes: 27 additions & 23 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,51 @@ aliases:
# Cache Management
- &restore-yarn-cache
keys:
- v1-yarn-{{ arch }}-{{ checksum "package.json" }}
- v1-yarn-{{ arch }}-{{ .Branch }}-{{ checksum "package.json" }}
# Fallback in case checksum fails
- v1-yarn-{{ arch }}-
- v1-yarn-{{ arch }}-{{ .Branch }}-
# Fallback in case this is a first-time run on a fork
- v1-yarn-{{ arch }}-master-
- &save-yarn-cache
paths:
- node_modules
- ~/.cache/yarn
key: v1-yarn-{{ arch }}-{{ checksum "package.json" }}
key: v1-yarn-{{ arch }}-{{ .Branch }}-{{ checksum "package.json" }}

- &restore-cache-analysis
keys:
- v1-analysis-dependencies-{{ arch }}-{{ checksum "package.json" }}{{ checksum "bots/package.json" }}
- v1-analysis-dependencies-{{ arch }}-{{ .Branch }}-{{ checksum "package.json" }}{{ checksum "bots/package.json" }}
# Fallback in case checksum fails
- v1-analysis-dependencies-{{ arch }}-
- v1-analysis-dependencies-{{ arch }}-{{ .Branch }}-
# Fallback in case this is a first-time run on a fork
- v1-analysis-dependencies-{{ arch }}-master-
- &save-cache-analysis
paths:
- bots/node_modules
- node_modules
key: v1-analysis-dependencies-{{ arch }}-{{ checksum "package.json" }}{{ checksum "bots/package.json" }}
key: v1-analysis-dependencies-{{ arch }}-{{ .Branch }}-{{ checksum "package.json" }}{{ checksum "bots/package.json" }}

- &restore-cache-android-packages
keys:
- v1-android-sdkmanager-packages-{{ arch }}-api-26-alpha-{{ checksum "scripts/circle-ci-android-setup.sh" }}
- v1-android-sdkmanager-packages-{{ arch }}-{{ .Branch }}-api-26-alpha-{{ checksum "scripts/circle-ci-android-setup.sh" }}
# Fallback in case checksum fails
- v1-android-sdkmanager-packages-{{ arch }}-api-26-alpha-
- v1-android-sdkmanager-packages-{{ arch }}-{{ .Branch }}-api-26-alpha-
# Fallback in case this is a first-time run on a fork
- v1-android-sdkmanager-packages-{{ arch }}-master-api-26-alpha-
- &save-cache-android-packages
paths:
- /opt/android/sdk
key: v1-android-sdkmanager-packages-{{ arch }}-api-26-alpha-{{ checksum "scripts/circle-ci-android-setup.sh" }}
key: v1-android-sdkmanager-packages-{{ arch }}-{{ .Branch }}-api-26-alpha-{{ checksum "scripts/circle-ci-android-setup.sh" }}

- &restore-cache-ndk
keys:
- v2-android-ndk-{{ arch }}-r10e-32-64
- v2-android-ndk-{{ arch }}-r10e-32-64-{{ checksum "scripts/circle-ci-android-setup.sh" }}
# Fallback in case checksum fails
- v2-android-ndk-{{ arch }}-r10e-32-64-
- &save-cache-ndk
paths:
- /opt/ndk
key: v2-android-ndk-{{ arch }}-r10e-32-64
key: v2-android-ndk-{{ arch }}-r10e-32-64-{{ checksum "scripts/circle-ci-android-setup.sh" }}

- &restore-cache-buck
keys:
Expand Down Expand Up @@ -152,9 +160,11 @@ aliases:
command: yarn flow check
when: always

- &run-license-checks
name: Check license
command: ./scripts/circleci/check_license.sh
- &run-sanity-checks
name: Sanity checks
command: |
./scripts/circleci/check_license.sh
./scripts/circleci/check_cache.sh
when: always

- &build-android-app
Expand Down Expand Up @@ -209,19 +219,11 @@ aliases:
name: Initial Setup
command: |
mkdir -p ~/react-native/reports/junit/
- &build-objc-ios-test-app
name: Build iOS Test App
command: ./scripts/objc-test-ios.sh
- &run-objc-ios-tests
name: iOS Test Suite
command: ./scripts/objc-test-ios.sh test

- &build-objc-tvos-test-app
name: Build tvOS Test App
command: ./scripts/objc-test-tvos.sh

- &run-objc-tvos-tests
name: tvOS Test Suite
command: ./scripts/objc-test-tvos.sh test
Expand Down Expand Up @@ -274,6 +276,9 @@ jobs:
- run: *yarn
- save-cache: *save-yarn-cache

# Basic checks against the checkout, cache...
- run: *run-sanity-checks

- persist_to_workspace:
root: .
paths: .
Expand All @@ -288,7 +293,6 @@ jobs:

- run: *run-lint-checks
- run: *run-flow-checks
- run: *run-license-checks

- store_test_results:
path: ~/react-native/reports/junit
Expand Down
26 changes: 26 additions & 0 deletions scripts/circleci/check_cache.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

set -e

# Make sure we don't accidentally restore a cache that contains the Metro
# filename issue that was fixed in Metro 0.25, originally introduced in
# D6752278. Once fixed, this was causing sporadic failures in the iOS
# and tvOS workflows as the issue persisted in the cached node_modules
#
# The filename issue can be summarized as follows:
# A version of Metro was published to npm with HmrClient.js and
# HmrClient.js.flow files, while the repo contains HMRClient.js and
# HMRClient.js.flow. This was due to a case issue in the publisher's
# host machine.
# The issue this is checking for is manifested by the presence of all
# of the following files: HmrClient.js, HMRClient.js, HmrClient.js.flow,
# HMRClient.js.flow.

EXPECTED='1'
ACTUAL=$(ls node_modules/metro/src/lib/bundle-modules/*.js | xargs | awk '{print tolower($0)}' | tr ' ' '\n' | grep hmrclient.js | wc -l | tr -d '[:space:]')

if [ "$EXPECTED" != "$ACTUAL" ]; then
echo "HmrClient.js crept into the cache?"
echo $(ls node_modules/metro/src/lib/bundle-modules/H*lient.js)
exit 1
fi

0 comments on commit c9d7562

Please sign in to comment.