From d0f7305e68d6823bbec20dd909bbca677d794d73 Mon Sep 17 00:00:00 2001 From: fortmarek Date: Fri, 2 Sep 2022 12:00:04 +0200 Subject: [PATCH 1/3] Add verdaccio --- .circleci/verdaccio/config.yml | 27 +++++++++++++++++++ scripts/run-ci-e2e-tests.js | 49 +++++++++++++++++++++++++++++++--- 2 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 .circleci/verdaccio/config.yml diff --git a/.circleci/verdaccio/config.yml b/.circleci/verdaccio/config.yml new file mode 100644 index 000000000000..de1d51f4d9ef --- /dev/null +++ b/.circleci/verdaccio/config.yml @@ -0,0 +1,27 @@ +storage: ./storage +auth: + htpasswd: + file: ./htpasswd +uplinks: + npmjs: + url: https://registry.yarnpkg.com/ + max_fails: 40 + maxage: 30m + timeout: 60s + fail_timeout: 10m + cache: false + agent_options: + keepAlive: true + maxSockets: 40 + maxFreeSockets: 10 +packages: + '@*/*': + access: $all + publish: $all + proxy: npmjs + '**': + access: $all + publish: $all + proxy: npmjs +logs: + - {type: file, path: verdaccio.log, format: pretty, level: debug} diff --git a/scripts/run-ci-e2e-tests.js b/scripts/run-ci-e2e-tests.js index 177cb102339a..4b1f0bd4b60c 100644 --- a/scripts/run-ci-e2e-tests.js +++ b/scripts/run-ci-e2e-tests.js @@ -35,6 +35,7 @@ const REACT_NATIVE_APP_DIR = `${REACT_NATIVE_TEMP_DIR}/template`; const numberOfRetries = argv.retries || 1; let SERVER_PID; let APPIUM_PID; +let VERDACCIO_PID; let exitCode; function describe(message) { @@ -70,6 +71,46 @@ try { const REACT_NATIVE_PACKAGE = path.join(ROOT, 'react-native-*.tgz'); + describe('Set up Verdaccio'); + const verdaccioProcess = spawn('npx', [ + 'verdaccio@5.15.3', + '--config', + '.circleci/verdaccio/config.yml', + ]); + VERDACCIO_PID = verdaccioProcess.pid; + exec('npx wait-on@6.0.1 http://localhost:4873'); + exec('npm set registry http://localhost:4873'); + exec('echo "//localhost:4873/:_authToken=secretToken" > .npmrc'); + + describe('Publish packages'); + const packages = JSON.parse( + JSON.parse(exec('yarn --json workspaces info').stdout).data, + ); + Object.keys(packages) + .filter( + packageName => + packageName !== '@react-native/tester' && + packageName !== '@react-native/repo-config', + ) + .filter(packageName => { + const yarnInfo = exec(`yarn info ${packageName} --json`); + if (yarnInfo.stderr !== '') { + return true; + } + const versions = JSON.parse( + exec(`yarn info ${packageName} --json`).stdout.trim(), + ).data.versions; + const currentVersion = require(`${process.cwd()}/${ + packages[packageName].location + }/package.json`).version; + return !versions.includes(currentVersion); + }) + .forEach(packageName => { + exec( + `cd ${packages[packageName].location} && npm publish --registry http://localhost:4873 --yes --access public`, + ); + }); + describe('Scaffold a basic React Native app from template'); exec(`rsync -a ${ROOT}/template ${REACT_NATIVE_TEMP_DIR}`); cd(REACT_NATIVE_APP_DIR); @@ -156,9 +197,7 @@ try { describe(`Start Metro, ${SERVER_PID}`); // shelljs exec('', {async: true}) does not emit stdout events, so we rely on good old spawn - const packagerProcess = spawn('yarn', ['start', '--max-workers 1'], { - env: process.env, - }); + const packagerProcess = spawn('yarn', ['start', '--max-workers 1']); SERVER_PID = packagerProcess.pid; // wait a bit to allow packager to startup exec('sleep 15s'); @@ -288,5 +327,9 @@ try { echo(`Killing appium ${APPIUM_PID}`); exec(`kill -9 ${APPIUM_PID}`); } + if (VERDACCIO_PID) { + echo(`Killing verdaccio ${VERDACCIO_PID}`); + exec(`kill -9 ${VERDACCIO_PID}`); + } } exit(exitCode); From 80bb93d6f81fa38d5540bbfe6e48cdf542b1e84d Mon Sep 17 00:00:00 2001 From: fortmarek Date: Wed, 14 Sep 2022 15:04:54 +0200 Subject: [PATCH 2/3] Improve verdaccio setup --- .circleci/verdaccio.yml | 44 ++++++++++++++++++++++++++++++++++ .circleci/verdaccio/config.yml | 27 --------------------- scripts/run-ci-e2e-tests.js | 15 +----------- template/package.json | 2 +- 4 files changed, 46 insertions(+), 42 deletions(-) create mode 100644 .circleci/verdaccio.yml delete mode 100644 .circleci/verdaccio/config.yml diff --git a/.circleci/verdaccio.yml b/.circleci/verdaccio.yml new file mode 100644 index 000000000000..74321150f916 --- /dev/null +++ b/.circleci/verdaccio.yml @@ -0,0 +1,44 @@ +storage: ./storage +auth: + htpasswd: + file: ./htpasswd +uplinks: + npmjs: + url: https://registry.yarnpkg.com/ + max_fails: 40 + maxage: 30m + timeout: 60s + fail_timeout: 10m + cache: false + agent_options: + keepAlive: true + maxSockets: 40 + maxFreeSockets: 10 +packages: + # Group and isolate all local packages, avoid being proxy from outside + '@react-native/*': + access: $all + publish: $all + # The below specific entries can be removed once they are renamed and have the @react-native prefix + '@react-native-community/eslint-config': + access: $all + publish: $all + '@react-native-community/eslint-plugin': + access: $all + publish: $all + 'react-native-codegen': + access: $all + publish: $all + 'react-native-gradle-plugin': + access: $all + publish: $all + '@*/*': + access: $all + publish: $authenticated + proxy: npmjs + '**': + access: $all + publish: $all + proxy: npmjs +logs: + - {type: file, path: verdaccio.log, format: json, level: warn} diff --git a/.circleci/verdaccio/config.yml b/.circleci/verdaccio/config.yml deleted file mode 100644 index de1d51f4d9ef..000000000000 --- a/.circleci/verdaccio/config.yml +++ /dev/null @@ -1,27 +0,0 @@ -storage: ./storage -auth: - htpasswd: - file: ./htpasswd -uplinks: - npmjs: - url: https://registry.yarnpkg.com/ - max_fails: 40 - maxage: 30m - timeout: 60s - fail_timeout: 10m - cache: false - agent_options: - keepAlive: true - maxSockets: 40 - maxFreeSockets: 10 -packages: - '@*/*': - access: $all - publish: $all - proxy: npmjs - '**': - access: $all - publish: $all - proxy: npmjs -logs: - - {type: file, path: verdaccio.log, format: pretty, level: debug} diff --git a/scripts/run-ci-e2e-tests.js b/scripts/run-ci-e2e-tests.js index 4b1f0bd4b60c..1a9920166900 100644 --- a/scripts/run-ci-e2e-tests.js +++ b/scripts/run-ci-e2e-tests.js @@ -75,7 +75,7 @@ try { const verdaccioProcess = spawn('npx', [ 'verdaccio@5.15.3', '--config', - '.circleci/verdaccio/config.yml', + '.circleci/verdaccio.yml', ]); VERDACCIO_PID = verdaccioProcess.pid; exec('npx wait-on@6.0.1 http://localhost:4873'); @@ -92,19 +92,6 @@ try { packageName !== '@react-native/tester' && packageName !== '@react-native/repo-config', ) - .filter(packageName => { - const yarnInfo = exec(`yarn info ${packageName} --json`); - if (yarnInfo.stderr !== '') { - return true; - } - const versions = JSON.parse( - exec(`yarn info ${packageName} --json`).stdout.trim(), - ).data.versions; - const currentVersion = require(`${process.cwd()}/${ - packages[packageName].location - }/package.json`).version; - return !versions.includes(currentVersion); - }) .forEach(packageName => { exec( `cd ${packages[packageName].location} && npm publish --registry http://localhost:4873 --yes --access public`, diff --git a/template/package.json b/template/package.json index 5300570ea3dc..98dd49a0886c 100644 --- a/template/package.json +++ b/template/package.json @@ -16,7 +16,7 @@ "devDependencies": { "@babel/core": "^7.12.9", "@babel/runtime": "^7.12.5", - "@react-native-community/eslint-config": "^2.0.0", + "@react-native-community/eslint-config": "^3.0.0", "babel-jest": "^26.6.3", "eslint": "^8.19.0", "jest": "^26.6.3", From 6fafd7a30494c123f74031560eaa38162614fe4d Mon Sep 17 00:00:00 2001 From: fortmarek Date: Wed, 21 Sep 2022 22:15:40 +0200 Subject: [PATCH 3/3] Address PR comments --- .circleci/verdaccio.yml | 2 +- scripts/run-ci-e2e-tests.js | 27 +++++++-------------------- scripts/setup-verdaccio.js | 30 ++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 21 deletions(-) create mode 100644 scripts/setup-verdaccio.js diff --git a/.circleci/verdaccio.yml b/.circleci/verdaccio.yml index 74321150f916..37e5d23b3802 100644 --- a/.circleci/verdaccio.yml +++ b/.circleci/verdaccio.yml @@ -4,7 +4,7 @@ auth: file: ./htpasswd uplinks: npmjs: - url: https://registry.yarnpkg.com/ + url: https://registry.npmjs.org/ max_fails: 40 maxage: 30m timeout: 60s diff --git a/scripts/run-ci-e2e-tests.js b/scripts/run-ci-e2e-tests.js index 1a9920166900..1c013ba07353 100644 --- a/scripts/run-ci-e2e-tests.js +++ b/scripts/run-ci-e2e-tests.js @@ -23,6 +23,7 @@ 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'); +const {setupVerdaccio} = require('./setup-verdaccio'); const SCRIPTS = __dirname; const ROOT = path.normalize(path.join(__dirname, '..')); @@ -72,31 +73,17 @@ try { const REACT_NATIVE_PACKAGE = path.join(ROOT, 'react-native-*.tgz'); describe('Set up Verdaccio'); - const verdaccioProcess = spawn('npx', [ - 'verdaccio@5.15.3', - '--config', - '.circleci/verdaccio.yml', - ]); - VERDACCIO_PID = verdaccioProcess.pid; - exec('npx wait-on@6.0.1 http://localhost:4873'); - exec('npm set registry http://localhost:4873'); - exec('echo "//localhost:4873/:_authToken=secretToken" > .npmrc'); + VERDACCIO_PID = setupVerdaccio(); describe('Publish packages'); const packages = JSON.parse( JSON.parse(exec('yarn --json workspaces info').stdout).data, ); - Object.keys(packages) - .filter( - packageName => - packageName !== '@react-native/tester' && - packageName !== '@react-native/repo-config', - ) - .forEach(packageName => { - exec( - `cd ${packages[packageName].location} && npm publish --registry http://localhost:4873 --yes --access public`, - ); - }); + Object.keys(packages).forEach(packageName => { + exec( + `cd ${packages[packageName].location} && npm publish --registry http://localhost:4873 --yes --access public`, + ); + }); describe('Scaffold a basic React Native app from template'); exec(`rsync -a ${ROOT}/template ${REACT_NATIVE_TEMP_DIR}`); diff --git a/scripts/setup-verdaccio.js b/scripts/setup-verdaccio.js new file mode 100644 index 000000000000..e62e7918540d --- /dev/null +++ b/scripts/setup-verdaccio.js @@ -0,0 +1,30 @@ +/** + * Copyright (c) Meta Platforms, Inc. and 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'; + +const {exec} = require('shelljs'); +const spawn = require('child_process').spawn; + +function setupVerdaccio() { + const verdaccioProcess = spawn('npx', [ + 'verdaccio@5.15.3', + '--config', + '.circleci/verdaccio.yml', + ]); + const VERDACCIO_PID = verdaccioProcess.pid; + exec('npx wait-on@6.0.1 http://localhost:4873'); + exec('npm set registry http://localhost:4873'); + exec('echo "//localhost:4873/:_authToken=secretToken" > .npmrc'); + return VERDACCIO_PID; +} + +module.exports = { + setupVerdaccio: setupVerdaccio, +};