Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] Clear cache to resolve iOS, tvOS workflow #18304

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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