2019-05-30 22:07:45 +00:00
version : 2.1
2019-02-24 01:01:34 +00:00
2020-03-30 14:19:23 +00:00
# -------------------------
# ORBS
# -------------------------
orbs :
win : circleci/windows@2.4.0
2023-07-26 14:23:31 +00:00
android : circleci/android@2.3.0
2020-03-30 14:19:23 +00:00
2019-02-24 01:01:34 +00:00
# -------------------------
2022-03-08 01:02:08 +00:00
# REFERENCES
2019-02-24 01:01:34 +00:00
# -------------------------
2022-03-08 01:02:08 +00:00
references :
defaults : &defaults
working_directory : ~/react-native
environment :
- GIT_COMMIT_DESC : git log --format=oneline -n 1 $CIRCLE_SHA1
# The public github tokens are publicly visible by design
- PUBLIC_PULLBOT_GITHUB_TOKEN_A : &github_pullbot_token_a "a6edf8e8d40ce4e8b11a"
- PUBLIC_PULLBOT_GITHUB_TOKEN_B : &github_pullbot_token_b "150e1341f4dd9c944d2a"
- PUBLIC_ANALYSISBOT_GITHUB_TOKEN_A : &github_analysisbot_token_a "312d354b5c36f082cfe9"
- PUBLIC_ANALYSISBOT_GITHUB_TOKEN_B : &github_analysisbot_token_b "07973d757026bdd9f196"
# Homebrew currently breaks while updating:
# https://discuss.circleci.com/t/brew-install-fails-while-updating/32992
- HOMEBREW_NO_AUTO_UPDATE : 1
hermes_workspace_root : &hermes_workspace_root
/tmp/hermes
2022-10-07 17:21:25 +00:00
hermes_tarball_artifacts_dir : &hermes_tarball_artifacts_dir
/tmp/hermes/hermes-runtime-darwin
Circle CI: Reduce build_hermes_macos Hermes SDK cache size by 75% (#34886)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34886
## Reduced cache size
The `build_hermes_macos` job can spend over 20 minutes restoring cached build artifacts (over 5 GB), when only `build_macosx` and `destroot` are required to be cached: `build_macosx` as it may contain a pre-built `hermesc` from previous builds, and `destroot` which contains the artifacts for previous iOS/macOS builds.
This is the `build_hermes_macos` Restore Cache step, before the changes in this diff:
```
Found a cache from build 308044 at v1-hermes-build_hermes_macos-debug-PEiMHp9XQ13KtYFQMKoT27DmHkkoxOi_PJUyW7PacZE=
Size: 5.2 GiB
Cached paths:
* /Users/distiller/react-native/sdks/hermes/build_host_hermesc
* /Users/distiller/react-native/sdks/hermes/build_iphoneos
* /Users/distiller/react-native/sdks/hermes/build_catalyst
* /Users/distiller/react-native/sdks/hermes/build_iphonesimulator
* /Users/distiller/react-native/sdks/hermes/build_macosx
* /Users/distiller/react-native/sdks/hermes/destroot
Downloading cache archive...
Unarchiving cache...
```
Size: 5.2 GiB
Time to restore cache: 183s
This is the `build_hermes_macos` Restore Cache step, after the changes in this diff:
```
Found a cache from build 310128 at v2-hermes-build_hermes_macos-debug-e7WmoA0+mfveXq1zsMYpgR6BYqVuuDjmVeLLyjqPJWk=
Size: 1.3 GiB
Cached paths:
* /Users/distiller/react-native/sdks/hermes/build_macosx
* /Users/distiller/react-native/sdks/hermes/destroot
Downloading cache archive...
Unarchiving cache...
```
Size: 1.3 GiB
Time to restore cache: 42s
**This is a size reduction of 75%, and execution time reduction of 77%.**
This savings will apply to every workflow that runs afterwards until the Hermes cache is invalidated due to a new commit landing in `facebook/hermes`.
## Added `export_hermesc`
As part of the work mentioned above, a reusable `export_hermesc` command was added, which will export hermesc for use in downstream steps. Either of the macOS or iOS build scripts will generate this binary. As we now only cache the macOS build dir, that version is loaded from cache by default if available:
- If the cache contains hermesc, both the macOS and iOS builds will use it.
- If the cache does not contain hermesc, then the iOS job will use the hermesc that was built by the macOS job previously.
- The `export_hermesc` command will work regardless of the order of the Hermes build scripts
## Refactoring of magic strings into reusable yaml references
Some additional changes to the Circle CI config were done in order to reduce repetition of artifacts/cache paths that are re-used across workflows.
Changelog: [Internal]
Reviewed By: cipolleschi
Differential Revision: D40153737
fbshipit-source-id: b9f07302ccc9bac1ce72a09b944d3210e6db2ec1
2022-10-12 16:55:31 +00:00
hermes_osxbin_artifacts_dir : &hermes_osxbin_artifacts_dir
/tmp/hermes/osx-bin
2022-03-08 01:02:08 +00:00
attach_hermes_workspace : &attach_hermes_workspace
attach_workspace :
at : *hermes_workspace_root
2023-08-04 15:15:55 +00:00
xcodebuild_derived_data_path : &xcodebuild_derived_data_path
~/Library/Developer/Xcode/DerivedData/
2022-03-08 01:02:08 +00:00
2022-12-14 10:17:16 +00:00
main_or_stable_only : &main_or_stable_only
filters :
branches :
only :
- main
- /0\.[0-9]+[\.[0-9]+]?-stable/
2022-05-25 18:44:42 +00:00
# -------------------------
# Dependency Anchors
# -------------------------
dependency_versions :
2023-04-02 10:32:15 +00:00
xcode_version : &xcode_version "14.3.0"
2023-06-15 23:06:18 +00:00
nodelts_image : &nodelts_image "cimg/node:20.2.0"
nodeprevlts_image : &nodeprevlts_image "cimg/node:18.12.1"
2023-08-07 19:06:02 +00:00
nodelts_browser_image : &nodelts_browser_image "cimg/node:20.2.0-browsers"
2022-05-25 18:44:42 +00:00
2022-05-12 18:08:29 +00:00
# -------------------------
# Cache Key Anchors
# -------------------------
# Anchors for the cache keys
cache_keys :
2022-05-18 14:43:51 +00:00
checkout_cache_key : &checkout_cache_key v1-checkout
2022-05-12 18:08:29 +00:00
gems_cache_key : &gems_cache_key v1-gems-{{ checksum "Gemfile.lock" }}
2023-08-07 16:40:58 +00:00
gradle_cache_key : &gradle_cache_key v2-gradle-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}-{{ checksum "packages/react-native/ReactAndroid/gradle.properties" }}
2023-08-07 19:06:02 +00:00
yarn_cache_key : &yarn_cache_key v6-yarn-cache-{{ .Environment.CIRCLE_JOB }}
2023-08-04 15:15:55 +00:00
rbenv_cache_key : &rbenv_cache_key v1-rbenv-{{ checksum "/tmp/required_ruby" }}
2023-05-30 11:10:17 +00:00
hermes_workspace_cache_key : &hermes_workspace_cache_key v5-hermes-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/hermes/hermesversion" }}
2023-06-14 14:46:07 +00:00
hermes_workspace_debug_cache_key : &hermes_workspace_debug_cache_key v2-hermes-{{ .Environment.CIRCLE_JOB }}-debug-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
hermes_workspace_release_cache_key : &hermes_workspace_release_cache_key v2-hermes-{{ .Environment.CIRCLE_JOB }}-release-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
2023-05-23 10:34:20 +00:00
hermes_linux_cache_key : &hermes_linux_cache_key v1-hermes-{{ .Environment.CIRCLE_JOB }}-linux-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
hermes_windows_cache_key : &hermes_windows_cache_key v2-hermes-{{ .Environment.CIRCLE_JOB }}-windows-{{ checksum "/Users/circleci/project/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
2023-08-04 15:15:55 +00:00
# Hermes iOS
2023-08-02 16:42:56 +00:00
hermesc_apple_cache_key : &hermesc_apple_cache_key v2-hermesc-apple-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
hermes_apple_slices_cache_key : &hermes_apple_slices_cache_key v2-hermes-apple-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
2022-12-13 12:19:43 +00:00
hermes_tarball_debug_cache_key : &hermes_tarball_debug_cache_key v4-hermes-tarball-debug-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
hermes_tarball_release_cache_key : &hermes_tarball_release_cache_key v3-hermes-tarball-release-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
2023-08-02 16:42:56 +00:00
hermes_macosx_bin_release_cache_key : &hermes_macosx_bin_release_cache_key v1-hermes-release-macosx-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
hermes_macosx_bin_debug_cache_key : &hermes_macosx_bin_debug_cache_key v1-hermes-debug-macosx-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
2023-08-04 15:15:55 +00:00
# Cocoapods - RNTester
2023-05-24 17:15:59 +00:00
pods_cache_key : &pods_cache_key v10-pods-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock.bak" }}-{{ checksum "packages/rn-tester/Podfile" }}
2023-08-04 15:15:55 +00:00
cocoapods_cache_key : &cocoapods_cache_key v7-cocoapods-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock" }}-{{ checksum "packages/rn-tester/Podfile" }}
rntester_podfile_lock_cache_key : &rntester_podfile_lock_cache_key v5-podfilelock-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile" }}-{{ checksum "/tmp/week_year" }}
# Cocoapods - Template
template_cocoapods_cache_key : &template_cocoapods_cache_key v1-cocoapods-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/iOSTemplateProject/ios/Podfile.lock" }}-{{ checksum "/tmp/iOSTemplateProject/ios/Podfile" }}
template_podfile_lock_cache_key : &template_podfile_lock_cache_key v1-podfilelock-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/iOSTemplateProject/ios/Podfile" }}-{{ checksum "/tmp/week_year" }}
# Windows
2022-05-12 18:08:29 +00:00
windows_yarn_cache_key : &windows_yarn_cache_key v1-win-yarn-cache-{{ arch }}-{{ checksum "yarn.lock" }}
2022-12-02 15:32:30 +00:00
windows_choco_cache_key : &windows_choco_cache_key v1-win-choco-cache-{{ .Environment.CIRCLE_JOB }}
2023-08-04 15:15:55 +00:00
2022-05-12 18:08:29 +00:00
2022-09-22 20:41:51 +00:00
cache_paths :
hermes_workspace_macos_cache_paths : &hermes_workspace_macos_cache_paths
2023-03-17 12:03:25 +00:00
- ~/react-native/packages/react-native/sdks/hermes/build_macosx
- ~/react-native/packages/react-native/sdks/hermes/destroot
2022-09-22 20:41:51 +00:00
hermes_tarball_cache_paths : &hermes_tarball_cache_paths
2022-10-07 17:21:25 +00:00
- *hermes_tarball_artifacts_dir
2022-09-22 20:41:51 +00:00
2022-03-08 01:02:08 +00:00
# -------------------------
# Filters
# -------------------------
# CircleCI filters are OR-ed, with all branches triggering by default and tags excluded by default
# CircleCI env-vars are only set with the branch OR tag that triggered the job, not both.
# In this case, CIRCLE_BRANCH is unset, but CIRCLE_TAG is set.
only_release_tags : &only_release_tags
# Both of the following conditions must be included!
# Ignore any commit on any branch by default.
branches :
ignore : /.*/
# Only act on version tags.
tags :
only : /v[0-9]+(\.[0-9]+)*(\-rc(\.[0-9]+)?)?/
2017-09-21 20:34:02 +00:00
2019-05-30 22:07:45 +00:00
# -------------------------
# EXECUTORS
# -------------------------
executors :
2020-02-14 07:11:41 +00:00
nodelts :
2019-05-30 22:07:45 +00:00
<< : *defaults
docker :
2021-06-04 14:18:34 +00:00
# Note: Version set separately for Windows builds, see below.
2022-05-25 18:44:42 +00:00
- image : *nodelts_image
2022-04-01 23:19:29 +00:00
resource_class : "xlarge"
2020-02-14 07:11:41 +00:00
nodeprevlts :
2019-05-30 22:07:45 +00:00
<< : *defaults
docker :
2022-05-25 18:44:42 +00:00
- image : *nodeprevlts_image
2022-04-01 23:19:29 +00:00
resource_class : "xlarge"
2023-08-07 19:06:02 +00:00
# Executor with Node & Java used to inspect and lint
node-browsers-small :
<< : *defaults
docker :
- image : *nodelts_browser_image
resource_class : "small"
2019-05-30 22:07:45 +00:00
reactnativeandroid :
<< : *defaults
docker :
2023-07-25 16:57:30 +00:00
- image : reactnativecommunity/react-native-android:v10.0
2022-04-01 23:19:29 +00:00
resource_class : "xlarge"
2019-05-30 22:07:45 +00:00
environment :
- TERM : "dumb"
2023-08-07 16:31:35 +00:00
- GRADLE_OPTS : '-Dfile.encoding=utf-8 -Dorg.gradle.jvmargs="-XX:+HeapDumpOnOutOfMemoryError"'
✅ Green CI: Fix JavaScript e2e tests, disable failing Android e2e test (#28392)
Summary:
Jobs now have a `run_disabled_tests` argument that allows for the selective execution of disabled tests. When working on re-enabling a failing test, the contributor just needs to set `run_disabled_tests` to `true` in the appropriate workflow in `.circleci/config.yml`.
Tests can be kept green by moving failing tests into the disabled section until a contributor can provide a fix, thus ensuring signal is maintained on master. For example, a failing end-to-end test might be disabled in order to allow the signal from unit tests to be provided, as opposed to flat out failing the entire job.
What was done in this PR:
* The failing `test_js_e2e` job has been fixed, and merged into the `test_js` job. An empty disabled tests section is added for future use.
* The failing `test_ios_e2e` job has been merged into `test_ios`, with all of its steps gated behind the `run_disabled_steps` argument.
* The failing Android end-to-end tests have been added to `test_android`, gated behind the `run_disabled_steps` argument
* The failing Podspecs test has been added back into `test_ios`, gated behind the `run_disabled_steps` argument
## Changelog
[Internal] [CI] - ✅ Green CI, disabled test infrastructure work
Pull Request resolved: https://github.com/facebook/react-native/pull/28392
Test Plan: Verified on Circle CI
Reviewed By: cpojer
Differential Revision: D20665512
Pulled By: hramos
fbshipit-source-id: 831738027f90f4b23313893d8342d7e654f34726
2020-03-26 13:49:03 +00:00
# Repeated here, as the environment key in this executor will overwrite the one in defaults
2020-12-07 11:10:46 +00:00
- PUBLIC_ANALYSISBOT_GITHUB_TOKEN_A : *github_analysisbot_token_a
- PUBLIC_ANALYSISBOT_GITHUB_TOKEN_B : *github_analysisbot_token_b
- PUBLIC_PULLBOT_GITHUB_TOKEN_A : *github_pullbot_token_a
- PUBLIC_PULLBOT_GITHUB_TOKEN_B : *github_pullbot_token_b
2019-05-30 22:07:45 +00:00
reactnativeios :
<< : *defaults
macos :
2022-05-25 18:44:42 +00:00
xcode : *xcode_version
2022-04-01 23:19:29 +00:00
resource_class : macos.x86.medium.gen2
2023-01-05 14:58:38 +00:00
environment :
- BUILD_FROM_SOURCE : true
2019-05-30 22:07:45 +00:00
# -------------------------
# COMMANDS
# -------------------------
commands :
2022-05-18 14:43:51 +00:00
# Checkout with cache, on machines that are using Docker the cache is ignored
checkout_code_with_cache :
parameters :
checkout_base_cache_key :
default : *checkout_cache_key
type : string
steps :
- restore_cache :
fix: Change checkout cache strategy (#35259)
Summary:
This PR updates he cache strategy for the `checkout_with_cache command`.
The previous strategy was using three keys in descending priority order to restore from the cache:
* `<< parameters.checkout_base_cache_key >>-{{ arch }}-{{ .Branch }}-{{ .Revision }}`
* `<< parameters.checkout_base_cache_key >>-{{ arch }}-{{ .Branch }}`
*`<< parameters.checkout_base_cache_key >>-{{ arch }}`
When it saves, it always saves using the first key.
The restore works as it follows:
1. It tries to restore the cache using the first key
2. If it fails, it checks whether there is a cache hit for a key that matches the second key as a pattern
3. If it fails, it checks whether there is a cache hit for a key that matches the third pattern
4. Otherwise, it is a cache miss.
This does not work well. Imagine that you submit some code in commit `xxxx` for branch `abc`.
The CI run the first time, it misses all the three keys and checks out the code normally.
Then, it stores the checked out code in the `checkout_key-abc-xxxx` key.
Then, you submit a commit `yyyy` in the same branch.
The CI starts, it tries with the key `checkout_key-abc-yyyy` but it misses
It tries with the key `checkout_key-abc` and it finds the cache for `checkout_key-abc-xxxx` and it restores it, forgetting about your changes.
While doing the release, we created a tag in a commit X. Then we manually had to remove it, but the CI had a cached version of .git with the tag for
the `0.71-stable` branch. And the release failed because the tag was already existing.
### Why this should work
With this solution, we are going to cache using the commit. If there is no cache for a specific commit, it will be a miss. It won't try to be smart and
retrieve the code from previous caches.
This should prevent stale caches and if we manually remove a tag, and then we do a new commit, it should work.
This is a good trade-off that allows to pay the checkout cost only for the first batch of jobs of the pipeline.
**NOTE:** This still won't work if we don't do a new commit.
## Changelog
[General] [Fixed] - Change Cache strategy to avoid cache bumps in Release
Pull Request resolved: https://github.com/facebook/react-native/pull/35259
Test Plan: 1. CircleCI must be green
Reviewed By: jacdebug
Differential Revision: D41120895
Pulled By: cipolleschi
fbshipit-source-id: 2b45da01803197dbe4a25a313a9dfc53a976d096
2022-11-08 14:50:25 +00:00
key : << parameters.checkout_base_cache_key >>-{{ arch }}-{{ .Branch }}-{{ .Revision }}
2022-08-23 13:43:01 +00:00
- checkout
2022-05-18 14:43:51 +00:00
- save_cache :
2022-10-07 17:21:25 +00:00
key : << parameters.checkout_base_cache_key >>-{{ arch }}-{{ .Branch }}-{{ .Revision }}
2022-05-18 14:43:51 +00:00
paths :
- ".git"
2019-05-30 22:07:45 +00:00
setup_artifacts :
steps :
- run :
name : Initial Setup
2019-12-20 00:53:54 +00:00
command : mkdir -p ./reports/{buck,build,junit,outputs}
2019-05-30 22:07:45 +00:00
2021-10-02 04:21:03 +00:00
setup_ruby :
2023-03-06 10:56:26 +00:00
parameters :
ruby_version :
default : "2.6.10"
type : string
2021-10-02 04:21:03 +00:00
steps :
- restore_cache :
2022-05-12 18:08:29 +00:00
key : *gems_cache_key
2023-03-06 10:56:26 +00:00
- run :
name : Set Required Ruby
command : echo << parameters.ruby_version >> > /tmp/required_ruby
- restore_cache :
key : *rbenv_cache_key
2022-04-12 14:59:52 +00:00
- run :
name : Bundle Install
command : |
2023-03-06 10:56:26 +00:00
# Check if rbenv is installed. CircleCI is migrating to rbenv so we may not need to always install it.
if [[ -z "$(command -v rbenv)" ]]; then
brew install rbenv ruby-build
2023-03-07 16:45:22 +00:00
# Load and init rbenv
(rbenv init 2> /dev/null) || true
echo '' >> ~/.bash_profile
echo 'eval "$(rbenv init - bash)"' >> ~/.bash_profile
source ~/.bash_profile
2023-03-06 10:56:26 +00:00
else
echo "rbenv found; Skipping installation"
fi
2023-03-07 16:45:22 +00:00
brew reinstall libyaml
gem install psych -- --with-libyaml-dir=$(brew --prefix libyaml)
export RUBY_CONFIGURE_OPTS=--with-libyaml-dir=$(brew --prefix libyaml)
2023-03-06 10:56:26 +00:00
# Install the right version of ruby
if [[ -z "$(rbenv versions | grep << parameters.ruby_version >>)" ]]; then
2023-03-09 16:40:05 +00:00
# ensure that `ruby-build` can see all the available versions of Ruby
# some PRs received machines in a weird state, this should make the pipelines
# more robust.
brew update && brew upgrade ruby-build
2023-03-06 10:56:26 +00:00
rbenv install << parameters.ruby_version >>
fi
# Set ruby dependencies
rbenv global << parameters.ruby_version >>
2023-03-07 16:45:22 +00:00
gem install bundler
2022-04-12 14:59:52 +00:00
bundle check || bundle install --path vendor/bundle --clean
2023-03-06 10:56:26 +00:00
- save_cache :
key : *rbenv_cache_key
paths :
- ~/.rbenv
2021-10-02 04:21:03 +00:00
- save_cache :
2022-05-12 18:08:29 +00:00
key : *gems_cache_key
2021-10-02 04:21:03 +00:00
paths :
- vendor/bundle
2019-05-30 22:07:45 +00:00
run_yarn :
2022-05-12 18:08:29 +00:00
parameters :
yarn_base_cache_key :
default : *yarn_cache_key
type : string
2019-05-30 22:07:45 +00:00
steps :
- restore_cache :
keys :
2022-05-12 18:08:29 +00:00
- << parameters.yarn_base_cache_key >>-{{ arch }}-{{ checksum "yarn.lock" }}
- << parameters.yarn_base_cache_key >>-{{ arch }}
- << parameters.yarn_base_cache_key >>
2019-05-30 22:07:45 +00:00
- run :
2020-04-01 00:36:31 +00:00
name : "Yarn: Install Dependencies"
2019-05-30 22:07:45 +00:00
command : |
# Skip yarn install on metro bump commits as the package is not yet
# available on npm
if [[ $(echo "$GIT_COMMIT_DESC" | grep -c "Bump metro@") -eq 0 ]]; then
yarn install --non-interactive --cache-folder ~/.cache/yarn
fi
- save_cache :
paths :
- ~/.cache/yarn
2022-05-12 18:08:29 +00:00
key : << parameters.yarn_base_cache_key >>-{{ arch }}-{{ checksum "yarn.lock" }}
2019-05-30 22:07:45 +00:00
Add shared monorepo build setup (#38718)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38718
> NOTE: Replaces https://github.com/facebook/react-native/pull/38240
## Context
RFC: Decoupling Flipper from React Native core: https://github.com/react-native-community/discussions-and-proposals/pull/641
## Changes
To support incoming new React Native packages around debugging (including migrating over [`react-native-community/cli-plugin-metro`](https://github.com/react-native-community/cli/tree/main/packages/cli-plugin-metro)) — which target Node.js and require a build step, this PR adds a minimal shared build setup across the `react-native` monorepo.
The setup is closely inspired/based on the build scripts in Jest, Metro, and React Native CLI — and is a simple set of script wrappers around Babel. These are available as build commands at the root of the repo:
- `yarn build` — Builds all configured packages. Functionally, this:
- Outputs a `dist/` directory with built files.
- Rewrites package.json `"exports"` to update every `./src/*` reference to `./dist/*` (source of truth).
- `scripts/build/babel-register.js` — Allows running all Node.js entry points from source, similar to the current setup in [facebook/metro](https://github.com/facebook/metro). (Example entry point file in this PR: `packages/dev-middleware/src/index.js`)
Build configuration (i.e. Babel config) is shared as a set standard across the monorepo, and **packages are opted-in to requiring a build**, configured in `scripts/build.config.js`.
```
const buildConfig /*: BuildConfig */ = {
// The packages to include for build and their build options
packages: {
'dev-middleware': {target: 'node'},
},
};
```
For now, there is a single `target: 'node'` option — this is necessary as `react-native`, unlike the above other projects, is a repository with packages targeting several runtimes. We may, in future, introduce a build step for other, non-Node, packages — which may be useful for things such as auto-generated TypeScript definitions.
{F1043312771}
**Differences from the Metro setup**
- References (and compiles out) repo-local `scripts/build/babel-register.js` — removing need for an npm-published dependency.
## Current integration points
- **CircleCI** — `yarn build` is added to the `build_npm_package` and `find_and_publish_bumped_packages` jobs.
**New Node.js package(s) are not load bearing quite yet**: There are not yet any built packages added to the dependencies of `packages/react-native/`, so this will be further tested in a later PR (and is actively being done in an internal commit stack).
### Alternative designs
**Per-package config file**
Replace `scripts/build/config.js` with a package-defined key in in `package.json`, similar to Jest's [`publishConfig`](https://github.com/jestjs/jest/blob/1f019afdcdfc54a6664908bb45f343db4e3d0848/packages/jest-cli/package.json#L87C3-L89C4).
```
"buildConfig": {
"type": "node"
},
```
This would be the only customisation required, with a single Babel config still standardised. Another option this might receive in future is `enableTypeScriptCodgeen`.
**Rollup**
More sophisticated build tool for Node.js, used by the React codebase (albeit within a custom script setup as well).
**Lerna and Nx**
- Most sophisticated setup enabling caching and optimised cloud runs.
- Probably the most likely thing we'll move towards at a later stage.
Changelog: [Internal]
Reviewed By: NickGerleman
Differential Revision: D47760330
fbshipit-source-id: 38ec94708ce3d9946a197d80885781e9707c5841
2023-08-03 11:42:30 +00:00
build_packages :
steps :
- run :
name : Build packages
command : yarn build
2019-05-30 22:07:45 +00:00
brew_install :
parameters :
package :
description : Homebrew package to install
type : string
steps :
2020-07-10 14:13:17 +00:00
- run :
✅ Green CI: Fix JavaScript e2e tests, disable failing Android e2e test (#28392)
Summary:
Jobs now have a `run_disabled_tests` argument that allows for the selective execution of disabled tests. When working on re-enabling a failing test, the contributor just needs to set `run_disabled_tests` to `true` in the appropriate workflow in `.circleci/config.yml`.
Tests can be kept green by moving failing tests into the disabled section until a contributor can provide a fix, thus ensuring signal is maintained on master. For example, a failing end-to-end test might be disabled in order to allow the signal from unit tests to be provided, as opposed to flat out failing the entire job.
What was done in this PR:
* The failing `test_js_e2e` job has been fixed, and merged into the `test_js` job. An empty disabled tests section is added for future use.
* The failing `test_ios_e2e` job has been merged into `test_ios`, with all of its steps gated behind the `run_disabled_steps` argument.
* The failing Android end-to-end tests have been added to `test_android`, gated behind the `run_disabled_steps` argument
* The failing Podspecs test has been added back into `test_ios`, gated behind the `run_disabled_steps` argument
## Changelog
[Internal] [CI] - ✅ Green CI, disabled test infrastructure work
Pull Request resolved: https://github.com/facebook/react-native/pull/28392
Test Plan: Verified on Circle CI
Reviewed By: cpojer
Differential Revision: D20665512
Pulled By: hramos
fbshipit-source-id: 831738027f90f4b23313893d8342d7e654f34726
2020-03-26 13:49:03 +00:00
name : "Brew: Install << parameters.package >>"
2023-02-17 13:43:22 +00:00
command : brew install << parameters.package >>
2019-05-30 22:07:45 +00:00
✅ Green CI: Fix JavaScript e2e tests, disable failing Android e2e test (#28392)
Summary:
Jobs now have a `run_disabled_tests` argument that allows for the selective execution of disabled tests. When working on re-enabling a failing test, the contributor just needs to set `run_disabled_tests` to `true` in the appropriate workflow in `.circleci/config.yml`.
Tests can be kept green by moving failing tests into the disabled section until a contributor can provide a fix, thus ensuring signal is maintained on master. For example, a failing end-to-end test might be disabled in order to allow the signal from unit tests to be provided, as opposed to flat out failing the entire job.
What was done in this PR:
* The failing `test_js_e2e` job has been fixed, and merged into the `test_js` job. An empty disabled tests section is added for future use.
* The failing `test_ios_e2e` job has been merged into `test_ios`, with all of its steps gated behind the `run_disabled_steps` argument.
* The failing Android end-to-end tests have been added to `test_android`, gated behind the `run_disabled_steps` argument
* The failing Podspecs test has been added back into `test_ios`, gated behind the `run_disabled_steps` argument
## Changelog
[Internal] [CI] - ✅ Green CI, disabled test infrastructure work
Pull Request resolved: https://github.com/facebook/react-native/pull/28392
Test Plan: Verified on Circle CI
Reviewed By: cpojer
Differential Revision: D20665512
Pulled By: hramos
fbshipit-source-id: 831738027f90f4b23313893d8342d7e654f34726
2020-03-26 13:49:03 +00:00
with_rntester_pods_cache_span :
2019-06-29 02:12:42 +00:00
parameters :
steps :
type : steps
steps :
2019-07-25 18:42:49 +00:00
- run :
name : Setup CocoaPods cache
2020-08-20 00:54:30 +00:00
# Copy packages/rn-tester/Podfile.lock since it can be changed by pod install
command : cp packages/rn-tester/Podfile.lock packages/rn-tester/Podfile.lock.bak
2019-06-29 02:12:42 +00:00
- restore_cache :
keys :
2023-07-25 10:14:56 +00:00
# The committed lockfile is generated using static libraries and USE_HERMES=1 so it could load an outdated cache if a change
2020-12-04 08:23:38 +00:00
# only affects the frameworks or hermes config. To help prevent this also cache based on the content of Podfile.
2022-05-12 18:08:29 +00:00
- *pods_cache_key
2019-06-29 02:12:42 +00:00
- steps : << parameters.steps >>
- save_cache :
paths :
2020-08-20 00:54:30 +00:00
- packages/rn-tester/Pods
2022-05-12 18:08:29 +00:00
key : *pods_cache_key
2019-06-29 02:12:42 +00:00
2019-05-30 22:07:45 +00:00
download_gradle_dependencies :
steps :
- restore_cache :
keys :
2022-05-12 18:08:29 +00:00
- *gradle_cache_key
2019-05-30 22:07:45 +00:00
- run :
name : Download Dependencies Using Gradle
2022-05-17 22:31:48 +00:00
command : ./gradlew downloadAll
2019-05-30 22:07:45 +00:00
- save_cache :
paths :
- ~/.gradle
2023-08-07 16:40:58 +00:00
- packages/react-native/ReactAndroid/build/downloads
- packages/react-native/ReactAndroid/build/third-party-ndk
2022-05-12 18:08:29 +00:00
key : *gradle_cache_key
2019-05-30 22:07:45 +00:00
2020-04-01 00:36:31 +00:00
run_e2e :
parameters :
platform :
description : Target platform
type : enum
enum : [ "android" , "ios" , "js" ]
default : "js"
retries :
description : How many times the job should try to run these tests
type : integer
default : 3
steps :
- run :
name : "Run Tests: << parameters.platform >> End-to-End Tests"
command : node ./scripts/run-ci-e2e-tests.js --<< parameters.platform >> --retries << parameters.retries >>
report_bundle_size :
parameters :
platform :
description : Target platform
type : enum
enum : [ "android" , "ios" ]
steps :
- run :
name : Report size of RNTester.app (analysis-bot)
2021-11-03 19:09:13 +00:00
command : GITHUB_TOKEN="$PUBLIC_ANALYSISBOT_GITHUB_TOKEN_A""$PUBLIC_ANALYSISBOT_GITHUB_TOKEN_B" scripts/circleci/report-bundle-size.sh << parameters.platform >> || true
2020-04-01 00:36:31 +00:00
2022-12-13 12:19:43 +00:00
get_react_native_version :
steps :
- run :
name : Get React Native version
command : |
2023-05-23 10:34:20 +00:00
VERSION=$(cat packages/react-native/package.json | jq -r '.version')
2022-12-13 12:19:43 +00:00
# Save the react native version we are building in a file so we can use that file as part of the cache key.
echo "$VERSION" > /tmp/react-native-version
echo "React Native Version is $(cat /tmp/react-native-version)"
2023-05-23 10:34:20 +00:00
HERMES_VERSION="$(cat /tmp/hermes/hermesversion)"
echo "Hermes commit is $HERMES_VERSION"
get_react_native_version_windows :
steps :
- run :
name : Get React Native version on Windows
command : |
$VERSION=cat packages/react-native/package.json | jq -r '.version'
# Save the react native version we are building in a file so we can use that file as part of the cache key.
echo "$VERSION" > /tmp/react-native-version
echo "React Native Version is $(cat /tmp/react-native-version)"
$HERMES_VERSION=cat C:\Users\circleci\project\tmp\hermes\hermesversion
echo "Hermes commit is $HERMES_VERSION"
2022-12-13 12:19:43 +00:00
2022-07-20 16:12:47 +00:00
with_hermes_tarball_cache_span :
2022-05-13 19:51:09 +00:00
parameters :
steps :
type : steps
2022-07-20 16:12:47 +00:00
set_tarball_path :
type : boolean
2022-08-23 13:43:01 +00:00
default : False
2022-09-22 20:41:51 +00:00
flavor :
default : "Debug"
2022-10-18 21:25:38 +00:00
description : The Hermes build type. Must be one of "Debug", "Release".
type : enum
enum : [ "Debug" , "Release" ]
2022-10-07 17:21:25 +00:00
hermes_tarball_artifacts_dir :
type : string
default : *hermes_tarball_artifacts_dir
2022-05-13 19:51:09 +00:00
steps :
2022-12-13 12:19:43 +00:00
- get_react_native_version
2022-09-22 20:41:51 +00:00
- when :
condition :
equal : [ << parameters.flavor >>, "Debug"]
steps :
- restore_cache :
keys :
- *hermes_tarball_debug_cache_key
- when :
condition :
equal : [ << parameters.flavor >>, "Release"]
steps :
- restore_cache :
keys :
- *hermes_tarball_release_cache_key
2022-07-20 16:12:47 +00:00
- when :
condition : << parameters.set_tarball_path >>
steps :
- run :
2022-10-07 17:21:25 +00:00
name : Set HERMES_ENGINE_TARBALL_PATH envvar if Hermes tarball is present
2022-07-20 16:12:47 +00:00
command : |
2022-10-07 17:21:25 +00:00
HERMES_TARBALL_ARTIFACTS_DIR=<< parameters.hermes_tarball_artifacts_dir >>
if [ ! -d $HERMES_TARBALL_ARTIFACTS_DIR ]; then
echo "Hermes tarball artifacts dir not present ($HERMES_TARBALL_ARTIFACTS_DIR). Build Hermes from source."
Reduce flakiness of CI (#34235)
Summary:
How the Hermes cache worked had a concurrency issue. It used to work by asking the Hermes repository for the latest commit and using that commit as cache key to try and retrieve a built version of Hermes to avoid to compile it more than once.
The problem happened when the `build_hermes_macos` was building Hermes using a commit A.
While building, another PR could be merged into `hermes:main`, creating commit B.
When this happened, the tasks `test_ios` and `test_ios_rntester`would try to retrieve a cached version of Hermes using commit B. That version did not exist because Hermes was created using commit A, and the job would either fail or trying to build Hermes from source, ending up taking a lot of time.
This PR attaches the `.hermes-cache-key-file` to the workspace and restores it in the other jobs, making sure that the same cache key is used in all three jobs.
## Changelog
<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[General] [Changed] - Attach the `.hermes-cache-key-file` to the workspace to avoid race conditions for new PR landing on Hermes and changing the head commit between the time Hermes is built and the time it has to be consumed.
Pull Request resolved: https://github.com/facebook/react-native/pull/34235
Test Plan:
Tested manually, looking at the messages in CI.
**build_hermes_macos**
<img width="881" alt="Screenshot 2022-07-21 at 15 40 02" src="https://user-images.githubusercontent.com/11162307/180241834-776f2291-63bb-4bb2-8837-14434b50fe61.png">
**test_ios_rntester**: notice that the `echo` is not executed, meaning that the `if` does not evaluate to true and, therefore, the file has been correctly attached.
<img width="956" alt="Screenshot 2022-07-21 at 15 40 52" src="https://user-images.githubusercontent.com/11162307/180242004-d9db0336-18d3-4321-a997-b538baa6beee.png">
**test_ios**: notice that the `echo` is not executed, meaning that the `if` does not evaluate to true and, therefore, the file has been correctly attached.
<img width="900" alt="Screenshot 2022-07-21 at 15 46 33" src="https://user-images.githubusercontent.com/11162307/180243359-79de5c7a-d2f0-4331-90c6-5bd2c0b5e1ac.png">
Reviewed By: cortinico
Differential Revision: D38037386
Pulled By: cipolleschi
fbshipit-source-id: 4db4f7c478e1afb2e4a18ba3d3f70896ed41d235
2022-07-22 12:56:02 +00:00
exit 0
2022-07-20 16:12:47 +00:00
fi
2022-10-07 17:21:25 +00:00
if [ ! -d ~/react-native ]; then
echo "No React Native checkout found. Run `checkout` first."
2022-09-22 20:41:51 +00:00
exit 0
fi
2022-10-07 17:21:25 +00:00
2023-03-17 12:03:25 +00:00
TARBALL_FILENAME=$(node ~/react-native/packages/react-native/scripts/hermes/get-tarball-name.js --buildType "<< parameters.flavor >>")
2022-11-14 16:31:30 +00:00
TARBALL_PATH=$HERMES_TARBALL_ARTIFACTS_DIR/$TARBALL_FILENAME
2022-10-07 17:21:25 +00:00
echo "Looking for $TARBALL_FILENAME in $HERMES_TARBALL_ARTIFACTS_DIR"
echo "$TARBALL_PATH"
2022-07-20 16:12:47 +00:00
if [ ! -f $TARBALL_PATH ]; then
2022-10-07 17:21:25 +00:00
echo "Hermes tarball not present ($TARBALL_PATH). Build Hermes from source."
Reduce flakiness of CI (#34235)
Summary:
How the Hermes cache worked had a concurrency issue. It used to work by asking the Hermes repository for the latest commit and using that commit as cache key to try and retrieve a built version of Hermes to avoid to compile it more than once.
The problem happened when the `build_hermes_macos` was building Hermes using a commit A.
While building, another PR could be merged into `hermes:main`, creating commit B.
When this happened, the tasks `test_ios` and `test_ios_rntester`would try to retrieve a cached version of Hermes using commit B. That version did not exist because Hermes was created using commit A, and the job would either fail or trying to build Hermes from source, ending up taking a lot of time.
This PR attaches the `.hermes-cache-key-file` to the workspace and restores it in the other jobs, making sure that the same cache key is used in all three jobs.
## Changelog
<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[General] [Changed] - Attach the `.hermes-cache-key-file` to the workspace to avoid race conditions for new PR landing on Hermes and changing the head commit between the time Hermes is built and the time it has to be consumed.
Pull Request resolved: https://github.com/facebook/react-native/pull/34235
Test Plan:
Tested manually, looking at the messages in CI.
**build_hermes_macos**
<img width="881" alt="Screenshot 2022-07-21 at 15 40 02" src="https://user-images.githubusercontent.com/11162307/180241834-776f2291-63bb-4bb2-8837-14434b50fe61.png">
**test_ios_rntester**: notice that the `echo` is not executed, meaning that the `if` does not evaluate to true and, therefore, the file has been correctly attached.
<img width="956" alt="Screenshot 2022-07-21 at 15 40 52" src="https://user-images.githubusercontent.com/11162307/180242004-d9db0336-18d3-4321-a997-b538baa6beee.png">
**test_ios**: notice that the `echo` is not executed, meaning that the `if` does not evaluate to true and, therefore, the file has been correctly attached.
<img width="900" alt="Screenshot 2022-07-21 at 15 46 33" src="https://user-images.githubusercontent.com/11162307/180243359-79de5c7a-d2f0-4331-90c6-5bd2c0b5e1ac.png">
Reviewed By: cortinico
Differential Revision: D38037386
Pulled By: cipolleschi
fbshipit-source-id: 4db4f7c478e1afb2e4a18ba3d3f70896ed41d235
2022-07-22 12:56:02 +00:00
exit 0
2022-07-20 16:12:47 +00:00
fi
2022-09-22 20:41:51 +00:00
echo "Found Hermes tarball at $TARBALL_PATH"
2022-07-20 16:12:47 +00:00
echo "export HERMES_ENGINE_TARBALL_PATH=$TARBALL_PATH" >> $BASH_ENV
2022-12-13 12:19:43 +00:00
- run :
name : Print Hermes version
command : |
HERMES_TARBALL_ARTIFACTS_DIR=<< parameters.hermes_tarball_artifacts_dir >>
2023-03-17 12:03:25 +00:00
TARBALL_FILENAME=$(node ~/react-native/packages/react-native/scripts/hermes/get-tarball-name.js --buildType "<< parameters.flavor >>")
2022-12-13 12:19:43 +00:00
TARBALL_PATH=$HERMES_TARBALL_ARTIFACTS_DIR/$TARBALL_FILENAME
if [[ -e $TARBALL_PATH ]]; then
tar -xf $TARBALL_PATH
echo 'print(HermesInternal?.getRuntimeProperties?.()["OSS Release Version"])' > test.js
./destroot/bin/hermes test.js
rm test.js
rm -rf destroot
else
echo 'No Hermes tarball found.'
fi
2022-05-13 19:51:09 +00:00
- steps : << parameters.steps >>
2022-09-22 20:41:51 +00:00
- when :
condition :
equal : [ << parameters.flavor >>, "Debug"]
steps :
- save_cache :
key : *hermes_tarball_debug_cache_key
paths : *hermes_tarball_cache_paths
- when :
condition :
equal : [ << parameters.flavor >>, "Release"]
steps :
- save_cache :
key : *hermes_tarball_release_cache_key
paths : *hermes_tarball_cache_paths
2022-05-13 19:51:09 +00:00
2023-08-02 16:42:56 +00:00
store_hermes_apple_artifacts :
description : Stores the tarball and the osx binaries
Circle CI: Reduce build_hermes_macos Hermes SDK cache size by 75% (#34886)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34886
## Reduced cache size
The `build_hermes_macos` job can spend over 20 minutes restoring cached build artifacts (over 5 GB), when only `build_macosx` and `destroot` are required to be cached: `build_macosx` as it may contain a pre-built `hermesc` from previous builds, and `destroot` which contains the artifacts for previous iOS/macOS builds.
This is the `build_hermes_macos` Restore Cache step, before the changes in this diff:
```
Found a cache from build 308044 at v1-hermes-build_hermes_macos-debug-PEiMHp9XQ13KtYFQMKoT27DmHkkoxOi_PJUyW7PacZE=
Size: 5.2 GiB
Cached paths:
* /Users/distiller/react-native/sdks/hermes/build_host_hermesc
* /Users/distiller/react-native/sdks/hermes/build_iphoneos
* /Users/distiller/react-native/sdks/hermes/build_catalyst
* /Users/distiller/react-native/sdks/hermes/build_iphonesimulator
* /Users/distiller/react-native/sdks/hermes/build_macosx
* /Users/distiller/react-native/sdks/hermes/destroot
Downloading cache archive...
Unarchiving cache...
```
Size: 5.2 GiB
Time to restore cache: 183s
This is the `build_hermes_macos` Restore Cache step, after the changes in this diff:
```
Found a cache from build 310128 at v2-hermes-build_hermes_macos-debug-e7WmoA0+mfveXq1zsMYpgR6BYqVuuDjmVeLLyjqPJWk=
Size: 1.3 GiB
Cached paths:
* /Users/distiller/react-native/sdks/hermes/build_macosx
* /Users/distiller/react-native/sdks/hermes/destroot
Downloading cache archive...
Unarchiving cache...
```
Size: 1.3 GiB
Time to restore cache: 42s
**This is a size reduction of 75%, and execution time reduction of 77%.**
This savings will apply to every workflow that runs afterwards until the Hermes cache is invalidated due to a new commit landing in `facebook/hermes`.
## Added `export_hermesc`
As part of the work mentioned above, a reusable `export_hermesc` command was added, which will export hermesc for use in downstream steps. Either of the macOS or iOS build scripts will generate this binary. As we now only cache the macOS build dir, that version is loaded from cache by default if available:
- If the cache contains hermesc, both the macOS and iOS builds will use it.
- If the cache does not contain hermesc, then the iOS job will use the hermesc that was built by the macOS job previously.
- The `export_hermesc` command will work regardless of the order of the Hermes build scripts
## Refactoring of magic strings into reusable yaml references
Some additional changes to the Circle CI config were done in order to reduce repetition of artifacts/cache paths that are re-used across workflows.
Changelog: [Internal]
Reviewed By: cipolleschi
Differential Revision: D40153737
fbshipit-source-id: b9f07302ccc9bac1ce72a09b944d3210e6db2ec1
2022-10-12 16:55:31 +00:00
parameters :
2022-10-18 21:25:38 +00:00
flavor :
default : "Debug"
description : The Hermes build type. Must be one of "Debug", "Release".
type : enum
enum : [ "Debug" , "Release" ]
Circle CI: Reduce build_hermes_macos Hermes SDK cache size by 75% (#34886)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34886
## Reduced cache size
The `build_hermes_macos` job can spend over 20 minutes restoring cached build artifacts (over 5 GB), when only `build_macosx` and `destroot` are required to be cached: `build_macosx` as it may contain a pre-built `hermesc` from previous builds, and `destroot` which contains the artifacts for previous iOS/macOS builds.
This is the `build_hermes_macos` Restore Cache step, before the changes in this diff:
```
Found a cache from build 308044 at v1-hermes-build_hermes_macos-debug-PEiMHp9XQ13KtYFQMKoT27DmHkkoxOi_PJUyW7PacZE=
Size: 5.2 GiB
Cached paths:
* /Users/distiller/react-native/sdks/hermes/build_host_hermesc
* /Users/distiller/react-native/sdks/hermes/build_iphoneos
* /Users/distiller/react-native/sdks/hermes/build_catalyst
* /Users/distiller/react-native/sdks/hermes/build_iphonesimulator
* /Users/distiller/react-native/sdks/hermes/build_macosx
* /Users/distiller/react-native/sdks/hermes/destroot
Downloading cache archive...
Unarchiving cache...
```
Size: 5.2 GiB
Time to restore cache: 183s
This is the `build_hermes_macos` Restore Cache step, after the changes in this diff:
```
Found a cache from build 310128 at v2-hermes-build_hermes_macos-debug-e7WmoA0+mfveXq1zsMYpgR6BYqVuuDjmVeLLyjqPJWk=
Size: 1.3 GiB
Cached paths:
* /Users/distiller/react-native/sdks/hermes/build_macosx
* /Users/distiller/react-native/sdks/hermes/destroot
Downloading cache archive...
Unarchiving cache...
```
Size: 1.3 GiB
Time to restore cache: 42s
**This is a size reduction of 75%, and execution time reduction of 77%.**
This savings will apply to every workflow that runs afterwards until the Hermes cache is invalidated due to a new commit landing in `facebook/hermes`.
## Added `export_hermesc`
As part of the work mentioned above, a reusable `export_hermesc` command was added, which will export hermesc for use in downstream steps. Either of the macOS or iOS build scripts will generate this binary. As we now only cache the macOS build dir, that version is loaded from cache by default if available:
- If the cache contains hermesc, both the macOS and iOS builds will use it.
- If the cache does not contain hermesc, then the iOS job will use the hermesc that was built by the macOS job previously.
- The `export_hermesc` command will work regardless of the order of the Hermes build scripts
## Refactoring of magic strings into reusable yaml references
Some additional changes to the Circle CI config were done in order to reduce repetition of artifacts/cache paths that are re-used across workflows.
Changelog: [Internal]
Reviewed By: cipolleschi
Differential Revision: D40153737
fbshipit-source-id: b9f07302ccc9bac1ce72a09b944d3210e6db2ec1
2022-10-12 16:55:31 +00:00
steps :
2023-08-02 16:42:56 +00:00
- when :
condition :
equal : [ << parameters.flavor >>, "Debug"]
steps :
- store_artifacts :
path : /tmp/hermes/hermes-runtime-darwin/hermes-ios-debug.tar.gz
- when :
condition :
equal : [ << parameters.flavor >>, "Release"]
steps :
- store_artifacts :
path : /tmp/hermes/hermes-runtime-darwin/hermes-ios-release.tar.gz
- store_artifacts :
path : /tmp/hermes/osx-bin/<< parameters.flavor >>/hermesc
Circle CI: Reduce build_hermes_macos Hermes SDK cache size by 75% (#34886)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34886
## Reduced cache size
The `build_hermes_macos` job can spend over 20 minutes restoring cached build artifacts (over 5 GB), when only `build_macosx` and `destroot` are required to be cached: `build_macosx` as it may contain a pre-built `hermesc` from previous builds, and `destroot` which contains the artifacts for previous iOS/macOS builds.
This is the `build_hermes_macos` Restore Cache step, before the changes in this diff:
```
Found a cache from build 308044 at v1-hermes-build_hermes_macos-debug-PEiMHp9XQ13KtYFQMKoT27DmHkkoxOi_PJUyW7PacZE=
Size: 5.2 GiB
Cached paths:
* /Users/distiller/react-native/sdks/hermes/build_host_hermesc
* /Users/distiller/react-native/sdks/hermes/build_iphoneos
* /Users/distiller/react-native/sdks/hermes/build_catalyst
* /Users/distiller/react-native/sdks/hermes/build_iphonesimulator
* /Users/distiller/react-native/sdks/hermes/build_macosx
* /Users/distiller/react-native/sdks/hermes/destroot
Downloading cache archive...
Unarchiving cache...
```
Size: 5.2 GiB
Time to restore cache: 183s
This is the `build_hermes_macos` Restore Cache step, after the changes in this diff:
```
Found a cache from build 310128 at v2-hermes-build_hermes_macos-debug-e7WmoA0+mfveXq1zsMYpgR6BYqVuuDjmVeLLyjqPJWk=
Size: 1.3 GiB
Cached paths:
* /Users/distiller/react-native/sdks/hermes/build_macosx
* /Users/distiller/react-native/sdks/hermes/destroot
Downloading cache archive...
Unarchiving cache...
```
Size: 1.3 GiB
Time to restore cache: 42s
**This is a size reduction of 75%, and execution time reduction of 77%.**
This savings will apply to every workflow that runs afterwards until the Hermes cache is invalidated due to a new commit landing in `facebook/hermes`.
## Added `export_hermesc`
As part of the work mentioned above, a reusable `export_hermesc` command was added, which will export hermesc for use in downstream steps. Either of the macOS or iOS build scripts will generate this binary. As we now only cache the macOS build dir, that version is loaded from cache by default if available:
- If the cache contains hermesc, both the macOS and iOS builds will use it.
- If the cache does not contain hermesc, then the iOS job will use the hermesc that was built by the macOS job previously.
- The `export_hermesc` command will work regardless of the order of the Hermes build scripts
## Refactoring of magic strings into reusable yaml references
Some additional changes to the Circle CI config were done in order to reduce repetition of artifacts/cache paths that are re-used across workflows.
Changelog: [Internal]
Reviewed By: cipolleschi
Differential Revision: D40153737
fbshipit-source-id: b9f07302ccc9bac1ce72a09b944d3210e6db2ec1
2022-10-12 16:55:31 +00:00
2023-08-02 16:42:56 +00:00
stop_job_if_apple_artifacts_are_there :
description : Stops the current job if there are already the required artifacts
parameters :
flavor :
default : "All"
description : The flavor of artifacts to check. Must be one of "Debug", "Release" or "All"
type : enum
enum : [ "Debug" , "Release" , "All" ]
steps :
- when :
condition :
equal : [ << parameters.flavor >>, "All"]
steps :
- run :
name : "Stop if tarballs are present"
command : |
if [[ -f /tmp/hermes/Release_tarball_present && -f /tmp/hermes/Debug_tarball_present && -f /tmp/hermes/Release_osx_bin && -f /tmp/hermes/Debug_osx_bin ]]; then
echo "Tarball and osx-bin present. Halting this job"
circleci-agent step halt
fi
- when :
condition :
not :
equal : [ << parameters.flavor >>, "All"]
steps :
- run :
name : "Stop if tarballs are present"
command : |
TARBALL_PATH=/tmp/hermes/<< parameters.flavor >>_tarball_present
OSX_BIN_PATH=/tmp/hermes/<< parameters.flavor >>_osx_bin
if [[ -f "$OSX_BIN_PATH" && -f "$TARBALL_PATH" ]]; then
echo "[HERMES] Tarball and hermesc binary present. Halting this job"
circleci-agent step halt
else
echo "[HERMES] Tarball not found. Building."
fi
check_if_tarball_is_present :
description : "Checks if the tarball of a specific Flavor is present and adds a marker file"
Circle CI: Reduce build_hermes_macos Hermes SDK cache size by 75% (#34886)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34886
## Reduced cache size
The `build_hermes_macos` job can spend over 20 minutes restoring cached build artifacts (over 5 GB), when only `build_macosx` and `destroot` are required to be cached: `build_macosx` as it may contain a pre-built `hermesc` from previous builds, and `destroot` which contains the artifacts for previous iOS/macOS builds.
This is the `build_hermes_macos` Restore Cache step, before the changes in this diff:
```
Found a cache from build 308044 at v1-hermes-build_hermes_macos-debug-PEiMHp9XQ13KtYFQMKoT27DmHkkoxOi_PJUyW7PacZE=
Size: 5.2 GiB
Cached paths:
* /Users/distiller/react-native/sdks/hermes/build_host_hermesc
* /Users/distiller/react-native/sdks/hermes/build_iphoneos
* /Users/distiller/react-native/sdks/hermes/build_catalyst
* /Users/distiller/react-native/sdks/hermes/build_iphonesimulator
* /Users/distiller/react-native/sdks/hermes/build_macosx
* /Users/distiller/react-native/sdks/hermes/destroot
Downloading cache archive...
Unarchiving cache...
```
Size: 5.2 GiB
Time to restore cache: 183s
This is the `build_hermes_macos` Restore Cache step, after the changes in this diff:
```
Found a cache from build 310128 at v2-hermes-build_hermes_macos-debug-e7WmoA0+mfveXq1zsMYpgR6BYqVuuDjmVeLLyjqPJWk=
Size: 1.3 GiB
Cached paths:
* /Users/distiller/react-native/sdks/hermes/build_macosx
* /Users/distiller/react-native/sdks/hermes/destroot
Downloading cache archive...
Unarchiving cache...
```
Size: 1.3 GiB
Time to restore cache: 42s
**This is a size reduction of 75%, and execution time reduction of 77%.**
This savings will apply to every workflow that runs afterwards until the Hermes cache is invalidated due to a new commit landing in `facebook/hermes`.
## Added `export_hermesc`
As part of the work mentioned above, a reusable `export_hermesc` command was added, which will export hermesc for use in downstream steps. Either of the macOS or iOS build scripts will generate this binary. As we now only cache the macOS build dir, that version is loaded from cache by default if available:
- If the cache contains hermesc, both the macOS and iOS builds will use it.
- If the cache does not contain hermesc, then the iOS job will use the hermesc that was built by the macOS job previously.
- The `export_hermesc` command will work regardless of the order of the Hermes build scripts
## Refactoring of magic strings into reusable yaml references
Some additional changes to the Circle CI config were done in order to reduce repetition of artifacts/cache paths that are re-used across workflows.
Changelog: [Internal]
Reviewed By: cipolleschi
Differential Revision: D40153737
fbshipit-source-id: b9f07302ccc9bac1ce72a09b944d3210e6db2ec1
2022-10-12 16:55:31 +00:00
parameters :
2022-10-18 21:25:38 +00:00
flavor :
default : "Debug"
2023-08-02 16:42:56 +00:00
description : The flavor of artifacts to check. Must be one of "Debug" or "Release"
2022-10-18 21:25:38 +00:00
type : enum
enum : [ "Debug" , "Release" ]
Circle CI: Reduce build_hermes_macos Hermes SDK cache size by 75% (#34886)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34886
## Reduced cache size
The `build_hermes_macos` job can spend over 20 minutes restoring cached build artifacts (over 5 GB), when only `build_macosx` and `destroot` are required to be cached: `build_macosx` as it may contain a pre-built `hermesc` from previous builds, and `destroot` which contains the artifacts for previous iOS/macOS builds.
This is the `build_hermes_macos` Restore Cache step, before the changes in this diff:
```
Found a cache from build 308044 at v1-hermes-build_hermes_macos-debug-PEiMHp9XQ13KtYFQMKoT27DmHkkoxOi_PJUyW7PacZE=
Size: 5.2 GiB
Cached paths:
* /Users/distiller/react-native/sdks/hermes/build_host_hermesc
* /Users/distiller/react-native/sdks/hermes/build_iphoneos
* /Users/distiller/react-native/sdks/hermes/build_catalyst
* /Users/distiller/react-native/sdks/hermes/build_iphonesimulator
* /Users/distiller/react-native/sdks/hermes/build_macosx
* /Users/distiller/react-native/sdks/hermes/destroot
Downloading cache archive...
Unarchiving cache...
```
Size: 5.2 GiB
Time to restore cache: 183s
This is the `build_hermes_macos` Restore Cache step, after the changes in this diff:
```
Found a cache from build 310128 at v2-hermes-build_hermes_macos-debug-e7WmoA0+mfveXq1zsMYpgR6BYqVuuDjmVeLLyjqPJWk=
Size: 1.3 GiB
Cached paths:
* /Users/distiller/react-native/sdks/hermes/build_macosx
* /Users/distiller/react-native/sdks/hermes/destroot
Downloading cache archive...
Unarchiving cache...
```
Size: 1.3 GiB
Time to restore cache: 42s
**This is a size reduction of 75%, and execution time reduction of 77%.**
This savings will apply to every workflow that runs afterwards until the Hermes cache is invalidated due to a new commit landing in `facebook/hermes`.
## Added `export_hermesc`
As part of the work mentioned above, a reusable `export_hermesc` command was added, which will export hermesc for use in downstream steps. Either of the macOS or iOS build scripts will generate this binary. As we now only cache the macOS build dir, that version is loaded from cache by default if available:
- If the cache contains hermesc, both the macOS and iOS builds will use it.
- If the cache does not contain hermesc, then the iOS job will use the hermesc that was built by the macOS job previously.
- The `export_hermesc` command will work regardless of the order of the Hermes build scripts
## Refactoring of magic strings into reusable yaml references
Some additional changes to the Circle CI config were done in order to reduce repetition of artifacts/cache paths that are re-used across workflows.
Changelog: [Internal]
Reviewed By: cipolleschi
Differential Revision: D40153737
fbshipit-source-id: b9f07302ccc9bac1ce72a09b944d3210e6db2ec1
2022-10-12 16:55:31 +00:00
steps :
- run :
2023-08-02 16:42:56 +00:00
name : Check if << parameters.flavor >> tarball is there
Circle CI: Reduce build_hermes_macos Hermes SDK cache size by 75% (#34886)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34886
## Reduced cache size
The `build_hermes_macos` job can spend over 20 minutes restoring cached build artifacts (over 5 GB), when only `build_macosx` and `destroot` are required to be cached: `build_macosx` as it may contain a pre-built `hermesc` from previous builds, and `destroot` which contains the artifacts for previous iOS/macOS builds.
This is the `build_hermes_macos` Restore Cache step, before the changes in this diff:
```
Found a cache from build 308044 at v1-hermes-build_hermes_macos-debug-PEiMHp9XQ13KtYFQMKoT27DmHkkoxOi_PJUyW7PacZE=
Size: 5.2 GiB
Cached paths:
* /Users/distiller/react-native/sdks/hermes/build_host_hermesc
* /Users/distiller/react-native/sdks/hermes/build_iphoneos
* /Users/distiller/react-native/sdks/hermes/build_catalyst
* /Users/distiller/react-native/sdks/hermes/build_iphonesimulator
* /Users/distiller/react-native/sdks/hermes/build_macosx
* /Users/distiller/react-native/sdks/hermes/destroot
Downloading cache archive...
Unarchiving cache...
```
Size: 5.2 GiB
Time to restore cache: 183s
This is the `build_hermes_macos` Restore Cache step, after the changes in this diff:
```
Found a cache from build 310128 at v2-hermes-build_hermes_macos-debug-e7WmoA0+mfveXq1zsMYpgR6BYqVuuDjmVeLLyjqPJWk=
Size: 1.3 GiB
Cached paths:
* /Users/distiller/react-native/sdks/hermes/build_macosx
* /Users/distiller/react-native/sdks/hermes/destroot
Downloading cache archive...
Unarchiving cache...
```
Size: 1.3 GiB
Time to restore cache: 42s
**This is a size reduction of 75%, and execution time reduction of 77%.**
This savings will apply to every workflow that runs afterwards until the Hermes cache is invalidated due to a new commit landing in `facebook/hermes`.
## Added `export_hermesc`
As part of the work mentioned above, a reusable `export_hermesc` command was added, which will export hermesc for use in downstream steps. Either of the macOS or iOS build scripts will generate this binary. As we now only cache the macOS build dir, that version is loaded from cache by default if available:
- If the cache contains hermesc, both the macOS and iOS builds will use it.
- If the cache does not contain hermesc, then the iOS job will use the hermesc that was built by the macOS job previously.
- The `export_hermesc` command will work regardless of the order of the Hermes build scripts
## Refactoring of magic strings into reusable yaml references
Some additional changes to the Circle CI config were done in order to reduce repetition of artifacts/cache paths that are re-used across workflows.
Changelog: [Internal]
Reviewed By: cipolleschi
Differential Revision: D40153737
fbshipit-source-id: b9f07302ccc9bac1ce72a09b944d3210e6db2ec1
2022-10-12 16:55:31 +00:00
command : |
2023-08-02 16:42:56 +00:00
FLAVOR=debug
if [[ << parameters.flavor >> == "Release" ]]; then
FLAVOR=release
fi
Circle CI: Reduce build_hermes_macos Hermes SDK cache size by 75% (#34886)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34886
## Reduced cache size
The `build_hermes_macos` job can spend over 20 minutes restoring cached build artifacts (over 5 GB), when only `build_macosx` and `destroot` are required to be cached: `build_macosx` as it may contain a pre-built `hermesc` from previous builds, and `destroot` which contains the artifacts for previous iOS/macOS builds.
This is the `build_hermes_macos` Restore Cache step, before the changes in this diff:
```
Found a cache from build 308044 at v1-hermes-build_hermes_macos-debug-PEiMHp9XQ13KtYFQMKoT27DmHkkoxOi_PJUyW7PacZE=
Size: 5.2 GiB
Cached paths:
* /Users/distiller/react-native/sdks/hermes/build_host_hermesc
* /Users/distiller/react-native/sdks/hermes/build_iphoneos
* /Users/distiller/react-native/sdks/hermes/build_catalyst
* /Users/distiller/react-native/sdks/hermes/build_iphonesimulator
* /Users/distiller/react-native/sdks/hermes/build_macosx
* /Users/distiller/react-native/sdks/hermes/destroot
Downloading cache archive...
Unarchiving cache...
```
Size: 5.2 GiB
Time to restore cache: 183s
This is the `build_hermes_macos` Restore Cache step, after the changes in this diff:
```
Found a cache from build 310128 at v2-hermes-build_hermes_macos-debug-e7WmoA0+mfveXq1zsMYpgR6BYqVuuDjmVeLLyjqPJWk=
Size: 1.3 GiB
Cached paths:
* /Users/distiller/react-native/sdks/hermes/build_macosx
* /Users/distiller/react-native/sdks/hermes/destroot
Downloading cache archive...
Unarchiving cache...
```
Size: 1.3 GiB
Time to restore cache: 42s
**This is a size reduction of 75%, and execution time reduction of 77%.**
This savings will apply to every workflow that runs afterwards until the Hermes cache is invalidated due to a new commit landing in `facebook/hermes`.
## Added `export_hermesc`
As part of the work mentioned above, a reusable `export_hermesc` command was added, which will export hermesc for use in downstream steps. Either of the macOS or iOS build scripts will generate this binary. As we now only cache the macOS build dir, that version is loaded from cache by default if available:
- If the cache contains hermesc, both the macOS and iOS builds will use it.
- If the cache does not contain hermesc, then the iOS job will use the hermesc that was built by the macOS job previously.
- The `export_hermesc` command will work regardless of the order of the Hermes build scripts
## Refactoring of magic strings into reusable yaml references
Some additional changes to the Circle CI config were done in order to reduce repetition of artifacts/cache paths that are re-used across workflows.
Changelog: [Internal]
Reviewed By: cipolleschi
Differential Revision: D40153737
fbshipit-source-id: b9f07302ccc9bac1ce72a09b944d3210e6db2ec1
2022-10-12 16:55:31 +00:00
2023-08-02 16:42:56 +00:00
if [[ -f "/tmp/hermes/hermes-runtime-darwin/hermes-ios-$FLAVOR.tar.gz" ]]; then
echo "[HERMES TARBALL] Found the << parameters.flavor >> tarball"
touch /tmp/hermes/<< parameters.flavor >>_tarball_present
fi
check_if_osx_bin_is_present :
description : "Checks if the osx bin of a specific Flavor is present and adds a marker file"
parameters :
flavor :
default : "Debug"
description : The flavor of artifacts to check. Must be one of "Debug" or "Release"
type : enum
enum : [ "Debug" , "Release" ]
steps :
- run :
name : Check if macosx binary is there
command : |
if [[ -d /tmp/hermes/osx-bin/<< parameters.flavor >> ]]; then
echo "[HERMES MACOSX BIN] Found the osx bin << parameters.flavor >>"
touch /tmp/hermes/<< parameters.flavor >>_osx_bin
Circle CI: Reduce build_hermes_macos Hermes SDK cache size by 75% (#34886)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34886
## Reduced cache size
The `build_hermes_macos` job can spend over 20 minutes restoring cached build artifacts (over 5 GB), when only `build_macosx` and `destroot` are required to be cached: `build_macosx` as it may contain a pre-built `hermesc` from previous builds, and `destroot` which contains the artifacts for previous iOS/macOS builds.
This is the `build_hermes_macos` Restore Cache step, before the changes in this diff:
```
Found a cache from build 308044 at v1-hermes-build_hermes_macos-debug-PEiMHp9XQ13KtYFQMKoT27DmHkkoxOi_PJUyW7PacZE=
Size: 5.2 GiB
Cached paths:
* /Users/distiller/react-native/sdks/hermes/build_host_hermesc
* /Users/distiller/react-native/sdks/hermes/build_iphoneos
* /Users/distiller/react-native/sdks/hermes/build_catalyst
* /Users/distiller/react-native/sdks/hermes/build_iphonesimulator
* /Users/distiller/react-native/sdks/hermes/build_macosx
* /Users/distiller/react-native/sdks/hermes/destroot
Downloading cache archive...
Unarchiving cache...
```
Size: 5.2 GiB
Time to restore cache: 183s
This is the `build_hermes_macos` Restore Cache step, after the changes in this diff:
```
Found a cache from build 310128 at v2-hermes-build_hermes_macos-debug-e7WmoA0+mfveXq1zsMYpgR6BYqVuuDjmVeLLyjqPJWk=
Size: 1.3 GiB
Cached paths:
* /Users/distiller/react-native/sdks/hermes/build_macosx
* /Users/distiller/react-native/sdks/hermes/destroot
Downloading cache archive...
Unarchiving cache...
```
Size: 1.3 GiB
Time to restore cache: 42s
**This is a size reduction of 75%, and execution time reduction of 77%.**
This savings will apply to every workflow that runs afterwards until the Hermes cache is invalidated due to a new commit landing in `facebook/hermes`.
## Added `export_hermesc`
As part of the work mentioned above, a reusable `export_hermesc` command was added, which will export hermesc for use in downstream steps. Either of the macOS or iOS build scripts will generate this binary. As we now only cache the macOS build dir, that version is loaded from cache by default if available:
- If the cache contains hermesc, both the macOS and iOS builds will use it.
- If the cache does not contain hermesc, then the iOS job will use the hermesc that was built by the macOS job previously.
- The `export_hermesc` command will work regardless of the order of the Hermes build scripts
## Refactoring of magic strings into reusable yaml references
Some additional changes to the Circle CI config were done in order to reduce repetition of artifacts/cache paths that are re-used across workflows.
Changelog: [Internal]
Reviewed By: cipolleschi
Differential Revision: D40153737
fbshipit-source-id: b9f07302ccc9bac1ce72a09b944d3210e6db2ec1
2022-10-12 16:55:31 +00:00
fi
2023-08-02 16:42:56 +00:00
setup_hermes_workspace :
description : "Setup Hermes Workspace"
steps :
- run :
name : Set up workspace
command : |
mkdir -p $HERMES_OSXBIN_ARTIFACTS_DIR ./packages/react-native/sdks/hermes
cp -r $HERMES_WS_DIR/hermes/* ./packages/react-native/sdks/hermes/.
cp -r ./packages/react-native/sdks/hermes-engine/utils ./packages/react-native/sdks/hermes/.
Circle CI: Reduce build_hermes_macos Hermes SDK cache size by 75% (#34886)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34886
## Reduced cache size
The `build_hermes_macos` job can spend over 20 minutes restoring cached build artifacts (over 5 GB), when only `build_macosx` and `destroot` are required to be cached: `build_macosx` as it may contain a pre-built `hermesc` from previous builds, and `destroot` which contains the artifacts for previous iOS/macOS builds.
This is the `build_hermes_macos` Restore Cache step, before the changes in this diff:
```
Found a cache from build 308044 at v1-hermes-build_hermes_macos-debug-PEiMHp9XQ13KtYFQMKoT27DmHkkoxOi_PJUyW7PacZE=
Size: 5.2 GiB
Cached paths:
* /Users/distiller/react-native/sdks/hermes/build_host_hermesc
* /Users/distiller/react-native/sdks/hermes/build_iphoneos
* /Users/distiller/react-native/sdks/hermes/build_catalyst
* /Users/distiller/react-native/sdks/hermes/build_iphonesimulator
* /Users/distiller/react-native/sdks/hermes/build_macosx
* /Users/distiller/react-native/sdks/hermes/destroot
Downloading cache archive...
Unarchiving cache...
```
Size: 5.2 GiB
Time to restore cache: 183s
This is the `build_hermes_macos` Restore Cache step, after the changes in this diff:
```
Found a cache from build 310128 at v2-hermes-build_hermes_macos-debug-e7WmoA0+mfveXq1zsMYpgR6BYqVuuDjmVeLLyjqPJWk=
Size: 1.3 GiB
Cached paths:
* /Users/distiller/react-native/sdks/hermes/build_macosx
* /Users/distiller/react-native/sdks/hermes/destroot
Downloading cache archive...
Unarchiving cache...
```
Size: 1.3 GiB
Time to restore cache: 42s
**This is a size reduction of 75%, and execution time reduction of 77%.**
This savings will apply to every workflow that runs afterwards until the Hermes cache is invalidated due to a new commit landing in `facebook/hermes`.
## Added `export_hermesc`
As part of the work mentioned above, a reusable `export_hermesc` command was added, which will export hermesc for use in downstream steps. Either of the macOS or iOS build scripts will generate this binary. As we now only cache the macOS build dir, that version is loaded from cache by default if available:
- If the cache contains hermesc, both the macOS and iOS builds will use it.
- If the cache does not contain hermesc, then the iOS job will use the hermesc that was built by the macOS job previously.
- The `export_hermesc` command will work regardless of the order of the Hermes build scripts
## Refactoring of magic strings into reusable yaml references
Some additional changes to the Circle CI config were done in order to reduce repetition of artifacts/cache paths that are re-used across workflows.
Changelog: [Internal]
Reviewed By: cipolleschi
Differential Revision: D40153737
fbshipit-source-id: b9f07302ccc9bac1ce72a09b944d3210e6db2ec1
2022-10-12 16:55:31 +00:00
2023-08-04 15:15:55 +00:00
with_xcodebuild_cache :
description : "Add caching to iOS jobs to speed up builds"
parameters :
steps :
type : steps
podfile_lock_path :
type : string
default : packages/rn-tester/Podfile.lock
pods_build_folder :
type : string
default : packages/rn-tester/Pods
podfile_lock_cache_key :
type : string
default : *rntester_podfile_lock_cache_key
cocoapods_cache_key :
type : string
default : *cocoapods_cache_key
steps :
- run :
name : Prepare Xcodebuild cache
command : |
WEEK=$(date +"%U")
YEAR=$(date +"%Y")
echo "$WEEK-$YEAR" > /tmp/week_year
- restore_cache :
key : << parameters.podfile_lock_cache_key >>
- restore_cache :
key : << parameters.cocoapods_cache_key >>
- steps : << parameters.steps >>
- save_cache :
key : << parameters.podfile_lock_cache_key >>
paths :
- << parameters.podfile_lock_path >>
- save_cache :
key : << parameters.cocoapods_cache_key >>
paths :
- << parameters.pods_build_folder >>
2019-02-24 01:01:34 +00:00
# -------------------------
# JOBS
# -------------------------
2017-09-21 20:34:02 +00:00
jobs :
2019-02-24 01:01:34 +00:00
# -------------------------
# JOBS: Analyze PR
# -------------------------
# Analyze pull request and raise any lint/flow issues.
# Issues will be posted to the PR itself via GitHub bots.
# This workflow should only fail if the bots fail to run.
analyze_pr :
2023-08-07 19:06:02 +00:00
executor : node-browsers-small
2019-02-24 01:01:34 +00:00
steps :
2022-08-23 13:43:01 +00:00
- checkout
2019-05-30 22:07:45 +00:00
- run_yarn
2019-02-24 01:01:34 +00:00
- run :
2019-05-22 02:35:40 +00:00
name : Run linters against modified files (analysis-bot)
command : GITHUB_TOKEN="$PUBLIC_ANALYSISBOT_GITHUB_TOKEN_A""$PUBLIC_ANALYSISBOT_GITHUB_TOKEN_B" yarn lint-ci
2019-02-24 01:01:34 +00:00
# -------------------------
# JOBS: Analyze Code
# -------------------------
2019-05-30 22:07:45 +00:00
analyze_code :
2023-08-07 19:06:02 +00:00
executor : node-browsers-small
2018-02-08 22:57:36 +00:00
steps :
2022-08-23 13:43:01 +00:00
- checkout
2019-05-30 22:07:45 +00:00
- setup_artifacts
- run_yarn
2018-02-08 22:57:36 +00:00
2019-02-24 01:01:34 +00:00
- run :
name : Lint code
2019-12-20 00:53:54 +00:00
command : scripts/circleci/exec_swallow_error.sh yarn lint --format junit -o ./reports/junit/eslint/results.xml
2019-04-12 16:50:13 +00:00
when : always
2019-02-24 01:01:34 +00:00
2020-12-07 11:10:46 +00:00
- run :
name : Lint Java
command : scripts/circleci/exec_swallow_error.sh yarn lint-java --check
when : always
2023-08-07 19:06:02 +00:00
- run :
name : Set server.max_workers=1 in .flowconfig
command : |
sed -i '/\[options\]/a server.max_workers=1' .flowconfig
sed -i '/\[options\]/a server.max_workers=1' .flowconfig.android
when : always
2019-04-09 23:03:21 +00:00
- run :
2019-02-24 01:01:34 +00:00
name : Check for errors in code using Flow (iOS)
command : yarn flow-check-ios
when : always
2019-04-09 23:03:21 +00:00
- run :
2019-02-24 01:01:34 +00:00
name : Check for errors in code using Flow (Android)
command : yarn flow-check-android
when : always
2022-09-19 19:26:00 +00:00
- run :
name : Run TypeScript tests
command : yarn test-typescript
when : always
2019-02-24 01:01:34 +00:00
- run :
name : Sanity checks
command : |
./scripts/circleci/check_license.sh
./scripts/circleci/validate_yarn_lockfile.sh
when : always
2017-09-21 20:34:02 +00:00
2019-04-12 16:50:13 +00:00
- run :
name : Check formatting
command : yarn run format-check
when : always
2018-02-01 01:08:06 +00:00
- store_test_results :
2019-12-20 00:53:54 +00:00
path : ./reports/junit
2018-02-01 01:08:06 +00:00
2019-02-24 01:01:34 +00:00
# -------------------------
# JOBS: Test JavaScript
# -------------------------
2019-05-30 22:07:45 +00:00
test_js :
parameters :
executor :
type : executor
2020-02-14 07:11:41 +00:00
default : nodelts
✅ Green CI: Fix JavaScript e2e tests, disable failing Android e2e test (#28392)
Summary:
Jobs now have a `run_disabled_tests` argument that allows for the selective execution of disabled tests. When working on re-enabling a failing test, the contributor just needs to set `run_disabled_tests` to `true` in the appropriate workflow in `.circleci/config.yml`.
Tests can be kept green by moving failing tests into the disabled section until a contributor can provide a fix, thus ensuring signal is maintained on master. For example, a failing end-to-end test might be disabled in order to allow the signal from unit tests to be provided, as opposed to flat out failing the entire job.
What was done in this PR:
* The failing `test_js_e2e` job has been fixed, and merged into the `test_js` job. An empty disabled tests section is added for future use.
* The failing `test_ios_e2e` job has been merged into `test_ios`, with all of its steps gated behind the `run_disabled_steps` argument.
* The failing Android end-to-end tests have been added to `test_android`, gated behind the `run_disabled_steps` argument
* The failing Podspecs test has been added back into `test_ios`, gated behind the `run_disabled_steps` argument
## Changelog
[Internal] [CI] - ✅ Green CI, disabled test infrastructure work
Pull Request resolved: https://github.com/facebook/react-native/pull/28392
Test Plan: Verified on Circle CI
Reviewed By: cpojer
Differential Revision: D20665512
Pulled By: hramos
fbshipit-source-id: 831738027f90f4b23313893d8342d7e654f34726
2020-03-26 13:49:03 +00:00
run_disabled_tests :
type : boolean
default : false
2019-05-30 22:07:45 +00:00
executor : << parameters.executor >>
2017-09-21 20:34:02 +00:00
steps :
2022-08-23 13:43:01 +00:00
- checkout
2019-05-30 22:07:45 +00:00
- setup_artifacts
- run_yarn
✅ Green CI: Fix JavaScript e2e tests, disable failing Android e2e test (#28392)
Summary:
Jobs now have a `run_disabled_tests` argument that allows for the selective execution of disabled tests. When working on re-enabling a failing test, the contributor just needs to set `run_disabled_tests` to `true` in the appropriate workflow in `.circleci/config.yml`.
Tests can be kept green by moving failing tests into the disabled section until a contributor can provide a fix, thus ensuring signal is maintained on master. For example, a failing end-to-end test might be disabled in order to allow the signal from unit tests to be provided, as opposed to flat out failing the entire job.
What was done in this PR:
* The failing `test_js_e2e` job has been fixed, and merged into the `test_js` job. An empty disabled tests section is added for future use.
* The failing `test_ios_e2e` job has been merged into `test_ios`, with all of its steps gated behind the `run_disabled_steps` argument.
* The failing Android end-to-end tests have been added to `test_android`, gated behind the `run_disabled_steps` argument
* The failing Podspecs test has been added back into `test_ios`, gated behind the `run_disabled_steps` argument
## Changelog
[Internal] [CI] - ✅ Green CI, disabled test infrastructure work
Pull Request resolved: https://github.com/facebook/react-native/pull/28392
Test Plan: Verified on Circle CI
Reviewed By: cpojer
Differential Revision: D20665512
Pulled By: hramos
fbshipit-source-id: 831738027f90f4b23313893d8342d7e654f34726
2020-03-26 13:49:03 +00:00
- run :
name : Install rsync
2022-04-11 16:39:10 +00:00
command : sudo apt update && sudo apt install rsync
2019-02-24 01:01:34 +00:00
2020-04-01 00:36:31 +00:00
# -------------------------
# Run JavaScript tests
2019-04-12 16:50:13 +00:00
- run :
✅ Green CI: Fix JavaScript e2e tests, disable failing Android e2e test (#28392)
Summary:
Jobs now have a `run_disabled_tests` argument that allows for the selective execution of disabled tests. When working on re-enabling a failing test, the contributor just needs to set `run_disabled_tests` to `true` in the appropriate workflow in `.circleci/config.yml`.
Tests can be kept green by moving failing tests into the disabled section until a contributor can provide a fix, thus ensuring signal is maintained on master. For example, a failing end-to-end test might be disabled in order to allow the signal from unit tests to be provided, as opposed to flat out failing the entire job.
What was done in this PR:
* The failing `test_js_e2e` job has been fixed, and merged into the `test_js` job. An empty disabled tests section is added for future use.
* The failing `test_ios_e2e` job has been merged into `test_ios`, with all of its steps gated behind the `run_disabled_steps` argument.
* The failing Android end-to-end tests have been added to `test_android`, gated behind the `run_disabled_steps` argument
* The failing Podspecs test has been added back into `test_ios`, gated behind the `run_disabled_steps` argument
## Changelog
[Internal] [CI] - ✅ Green CI, disabled test infrastructure work
Pull Request resolved: https://github.com/facebook/react-native/pull/28392
Test Plan: Verified on Circle CI
Reviewed By: cpojer
Differential Revision: D20665512
Pulled By: hramos
fbshipit-source-id: 831738027f90f4b23313893d8342d7e654f34726
2020-03-26 13:49:03 +00:00
name : "Run Tests: JavaScript Tests"
2019-04-12 16:50:13 +00:00
command : node ./scripts/run-ci-javascript-tests.js --maxWorkers 2
2020-04-01 00:36:31 +00:00
- run_e2e :
platform : js
2019-02-24 01:01:34 +00:00
✅ Green CI: Fix JavaScript e2e tests, disable failing Android e2e test (#28392)
Summary:
Jobs now have a `run_disabled_tests` argument that allows for the selective execution of disabled tests. When working on re-enabling a failing test, the contributor just needs to set `run_disabled_tests` to `true` in the appropriate workflow in `.circleci/config.yml`.
Tests can be kept green by moving failing tests into the disabled section until a contributor can provide a fix, thus ensuring signal is maintained on master. For example, a failing end-to-end test might be disabled in order to allow the signal from unit tests to be provided, as opposed to flat out failing the entire job.
What was done in this PR:
* The failing `test_js_e2e` job has been fixed, and merged into the `test_js` job. An empty disabled tests section is added for future use.
* The failing `test_ios_e2e` job has been merged into `test_ios`, with all of its steps gated behind the `run_disabled_steps` argument.
* The failing Android end-to-end tests have been added to `test_android`, gated behind the `run_disabled_steps` argument
* The failing Podspecs test has been added back into `test_ios`, gated behind the `run_disabled_steps` argument
## Changelog
[Internal] [CI] - ✅ Green CI, disabled test infrastructure work
Pull Request resolved: https://github.com/facebook/react-native/pull/28392
Test Plan: Verified on Circle CI
Reviewed By: cpojer
Differential Revision: D20665512
Pulled By: hramos
fbshipit-source-id: 831738027f90f4b23313893d8342d7e654f34726
2020-03-26 13:49:03 +00:00
# Optionally, run disabled tests
- when :
condition : << parameters.run_disabled_tests >>
steps :
2020-04-01 00:36:31 +00:00
- run : echo "Failing tests may be moved here temporarily."
# -------------------------
✅ Green CI: Fix JavaScript e2e tests, disable failing Android e2e test (#28392)
Summary:
Jobs now have a `run_disabled_tests` argument that allows for the selective execution of disabled tests. When working on re-enabling a failing test, the contributor just needs to set `run_disabled_tests` to `true` in the appropriate workflow in `.circleci/config.yml`.
Tests can be kept green by moving failing tests into the disabled section until a contributor can provide a fix, thus ensuring signal is maintained on master. For example, a failing end-to-end test might be disabled in order to allow the signal from unit tests to be provided, as opposed to flat out failing the entire job.
What was done in this PR:
* The failing `test_js_e2e` job has been fixed, and merged into the `test_js` job. An empty disabled tests section is added for future use.
* The failing `test_ios_e2e` job has been merged into `test_ios`, with all of its steps gated behind the `run_disabled_steps` argument.
* The failing Android end-to-end tests have been added to `test_android`, gated behind the `run_disabled_steps` argument
* The failing Podspecs test has been added back into `test_ios`, gated behind the `run_disabled_steps` argument
## Changelog
[Internal] [CI] - ✅ Green CI, disabled test infrastructure work
Pull Request resolved: https://github.com/facebook/react-native/pull/28392
Test Plan: Verified on Circle CI
Reviewed By: cpojer
Differential Revision: D20665512
Pulled By: hramos
fbshipit-source-id: 831738027f90f4b23313893d8342d7e654f34726
2020-03-26 13:49:03 +00:00
2018-08-21 00:31:59 +00:00
- store_test_results :
2019-12-20 00:53:54 +00:00
path : ./reports/junit
✅ Green CI: Fix JavaScript e2e tests, disable failing Android e2e test (#28392)
Summary:
Jobs now have a `run_disabled_tests` argument that allows for the selective execution of disabled tests. When working on re-enabling a failing test, the contributor just needs to set `run_disabled_tests` to `true` in the appropriate workflow in `.circleci/config.yml`.
Tests can be kept green by moving failing tests into the disabled section until a contributor can provide a fix, thus ensuring signal is maintained on master. For example, a failing end-to-end test might be disabled in order to allow the signal from unit tests to be provided, as opposed to flat out failing the entire job.
What was done in this PR:
* The failing `test_js_e2e` job has been fixed, and merged into the `test_js` job. An empty disabled tests section is added for future use.
* The failing `test_ios_e2e` job has been merged into `test_ios`, with all of its steps gated behind the `run_disabled_steps` argument.
* The failing Android end-to-end tests have been added to `test_android`, gated behind the `run_disabled_steps` argument
* The failing Podspecs test has been added back into `test_ios`, gated behind the `run_disabled_steps` argument
## Changelog
[Internal] [CI] - ✅ Green CI, disabled test infrastructure work
Pull Request resolved: https://github.com/facebook/react-native/pull/28392
Test Plan: Verified on Circle CI
Reviewed By: cpojer
Differential Revision: D20665512
Pulled By: hramos
fbshipit-source-id: 831738027f90f4b23313893d8342d7e654f34726
2020-03-26 13:49:03 +00:00
2022-04-02 07:02:11 +00:00
# -------------------------
# JOBS: iOS Unit Tests
2019-02-24 01:01:34 +00:00
# -------------------------
2022-04-28 15:53:24 +00:00
test_ios :
2019-05-30 22:07:45 +00:00
executor : reactnativeios
2019-07-25 18:42:49 +00:00
parameters :
2020-04-01 00:36:31 +00:00
run_unit_tests :
description : Specifies whether unit tests should run.
type : boolean
default : false
✅ Green CI: Fix JavaScript e2e tests, disable failing Android e2e test (#28392)
Summary:
Jobs now have a `run_disabled_tests` argument that allows for the selective execution of disabled tests. When working on re-enabling a failing test, the contributor just needs to set `run_disabled_tests` to `true` in the appropriate workflow in `.circleci/config.yml`.
Tests can be kept green by moving failing tests into the disabled section until a contributor can provide a fix, thus ensuring signal is maintained on master. For example, a failing end-to-end test might be disabled in order to allow the signal from unit tests to be provided, as opposed to flat out failing the entire job.
What was done in this PR:
* The failing `test_js_e2e` job has been fixed, and merged into the `test_js` job. An empty disabled tests section is added for future use.
* The failing `test_ios_e2e` job has been merged into `test_ios`, with all of its steps gated behind the `run_disabled_steps` argument.
* The failing Android end-to-end tests have been added to `test_android`, gated behind the `run_disabled_steps` argument
* The failing Podspecs test has been added back into `test_ios`, gated behind the `run_disabled_steps` argument
## Changelog
[Internal] [CI] - ✅ Green CI, disabled test infrastructure work
Pull Request resolved: https://github.com/facebook/react-native/pull/28392
Test Plan: Verified on Circle CI
Reviewed By: cpojer
Differential Revision: D20665512
Pulled By: hramos
fbshipit-source-id: 831738027f90f4b23313893d8342d7e654f34726
2020-03-26 13:49:03 +00:00
run_disabled_tests :
2020-04-01 00:36:31 +00:00
description : Specifies whether disabled tests should run. Set this to true to debug failing tests.
✅ Green CI: Fix JavaScript e2e tests, disable failing Android e2e test (#28392)
Summary:
Jobs now have a `run_disabled_tests` argument that allows for the selective execution of disabled tests. When working on re-enabling a failing test, the contributor just needs to set `run_disabled_tests` to `true` in the appropriate workflow in `.circleci/config.yml`.
Tests can be kept green by moving failing tests into the disabled section until a contributor can provide a fix, thus ensuring signal is maintained on master. For example, a failing end-to-end test might be disabled in order to allow the signal from unit tests to be provided, as opposed to flat out failing the entire job.
What was done in this PR:
* The failing `test_js_e2e` job has been fixed, and merged into the `test_js` job. An empty disabled tests section is added for future use.
* The failing `test_ios_e2e` job has been merged into `test_ios`, with all of its steps gated behind the `run_disabled_steps` argument.
* The failing Android end-to-end tests have been added to `test_android`, gated behind the `run_disabled_steps` argument
* The failing Podspecs test has been added back into `test_ios`, gated behind the `run_disabled_steps` argument
## Changelog
[Internal] [CI] - ✅ Green CI, disabled test infrastructure work
Pull Request resolved: https://github.com/facebook/react-native/pull/28392
Test Plan: Verified on Circle CI
Reviewed By: cpojer
Differential Revision: D20665512
Pulled By: hramos
fbshipit-source-id: 831738027f90f4b23313893d8342d7e654f34726
2020-03-26 13:49:03 +00:00
type : boolean
default : false
2022-10-12 22:23:55 +00:00
jsengine :
default : "Hermes"
description : Which JavaScript engine to use. Must be one of "Hermes", "JSC".
type : enum
enum : [ "Hermes" , "JSC" ]
2023-03-06 10:56:26 +00:00
ruby_version :
default : "2.6.10"
description : The version of ruby that must be used
type : string
2019-04-24 16:26:56 +00:00
environment :
2019-12-20 00:53:54 +00:00
- REPORTS_DIR : "./reports/junit"
2017-10-13 23:11:53 +00:00
steps :
2022-05-18 14:43:51 +00:00
- checkout_code_with_cache
2019-05-30 22:07:45 +00:00
- setup_artifacts
2023-03-06 10:56:26 +00:00
- setup_ruby :
ruby_version : << parameters.ruby_version >>
2023-02-15 12:20:20 +00:00
- brew_install :
package : xcbeautify
2022-05-03 14:11:54 +00:00
- run :
name : Run Ruby Tests
command : |
2023-04-02 10:32:15 +00:00
cd packages/react-native/scripts
2022-05-11 17:00:28 +00:00
sh run_ruby_tests.sh
2019-05-30 22:07:45 +00:00
- run_yarn
2022-08-03 10:34:29 +00:00
- *attach_hermes_workspace
2019-06-29 02:12:42 +00:00
- run : |
2020-08-20 00:54:30 +00:00
cd packages/rn-tester
2019-06-29 02:12:42 +00:00
bundle check || bundle install
2019-02-24 01:01:34 +00:00
- run :
2019-06-29 02:12:42 +00:00
name : Boot iPhone Simulator
command : source scripts/.tests.env && xcrun simctl boot "$IOS_DEVICE" || true
2019-04-24 16:26:56 +00:00
- run :
✅ Green CI: Fix JavaScript e2e tests, disable failing Android e2e test (#28392)
Summary:
Jobs now have a `run_disabled_tests` argument that allows for the selective execution of disabled tests. When working on re-enabling a failing test, the contributor just needs to set `run_disabled_tests` to `true` in the appropriate workflow in `.circleci/config.yml`.
Tests can be kept green by moving failing tests into the disabled section until a contributor can provide a fix, thus ensuring signal is maintained on master. For example, a failing end-to-end test might be disabled in order to allow the signal from unit tests to be provided, as opposed to flat out failing the entire job.
What was done in this PR:
* The failing `test_js_e2e` job has been fixed, and merged into the `test_js` job. An empty disabled tests section is added for future use.
* The failing `test_ios_e2e` job has been merged into `test_ios`, with all of its steps gated behind the `run_disabled_steps` argument.
* The failing Android end-to-end tests have been added to `test_android`, gated behind the `run_disabled_steps` argument
* The failing Podspecs test has been added back into `test_ios`, gated behind the `run_disabled_steps` argument
## Changelog
[Internal] [CI] - ✅ Green CI, disabled test infrastructure work
Pull Request resolved: https://github.com/facebook/react-native/pull/28392
Test Plan: Verified on Circle CI
Reviewed By: cpojer
Differential Revision: D20665512
Pulled By: hramos
fbshipit-source-id: 831738027f90f4b23313893d8342d7e654f34726
2020-03-26 13:49:03 +00:00
name : Configure Environment Variables
2019-06-29 02:12:42 +00:00
command : |
2022-11-25 14:44:21 +00:00
echo 'export PATH=/usr/local/opt/node@18/bin:$PATH' >> $BASH_ENV
✅ Green CI: Fix JavaScript e2e tests, disable failing Android e2e test (#28392)
Summary:
Jobs now have a `run_disabled_tests` argument that allows for the selective execution of disabled tests. When working on re-enabling a failing test, the contributor just needs to set `run_disabled_tests` to `true` in the appropriate workflow in `.circleci/config.yml`.
Tests can be kept green by moving failing tests into the disabled section until a contributor can provide a fix, thus ensuring signal is maintained on master. For example, a failing end-to-end test might be disabled in order to allow the signal from unit tests to be provided, as opposed to flat out failing the entire job.
What was done in this PR:
* The failing `test_js_e2e` job has been fixed, and merged into the `test_js` job. An empty disabled tests section is added for future use.
* The failing `test_ios_e2e` job has been merged into `test_ios`, with all of its steps gated behind the `run_disabled_steps` argument.
* The failing Android end-to-end tests have been added to `test_android`, gated behind the `run_disabled_steps` argument
* The failing Podspecs test has been added back into `test_ios`, gated behind the `run_disabled_steps` argument
## Changelog
[Internal] [CI] - ✅ Green CI, disabled test infrastructure work
Pull Request resolved: https://github.com/facebook/react-native/pull/28392
Test Plan: Verified on Circle CI
Reviewed By: cpojer
Differential Revision: D20665512
Pulled By: hramos
fbshipit-source-id: 831738027f90f4b23313893d8342d7e654f34726
2020-03-26 13:49:03 +00:00
source $BASH_ENV
2019-04-24 16:26:56 +00:00
2022-05-13 17:51:41 +00:00
- run :
name : "Brew: Tap wix/brew"
2023-02-17 13:43:22 +00:00
command : brew tap wix/brew
2022-05-13 17:51:41 +00:00
- brew_install :
2022-10-12 22:23:55 +00:00
package : applesimutils watchman
2019-05-31 23:42:18 +00:00
2019-07-11 18:54:38 +00:00
- run :
✅ Green CI: Fix JavaScript e2e tests, disable failing Android e2e test (#28392)
Summary:
Jobs now have a `run_disabled_tests` argument that allows for the selective execution of disabled tests. When working on re-enabling a failing test, the contributor just needs to set `run_disabled_tests` to `true` in the appropriate workflow in `.circleci/config.yml`.
Tests can be kept green by moving failing tests into the disabled section until a contributor can provide a fix, thus ensuring signal is maintained on master. For example, a failing end-to-end test might be disabled in order to allow the signal from unit tests to be provided, as opposed to flat out failing the entire job.
What was done in this PR:
* The failing `test_js_e2e` job has been fixed, and merged into the `test_js` job. An empty disabled tests section is added for future use.
* The failing `test_ios_e2e` job has been merged into `test_ios`, with all of its steps gated behind the `run_disabled_steps` argument.
* The failing Android end-to-end tests have been added to `test_android`, gated behind the `run_disabled_steps` argument
* The failing Podspecs test has been added back into `test_ios`, gated behind the `run_disabled_steps` argument
## Changelog
[Internal] [CI] - ✅ Green CI, disabled test infrastructure work
Pull Request resolved: https://github.com/facebook/react-native/pull/28392
Test Plan: Verified on Circle CI
Reviewed By: cpojer
Differential Revision: D20665512
Pulled By: hramos
fbshipit-source-id: 831738027f90f4b23313893d8342d7e654f34726
2020-03-26 13:49:03 +00:00
name : Configure Watchman
2021-10-01 03:23:45 +00:00
command : echo "{}" > .watchmanconfig
2019-07-11 18:54:38 +00:00
2020-07-10 14:13:17 +00:00
- run :
2020-04-01 00:36:31 +00:00
name : Setup the CocoaPods environment
2023-03-06 10:56:26 +00:00
command : |
bundle exec pod setup
2020-04-01 00:36:31 +00:00
2022-07-20 16:12:47 +00:00
- with_hermes_tarball_cache_span :
2022-08-23 13:43:01 +00:00
set_tarball_path : True
2020-04-01 00:36:31 +00:00
steps :
2022-05-13 19:51:09 +00:00
- with_rntester_pods_cache_span :
steps :
- run :
name : Generate RNTesterPods Workspace
2022-10-12 22:23:55 +00:00
command : |
if [[ << parameters.jsengine >> == "JSC" ]]; then
export USE_HERMES=0
fi
2023-02-28 15:14:02 +00:00
cd packages/rn-tester
bundle install
bundle exec pod install --verbose
2020-02-13 06:18:46 +00:00
2020-04-01 00:36:31 +00:00
# -------------------------
# Runs iOS unit tests
- when :
condition : << parameters.run_unit_tests >>
steps :
2020-07-10 14:13:17 +00:00
- run :
2020-04-01 00:36:31 +00:00
name : "Run Tests: iOS Unit and Integration Tests"
command : yarn test-ios
2022-08-03 10:34:29 +00:00
- run :
name : Zip Derived data folder
when : always
command : |
echo "zipping tests results"
cd /Users/distiller/Library/Developer/Xcode
XCRESULT_PATH=$(find . -name '*.xcresult')
tar -zcvf xcresults.tar.gz $XCRESULT_PATH
- store_artifacts :
path : /Users/distiller/Library/Developer/Xcode/xcresults.tar.gz
2017-10-13 23:11:53 +00:00
✅ Green CI: Fix JavaScript e2e tests, disable failing Android e2e test (#28392)
Summary:
Jobs now have a `run_disabled_tests` argument that allows for the selective execution of disabled tests. When working on re-enabling a failing test, the contributor just needs to set `run_disabled_tests` to `true` in the appropriate workflow in `.circleci/config.yml`.
Tests can be kept green by moving failing tests into the disabled section until a contributor can provide a fix, thus ensuring signal is maintained on master. For example, a failing end-to-end test might be disabled in order to allow the signal from unit tests to be provided, as opposed to flat out failing the entire job.
What was done in this PR:
* The failing `test_js_e2e` job has been fixed, and merged into the `test_js` job. An empty disabled tests section is added for future use.
* The failing `test_ios_e2e` job has been merged into `test_ios`, with all of its steps gated behind the `run_disabled_steps` argument.
* The failing Android end-to-end tests have been added to `test_android`, gated behind the `run_disabled_steps` argument
* The failing Podspecs test has been added back into `test_ios`, gated behind the `run_disabled_steps` argument
## Changelog
[Internal] [CI] - ✅ Green CI, disabled test infrastructure work
Pull Request resolved: https://github.com/facebook/react-native/pull/28392
Test Plan: Verified on Circle CI
Reviewed By: cpojer
Differential Revision: D20665512
Pulled By: hramos
fbshipit-source-id: 831738027f90f4b23313893d8342d7e654f34726
2020-03-26 13:49:03 +00:00
# Optionally, run disabled tests
- when :
condition : << parameters.run_disabled_tests >>
steps :
2020-04-01 00:36:31 +00:00
- run : echo "Failing tests may be moved here temporarily."
✅ Green CI: Fix JavaScript e2e tests, disable failing Android e2e test (#28392)
Summary:
Jobs now have a `run_disabled_tests` argument that allows for the selective execution of disabled tests. When working on re-enabling a failing test, the contributor just needs to set `run_disabled_tests` to `true` in the appropriate workflow in `.circleci/config.yml`.
Tests can be kept green by moving failing tests into the disabled section until a contributor can provide a fix, thus ensuring signal is maintained on master. For example, a failing end-to-end test might be disabled in order to allow the signal from unit tests to be provided, as opposed to flat out failing the entire job.
What was done in this PR:
* The failing `test_js_e2e` job has been fixed, and merged into the `test_js` job. An empty disabled tests section is added for future use.
* The failing `test_ios_e2e` job has been merged into `test_ios`, with all of its steps gated behind the `run_disabled_steps` argument.
* The failing Android end-to-end tests have been added to `test_android`, gated behind the `run_disabled_steps` argument
* The failing Podspecs test has been added back into `test_ios`, gated behind the `run_disabled_steps` argument
## Changelog
[Internal] [CI] - ✅ Green CI, disabled test infrastructure work
Pull Request resolved: https://github.com/facebook/react-native/pull/28392
Test Plan: Verified on Circle CI
Reviewed By: cpojer
Differential Revision: D20665512
Pulled By: hramos
fbshipit-source-id: 831738027f90f4b23313893d8342d7e654f34726
2020-03-26 13:49:03 +00:00
- run :
name : "Run Tests: CocoaPods"
command : ./scripts/process-podspecs.sh
- run :
name : Free up port 8081 for iOS End-to-End Tests
command : |
# free up port 8081 for the packager before running tests
set +eo pipefail
lsof -i tcp:8081 | awk 'NR!=1 {print $2}' | xargs kill
set -eo pipefail
2020-04-01 00:36:31 +00:00
- run_e2e :
platform : ios
# -------------------------
2019-05-30 22:07:45 +00:00
2020-04-01 00:36:31 +00:00
# Collect Results
- report_bundle_size :
platform : ios
2019-05-30 22:07:45 +00:00
- store_test_results :
2019-12-20 00:53:54 +00:00
path : ./reports/junit
2019-05-30 22:07:45 +00:00
2019-02-24 01:01:34 +00:00
# -------------------------
2023-07-26 14:23:31 +00:00
# JOBS: iOS E2E Tests
# -------------------------
test_e2e_ios :
executor : reactnativeios
parameters :
ruby_version :
default : "2.7.7"
description : The version of ruby that must be used
type : string
steps :
- checkout_code_with_cache
- run_yarn
- attach_workspace :
at : .
- run :
name : Install appium
command : npm install appium@2.0.0 -g
- run :
name : Install appium drivers
command : |
appium driver install uiautomator2
appium driver install xcuitest
- run :
name : Start Appium server
command : appium --base-path /wd/hub
background : true
- run :
name : Start Metro
command : |
cd packages/rn-tester
yarn start
background : true
- brew_install :
package : cmake
- setup_ruby :
ruby_version : << parameters.ruby_version >>
- run :
name : Install Bundler
command : |
cd packages/rn-tester
bundle check || bundle install
bundle exec pod setup
2023-08-07 14:01:03 +00:00
RCT_NEW_ARCH_ENABLED=1 bundle exec pod install --verbose
2023-07-26 14:23:31 +00:00
- run :
name : Boot iOS Simulator
command : source scripts/.tests.env && xcrun simctl boot "$IOS_DEVICE" || true
- run :
name : Build app
command : |
xcodebuild build \
-workspace packages/rn-tester/RNTesterPods.xcworkspace \
-configuration Debug \
-scheme RNTester \
-sdk iphonesimulator \
-derivedDataPath /tmp/e2e/
- run :
name : Move app to correct directory
command : mv /tmp/e2e/Build/Products/Debug-iphonesimulator/RNTester.app packages/rn-tester-e2e/apps/rn-tester.app
- run :
name : Check Appium server status
2023-08-01 04:36:49 +00:00
command : scripts/circleci/check_appium_server_status.sh
2023-07-26 14:23:31 +00:00
- run :
name : Run E2E tests
command : |
cd packages/rn-tester-e2e
2023-08-02 10:38:08 +00:00
yarn test-e2e ios
2023-07-26 14:23:31 +00:00
# -------------------------
# JOBS: Android E2E Tests
# -------------------------
test_e2e_android :
executor :
name : android/android-machine
tag : 2023.07 .1
steps :
- checkout_code_with_cache
- run_yarn
- android/create-avd :
avd-name : e2e_emulator
system-image : system-images;android-33;google_apis;x86_64
install : true
- android/start-emulator :
avd-name : e2e_emulator
no-window : true
restore-gradle-cache-prefix : v1a
post-emulator-launch-assemble-command : ""
- run :
name : Install appium
command : npm install appium@2.0.0 -g
- run :
name : Install appium drivers
command : |
appium driver install uiautomator2
appium driver install xcuitest
- run :
name : Start Appium server
command : appium --base-path /wd/hub
background : true
- run :
name : Start Metro
command : |
cd packages/rn-tester
yarn start
background : true
- attach_workspace :
at : .
- run :
name : Build app
command : |
./gradlew :packages:rn-tester:android:app:assembleHermesDebug -PreactNativeArchitectures=x86_64
- run :
name : Move app to correct directory
command : mv packages/rn-tester/android/app/build/outputs/apk/hermes/debug/app-hermes-x86_64-debug.apk packages/rn-tester-e2e/apps/rn-tester.apk
- run :
name : Check Appium server status
command : |
if ! nc -z 127.0.0.1 4723; then
echo Could not find Appium server
exit 1
fi
- run :
name : Run E2E tests
command : |
cd packages/rn-tester-e2e
2023-08-02 10:38:08 +00:00
yarn test-e2e android
2023-07-26 14:23:31 +00:00
# -------------------------
2019-02-24 01:01:34 +00:00
# JOBS: Test Android
# -------------------------
2018-02-08 22:57:36 +00:00
test_android :
2019-05-30 22:07:45 +00:00
executor : reactnativeandroid
2017-09-21 20:34:02 +00:00
steps :
2022-08-23 13:43:01 +00:00
- checkout
2019-05-30 22:07:45 +00:00
- setup_artifacts
- run_yarn
- download_gradle_dependencies
2017-12-22 19:07:48 +00:00
2022-05-16 16:27:54 +00:00
- run :
name : Build & Test React Native using Gradle
2023-03-17 17:26:34 +00:00
command : ./gradlew build
2022-05-16 16:27:54 +00:00
2022-08-11 09:46:00 +00:00
- report_bundle_size :
platform : android
2019-04-09 23:03:21 +00:00
2023-05-05 14:01:00 +00:00
- store_test_results :
path : ~/react-native/packages/react-native-gradle-plugin/build/test-results
2023-05-23 10:34:20 +00:00
2023-05-05 14:01:00 +00:00
- store_test_results :
path : ~/react-native/packages/react-native/ReactAndroid/build/test-results
2022-11-24 18:21:57 +00:00
- store_artifacts :
path : ~/react-native/packages/rn-tester/android/app/build/outputs/apk/
destination : rntester-apk
2021-09-24 08:02:07 +00:00
# -------------------------
# JOBS: Test Android Template
# -------------------------
test_android_template :
executor : reactnativeandroid
2022-08-08 11:44:48 +00:00
parameters :
flavor :
default : "Debug"
2022-10-13 20:03:45 +00:00
description : The Android build type. Must be one of "Debug", "Release".
type : enum
enum : [ "Debug" , "Release" ]
2022-10-27 21:40:27 +00:00
architecture :
default : "OldArch"
description : Which React Native architecture to use. Must be one of "NewArch", "OldArch".
type : enum
enum : [ "NewArch" , "OldArch" ]
2022-09-12 19:33:07 +00:00
jsengine :
default : "Hermes"
2022-10-13 20:03:45 +00:00
description : Which JavaScript engine to use. Must be one of "Hermes", "JSC".
type : enum
enum : [ "Hermes" , "JSC" ]
2022-08-08 11:44:48 +00:00
environment :
- PROJECT_NAME : "AndroidTemplateProject"
2021-09-24 08:02:07 +00:00
steps :
2022-08-08 11:44:48 +00:00
- checkout_code_with_cache
2021-09-24 08:02:07 +00:00
- run_yarn
2022-02-09 16:23:43 +00:00
- attach_workspace :
at : .
2021-09-24 08:02:07 +00:00
- run :
2022-02-09 16:23:43 +00:00
name : Create Android template project
2021-09-24 08:02:07 +00:00
command : |
2022-02-09 16:23:43 +00:00
REPO_ROOT=$(pwd)
2023-06-12 21:34:52 +00:00
node ./scripts/update-template-package.js "{\"react-native\":\"file:$REPO_ROOT/build/$(cat build/react-native-package-version)\"}"
2023-03-17 12:03:25 +00:00
node ./scripts/template/initialize.js --reactNativeRootPath $REPO_ROOT --templateName $PROJECT_NAME --templateConfigPath "$REPO_ROOT/packages/react-native" --directory "/tmp/$PROJECT_NAME"
2021-09-24 08:02:07 +00:00
- run :
2022-10-27 21:40:27 +00:00
name : Build the template application for << parameters.flavor >> with Architecture set to << parameters.architecture >>, and using the << parameters.jsengine>> JS engine.
2022-10-25 20:13:14 +00:00
command : |
cd /tmp/$PROJECT_NAME/android/
2022-10-27 21:40:27 +00:00
if [[ << parameters.architecture >> == "NewArch" ]]; then
export ORG_GRADLE_PROJECT_newArchEnabled=true
else
export ORG_GRADLE_PROJECT_newArchEnabled=false
fi
if [[ << parameters.jsengine >> == "Hermes" ]]; then
export ORG_GRADLE_PROJECT_hermesEnabled=true
else
export ORG_GRADLE_PROJECT_hermesEnabled=false
fi
./gradlew assemble<< parameters.flavor >> -PREACT_NATIVE_MAVEN_LOCAL_REPO=/root/react-native/maven-local
2021-09-24 08:02:07 +00:00
2022-11-24 18:21:57 +00:00
- store_artifacts :
2023-06-20 17:26:47 +00:00
path : /tmp/AndroidTemplateProject/android/app/build/outputs/apk/
2022-11-24 18:21:57 +00:00
destination : template-apk
2021-10-28 22:46:53 +00:00
# -------------------------
# JOBS: Test iOS Template
# -------------------------
test_ios_template :
executor : reactnativeios
2022-08-31 15:54:06 +00:00
parameters :
flavor :
default : "Debug"
2022-10-13 20:03:45 +00:00
description : The Xcode build type. Must be one of "Debug", "Release".
type : enum
enum : [ "Debug" , "Release" ]
2022-08-31 15:54:06 +00:00
architecture :
default : "OldArch"
2022-10-13 20:03:45 +00:00
description : Which React Native architecture to use. Must be one of "NewArch", "OldArch".
type : enum
enum : [ "NewArch" , "OldArch" ]
2022-08-31 15:54:06 +00:00
jsengine :
default : "Hermes"
2022-10-13 20:03:45 +00:00
description : Which JavaScript engine to use. Must be one of "Hermes", "JSC".
type : enum
enum : [ "Hermes" , "JSC" ]
2022-09-06 10:25:45 +00:00
flipper :
default : "WithFlipper"
2022-10-13 20:03:45 +00:00
description : Whether Flipper is enabled. Must be one of "WithFlipper", "WithoutFlipper".
type : enum
enum : [ "WithFlipper" , "WithoutFlipper" ]
2022-11-29 16:53:50 +00:00
use_frameworks :
default : "StaticLibraries"
description : Which kind of option we want to use for `use_frameworks!`
type : enum
2023-07-25 10:14:56 +00:00
enum : [ "StaticLibraries" , "DynamicFrameworks" ]
2023-03-06 10:56:26 +00:00
ruby_version :
default : "2.6.10"
description : The version of ruby that must be used
type : string
2023-08-04 15:15:55 +00:00
podfile_lock_path :
type : string
default : "/tmp/iOSTemplateProject/ios/Podfile.lock"
pods_build_folder :
type : string
default : "/tmp/iOSTemplateProject/ios/Pods"
podfile_lock_cache_key :
type : string
default : *template_podfile_lock_cache_key
cocoapods_cache_key :
type : string
default : *template_cocoapods_cache_key
2021-10-28 22:46:53 +00:00
environment :
- PROJECT_NAME : "iOSTemplateProject"
2022-06-09 18:18:30 +00:00
- HERMES_WS_DIR : *hermes_workspace_root
2021-10-28 22:46:53 +00:00
steps :
2022-05-18 14:43:51 +00:00
- checkout_code_with_cache
2021-10-28 22:46:53 +00:00
- run_yarn
- attach_workspace :
at : .
2022-06-09 18:18:30 +00:00
- *attach_hermes_workspace
2023-03-06 10:56:26 +00:00
- setup_ruby :
ruby_version : << parameters.ruby_version >>
2022-08-31 15:54:06 +00:00
- when :
condition :
equal : [ "Hermes" , << parameters.jsengine >>]
steps :
- run :
name : Set HERMES_ENGINE_TARBALL_PATH
command : |
2022-11-14 16:31:30 +00:00
BUILD_TYPE="<< parameters.flavor >>"
2023-03-17 12:03:25 +00:00
TARBALL_FILENAME=$(node ./packages/react-native/scripts/hermes/get-tarball-name.js --buildType "$BUILD_TYPE")
2022-11-14 16:31:30 +00:00
echo "export HERMES_ENGINE_TARBALL_PATH=$HERMES_WS_DIR/hermes-runtime-darwin/$TARBALL_FILENAME" >> $BASH_ENV
2021-10-28 22:46:53 +00:00
- run :
name : Create iOS template project
command : |
REPO_ROOT=$(pwd)
PACKAGE=$(cat build/react-native-package-version)
PATH_TO_PACKAGE="$REPO_ROOT/build/$PACKAGE"
2023-06-12 21:34:52 +00:00
node ./scripts/update-template-package.js "{\"react-native\":\"file:$PATH_TO_PACKAGE\"}"
2023-03-17 12:03:25 +00:00
node ./scripts/template/initialize.js --reactNativeRootPath $REPO_ROOT --templateName $PROJECT_NAME --templateConfigPath "$REPO_ROOT/packages/react-native" --directory "/tmp/$PROJECT_NAME"
2023-08-04 15:15:55 +00:00
- with_xcodebuild_cache :
podfile_lock_path : << parameters.podfile_lock_path >>
pods_build_folder : << parameters.pods_build_folder >>
cocoapods_cache_key : << parameters.cocoapods_cache_key >>
podfile_lock_cache_key : << parameters.podfile_lock_cache_key >>
steps :
- run :
name : Install iOS dependencies - Configuration << parameters.flavor >>; New Architecture << parameters.architecture >>; JS Engine << parameters.jsengine>>; Flipper << parameters.flipper >>
command : |
cd /tmp/$PROJECT_NAME/ios
2022-08-31 15:54:06 +00:00
2023-08-04 15:15:55 +00:00
if [[ << parameters.architecture >> == "NewArch" ]]; then
export RCT_NEW_ARCH_ENABLED=1
fi
2022-08-31 15:54:06 +00:00
2023-08-04 15:15:55 +00:00
if [[ << parameters.jsengine >> == "JSC" ]]; then
export USE_HERMES=0
fi
2022-08-31 15:54:06 +00:00
2023-08-04 15:15:55 +00:00
if [[ << parameters.flipper >> == "WithoutFlipper" ]]; then
export NO_FLIPPER=1
fi
2022-09-06 10:25:45 +00:00
2023-08-04 15:15:55 +00:00
if [[ << parameters.use_frameworks >> == "DynamicFrameworks" ]]; then
export USE_FRAMEWORKS=dynamic
fi
2022-11-29 16:53:50 +00:00
2023-08-04 15:15:55 +00:00
cd ..
bundle install
bundle exec pod install --project-directory=ios
- run :
name : Build template project
command : |
xcodebuild build \
-configuration << parameters.flavor >> \
-workspace /tmp/$PROJECT_NAME/ios/$PROJECT_NAME.xcworkspace \
-scheme $PROJECT_NAME \
-sdk iphonesimulator
2021-10-28 22:46:53 +00:00
2022-02-03 19:08:56 +00:00
# -------------------------
# JOBS: Test iOS RNTester
# -------------------------
2023-05-30 14:15:02 +00:00
# This job builds configures Xcode so that Hermes is built from source
# (but only the iphonesimulator slice) and integrated with the Xcode
# build toolchain. The `test_ios_rntester` job, instead, takes the
# same prebuilt for Hermes that we are going to use in the Release.
test_ios_rntester_hermes_xcode_integration :
executor : reactnativeios
steps :
- checkout_code_with_cache
- run_yarn
- brew_install :
package : cmake
2023-08-04 15:15:55 +00:00
- with_xcodebuild_cache :
steps :
- run :
name : Pod install
command : |
cd packages/rn-tester
bundle install
RCT_NEW_ARCH_ENABLED=1 bundle exec pod install
- run :
name : Build RNTester
command : |
xcodebuild build \
-workspace packages/rn-tester/RNTesterPods.xcworkspace \
-scheme RNTester \
-sdk iphonesimulator
2023-05-30 14:15:02 +00:00
2022-02-03 19:08:56 +00:00
test_ios_rntester :
executor : reactnativeios
2022-10-04 17:15:30 +00:00
parameters :
2022-10-12 22:23:55 +00:00
jsengine :
default : "Hermes"
description : Which JavaScript engine to use. Must be one of "Hermes", "JSC".
type : enum
enum : [ "Hermes" , "JSC" ]
2022-10-13 20:03:45 +00:00
architecture :
default : "OldArch"
description : Which React Native architecture to use. Must be one of "OldArch", "NewArch".
type : enum
enum : [ "NewArch" , "OldArch" ]
2023-05-15 15:14:59 +00:00
use_frameworks :
default : "StaticLibraries"
2023-07-25 10:14:56 +00:00
description : The dependency building and linking strategy to use. Must be one of "StaticLibraries", "DynamicFrameworks"
2023-05-15 15:14:59 +00:00
type : enum
2023-07-25 10:14:56 +00:00
enum : [ "StaticLibraries" , "DynamicFrameworks" ]
2023-03-06 10:56:26 +00:00
ruby_version :
default : "2.6.10"
description : The version of ruby that must be used
type : string
2022-02-03 19:08:56 +00:00
steps :
2022-05-18 14:43:51 +00:00
- checkout_code_with_cache
2022-02-03 19:08:56 +00:00
- run_yarn
2022-08-03 10:34:29 +00:00
- *attach_hermes_workspace
2022-02-03 19:08:56 +00:00
2022-05-13 14:15:15 +00:00
# The macOS machine can run out of storage if Hermes is enabled and built from source.
# Since this job does not use the iOS Simulator, deleting it provides a quick way to
# free up space.
- run :
name : Delete iOS Simulators
background : true
command : sudo rm -rf /Library/Developer/CoreSimulator/Profiles/Runtimes/
2023-03-06 10:56:26 +00:00
- setup_ruby :
ruby_version : << parameters.ruby_version >>
2022-07-20 16:12:47 +00:00
- with_hermes_tarball_cache_span :
2022-08-23 13:43:01 +00:00
set_tarball_path : True
2022-05-13 19:51:09 +00:00
steps :
2023-08-04 15:15:55 +00:00
- with_xcodebuild_cache :
steps :
- run :
name : Install CocoaPods dependencies - Architecture << parameters.architecture >>
command : |
if [[ << parameters.architecture >> == "NewArch" ]]; then
export RCT_NEW_ARCH_ENABLED=1
fi
2022-10-12 22:23:55 +00:00
2023-08-04 15:15:55 +00:00
if [[ << parameters.jsengine >> == "JSC" ]]; then
export USE_HERMES=0
fi
2023-05-15 15:14:59 +00:00
2023-08-04 15:15:55 +00:00
if [[ << parameters.use_frameworks >> == "DynamicFrameworks" ]]; then
export NO_FLIPPER=1
export USE_FRAMEWORKS=dynamic
fi
2023-03-06 10:56:26 +00:00
2023-08-04 15:15:55 +00:00
cd packages/rn-tester
2022-02-03 19:08:56 +00:00
2023-08-04 15:15:55 +00:00
bundle install
bundle exec pod install
- run :
name : Build RNTester
command : |
xcodebuild build \
-workspace packages/rn-tester/RNTesterPods.xcworkspace \
-scheme RNTester \
-sdk iphonesimulator
2022-02-03 19:08:56 +00:00
2020-04-01 00:36:31 +00:00
# -------------------------
# JOBS: Windows
# -------------------------
test_windows :
executor :
name : win/default
parameters :
run_disabled_tests :
type : boolean
default : false
environment :
- ANDROID_HOME : "C:\\Android\\android-sdk"
2021-01-04 17:12:53 +00:00
- ANDROID_NDK : "C:\\Android\\android-sdk\\ndk\\20.1.5948944"
2022-11-09 03:12:02 +00:00
- ANDROID_BUILD_VERSION : 33
2023-07-26 18:02:05 +00:00
- ANDROID_TOOLS_VERSION : 33.0 .1
2022-12-02 15:32:30 +00:00
- CHOCO_CACHE_DIR : "C:\\ChocoCache"
2020-04-01 00:36:31 +00:00
steps :
2022-08-23 13:43:01 +00:00
- checkout_code_with_cache
2020-04-01 00:36:31 +00:00
2022-12-02 15:32:30 +00:00
- restore_cache :
keys :
- *windows_choco_cache_key
- run :
name : Choco cache
# Cache our dependencies which can be flakey to download
command : |
if (!Test-Path $env:CHOCO_CACHE_DIR) {
mkdir $env:CHOCO_CACHE_DIR
}
choco config set --name cacheLocation --value $env:CHOCO_CACHE_DIR
2021-06-04 14:18:34 +00:00
- run :
CircleCI: Use `nodejs-lts` for Windows tests (#34726)
Summary:
Currently we use `nvm install 16` in the `test_windows` CircleCI job. With the "official" non-Windows NVM, this means latest 16 (16.17.0), but that's not the case for NVM-Windows, [which simply appends `.0.0`](https://github.com/coreybutler/nvm-windows/blob/1.1.7/src/nvm.go#L384) unless [the major version is one character long](https://github.com/coreybutler/nvm-windows/blob/1.1.7/src/nvm.go#L210). The Windows orb includes NVM-Windows 1.1.7 (even on the latest 5.0.0 orb), which does not support `nvm install lts` (added 1.1.9). Updating NVM isn't trivial as the system/orb version takes precedence over any Chocolately installation.
Running tests on 16.0.0 blocks Jest 29, which requires [`^16.10.0`](https://github.com/facebook/jest/blob/v29.0.3/packages/jest-create-cache-key-function/package.json#L17).
I initially tried installing a specific Node JS version with NVM, but NVM-Windows 1.1.7 doesn't support newer Node versions due to https://github.com/npm/cli/issues/4234.
So this PR switches from using NVM-Windows to just using Chocolately Node JS packages. `nodejs-lts` tracks the latest LTS. IMO, given we're only testing against one Node JS version with Windows, the latest LTS is a good option, but versions can be specified with `--version` if we want to pin it instead.
Yarn is available through [corepack](https://nodejs.org/api/corepack.html#corepack) since 16.9, so doesn't need to be installed separately.
## Changelog
[Internal] [Fixed] - CircleCI: Update Node JS version used on Windows tests from 16.0.0 to 16.17.0
Pull Request resolved: https://github.com/facebook/react-native/pull/34726
Test Plan: Tested via painful trial and error on my fork: https://app.circleci.com/pipelines/github/robhogan/react-native/19/workflows/0c23a77f-40d2-4c36-933b-53c14acb7907
Reviewed By: cipolleschi
Differential Revision: D39647377
Pulled By: robhogan
fbshipit-source-id: 733da49c632eab26a09ba9cd0175419b9144f9d2
2022-09-20 10:32:04 +00:00
name : Disable NVM
# Use choco to manage node versions due to https://github.com/npm/cli/issues/4234
command : nvm off
- run :
name : Install Node JS
2021-06-04 14:18:34 +00:00
# Note: Version set separately for non-Windows builds, see above.
CircleCI: Use `nodejs-lts` for Windows tests (#34726)
Summary:
Currently we use `nvm install 16` in the `test_windows` CircleCI job. With the "official" non-Windows NVM, this means latest 16 (16.17.0), but that's not the case for NVM-Windows, [which simply appends `.0.0`](https://github.com/coreybutler/nvm-windows/blob/1.1.7/src/nvm.go#L384) unless [the major version is one character long](https://github.com/coreybutler/nvm-windows/blob/1.1.7/src/nvm.go#L210). The Windows orb includes NVM-Windows 1.1.7 (even on the latest 5.0.0 orb), which does not support `nvm install lts` (added 1.1.9). Updating NVM isn't trivial as the system/orb version takes precedence over any Chocolately installation.
Running tests on 16.0.0 blocks Jest 29, which requires [`^16.10.0`](https://github.com/facebook/jest/blob/v29.0.3/packages/jest-create-cache-key-function/package.json#L17).
I initially tried installing a specific Node JS version with NVM, but NVM-Windows 1.1.7 doesn't support newer Node versions due to https://github.com/npm/cli/issues/4234.
So this PR switches from using NVM-Windows to just using Chocolately Node JS packages. `nodejs-lts` tracks the latest LTS. IMO, given we're only testing against one Node JS version with Windows, the latest LTS is a good option, but versions can be specified with `--version` if we want to pin it instead.
Yarn is available through [corepack](https://nodejs.org/api/corepack.html#corepack) since 16.9, so doesn't need to be installed separately.
## Changelog
[Internal] [Fixed] - CircleCI: Update Node JS version used on Windows tests from 16.0.0 to 16.17.0
Pull Request resolved: https://github.com/facebook/react-native/pull/34726
Test Plan: Tested via painful trial and error on my fork: https://app.circleci.com/pipelines/github/robhogan/react-native/19/workflows/0c23a77f-40d2-4c36-933b-53c14acb7907
Reviewed By: cipolleschi
Differential Revision: D39647377
Pulled By: robhogan
fbshipit-source-id: 733da49c632eab26a09ba9cd0175419b9144f9d2
2022-09-20 10:32:04 +00:00
command : choco install nodejs-lts
2021-06-04 14:18:34 +00:00
2020-04-01 00:36:31 +00:00
# Setup Dependencies
- run :
CircleCI: Use `nodejs-lts` for Windows tests (#34726)
Summary:
Currently we use `nvm install 16` in the `test_windows` CircleCI job. With the "official" non-Windows NVM, this means latest 16 (16.17.0), but that's not the case for NVM-Windows, [which simply appends `.0.0`](https://github.com/coreybutler/nvm-windows/blob/1.1.7/src/nvm.go#L384) unless [the major version is one character long](https://github.com/coreybutler/nvm-windows/blob/1.1.7/src/nvm.go#L210). The Windows orb includes NVM-Windows 1.1.7 (even on the latest 5.0.0 orb), which does not support `nvm install lts` (added 1.1.9). Updating NVM isn't trivial as the system/orb version takes precedence over any Chocolately installation.
Running tests on 16.0.0 blocks Jest 29, which requires [`^16.10.0`](https://github.com/facebook/jest/blob/v29.0.3/packages/jest-create-cache-key-function/package.json#L17).
I initially tried installing a specific Node JS version with NVM, but NVM-Windows 1.1.7 doesn't support newer Node versions due to https://github.com/npm/cli/issues/4234.
So this PR switches from using NVM-Windows to just using Chocolately Node JS packages. `nodejs-lts` tracks the latest LTS. IMO, given we're only testing against one Node JS version with Windows, the latest LTS is a good option, but versions can be specified with `--version` if we want to pin it instead.
Yarn is available through [corepack](https://nodejs.org/api/corepack.html#corepack) since 16.9, so doesn't need to be installed separately.
## Changelog
[Internal] [Fixed] - CircleCI: Update Node JS version used on Windows tests from 16.0.0 to 16.17.0
Pull Request resolved: https://github.com/facebook/react-native/pull/34726
Test Plan: Tested via painful trial and error on my fork: https://app.circleci.com/pipelines/github/robhogan/react-native/19/workflows/0c23a77f-40d2-4c36-933b-53c14acb7907
Reviewed By: cipolleschi
Differential Revision: D39647377
Pulled By: robhogan
fbshipit-source-id: 733da49c632eab26a09ba9cd0175419b9144f9d2
2022-09-20 10:32:04 +00:00
name : Enable Yarn with corepack
command : corepack enable
2020-04-01 00:36:31 +00:00
2023-06-26 12:44:12 +00:00
# it looks like that, last week, envinfo released version 7.9.0 which does not works
# with Windows. I have opened an issue here: https://github.com/tabrindle/envinfo/issues/238
# TODO: T156811874 - Revert this to npx envinfo@latest when the issue is addressed
- run :
name : Display Environment info
command : |
npm install -g envinfo
envinfo -v
envinfo
2020-04-01 00:36:31 +00:00
- restore_cache :
keys :
2022-05-12 18:08:29 +00:00
- *windows_yarn_cache_key
2020-04-01 00:36:31 +00:00
- run :
name : "Yarn: Install Dependencies"
command : yarn install --frozen-lockfile --non-interactive
2022-12-02 15:32:30 +00:00
2020-04-01 00:36:31 +00:00
- save_cache :
2022-05-12 18:08:29 +00:00
key : *windows_yarn_cache_key
2020-04-01 00:36:31 +00:00
paths :
- C:\Users\circleci\AppData\Local\Yarn
- run :
name : Install Android SDK Tools
2022-12-02 15:32:30 +00:00
command : choco install android-sdk;
- save_cache :
key : *windows_choco_cache_key
paths :
- $env:CHOCO_CACHE_DIR
2020-04-01 00:36:31 +00:00
- run :
name : Setup Android SDKs
command : |
sdkmanager --licenses
2020-10-20 23:58:29 +00:00
sdkmanager "system-images;android-21;google_apis;armeabi-v7a"
2020-04-01 00:36:31 +00:00
sdkmanager "platforms;android-%ANDROID_BUILD_VERSION%"
sdkmanager "build-tools;%ANDROID_TOOLS_VERSION%"
sdkmanager "add-ons;addon-google_apis-google-23"
sdkmanager "extras;android;m2repository"
# -------------------------
# Run Tests
- run :
name : "Flow: Check Android"
command : yarn flow-check-android
- run :
name : "Flow: Check iOS"
command : yarn flow-check-ios
- run :
name : "Run Tests: JavaScript Tests"
command : yarn test
# Optionally, run disabled tests
- when :
condition : << parameters.run_disabled_tests >>
steps :
- run : echo "Failing tests may be moved here temporarily."
- run :
name : Android Build
2020-08-20 00:54:30 +00:00
command : ./gradlew.bat packages:rn-tester:android:app:assembleRelease
2020-04-01 00:36:31 +00:00
2022-03-08 01:02:08 +00:00
# -------------------------
Circle CI: Reduce build_hermes_macos Hermes SDK cache size by 75% (#34886)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34886
## Reduced cache size
The `build_hermes_macos` job can spend over 20 minutes restoring cached build artifacts (over 5 GB), when only `build_macosx` and `destroot` are required to be cached: `build_macosx` as it may contain a pre-built `hermesc` from previous builds, and `destroot` which contains the artifacts for previous iOS/macOS builds.
This is the `build_hermes_macos` Restore Cache step, before the changes in this diff:
```
Found a cache from build 308044 at v1-hermes-build_hermes_macos-debug-PEiMHp9XQ13KtYFQMKoT27DmHkkoxOi_PJUyW7PacZE=
Size: 5.2 GiB
Cached paths:
* /Users/distiller/react-native/sdks/hermes/build_host_hermesc
* /Users/distiller/react-native/sdks/hermes/build_iphoneos
* /Users/distiller/react-native/sdks/hermes/build_catalyst
* /Users/distiller/react-native/sdks/hermes/build_iphonesimulator
* /Users/distiller/react-native/sdks/hermes/build_macosx
* /Users/distiller/react-native/sdks/hermes/destroot
Downloading cache archive...
Unarchiving cache...
```
Size: 5.2 GiB
Time to restore cache: 183s
This is the `build_hermes_macos` Restore Cache step, after the changes in this diff:
```
Found a cache from build 310128 at v2-hermes-build_hermes_macos-debug-e7WmoA0+mfveXq1zsMYpgR6BYqVuuDjmVeLLyjqPJWk=
Size: 1.3 GiB
Cached paths:
* /Users/distiller/react-native/sdks/hermes/build_macosx
* /Users/distiller/react-native/sdks/hermes/destroot
Downloading cache archive...
Unarchiving cache...
```
Size: 1.3 GiB
Time to restore cache: 42s
**This is a size reduction of 75%, and execution time reduction of 77%.**
This savings will apply to every workflow that runs afterwards until the Hermes cache is invalidated due to a new commit landing in `facebook/hermes`.
## Added `export_hermesc`
As part of the work mentioned above, a reusable `export_hermesc` command was added, which will export hermesc for use in downstream steps. Either of the macOS or iOS build scripts will generate this binary. As we now only cache the macOS build dir, that version is loaded from cache by default if available:
- If the cache contains hermesc, both the macOS and iOS builds will use it.
- If the cache does not contain hermesc, then the iOS job will use the hermesc that was built by the macOS job previously.
- The `export_hermesc` command will work regardless of the order of the Hermes build scripts
## Refactoring of magic strings into reusable yaml references
Some additional changes to the Circle CI config were done in order to reduce repetition of artifacts/cache paths that are re-used across workflows.
Changelog: [Internal]
Reviewed By: cipolleschi
Differential Revision: D40153737
fbshipit-source-id: b9f07302ccc9bac1ce72a09b944d3210e6db2ec1
2022-10-12 16:55:31 +00:00
# JOBS: Build Hermes
2022-03-08 01:02:08 +00:00
# -------------------------
2022-04-02 07:02:11 +00:00
prepare_hermes_workspace :
2022-03-08 01:02:08 +00:00
docker :
2023-06-15 23:06:18 +00:00
- image : debian:bullseye
2022-03-08 01:02:08 +00:00
environment :
- HERMES_WS_DIR : *hermes_workspace_root
2023-05-30 11:10:17 +00:00
- HERMES_VERSION_FILE : "packages/react-native/sdks/.hermesversion"
2023-01-05 14:58:38 +00:00
- BUILD_FROM_SOURCE : true
2022-03-08 01:02:08 +00:00
steps :
- run :
name : Install dependencies
command : |
2022-05-06 15:02:33 +00:00
apt update
2023-08-02 16:42:56 +00:00
apt install -y wget git curl jq
2023-06-22 16:53:21 +00:00
curl -sL https://deb.nodesource.com/setup_18.x | bash -
2022-05-13 07:08:04 +00:00
apt install -y nodejs
npm install --global yarn
2022-08-23 13:43:01 +00:00
- checkout
2022-03-08 01:02:08 +00:00
- run :
2022-05-06 15:02:33 +00:00
name : Set up Hermes workspace and caching
command : |
mkdir -p "/tmp/hermes" "/tmp/hermes/download" "/tmp/hermes/hermes"
if [ -f "$HERMES_VERSION_FILE" ]; then
2023-05-30 11:10:17 +00:00
echo "Hermes Version file found! Using this version for the build:"
2022-05-06 15:02:33 +00:00
cat $HERMES_VERSION_FILE > /tmp/hermes/hermesversion
else
2023-05-30 11:10:17 +00:00
echo "Hermes Version file not found!!!"
echo "Using the last commit from main for the build:"
2022-05-06 15:02:33 +00:00
HERMES_TAG_SHA=$(git ls-remote https://github.com/facebook/hermes main | cut -f 1 | tr -d '[:space:]')
echo $HERMES_TAG_SHA > /tmp/hermes/hermesversion
fi
2022-08-03 10:34:29 +00:00
cat /tmp/hermes/hermesversion
2023-08-02 16:42:56 +00:00
- get_react_native_version
2022-05-06 15:02:33 +00:00
- restore_cache :
2022-09-22 20:41:51 +00:00
key : *hermes_workspace_cache_key
2023-08-02 16:42:56 +00:00
- run_yarn
2022-03-23 20:18:52 +00:00
- run :
name : Download Hermes tarball
2022-03-08 01:02:08 +00:00
command : |
2023-03-17 12:03:25 +00:00
node packages/react-native/scripts/hermes/prepare-hermes-for-build $CIRCLE_PULL_REQUEST
cp packages/react-native/sdks/download/* $HERMES_WS_DIR/download/.
cp -r packages/react-native/sdks/hermes/* $HERMES_WS_DIR/hermes/.
2022-08-03 10:34:29 +00:00
cat /tmp/hermes/hermesversion
2022-05-06 15:02:33 +00:00
- save_cache :
2022-09-22 20:41:51 +00:00
key : *hermes_workspace_cache_key
2022-05-06 15:02:33 +00:00
paths :
- /tmp/hermes/download/
- /tmp/hermes/hermes/
2023-08-02 16:42:56 +00:00
# Check if we already built the tarball
# if yes, we can skip the building and we can skip some jobs building
- restore_cache :
keys :
- *hermes_tarball_release_cache_key
- check_if_tarball_is_present :
flavor : Release
- restore_cache :
keys :
- *hermes_tarball_debug_cache_key
- check_if_tarball_is_present :
flavor : Debug
- restore_cache :
keys :
- *hermes_macosx_bin_release_cache_key
- check_if_osx_bin_is_present :
flavor : Release
- restore_cache :
keys :
- *hermes_macosx_bin_debug_cache_key
- check_if_osx_bin_is_present :
flavor : Debug
2022-03-08 01:02:08 +00:00
- persist_to_workspace :
root : *hermes_workspace_root
paths :
2022-03-23 20:18:52 +00:00
- download
2022-03-08 01:02:08 +00:00
- hermes
2023-08-02 16:42:56 +00:00
- hermes-runtime-darwin
- osx-bin
2022-03-23 20:18:52 +00:00
- hermesversion
2023-08-02 16:42:56 +00:00
- Release_tarball_present
- Debug_tarball_present
- Release_osx_bin
- Debug_osx_bin
- persist_to_workspace :
root : /tmp
paths :
- react-native-version
2022-03-08 01:02:08 +00:00
2022-04-02 07:02:11 +00:00
build_hermesc_linux :
2022-03-08 01:02:08 +00:00
docker :
2022-04-27 18:48:25 +00:00
- image : debian:bullseye
resource_class : "xlarge"
2022-03-08 01:02:08 +00:00
steps :
2023-05-23 10:34:20 +00:00
- checkout_code_with_cache
2022-03-08 01:02:08 +00:00
- run :
name : Install dependencies
command : |
2022-04-27 18:48:25 +00:00
apt update
apt install -y git openssh-client cmake build-essential \
2023-05-23 10:34:20 +00:00
libreadline-dev libicu-dev jq zip python3
2022-04-27 18:48:25 +00:00
- *attach_hermes_workspace
2023-05-23 10:34:20 +00:00
- get_react_native_version
2022-05-06 15:02:33 +00:00
- restore_cache :
2023-05-23 10:34:20 +00:00
key : *hermes_linux_cache_key
2022-03-08 01:02:08 +00:00
- run :
name : Set up workspace
command : |
2022-04-27 18:48:25 +00:00
mkdir -p /tmp/hermes/linux64-bin
2022-03-08 01:02:08 +00:00
- run :
2022-04-27 18:48:25 +00:00
name : Build HermesC for Linux
2022-03-08 01:02:08 +00:00
command : |
2022-05-06 15:02:33 +00:00
if [ -f /tmp/hermes/linux64-bin/hermesc ]; then
echo 'Skipping; Clean "/tmp/hermes/linux64-bin" to rebuild.'
else
cd /tmp/hermes
cmake -S hermes -B build -DHERMES_STATIC_LINK=ON -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=True -DCMAKE_CXX_FLAGS=-s -DCMAKE_C_FLAGS=-s \
-DCMAKE_EXE_LINKER_FLAGS="-Wl,--whole-archive -lpthread -Wl,--no-whole-archive"
cmake --build build --target check-hermes -j 4
cp /tmp/hermes/build/bin/hermesc /tmp/hermes/linux64-bin/.
fi
- save_cache :
2023-05-23 10:34:20 +00:00
key : *hermes_linux_cache_key
2022-05-06 15:02:33 +00:00
paths :
- /tmp/hermes/linux64-bin/
- /tmp/hermes/hermes/destroot/
2022-04-27 18:48:25 +00:00
- store_artifacts :
path : /tmp/hermes/linux64-bin/
2022-03-23 20:18:52 +00:00
- persist_to_workspace :
2022-04-27 18:48:25 +00:00
root : /tmp/hermes/
2022-03-23 20:18:52 +00:00
paths :
2022-04-27 18:48:25 +00:00
- linux64-bin
2022-03-08 01:02:08 +00:00
2023-08-02 16:42:56 +00:00
build_hermesc_apple :
executor : reactnativeios
environment :
- HERMES_WS_DIR : *hermes_workspace_root
- HERMES_TARBALL_ARTIFACTS_DIR : *hermes_tarball_artifacts_dir
steps :
- *attach_hermes_workspace
- stop_job_if_apple_artifacts_are_there :
flavor : "All"
- checkout_code_with_cache
- get_react_native_version
- setup_hermes_workspace
- restore_cache :
key : *hermesc_apple_cache_key
- brew_install :
package : cmake
- run :
name : "Build HermesC Apple"
command : |
cd ./packages/react-native/sdks/hermes || exit 1
. ./utils/build-apple-framework.sh
build_host_hermesc_if_needed
- save_cache :
key : *hermesc_apple_cache_key
paths :
- ./packages/react-native/sdks/hermes/build_host_hermesc
- persist_to_workspace :
root : ./packages/react-native/sdks/hermes/
paths :
- build_host_hermesc
build_apple_slices_hermes :
2022-09-22 20:41:51 +00:00
parameters :
2023-08-02 16:42:56 +00:00
slice_base_cache_key :
default : *hermes_apple_slices_cache_key
type : string
2022-09-22 20:41:51 +00:00
flavor :
default : "Debug"
2022-10-18 21:25:38 +00:00
description : The Hermes build type. Must be one of "Debug", "Release".
type : enum
enum : [ "Debug" , "Release" ]
2023-08-02 16:42:56 +00:00
slice :
default : "iphoneos"
description : The Hermes Slice that this job has to build
type : enum
enum : [ "macosx" , "iphoneos" , "iphonesimulator" , "catalyst" ]
2022-04-01 23:19:29 +00:00
executor : reactnativeios
2022-03-08 01:02:08 +00:00
environment :
- HERMES_WS_DIR : *hermes_workspace_root
2022-10-07 17:21:25 +00:00
- HERMES_TARBALL_ARTIFACTS_DIR : *hermes_tarball_artifacts_dir
Circle CI: Reduce build_hermes_macos Hermes SDK cache size by 75% (#34886)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34886
## Reduced cache size
The `build_hermes_macos` job can spend over 20 minutes restoring cached build artifacts (over 5 GB), when only `build_macosx` and `destroot` are required to be cached: `build_macosx` as it may contain a pre-built `hermesc` from previous builds, and `destroot` which contains the artifacts for previous iOS/macOS builds.
This is the `build_hermes_macos` Restore Cache step, before the changes in this diff:
```
Found a cache from build 308044 at v1-hermes-build_hermes_macos-debug-PEiMHp9XQ13KtYFQMKoT27DmHkkoxOi_PJUyW7PacZE=
Size: 5.2 GiB
Cached paths:
* /Users/distiller/react-native/sdks/hermes/build_host_hermesc
* /Users/distiller/react-native/sdks/hermes/build_iphoneos
* /Users/distiller/react-native/sdks/hermes/build_catalyst
* /Users/distiller/react-native/sdks/hermes/build_iphonesimulator
* /Users/distiller/react-native/sdks/hermes/build_macosx
* /Users/distiller/react-native/sdks/hermes/destroot
Downloading cache archive...
Unarchiving cache...
```
Size: 5.2 GiB
Time to restore cache: 183s
This is the `build_hermes_macos` Restore Cache step, after the changes in this diff:
```
Found a cache from build 310128 at v2-hermes-build_hermes_macos-debug-e7WmoA0+mfveXq1zsMYpgR6BYqVuuDjmVeLLyjqPJWk=
Size: 1.3 GiB
Cached paths:
* /Users/distiller/react-native/sdks/hermes/build_macosx
* /Users/distiller/react-native/sdks/hermes/destroot
Downloading cache archive...
Unarchiving cache...
```
Size: 1.3 GiB
Time to restore cache: 42s
**This is a size reduction of 75%, and execution time reduction of 77%.**
This savings will apply to every workflow that runs afterwards until the Hermes cache is invalidated due to a new commit landing in `facebook/hermes`.
## Added `export_hermesc`
As part of the work mentioned above, a reusable `export_hermesc` command was added, which will export hermesc for use in downstream steps. Either of the macOS or iOS build scripts will generate this binary. As we now only cache the macOS build dir, that version is loaded from cache by default if available:
- If the cache contains hermesc, both the macOS and iOS builds will use it.
- If the cache does not contain hermesc, then the iOS job will use the hermesc that was built by the macOS job previously.
- The `export_hermesc` command will work regardless of the order of the Hermes build scripts
## Refactoring of magic strings into reusable yaml references
Some additional changes to the Circle CI config were done in order to reduce repetition of artifacts/cache paths that are re-used across workflows.
Changelog: [Internal]
Reviewed By: cipolleschi
Differential Revision: D40153737
fbshipit-source-id: b9f07302ccc9bac1ce72a09b944d3210e6db2ec1
2022-10-12 16:55:31 +00:00
- HERMES_OSXBIN_ARTIFACTS_DIR : *hermes_osxbin_artifacts_dir
2022-03-08 01:02:08 +00:00
steps :
2023-08-02 16:42:56 +00:00
- *attach_hermes_workspace
- stop_job_if_apple_artifacts_are_there :
flavor : << parameters.flavor >>
- checkout_code_with_cache
- get_react_native_version
- setup_hermes_workspace
- restore_cache :
key : *hermesc_apple_cache_key
- brew_install :
package : cmake
- restore_cache :
key : << parameters.slice_base_cache_key >>-<< parameters.slice >>-<< parameters.flavor >>
- run :
name : Build the Hermes << parameters.slice >> frameworks
command : |
cd ./packages/react-native/sdks/hermes || exit 1
SLICE=<< parameters.slice >>
FLAVOR=<< parameters.flavor >>
FINAL_PATH=build_"$SLICE"_"$FLAVOR"
echo "Final path for this slice is: $FINAL_PATH"
if [[ -d "$FINAL_PATH" ]]; then
echo "[HERMES] Skipping! Found the requested slice at $FINAL_PATH".
exit 0
fi
if [[ "$SLICE" == "macosx" ]]; then
echo "[HERMES] Building Hermes for MacOS"
BUILD_TYPE="<< parameters.flavor >>" ./utils/build-mac-framework.sh
else
echo "[HERMES] Building Hermes for iOS: $SLICE"
BUILD_TYPE="<< parameters.flavor >>" ./utils/build-ios-framework.sh "$SLICE"
fi
echo "Moving from build_$SLICE to $FINAL_PATH"
mv build_"$SLICE" "$FINAL_PATH"
- save_cache :
key : << parameters.slice_base_cache_key >>-<< parameters.slice >>-<< parameters.flavor >>
paths :
- ./packages/react-native/sdks/hermes/build_<< parameters.slice >>_<< parameters.flavor >>
build_hermes_macos :
parameters :
slice_base_cache_key :
default : *hermes_apple_slices_cache_key
type : string
flavor :
default : "Debug"
description : The Hermes build type. Must be one of "Debug", "Release".
type : enum
enum : [ "Debug" , "Release" ]
executor : reactnativeios
environment :
- HERMES_WS_DIR : *hermes_workspace_root
- HERMES_TARBALL_ARTIFACTS_DIR : *hermes_tarball_artifacts_dir
steps :
- *attach_hermes_workspace
# Try to store the artifacts if they are already in the workspace
- store_hermes_apple_artifacts :
flavor : << parameters.flavor >>
- stop_job_if_apple_artifacts_are_there :
flavor : << parameters.flavor >>
2022-05-18 14:43:51 +00:00
- checkout_code_with_cache
2022-10-07 17:21:25 +00:00
- run_yarn
2022-12-13 12:19:43 +00:00
- get_react_native_version
2023-08-02 16:42:56 +00:00
- brew_install :
package : cmake
- setup_hermes_workspace
- restore_cache :
key : << parameters.slice_base_cache_key >>-macosx-<< parameters.flavor >>
- restore_cache :
key : << parameters.slice_base_cache_key >>-iphoneos-<< parameters.flavor >>
- restore_cache :
key : << parameters.slice_base_cache_key >>-iphonesimulator-<< parameters.flavor >>
- restore_cache :
key : << parameters.slice_base_cache_key >>-catalyst-<< parameters.flavor >>
- run :
name : "Move back build folders"
command : |
cd ./packages/react-native/sdks/hermes || exit 1
mv build_macosx_<< parameters.flavor >> build_macosx
mv build_iphoneos_<< parameters.flavor >> build_iphoneos
mv build_iphonesimulator_<< parameters.flavor >> build_iphonesimulator
mv build_catalyst_<< parameters.flavor >> build_catalyst
- run :
name : "Prepare destroot folder"
command : |
cd ./packages/react-native/sdks/hermes || exit 1
. ./utils/build-apple-framework.sh
prepare_dest_root_for_ci
- run :
name : "Create fat framework for iOS"
command : |
cd ./packages/react-native/sdks/hermes || exit 1
echo "[HERMES] Creating the universal framework"
./utils/build-ios-framework.sh build_framework
- run :
name : Package the Hermes Apple frameworks
command : |
BUILD_TYPE="<< parameters.flavor >>"
echo "Packaging Hermes Apple frameworks for $BUILD_TYPE build type"
TARBALL_OUTPUT_DIR=$(mktemp -d /tmp/hermes-tarball-output-XXXXXXXX)
TARBALL_FILENAME=$(node ./packages/react-native/scripts/hermes/get-tarball-name.js --buildType "$BUILD_TYPE")
echo "Packaging Hermes Apple frameworks for $BUILD_TYPE build type"
TARBALL_OUTPUT_PATH=$(node ./packages/react-native/scripts/hermes/create-tarball.js \
--inputDir ./packages/react-native/sdks/hermes \
--buildType "$BUILD_TYPE" \
--outputDir $TARBALL_OUTPUT_DIR)
echo "Hermes tarball saved to $TARBALL_OUTPUT_PATH"
mkdir -p $HERMES_TARBALL_ARTIFACTS_DIR
cp $TARBALL_OUTPUT_PATH $HERMES_TARBALL_ARTIFACTS_DIR/.
mkdir -p /tmp/hermes/osx-bin/<< parameters.flavor >>
cp ./packages/react-native/sdks/hermes/build_macosx/bin/* /tmp/hermes/osx-bin/<< parameters.flavor >>
2022-09-22 20:41:51 +00:00
- when :
condition :
equal : [ << parameters.flavor >>, "Debug"]
steps :
2023-08-02 16:42:56 +00:00
- save_cache :
key : *hermes_tarball_debug_cache_key
paths : *hermes_tarball_cache_paths
- save_cache :
key : *hermes_macosx_bin_debug_cache_key
paths : /tmp/hermes/osx-bin/Debug
2022-09-22 20:41:51 +00:00
- when :
condition :
equal : [ << parameters.flavor >>, "Release"]
steps :
2023-08-02 16:42:56 +00:00
- save_cache :
key : *hermes_tarball_release_cache_key
paths : *hermes_tarball_cache_paths
- save_cache :
key : *hermes_macosx_bin_release_cache_key
paths : /tmp/hermes/osx-bin/Release
- store_hermes_apple_artifacts :
2022-09-22 20:41:51 +00:00
flavor : << parameters.flavor >>
2023-08-02 16:42:56 +00:00
- persist_to_workspace :
root : /tmp/hermes/
paths :
- hermes-runtime-darwin
- osx-bin
2022-03-08 01:02:08 +00:00
2022-04-02 07:02:11 +00:00
build_hermesc_windows :
2022-03-08 01:02:08 +00:00
executor :
name : win/default
shell : powershell.exe
environment :
- HERMES_WS_DIR : 'C:\tmp\hermes'
- ICU_URL : "https://github.com/unicode-org/icu/releases/download/release-64-2/icu4c-64_2-Win64-MSVC2017.zip"
- MSBUILD_DIR : 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin'
- CMAKE_DIR : 'C:\Program Files\CMake\bin'
steps :
2023-05-23 10:34:20 +00:00
- checkout_code_with_cache
2022-03-08 01:02:08 +00:00
- *attach_hermes_workspace
2023-05-23 10:34:20 +00:00
- get_react_native_version_windows
2022-05-06 15:02:33 +00:00
- restore_cache :
2022-05-12 18:08:29 +00:00
key : *hermes_windows_cache_key
2022-03-08 01:02:08 +00:00
- run :
name : Set up workspace
command : |
New-Item -ItemType Directory $Env:HERMES_WS_DIR
New-Item -ItemType Directory $Env:HERMES_WS_DIR\icu
New-Item -ItemType Directory $Env:HERMES_WS_DIR\deps
2022-04-27 18:48:25 +00:00
New-Item -ItemType Directory $Env:HERMES_WS_DIR\win64-bin
2022-03-08 01:02:08 +00:00
New-Item -ItemType SymbolicLink -Target tmp\hermes\hermes -Path $Env:HERMES_WS_DIR -Name hermes
- run :
2022-04-27 18:48:25 +00:00
name : Build HermesC for Windows
2022-03-08 01:02:08 +00:00
command : |
2022-05-06 15:02:33 +00:00
if (-not(Test-Path -Path $Env:HERMES_WS_DIR\win64-bin\hermesc.exe)) {
2022-09-29 14:22:39 +00:00
choco install --no-progress cmake --version 3.14.7
2022-05-06 15:02:33 +00:00
if (-not $?) { throw "Failed to install CMake" }
cd $Env:HERMES_WS_DIR\icu
# If Invoke-WebRequest shows a progress bar, it will fail with
# Win32 internal error "Access is denied" 0x5 occurred [...]
$progressPreference = 'silentlyContinue'
Invoke-WebRequest -Uri "$Env:ICU_URL" -OutFile "icu.zip"
Expand-Archive -Path "icu.zip" -DestinationPath "."
cd $Env:HERMES_WS_DIR
Copy-Item -Path "icu\bin64\icu*.dll" -Destination "deps"
# Include MSVC++ 2015 redistributables
Copy-Item -Path "c:\windows\system32\msvcp140.dll" -Destination "deps"
Copy-Item -Path "c:\windows\system32\vcruntime140.dll" -Destination "deps"
Copy-Item -Path "c:\windows\system32\vcruntime140_1.dll" -Destination "deps"
$Env:PATH += ";$Env:CMAKE_DIR;$Env:MSBUILD_DIR"
$Env:ICU_ROOT = "$Env:HERMES_WS_DIR\icu"
cmake -S hermes -B build_release -G 'Visual Studio 16 2019' -Ax64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=True -DHERMES_ENABLE_WIN10_ICU_FALLBACK=OFF
if (-not $?) { throw "Failed to configure Hermes" }
cd build_release
cmake --build . --target hermesc --config Release
if (-not $?) { throw "Failed to build Hermes" }
cd $Env:HERMES_WS_DIR
Copy-Item -Path "build_release\bin\Release\hermesc.exe" -Destination "win64-bin"
# Include Windows runtime dependencies
Copy-Item -Path "deps\*" -Destination "win64-bin"
}
else {
Write-Host "Skipping; Clean c:\tmp\hermes\win64-bin to rebuild."
}
- save_cache :
2022-05-12 18:08:29 +00:00
key : *hermes_windows_cache_key
2022-05-06 15:02:33 +00:00
paths :
- C:\tmp\hermes\win64-bin\
- C:\tmp\hermes\hermes\icu\
- C:\tmp\hermes\hermes\deps\
- C:\tmp\hermes\hermes\build_release\
2022-04-27 18:48:25 +00:00
- store_artifacts :
2022-05-06 15:02:33 +00:00
path : C:\tmp\hermes\win64-bin\
2022-03-08 01:02:08 +00:00
- persist_to_workspace :
2022-05-06 15:02:33 +00:00
root : C:\tmp\hermes\
2022-03-08 01:02:08 +00:00
paths :
2022-04-27 18:48:25 +00:00
- win64-bin
2022-03-08 01:02:08 +00:00
2019-02-24 01:01:34 +00:00
# -------------------------
# JOBS: Releases
# -------------------------
2021-12-01 00:48:47 +00:00
prepare_package_for_release :
2022-01-24 22:06:49 +00:00
parameters :
version :
type : string
latest :
type : boolean
default : false
2022-10-20 00:54:22 +00:00
dryrun :
type : boolean
default : false
2021-12-01 00:48:47 +00:00
executor : reactnativeios
steps :
2022-05-18 14:43:51 +00:00
- checkout_code_with_cache
2021-12-03 21:15:38 +00:00
- run_yarn
2021-12-01 00:48:47 +00:00
- add_ssh_keys :
fingerprints :
2023-01-09 12:34:41 +00:00
- "1f:c7:61:c4:e2:ff:77:e3:cc:ca:a7:34:c2:79:e3:3c"
2022-10-12 23:19:28 +00:00
- brew_install :
package : cmake
2021-12-01 00:48:47 +00:00
- run :
name : "Set new react-native version and commit changes"
command : |
2022-11-21 18:52:17 +00:00
VERSION=<< parameters.version >>
if [[ -z "$VERSION" ]]; then
VERSION=$(grep '"version"' package.json | cut -d '"' -f 4 | head -1)
echo "Using the version from the package.json: $VERSION"
fi
node ./scripts/prepare-package-for-release.js -v "$VERSION" -l << parameters.latest >> --dry-run << parameters.dryrun >>
2021-12-01 00:48:47 +00:00
2021-09-28 23:26:08 +00:00
build_npm_package :
2020-03-14 04:46:45 +00:00
parameters :
2022-10-20 00:54:22 +00:00
release_type :
description : The type of release to build. Must be one of "nightly", "release", "dry-run".
type : enum
enum : [ "nightly" , "release" , "dry-run" ]
default : "dry-run"
2019-05-30 22:07:45 +00:00
executor : reactnativeandroid
2022-03-23 20:18:52 +00:00
environment :
- HERMES_WS_DIR : *hermes_workspace_root
2018-07-23 20:28:17 +00:00
steps :
2020-03-24 18:04:57 +00:00
- run :
name : Add github.com to SSH known hosts
command : |
mkdir -p ~/.ssh
echo '|1|If6MU203eXTaaWL678YEfWkVMrw=|kqLeIAyTy8pzpj8x8Ae4Fr8Mtlc= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==' >> ~/.ssh/known_hosts
2022-08-23 13:43:01 +00:00
- checkout
2022-04-20 20:03:29 +00:00
- *attach_hermes_workspace
- run :
2022-10-14 14:30:29 +00:00
name : Copy Hermes binaries
2022-04-20 20:03:29 +00:00
command : |
2023-03-17 12:03:25 +00:00
mkdir -p ./packages/react-native/sdks/hermesc ./packages/react-native/sdks/hermesc/osx-bin ./packages/react-native/sdks/hermesc/win64-bin ./packages/react-native/sdks/hermesc/linux64-bin
2022-10-18 21:25:38 +00:00
# When build_hermes_macos runs as a matrix, it outputs
if [[ -d $HERMES_WS_DIR/osx-bin/Release ]]; then
2023-03-17 12:03:25 +00:00
cp -r $HERMES_WS_DIR/osx-bin/Release/* ./packages/react-native/sdks/hermesc/osx-bin/.
2022-10-18 21:25:38 +00:00
elif [[ -d $HERMES_WS_DIR/osx-bin/Debug ]]; then
2023-03-17 12:03:25 +00:00
cp -r $HERMES_WS_DIR/osx-bin/Debug/* ./packages/react-native/sdks/hermesc/osx-bin/.
2022-10-18 21:25:38 +00:00
else
ls $HERMES_WS_DIR/osx-bin || echo "hermesc macOS artifacts directory missing."
echo "Could not locate macOS hermesc binary."; exit 1;
fi
2023-03-17 12:03:25 +00:00
cp -r $HERMES_WS_DIR/win64-bin/* ./packages/react-native/sdks/hermesc/win64-bin/.
cp -r $HERMES_WS_DIR/linux64-bin/* ./packages/react-native/sdks/hermesc/linux64-bin/.
2023-03-20 14:05:52 +00:00
mkdir -p ./packages/react-native/ReactAndroid/external-artifacts/artifacts/
cp $HERMES_WS_DIR/hermes-runtime-darwin/hermes-ios-debug.tar.gz ./packages/react-native/ReactAndroid/external-artifacts/artifacts/hermes-ios-debug.tar.gz
cp $HERMES_WS_DIR/hermes-runtime-darwin/hermes-ios-release.tar.gz ./packages/react-native/ReactAndroid/external-artifacts/artifacts/hermes-ios-release.tar.gz
2022-04-01 09:41:04 +00:00
2019-05-30 22:07:45 +00:00
- run_yarn
Add shared monorepo build setup (#38718)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38718
> NOTE: Replaces https://github.com/facebook/react-native/pull/38240
## Context
RFC: Decoupling Flipper from React Native core: https://github.com/react-native-community/discussions-and-proposals/pull/641
## Changes
To support incoming new React Native packages around debugging (including migrating over [`react-native-community/cli-plugin-metro`](https://github.com/react-native-community/cli/tree/main/packages/cli-plugin-metro)) — which target Node.js and require a build step, this PR adds a minimal shared build setup across the `react-native` monorepo.
The setup is closely inspired/based on the build scripts in Jest, Metro, and React Native CLI — and is a simple set of script wrappers around Babel. These are available as build commands at the root of the repo:
- `yarn build` — Builds all configured packages. Functionally, this:
- Outputs a `dist/` directory with built files.
- Rewrites package.json `"exports"` to update every `./src/*` reference to `./dist/*` (source of truth).
- `scripts/build/babel-register.js` — Allows running all Node.js entry points from source, similar to the current setup in [facebook/metro](https://github.com/facebook/metro). (Example entry point file in this PR: `packages/dev-middleware/src/index.js`)
Build configuration (i.e. Babel config) is shared as a set standard across the monorepo, and **packages are opted-in to requiring a build**, configured in `scripts/build.config.js`.
```
const buildConfig /*: BuildConfig */ = {
// The packages to include for build and their build options
packages: {
'dev-middleware': {target: 'node'},
},
};
```
For now, there is a single `target: 'node'` option — this is necessary as `react-native`, unlike the above other projects, is a repository with packages targeting several runtimes. We may, in future, introduce a build step for other, non-Node, packages — which may be useful for things such as auto-generated TypeScript definitions.
{F1043312771}
**Differences from the Metro setup**
- References (and compiles out) repo-local `scripts/build/babel-register.js` — removing need for an npm-published dependency.
## Current integration points
- **CircleCI** — `yarn build` is added to the `build_npm_package` and `find_and_publish_bumped_packages` jobs.
**New Node.js package(s) are not load bearing quite yet**: There are not yet any built packages added to the dependencies of `packages/react-native/`, so this will be further tested in a later PR (and is actively being done in an internal commit stack).
### Alternative designs
**Per-package config file**
Replace `scripts/build/config.js` with a package-defined key in in `package.json`, similar to Jest's [`publishConfig`](https://github.com/jestjs/jest/blob/1f019afdcdfc54a6664908bb45f343db4e3d0848/packages/jest-cli/package.json#L87C3-L89C4).
```
"buildConfig": {
"type": "node"
},
```
This would be the only customisation required, with a single Babel config still standardised. Another option this might receive in future is `enableTypeScriptCodgeen`.
**Rollup**
More sophisticated build tool for Node.js, used by the React codebase (albeit within a custom script setup as well).
**Lerna and Nx**
- Most sophisticated setup enabling caching and optimised cloud runs.
- Probably the most likely thing we'll move towards at a later stage.
Changelog: [Internal]
Reviewed By: NickGerleman
Differential Revision: D47760330
fbshipit-source-id: 38ec94708ce3d9946a197d80885781e9707c5841
2023-08-03 11:42:30 +00:00
- build_packages
2019-05-30 22:07:45 +00:00
- download_gradle_dependencies
2022-03-23 20:18:52 +00:00
# START: Stables and nightlies
2023-01-31 16:00:08 +00:00
# This conditional step sets up the necessary credentials for publishing react-native to npm.
2021-09-28 23:26:08 +00:00
- when :
condition :
or :
2022-10-20 00:54:22 +00:00
- equal : [ "release" , << parameters.release_type >> ]
- equal : [ "nightly" , << parameters.release_type >> ]
2021-09-28 23:26:08 +00:00
steps :
- run : echo "//registry.npmjs.org/:_authToken=${CIRCLE_NPM_TOKEN}" > ~/.npmrc
2022-03-23 20:18:52 +00:00
# END: Stables and nightlies
2022-10-20 00:54:22 +00:00
- run : node ./scripts/publish-npm.js --<< parameters.release_type >>
2022-05-06 17:50:10 +00:00
- run :
name : Zip Hermes Native Symbols
2023-03-17 12:03:25 +00:00
command : zip -r /tmp/hermes-native-symbols.zip ~/react-native/packages/react-native/ReactAndroid/hermes-engine/build/intermediates/cmake/
2022-05-06 17:50:10 +00:00
- store_artifacts :
path : /tmp/hermes-native-symbols.zip
2022-10-25 20:13:14 +00:00
- run :
name : Zip Maven Artifacts from /tmp/maven-local
command : zip -r /tmp/maven-local.zip /tmp/maven-local
- store_artifacts :
path : /tmp/maven-local.zip
- persist_to_workspace :
root : /tmp
paths :
- maven-local
2022-03-23 20:18:52 +00:00
# START: Commitlies
# Provide a react-native package for this commit as a Circle CI release artifact.
2021-09-24 20:47:36 +00:00
- when :
condition :
2022-10-20 00:54:22 +00:00
equal : [ "dry-run" , << parameters.release_type >> ]
2021-09-24 20:47:36 +00:00
steps :
2021-09-25 17:04:47 +00:00
- run :
name : Build release package as a job artifact
command : |
mkdir -p build
2023-03-17 12:03:25 +00:00
FILENAME=$(cd packages/react-native; npm pack | tail -1)
mv packages/react-native/$FILENAME build/
2021-10-28 22:46:53 +00:00
echo $FILENAME > build/react-native-package-version
2021-09-24 20:47:36 +00:00
- store_artifacts :
2021-09-25 17:04:47 +00:00
path : ~/react-native/build/
2021-09-24 20:47:36 +00:00
destination : build
2021-10-28 22:46:53 +00:00
- persist_to_workspace :
root : .
paths :
- build/*
2022-03-23 20:18:52 +00:00
# END: Commitlies
2021-10-28 22:46:53 +00:00
2022-03-23 20:18:52 +00:00
# START: Commits from pull requests
# When building commits from pull requests, leave a comment on the PR with a link to build artifacts
2021-10-09 00:53:18 +00:00
- when :
condition :
matches : { pattern: '^pull\/.*$', value : << pipeline.git.branch >> }
steps :
- run :
name : Post link to PR build artifacts (pull-bot)
2021-11-06 00:27:23 +00:00
command : GITHUB_TOKEN="$PUBLIC_PULLBOT_GITHUB_TOKEN_A""$PUBLIC_PULLBOT_GITHUB_TOKEN_B" scripts/circleci/post-artifacts-link.sh || true
2022-03-23 20:18:52 +00:00
# END: Commits from pull requests
2018-07-23 20:28:17 +00:00
2022-03-23 20:18:52 +00:00
# START: Stable releases
2021-11-12 19:31:21 +00:00
- when :
condition :
2022-10-20 00:54:22 +00:00
equal : [ "release" , << parameters.release_type >> ]
2021-11-12 19:31:21 +00:00
steps :
- run :
name : Update rn-diff-purge to generate upgrade-support diff
command : |
curl -X POST https://api.github.com/repos/react-native-community/rn-diff-purge/dispatches \
-H "Accept: application/vnd.github.v3+json" \
2023-01-11 18:58:25 +00:00
-H "Authorization: Bearer $REACT_NATIVE_BOT_GITHUB_TOKEN" \
2021-11-12 19:31:21 +00:00
-d "{\"event_type\": \"publish\", \"client_payload\": { \"version\": \"${CIRCLE_TAG:1}\" }}"
2022-10-20 00:54:22 +00:00
# END: Stable releases
2020-02-27 02:07:09 +00:00
# -------------------------
# JOBS: Nightly
# -------------------------
nightly_job :
2021-10-01 22:31:24 +00:00
machine :
image : ubuntu-2004:202010-01
2020-02-27 02:07:09 +00:00
steps :
- run :
name : Nightly
command : |
echo "Nightly build run"
2022-12-14 10:17:16 +00:00
find_and_publish_bumped_packages :
2023-02-14 15:06:53 +00:00
executor : nodelts
2022-12-14 10:17:16 +00:00
steps :
- checkout
2023-02-14 15:06:53 +00:00
- run_yarn
Add shared monorepo build setup (#38718)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38718
> NOTE: Replaces https://github.com/facebook/react-native/pull/38240
## Context
RFC: Decoupling Flipper from React Native core: https://github.com/react-native-community/discussions-and-proposals/pull/641
## Changes
To support incoming new React Native packages around debugging (including migrating over [`react-native-community/cli-plugin-metro`](https://github.com/react-native-community/cli/tree/main/packages/cli-plugin-metro)) — which target Node.js and require a build step, this PR adds a minimal shared build setup across the `react-native` monorepo.
The setup is closely inspired/based on the build scripts in Jest, Metro, and React Native CLI — and is a simple set of script wrappers around Babel. These are available as build commands at the root of the repo:
- `yarn build` — Builds all configured packages. Functionally, this:
- Outputs a `dist/` directory with built files.
- Rewrites package.json `"exports"` to update every `./src/*` reference to `./dist/*` (source of truth).
- `scripts/build/babel-register.js` — Allows running all Node.js entry points from source, similar to the current setup in [facebook/metro](https://github.com/facebook/metro). (Example entry point file in this PR: `packages/dev-middleware/src/index.js`)
Build configuration (i.e. Babel config) is shared as a set standard across the monorepo, and **packages are opted-in to requiring a build**, configured in `scripts/build.config.js`.
```
const buildConfig /*: BuildConfig */ = {
// The packages to include for build and their build options
packages: {
'dev-middleware': {target: 'node'},
},
};
```
For now, there is a single `target: 'node'` option — this is necessary as `react-native`, unlike the above other projects, is a repository with packages targeting several runtimes. We may, in future, introduce a build step for other, non-Node, packages — which may be useful for things such as auto-generated TypeScript definitions.
{F1043312771}
**Differences from the Metro setup**
- References (and compiles out) repo-local `scripts/build/babel-register.js` — removing need for an npm-published dependency.
## Current integration points
- **CircleCI** — `yarn build` is added to the `build_npm_package` and `find_and_publish_bumped_packages` jobs.
**New Node.js package(s) are not load bearing quite yet**: There are not yet any built packages added to the dependencies of `packages/react-native/`, so this will be further tested in a later PR (and is actively being done in an internal commit stack).
### Alternative designs
**Per-package config file**
Replace `scripts/build/config.js` with a package-defined key in in `package.json`, similar to Jest's [`publishConfig`](https://github.com/jestjs/jest/blob/1f019afdcdfc54a6664908bb45f343db4e3d0848/packages/jest-cli/package.json#L87C3-L89C4).
```
"buildConfig": {
"type": "node"
},
```
This would be the only customisation required, with a single Babel config still standardised. Another option this might receive in future is `enableTypeScriptCodgeen`.
**Rollup**
More sophisticated build tool for Node.js, used by the React codebase (albeit within a custom script setup as well).
**Lerna and Nx**
- Most sophisticated setup enabling caching and optimised cloud runs.
- Probably the most likely thing we'll move towards at a later stage.
Changelog: [Internal]
Reviewed By: NickGerleman
Differential Revision: D47760330
fbshipit-source-id: 38ec94708ce3d9946a197d80885781e9707c5841
2023-08-03 11:42:30 +00:00
- build_packages
2022-12-14 10:17:16 +00:00
- run :
name : Set NPM auth token
command : echo "//registry.npmjs.org/:_authToken=${CIRCLE_NPM_TOKEN}" > ~/.npmrc
- run :
name : Find and publish all bumped packages
command : node ./scripts/monorepo/find-and-publish-all-bumped-packages.js
2022-01-24 22:06:49 +00:00
# -------------------------
# PIPELINE PARAMETERS
# -------------------------
parameters :
2023-01-27 09:33:21 +00:00
run_release_workflow :
2022-01-24 22:06:49 +00:00
default : false
type : boolean
release_latest :
default : false
type : boolean
release_version :
default : "9999"
type : string
2023-01-27 09:33:21 +00:00
run_nightly_workflow :
default : false
type : boolean
2019-02-24 01:01:34 +00:00
# -------------------------
2023-01-27 09:33:21 +00:00
# WORKFLOWS
#
# When creating a new workflow, make sure to include condition:
#
# when:
# and:
# - equal: [ false, << pipeline.parameters.run_release_workflow >> ]
# - equal: [ false, << pipeline.parameters.run_nightly_workflow >> ]
2022-01-24 22:06:49 +00:00
#
# It's setup this way so we can trigger a release via a POST
# See limitations: https://support.circleci.com/hc/en-us/articles/360050351292-How-to-trigger-a-workflow-via-CircleCI-API-v2
2019-02-24 01:01:34 +00:00
# -------------------------
2023-01-27 09:33:21 +00:00
2017-09-21 20:34:02 +00:00
workflows :
2020-02-27 02:07:09 +00:00
version : 2
2018-02-13 16:08:18 +00:00
tests :
2023-01-27 09:33:21 +00:00
when :
and :
- equal : [ false , << pipeline.parameters.run_release_workflow >> ]
- equal : [ false , << pipeline.parameters.run_nightly_workflow >> ]
2017-09-21 20:34:02 +00:00
jobs :
2023-07-30 14:57:49 +00:00
- prepare_package_for_release :
name : prepare_package_for_release
version : ''
latest : false
dryrun : true
2022-04-02 07:02:11 +00:00
- prepare_hermes_workspace
2023-08-04 15:15:55 +00:00
- test_ios_rntester_hermes_xcode_integration
2022-04-02 07:02:11 +00:00
- build_hermesc_linux :
2022-03-23 20:18:52 +00:00
requires :
2022-04-02 07:02:11 +00:00
- prepare_hermes_workspace
2023-08-02 16:42:56 +00:00
- build_hermesc_apple :
2022-03-23 20:18:52 +00:00
requires :
2022-04-02 07:02:11 +00:00
- prepare_hermes_workspace
2023-08-02 16:42:56 +00:00
- build_apple_slices_hermes :
requires :
- build_hermesc_apple
matrix :
parameters :
flavor : [ "Debug" , "Release" ]
slice : [ "macosx" , "iphoneos" , "iphonesimulator" , "catalyst" ]
- build_hermes_macos :
requires :
- build_apple_slices_hermes
2022-10-18 21:25:38 +00:00
matrix :
parameters :
flavor : [ "Debug" , "Release" ]
2022-04-02 07:02:11 +00:00
- build_hermesc_windows :
2022-03-23 20:18:52 +00:00
requires :
2022-04-02 07:02:11 +00:00
- prepare_hermes_workspace
2021-10-28 22:46:53 +00:00
- build_npm_package :
# Build a release package on every untagged commit, but do not publish to npm.
2022-10-20 00:54:22 +00:00
release_type : "dry-run"
2022-04-20 20:03:29 +00:00
requires :
2022-04-27 18:48:25 +00:00
- build_hermesc_linux
2022-05-23 19:14:29 +00:00
- build_hermes_macos
2022-04-27 18:48:25 +00:00
- build_hermesc_windows
2021-09-15 08:33:10 +00:00
- test_js :
run_disabled_tests : false
2023-05-05 14:01:00 +00:00
- test_android
2023-07-26 14:23:31 +00:00
- test_e2e_ios :
ruby_version : "2.7.7"
- test_e2e_android
2021-09-24 08:02:07 +00:00
- test_android_template :
2022-02-09 16:23:43 +00:00
requires :
- build_npm_package
2022-08-08 11:44:48 +00:00
matrix :
parameters :
2022-10-27 21:40:27 +00:00
architecture : [ "NewArch" , "OldArch" ]
2022-09-12 19:33:07 +00:00
jsengine : [ "Hermes" , "JSC" ]
2022-08-08 11:44:48 +00:00
flavor : [ "Debug" , "Release" ]
2023-03-06 10:56:26 +00:00
- test_ios_template :
requires :
- build_npm_package
name : "Test Template with Ruby 3.2.0"
ruby_version : "3.2.0"
architecture : "NewArch"
flavor : "Debug"
2021-10-28 22:46:53 +00:00
- test_ios_template :
requires :
- build_npm_package
2022-08-31 15:54:06 +00:00
matrix :
parameters :
architecture : [ "NewArch" , "OldArch" ]
flavor : [ "Debug" , "Release" ]
jsengine : [ "Hermes" , "JSC" ]
2022-09-06 10:25:45 +00:00
flipper : [ "WithFlipper" , "WithoutFlipper" ]
2023-07-25 10:14:56 +00:00
use_frameworks : [ "StaticLibraries" , "DynamicFrameworks" ]
2023-01-12 15:36:45 +00:00
exclude :
- architecture : "NewArch"
flavor : "Release"
jsengine : "Hermes"
flipper : "WithFlipper"
use_frameworks : "StaticLibraries"
2023-01-30 12:25:26 +00:00
- architecture : "NewArch"
flavor : "Release"
jsengine : "Hermes"
flipper : "WithFlipper"
use_frameworks : "DynamicFrameworks"
2023-01-12 15:36:45 +00:00
- architecture : "NewArch"
flavor : "Release"
jsengine : "JSC"
flipper : "WithFlipper"
use_frameworks : "StaticLibraries"
2023-01-30 12:25:26 +00:00
- architecture : "NewArch"
flavor : "Release"
jsengine : "JSC"
flipper : "WithFlipper"
use_frameworks : "DynamicFrameworks"
2023-01-12 15:36:45 +00:00
- architecture : "OldArch"
flavor : "Release"
jsengine : "Hermes"
flipper : "WithFlipper"
use_frameworks : "StaticLibraries"
2023-01-30 12:25:26 +00:00
- architecture : "OldArch"
flavor : "Release"
jsengine : "Hermes"
flipper : "WithFlipper"
use_frameworks : "DynamicFrameworks"
2023-01-12 15:36:45 +00:00
- architecture : "OldArch"
flavor : "Release"
jsengine : "JSC"
flipper : "WithFlipper"
use_frameworks : "StaticLibraries"
2023-01-30 12:25:26 +00:00
- architecture : "OldArch"
flavor : "Release"
jsengine : "JSC"
flipper : "WithFlipper"
use_frameworks : "DynamicFrameworks"
- architecture : "NewArch"
flavor : "Debug"
jsengine : "Hermes"
flipper : "WithFlipper"
use_frameworks : "DynamicFrameworks"
- architecture : "NewArch"
flavor : "Debug"
jsengine : "JSC"
flipper : "WithFlipper"
use_frameworks : "DynamicFrameworks"
- architecture : "OldArch"
flavor : "Debug"
jsengine : "Hermes"
flipper : "WithFlipper"
use_frameworks : "DynamicFrameworks"
- architecture : "OldArch"
flavor : "Debug"
jsengine : "JSC"
flipper : "WithFlipper"
use_frameworks : "DynamicFrameworks"
2023-03-06 10:56:26 +00:00
- test_ios_rntester :
requires :
- build_hermes_macos
name : "Test RNTester with Ruby 3.2.0"
ruby_version : "3.2.0"
architecture : "NewArch"
2022-07-20 16:12:47 +00:00
- test_ios_rntester :
requires :
- build_hermes_macos
2022-10-04 17:15:30 +00:00
matrix :
parameters :
architecture : [ "NewArch" , "OldArch" ]
2022-10-12 22:23:55 +00:00
jsengine : [ "Hermes" , "JSC" ]
2023-07-25 10:14:56 +00:00
use_frameworks : [ "StaticLibraries" , "DynamicFrameworks" ]
2023-03-06 10:56:26 +00:00
- test_ios :
name : "Test iOS with Ruby 3.2.0"
run_unit_tests : true
requires :
- build_hermes_macos
ruby_version : "3.2.0"
2022-04-28 15:53:24 +00:00
- test_ios :
2022-04-21 20:49:40 +00:00
run_unit_tests : true
2022-07-20 16:12:47 +00:00
requires :
- build_hermes_macos
2022-10-12 22:23:55 +00:00
matrix :
parameters :
jsengine : [ "Hermes" , "JSC" ]
2019-05-30 22:07:45 +00:00
- test_js :
2020-02-14 07:11:41 +00:00
name : test_js_prev_lts
executor : nodeprevlts
2020-04-01 00:36:31 +00:00
- test_windows :
run_disabled_tests : false
2022-01-24 22:06:49 +00:00
# This workflow should only be triggered by release script
package_release :
2023-01-27 09:33:21 +00:00
when : << pipeline.parameters.run_release_workflow >>
2018-12-01 03:45:56 +00:00
jobs :
2023-01-27 09:33:21 +00:00
# This job will push a tag that will trigger the publish_release workflow
2021-12-01 00:48:47 +00:00
- prepare_package_for_release :
name : prepare_package_for_release
2022-01-24 22:06:49 +00:00
version : << pipeline.parameters.release_version >>
latest : << pipeline.parameters.release_latest >>
2021-12-01 00:48:47 +00:00
2023-01-27 09:33:21 +00:00
# This job will run only when a tag is published due to all the jobs being filtered.
2022-01-24 22:06:49 +00:00
publish_release :
jobs :
2022-04-02 07:02:11 +00:00
- prepare_hermes_workspace :
2022-03-23 20:18:52 +00:00
filters : *only_release_tags
2022-04-02 07:02:11 +00:00
- build_hermesc_linux :
2022-04-28 17:44:06 +00:00
filters : *only_release_tags
2022-03-23 20:18:52 +00:00
requires :
2022-04-02 07:02:11 +00:00
- prepare_hermes_workspace
2023-08-02 16:42:56 +00:00
- build_apple_slices_hermes :
2022-04-28 17:44:06 +00:00
filters : *only_release_tags
2022-03-23 20:18:52 +00:00
requires :
2022-04-02 07:02:11 +00:00
- prepare_hermes_workspace
2022-09-22 20:41:51 +00:00
matrix :
parameters :
flavor : [ "Debug" , "Release" ]
2023-08-02 16:42:56 +00:00
slice : [ "macosx" , "iphoneos" , "iphonesimulator" , "catalyst" ]
2022-04-02 07:02:11 +00:00
- build_hermesc_windows :
2022-04-28 17:44:06 +00:00
filters : *only_release_tags
2022-03-23 20:18:52 +00:00
requires :
2022-04-02 07:02:11 +00:00
- prepare_hermes_workspace
2023-08-02 16:42:56 +00:00
- build_hermes_macos :
requires :
- build_apple_slices_hermes
matrix :
parameters :
flavor : [ "Debug" , "Release" ]
2022-01-24 22:06:49 +00:00
# This job will trigger when a version tag is pushed (by package_release)
2021-09-28 23:26:08 +00:00
- build_npm_package :
name : build_and_publish_npm_package
2022-10-20 00:54:22 +00:00
release_type : "release"
2022-03-08 01:02:08 +00:00
filters : *only_release_tags
2022-04-20 20:03:29 +00:00
requires :
2022-04-27 18:48:25 +00:00
- build_hermesc_linux
2022-05-23 19:14:29 +00:00
- build_hermes_macos
2022-04-27 18:48:25 +00:00
- build_hermesc_windows
2018-06-14 20:48:15 +00:00
2018-12-01 03:45:56 +00:00
analysis :
2023-01-27 09:33:21 +00:00
when :
and :
- equal : [ false , << pipeline.parameters.run_release_workflow >> ]
- equal : [ false , << pipeline.parameters.run_nightly_workflow >> ]
2018-12-01 03:45:56 +00:00
jobs :
2022-03-08 01:02:08 +00:00
# Run lints on every commit
- analyze_code
2019-05-30 22:07:45 +00:00
2022-05-23 08:12:25 +00:00
# Run code checks on PRs
- analyze_pr
2018-12-01 03:45:56 +00:00
2020-02-27 02:07:09 +00:00
nightly :
2023-01-27 09:33:21 +00:00
when : << pipeline.parameters.run_nightly_workflow >>
2020-02-27 02:07:09 +00:00
jobs :
- nightly_job
2022-04-02 07:02:11 +00:00
- prepare_hermes_workspace
- build_hermesc_linux :
2022-03-08 01:02:08 +00:00
requires :
2022-04-02 07:02:11 +00:00
- prepare_hermes_workspace
2023-08-02 16:42:56 +00:00
- build_apple_slices_hermes :
2022-03-08 01:02:08 +00:00
requires :
2022-04-02 07:02:11 +00:00
- prepare_hermes_workspace
2022-10-18 21:25:38 +00:00
matrix :
parameters :
flavor : [ "Debug" , "Release" ]
2023-08-02 16:42:56 +00:00
slice : [ "macosx" , "iphoneos" , "iphonesimulator" , "catalyst" ]
2022-04-02 07:02:11 +00:00
- build_hermesc_windows :
2022-03-08 01:02:08 +00:00
requires :
2022-04-02 07:02:11 +00:00
- prepare_hermes_workspace
2023-08-02 16:42:56 +00:00
- build_hermes_macos :
requires :
- build_apple_slices_hermes
matrix :
parameters :
flavor : [ "Debug" , "Release" ]
2021-09-28 23:26:08 +00:00
- build_npm_package :
2022-10-20 00:54:22 +00:00
release_type : "nightly"
2022-04-20 20:03:29 +00:00
requires :
2022-04-27 18:48:25 +00:00
- build_hermesc_linux
2022-05-23 19:14:29 +00:00
- build_hermes_macos
2022-04-27 18:48:25 +00:00
- build_hermesc_windows
2022-12-14 10:17:16 +00:00
publish_bumped_packages :
2023-01-27 09:33:21 +00:00
when :
and :
- equal : [ false , << pipeline.parameters.run_release_workflow >> ]
- equal : [ false , << pipeline.parameters.run_nightly_workflow >> ]
2022-12-14 10:17:16 +00:00
jobs :
- find_and_publish_bumped_packages :
<< : *main_or_stable_only