Skip to content

Commit 6d692d5

Browse files
author
Brian Vaughn
committed
Run DevTools e2e tests on Circle CI
1 parent bcd24a6 commit 6d692d5

File tree

2 files changed

+112
-0
lines changed

2 files changed

+112
-0
lines changed

.circleci/config.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,23 @@ jobs:
200200
- store_artifacts:
201201
path: ./build/devtools.tgz
202202

203+
run_devtools_e2e_tests:
204+
docker: *docker
205+
environment: *environment
206+
steps:
207+
- checkout
208+
- attach_workspace:
209+
at: .
210+
- run: yarn workspaces info | head -n -1 > workspace_info.txt
211+
- *restore_node_modules
212+
- run:
213+
name: Install Packages
214+
command: yarn --frozen-lockfile --cache-folder ~/.cache/yarn
215+
- run:
216+
environment:
217+
RELEASE_CHANNEL: experimental
218+
command: ./scripts/circleci/run_devtools_e2e_tests.js
219+
203220
yarn_lint_build:
204221
docker: *docker
205222
environment: *environment
@@ -452,6 +469,9 @@ workflows:
452469
- build_devtools_and_process_artifacts:
453470
requires:
454471
- yarn_build_combined
472+
- run_devtools_e2e_tests:
473+
requires:
474+
- build_devtools_and_process_artifacts
455475

456476
fuzz_tests:
457477
unless: << pipeline.parameters.prerelease_commit_sha >>
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!/usr/bin/env node
2+
3+
'use strict';
4+
5+
const {spawn} = require('child_process');
6+
const {join} = require('path');
7+
8+
const ROOT_PATH = join(__dirname, '..', '..');
9+
10+
let serverProcess = null;
11+
let testProcess = null;
12+
13+
function runTestShell() {
14+
const shellPackagePath = join(ROOT_PATH, 'packages', 'react-devtools-shell');
15+
16+
const timeoutID = setTimeout(() => {
17+
// Assume the test shell server failed to start.
18+
console.error('Testing shell server failed to start');
19+
exitWithCode(1);
20+
}, 30000);
21+
22+
console.log('Starting testing shell server');
23+
24+
serverProcess = spawn('yarn', ['start'], {cwd: shellPackagePath});
25+
serverProcess.stdout.on('data', data => {
26+
if (`${data}`.includes('Compiled successfully.')) {
27+
console.log('Testing shell server running');
28+
29+
clearTimeout(timeoutID);
30+
31+
runEndToEndTests();
32+
}
33+
});
34+
serverProcess.stderr.on('data', data => {
35+
// Mostly non-fatal errors like Babel optimization warnings etc.
36+
// But we do need to handle the case where the port is already in use.
37+
console.error(`${data}`);
38+
if (`${data}`.includes('EADDRINUSE')) {
39+
console.log('Free up the port and re-run tests:');
40+
console.log(' kill -9 $(lsof -ti:8080)');
41+
42+
exitWithCode(1);
43+
}
44+
});
45+
}
46+
47+
async function runEndToEndTests() {
48+
const inlinePackagePath = join(
49+
ROOT_PATH,
50+
'packages',
51+
'react-devtools-inline'
52+
);
53+
54+
console.log('Running e2e tests');
55+
56+
testProcess = spawn('yarn', ['test:e2e'], {cwd: inlinePackagePath});
57+
testProcess.stdout.on('data', data => {
58+
console.log(`${data}`);
59+
});
60+
testProcess.stderr.on('data', data => {
61+
console.error(`${data}`);
62+
exitWithCode(1);
63+
});
64+
testProcess.on('close', code => {
65+
console.log(`Tests completed with code: ${code}`);
66+
exitWithCode(code);
67+
});
68+
}
69+
70+
function exitWithCode(code) {
71+
if (serverProcess !== null) {
72+
try {
73+
console.log('Shutting down shell server process');
74+
serverProcess.kill();
75+
} catch (error) {
76+
console.error(error);
77+
}
78+
}
79+
80+
if (testProcess !== null) {
81+
try {
82+
console.log('Shutting down test process');
83+
testProcess.kill();
84+
} catch (error) {
85+
console.error(error);
86+
}
87+
}
88+
89+
process.exit(code);
90+
}
91+
92+
runTestShell();

0 commit comments

Comments
 (0)