forked from DevExpress/testcafe-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
64 lines (49 loc) · 1.79 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const os = require('os');
const { execSync } = require('child_process');
const { getInput } = require('@actions/core');
function log (message) {
console.log(message);
}
function getInputStr (argValue) {
if (!argValue)
return 'not specified';
return argValue;
}
const testCafeArguments = getInput('args');
const version = getInput('version');
const branch = getInput('branch');
const commit = getInput('commit');
const skipInstall = getInput('skip-install') === 'true';
const branchCmd = branch && !commit ? `-b ${branch}` : '';
const gitCloneCmd = `git clone https://github.com/DevExpress/testcafe.git ${branchCmd}`;
const gitCheckoutCmd = `git -C testcafe checkout ${commit}`;
let testCafeCmd = '';
log(`VERSION: ${getInputStr(version)}`);
log(`BRANCH: ${getInputStr(branch)}`);
log(`COMMIT: ${getInputStr(commit)}`);
log(`SKIP INSTALL: ${skipInstall}`);
if (branch || commit) {
log('Cloning the TestCafe repository...');
log(gitCloneCmd);
execSync(gitCloneCmd, { stdio: 'inherit' });
log('Checking out the repository...');
log(gitCheckoutCmd);
execSync(gitCheckoutCmd, { stdio: 'inherit' });
log('Installing npm packages...');
execSync(`cd testcafe && npm install `, { stdio: 'inherit' });
log('Building TestCafe...');
execSync(`cd testcafe && npx gulp fast-build`, { stdio: 'inherit' });
testCafeCmd = 'node testcafe/bin/testcafe';
}
else {
if (!skipInstall) {
log('Installing TestCafe from npm...');
execSync(`npm i testcafe@${version}`);
}
testCafeCmd = 'npx testcafe';
}
let xvfbCmd = '';
if (os.type() === 'Linux')
xvfbCmd = `xvfb-run --server-args="-screen 0 1280x720x24" `;
log('Running TestCafe...');
execSync(`${xvfbCmd}${testCafeCmd} ${testCafeArguments}`, { stdio: 'inherit' });