-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use verdaccio for the template e2e test #34577
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
storage: ./storage | ||
auth: | ||
htpasswd: | ||
file: ./htpasswd | ||
uplinks: | ||
npmjs: | ||
url: https://registry.npmjs.org/ | ||
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} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, '..')); | ||
|
@@ -35,6 +36,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 +72,19 @@ try { | |
|
||
const REACT_NATIVE_PACKAGE = path.join(ROOT, 'react-native-*.tgz'); | ||
|
||
describe('Set up Verdaccio'); | ||
fortmarek marked this conversation as resolved.
Show resolved
Hide resolved
|
||
VERDACCIO_PID = setupVerdaccio(); | ||
|
||
describe('Publish packages'); | ||
const packages = JSON.parse( | ||
JSON.parse(exec('yarn --json workspaces info').stdout).data, | ||
); | ||
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}`); | ||
cd(REACT_NATIVE_APP_DIR); | ||
|
@@ -156,9 +171,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 +301,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}`); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any particular reason for doing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using |
||
} | ||
} | ||
exit(exitCode); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This prohibits unauthenticated users to published organization-scoped packages. I've seen this being done both in the Microsoft PR and the docusaurus one. @juanpicado, do you know the exact reasoning behind this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great thanks for the clarification 👍