Skip to content
This repository was archived by the owner on Aug 15, 2023. It is now read-only.

Commit f8b44e9

Browse files
committed
ci: use 'xvfb' node module in cli-yt-home
1 parent f63d072 commit f8b44e9

7 files changed

+59
-8
lines changed

.github/workflows/guardoni_pull_request.yml

+11-7
Original file line numberDiff line numberDiff line change
@@ -123,23 +123,27 @@ jobs:
123123
platforms/guardoni/dist
124124
platforms/ycai/studio/build
125125
126+
# - name: Install Xvfb
127+
# run: sudo apt install xvfb
128+
126129
- name: Install dependencies
127130
run: yarn
128131

129132
- name: Start PM2
130-
run: |
131-
yarn pm2 start --env test ./platforms/ecosystem.config.js
132-
sleep 5
133+
run: yarn pm2 start --env test ./platforms/ecosystem.config.js
133134

134135
- name: Build Guardoni for ${{ matrix.config.os }}
135136
working-directory: ./platforms/guardoni
136137
run: ./scripts/cli-build.mjs
137138

138-
# - name: Test CLI - YT Home
139-
# run: yarn guardoni cli-yt-test-home
139+
- name: Test CLI - YT Home
140+
uses: GabrielBB/xvfb-action@v1
141+
with:
142+
working-directory: ./platforms/guardoni
143+
run: ./scripts/cli-yt-test-home.mjs
140144

141-
# - name: Test CLI - YT Videos
142-
# run: yarn guardoni cli-yt-test-videos
145+
- name: Test CLI - YT Videos
146+
run: yarn guardoni cli-yt-test-videos
143147

144148
- name: Stop PM2
145149
run: yarn pm2 stop all
Binary file not shown.
Binary file not shown.

platforms/guardoni/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@
130130
"webpack": "^5.73.0",
131131
"webpack-bundle-analyzer": "^4.5.0",
132132
"webpack-cli": "^4.10.0",
133-
"webpack-node-externals": "^3.0.0"
133+
"webpack-node-externals": "^3.0.0",
134+
"xvfb": "^0.4.0"
134135
},
135136
"pkg": {
136137
"scripts": [

platforms/guardoni/scripts/cli-yt-test-home.mjs

+20
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { $, os, fetch } from 'zx';
55
import { normalizePlatform, getGuardoniCliPkgName } from './utils.mjs';
66
import dotenv from 'dotenv';
77
import assert from 'assert';
8+
// import Xvfb from 'xvfb';
89

910
dotenv.config({ path: '.env.development' });
1011

@@ -30,6 +31,20 @@ void (async function () {
3031
`--secretKey=${process.env.SECRET_KEY}`,
3132
];
3233

34+
// start xvfb
35+
// const xvfb = new Xvfb({
36+
// silent: true,
37+
// reuse: true,
38+
// xvfb_args: [':95'],
39+
// });
40+
41+
// process.env.DISPLAY = ':95';
42+
43+
// xvfb.start((err) => {
44+
// // eslint-disable-next-line no-console
45+
// if (err) console.error(err);
46+
// });
47+
3348
// reject cookie modal
3449
await $`${cli} ${flags} yt-navigate --cookie-modal=reject --exit --headless=false`;
3550

@@ -54,11 +69,16 @@ void (async function () {
5469

5570
await $`echo ${yt_home_experiment_public_key}`;
5671

72+
// wait the parser to finish process metadata
73+
await $`sleep 5`;
74+
5775
assert.strictEqual(yt_home_experiment_public_key, process.env.PUBLIC_KEY);
5876
const metadata = await fetch(
5977
`http://localhost:9000/api/v2/metadata?experimentId=${yt_home_experiment_id}`
6078
).then((r) => r.json());
6179

6280
assert.strictEqual(metadata[0].experimentId, yt_home_experiment_id);
6381
assert.strictEqual(metadata[0].type, 'home');
82+
83+
// xvfb.stop();
6484
})();

platforms/guardoni/scripts/cli-yt-test-videos.mjs

+3
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ void (async function () {
5454

5555
assert.strictEqual(ytVideoExperimentPubKey, process.env.PUBLIC_KEY);
5656

57+
// wait the parser to finish process metadata
58+
await $`sleep 5`;
59+
5760
const metadata = await fetch(
5861
`http://localhost:9000/api/v2/metadata?experimentId=${yt_video_experiment_id}`
5962
).then((r) => r.json());

yarn.lock

+23
Original file line numberDiff line numberDiff line change
@@ -14656,6 +14656,7 @@ __metadata:
1465614656
webpack-cli: ^4.10.0
1465714657
webpack-node-externals: ^3.0.0
1465814658
ws: ^8.5.0
14659+
xvfb: ^0.4.0
1465914660
yaml: ^1.10.2
1466014661
yargs: ^17.5.1
1466114662
bin:
@@ -24592,6 +24593,16 @@ __metadata:
2459224593
languageName: node
2459324594
linkType: hard
2459424595

24596+
"sleep@npm:6.1.0":
24597+
version: 6.1.0
24598+
resolution: "sleep@npm:6.1.0"
24599+
dependencies:
24600+
nan: ^2.13.2
24601+
node-gyp: latest
24602+
checksum: 607465cdcfd630a80effcd44c887b29af7de061c5341ef99af064d6c08154d61bbb865626eb84868939cbcd668e9eb301a0ba320f5c2f5bc3f4b459492c6259e
24603+
languageName: node
24604+
linkType: hard
24605+
2459524606
"slice-ansi@npm:^3.0.0":
2459624607
version: 3.0.0
2459724608
resolution: "slice-ansi@npm:3.0.0"
@@ -28296,6 +28307,18 @@ __metadata:
2829628307
languageName: node
2829728308
linkType: hard
2829828309

28310+
"xvfb@npm:^0.4.0":
28311+
version: 0.4.0
28312+
resolution: "xvfb@npm:0.4.0"
28313+
dependencies:
28314+
sleep: 6.1.0
28315+
dependenciesMeta:
28316+
sleep:
28317+
optional: true
28318+
checksum: d8c446dd6e31a19067692b7ccd562758c855483b8e77275f95d77da136b5f94a1606b1b3f4e97fe85218f6a3ff8a39af05641c050c5396f4269f5914bd41eb65
28319+
languageName: node
28320+
linkType: hard
28321+
2829928322
"y18n@npm:^4.0.0":
2830028323
version: 4.0.3
2830128324
resolution: "y18n@npm:4.0.3"

0 commit comments

Comments
 (0)