Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ commands:
steps:
- restore_cache:
keys:
- v4-yarn-cache-{{ arch }}-{{ checksum "yarn.lock" }}
- v5-yarn-cache-{{ .Environment.CIRCLE_JOB }}-{{ arch }}-{{ checksum "yarn.lock" }}
- v5-yarn-cache-{{ .Environment.CIRCLE_JOB }}-{{ arch }}
- v5-yarn-cache-{{ .Environment.CIRCLE_JOB }}
- run:
name: "Yarn: Install Dependencies"
command: |
Expand All @@ -89,7 +91,7 @@ commands:
- save_cache:
paths:
- ~/.cache/yarn
key: v4-yarn-cache-{{ arch }}-{{ checksum "yarn.lock" }}
key: v5-yarn-cache-{{ .Environment.CIRCLE_JOB }}-{{ arch }}-{{ checksum "yarn.lock" }}

install_buck_tooling:
steps:
Expand Down Expand Up @@ -337,8 +339,8 @@ jobs:
name: "Run Tests: JavaScript Tests"
command: node ./scripts/run-ci-javascript-tests.js --maxWorkers 2
# TODO(macOS GH#949): Disable this failing test
# - run_e2e:
# platform: js
- run_e2e:
platform: js

# Optionally, run disabled tests
- when:
Expand Down Expand Up @@ -825,11 +827,11 @@ workflows:
# requires:
# - setup_ios
# TODO(macOS GH#949): Disable this failing test
# - test_js:
# name: test_js_prev_lts
# executor: nodeprevlts
# requires:
# - setup_js
- test_js:
name: test_js_prev_lts
executor: nodeprevlts
requires:
- setup_js
- test_docker:
filters:
branches:
Expand Down
3 changes: 3 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
; Ignore everything in android-patches
<PROJECT_ROOT>/android-patches/.*

; Ignore intentional malformed file in package.json
.*/node_modules/resolve/test/resolver/malformed_package_json/package.json

[untyped]
.*/node_modules/@react-native-community/cli/.*/.*

Expand Down
30 changes: 9 additions & 21 deletions scripts/run-ci-e2e-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
* --skip-cli-install - to skip react-native-cli global installation (for local debugging)
* --retries [num] - how many times to retry possible flaky commands: yarn add and running tests, default 1
*/
/*eslint-disable no-undef */
require('shelljs/global');

const {cd, cp, echo, exec, exit, mv, rm} = require('shelljs');
const spawn = require('child_process').spawn;
const argv = require('yargs').argv;
const path = require('path');
Expand Down Expand Up @@ -56,25 +55,13 @@ try {
}
}

if (argv.js) {
describe('Install Flow');
if (
tryExecNTimes(
() => {
return exec('npm install --save-dev flow-bin').code;
},
numberOfRetries,
() => exec('sleep 10s'),
)
) {
echo('Failed to install Flow');
echo('Most common reason is npm registry connectivity, try again');
exitCode = 1;
throw Error(exitCode);
}
describe('Create react-native package');
if (exec('node ./scripts/set-rn-version.js --version 1000.0.0').code) {
echo('Failed to set version and update package.json ready for release');
exitCode = 1;
throw Error(exitCode);
}

describe('Create react-native package');
if (exec('npm pack').code) {
echo('Failed to pack react-native');
exitCode = 1;
Expand Down Expand Up @@ -281,6 +268,9 @@ try {
throw Error(exitCode);
}
describe('Test: Flow check');
// The resolve package included a test for a malformed package.json (see https://github.com/browserify/resolve/issues/89)
// that is failing the flow check. We're removing it.
rm('-rf', './node_modules/resolve/test/resolver/malformed_package_json');
if (exec(`${ROOT}/node_modules/.bin/flow check`).code) {
echo('Flow check failed.');
exitCode = 1;
Expand All @@ -303,5 +293,3 @@ try {
}
}
exit(exitCode);

/*eslint-enable no-undef */
5 changes: 1 addition & 4 deletions scripts/run-ci-javascript-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
* --jestBinary [path] - path to jest binary, defaults to local node modules
* --yarnBinary [path] - path to yarn binary, defaults to yarn
*/
/*eslint-disable no-undef */
require('shelljs/global');

const {echo, exec, exit} = require('shelljs');
const argv = require('yargs').argv;

const numberOfMaxWorkers = argv.maxWorkers || 1;
Expand Down Expand Up @@ -72,5 +71,3 @@ try {
echo('Finished.');
}
exit(exitCode);

/*eslint-enable no-undef */
163 changes: 163 additions & 0 deletions scripts/set-rn-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/

'use strict';

/**
* This script updates relevant React Native files with supplied version:
* * Prepares a package.json suitable for package consumption
* * Updates package.json for template project
* * Updates the version in gradle files and makes sure they are consistent between each other
* * Creates a gemfile
*/
const fs = require('fs');
const {cat, echo, exec, exit, sed} = require('shelljs');
const yargs = require('yargs');
const {parseVersion} = require('./version-utils');

let argv = yargs.option('v', {
alias: 'to-version',
type: 'string',
}).argv;

const version = argv.toVersion;

if (!version) {
echo('You must specify a version using -v');
exit(1);
}

let major,
minor,
patch,
prerelease = -1;
try {
({major, minor, patch, prerelease} = parseVersion(version));
} catch (e) {
echo(e.message);
exit(1);
}

fs.writeFileSync(
'ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java',
cat('scripts/versiontemplates/ReactNativeVersion.java.template')
.replace('${major}', major)
.replace('${minor}', minor)
.replace('${patch}', patch)
.replace(
'${prerelease}',
prerelease !== undefined ? `"${prerelease}"` : 'null',
),
'utf-8',
);

fs.writeFileSync(
'React/Base/RCTVersion.m',
cat('scripts/versiontemplates/RCTVersion.m.template')
.replace('${major}', `@(${major})`)
.replace('${minor}', `@(${minor})`)
.replace('${patch}', `@(${patch})`)
.replace(
'${prerelease}',
prerelease !== undefined ? `@"${prerelease}"` : '[NSNull null]',
),
'utf-8',
);

fs.writeFileSync(
'ReactCommon/cxxreact/ReactNativeVersion.h',
cat('scripts/versiontemplates/ReactNativeVersion.h.template')
.replace('${major}', major)
.replace('${minor}', minor)
.replace('${patch}', patch)
.replace(
'${prerelease}',
prerelease !== undefined ? `"${prerelease}"` : '""',
),
'utf-8',
);

fs.writeFileSync(
'Libraries/Core/ReactNativeVersion.js',
cat('scripts/versiontemplates/ReactNativeVersion.js.template')
.replace('${major}', major)
.replace('${minor}', minor)
.replace('${patch}', patch)
.replace(
'${prerelease}',
prerelease !== undefined ? `'${prerelease}'` : 'null',
),
'utf-8',
);

let packageJson = JSON.parse(cat('package.json'));
packageJson.version = version;
delete packageJson.workspaces;
delete packageJson.private;

// Copy dependencies over from repo-config/package.json
const repoConfigJson = JSON.parse(cat('repo-config/package.json'));
packageJson.devDependencies = {
...packageJson.devDependencies,
...repoConfigJson.dependencies,
};
// Make react-native-codegen a direct dependency of react-native
delete packageJson.devDependencies['react-native-codegen'];
packageJson.dependencies = {
...packageJson.dependencies,
'react-native-codegen': repoConfigJson.dependencies['react-native-codegen'],
};
fs.writeFileSync('package.json', JSON.stringify(packageJson, null, 2), 'utf-8');

// Change ReactAndroid/gradle.properties
if (
sed(
'-i',
/^VERSION_NAME=.*/,
`VERSION_NAME=${version}`,
'ReactAndroid/gradle.properties',
).code
) {
echo("Couldn't update version for Gradle");
exit(1);
}

// Change react-native version in the template's package.json
exec(`node scripts/set-rn-template-version.js ${version}`);

// Make sure to update ruby version
if (exec('scripts/update-ruby.sh').code) {
echo('Failed to update Ruby version');
exit(1);
}

// Verify that files changed, we just do a git diff and check how many times version is added across files
const filesToValidate = [
'package.json',
'ReactAndroid/gradle.properties',
'template/package.json',
];
const numberOfChangedLinesWithNewVersion = exec(
`git diff -U0 ${filesToValidate.join(
' ',
)}| grep '^[+]' | grep -c ${version} `,
{silent: true},
).stdout.trim();

if (+numberOfChangedLinesWithNewVersion !== filesToValidate.length) {
echo(
`Failed to update all the files: [${filesToValidate.join(
', ',
)}] must have versions in them`,
);
echo('Fix the issue and try again');
exit(1);
}

exit(0);
3 changes: 3 additions & 0 deletions template/_flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ node_modules/react-native/Libraries/polyfills/.*
; TODO(macOS GH#774): Ignore metro.config.js
<PROJECT_ROOT>/metro.config.js

; Ignore intentional malformed file in package.json
.*/node_modules/resolve/test/resolver/malformed_package_json/package.json

[untyped]
.*/node_modules/@react-native-community/cli/.*/.*

Expand Down
Loading