Skip to content

Commit

Permalink
Add verdaccio
Browse files Browse the repository at this point in the history
  • Loading branch information
fortmarek committed Sep 6, 2022
1 parent c34659a commit 83a5efe
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 6 deletions.
1 change: 1 addition & 0 deletions .circleci/verdaccio/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/storage
27 changes: 27 additions & 0 deletions .circleci/verdaccio/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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:
'@*/*':
access: $all
publish: $all
proxy: npmjs
'**':
access: $all
publish: $all
proxy: npmjs
logs:
- {type: file, path: verdaccio.log, format: pretty, level: debug}
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//localhost:4873/:_authToken="secretToken"
45 changes: 39 additions & 6 deletions scripts/run-ci-e2e-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
*/

const {cd, cp, echo, exec, exit, mv, rm} = require('shelljs');
const spawn = require('child_process').spawn;
const child_process = require('child_process');
const argv = require('yargs').argv;
const path = require('path');
const fs = require('fs');

const SCRIPTS = __dirname;
const ROOT = path.normalize(path.join(__dirname, '..'));
Expand All @@ -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) {
Expand Down Expand Up @@ -70,6 +72,27 @@ try {

const REACT_NATIVE_PACKAGE = path.join(ROOT, 'react-native-*.tgz');

describe('Verdaccio');
const verdaccioProcess = child_process.spawn(
'npx',
['verdaccio', '--config', './.circleci/verdaccio/config.yml'],
{
stdio: 'inherit',
},
);
VERDACCIO_PID = verdaccioProcess.pid;
exec('npm set registry http://localhost:4873');

exec('node ./scripts/wait-for-verdaccio.js');

echo('Publish packages');
const packages = fs.readdirSync('packages');
packages.forEach(current_package => {
exec(
`cd packages/${current_package} && 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);
Expand Down Expand Up @@ -144,7 +167,9 @@ try {
}

describe(`Start appium server, ${APPIUM_PID}`);
const appiumProcess = spawn('node', ['./node_modules/.bin/appium']);
const appiumProcess = child_process.spawn('node', [
'./node_modules/.bin/appium',
]);
APPIUM_PID = appiumProcess.pid;

describe('Build the app');
Expand All @@ -156,9 +181,13 @@ 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 = child_process.spawn(
'yarn',
['start', '--max-workers 1'],
{
env: process.env,
},
);
SERVER_PID = packagerProcess.pid;
// wait a bit to allow packager to startup
exec('sleep 15s');
Expand All @@ -185,7 +214,7 @@ try {
const packagerEnv = Object.create(process.env);
packagerEnv.REACT_NATIVE_MAX_WORKERS = 1;
describe('Start Metro');
const packagerProcess = spawn('yarn', ['start'], {
const packagerProcess = child_process.spawn('yarn', ['start'], {
stdio: 'inherit',
env: packagerEnv,
});
Expand Down Expand Up @@ -288,5 +317,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);
21 changes: 21 additions & 0 deletions scripts/wait-for-verdaccio.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env node
// @ts-check

const http = require('http');

function queryForServerStatus() {

http.get('http://localhost:4873', res => {
console.log(`Server status: ${res.statusCode}`);
if (res.statusCode !== 200) {
setTimeout(queryForServerStatus, 2000);
}
}).on('error', err => {
console.log(err.name, err.stack, err.message);
setTimeout(queryForServerStatus, 2000);
});
}

console.log('Waiting for verdaccio instance to respond...');

queryForServerStatus();

0 comments on commit 83a5efe

Please sign in to comment.