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

Commit

Permalink
ci: use 'xvfb' node module in cli-yt-home
Browse files Browse the repository at this point in the history
  • Loading branch information
ascariandrea committed Jul 18, 2022
1 parent f63d072 commit cdfaf16
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 8 deletions.
18 changes: 11 additions & 7 deletions .github/workflows/guardoni_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,23 +123,27 @@ jobs:
platforms/guardoni/dist
platforms/ycai/studio/build
# - name: Install Xvfb
# run: sudo apt install xvfb

- name: Install dependencies
run: yarn

- name: Start PM2
run: |
yarn pm2 start --env test ./platforms/ecosystem.config.js
sleep 5
run: yarn pm2 start --env test ./platforms/ecosystem.config.js

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

# - name: Test CLI - YT Home
# run: yarn guardoni cli-yt-test-home
- name: Test CLI - YT Home
working-directory: ./platforms/guardoni
env:
DISPLAY: ':99.0'
run: xvfb-run --auto-servernum ./scripts/cli-yt-test-home.mjs

# - name: Test CLI - YT Videos
# run: yarn guardoni cli-yt-test-videos
- name: Test CLI - YT Videos
run: yarn guardoni cli-yt-test-videos

- name: Stop PM2
run: yarn pm2 stop all
Binary file not shown.
Binary file not shown.
3 changes: 2 additions & 1 deletion platforms/guardoni/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@
"webpack": "^5.73.0",
"webpack-bundle-analyzer": "^4.5.0",
"webpack-cli": "^4.10.0",
"webpack-node-externals": "^3.0.0"
"webpack-node-externals": "^3.0.0",
"xvfb": "^0.4.0"
},
"pkg": {
"scripts": [
Expand Down
20 changes: 20 additions & 0 deletions platforms/guardoni/scripts/cli-yt-test-home.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { $, os, fetch } from 'zx';
import { normalizePlatform, getGuardoniCliPkgName } from './utils.mjs';
import dotenv from 'dotenv';
import assert from 'assert';
// import Xvfb from 'xvfb';

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

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

// start xvfb
// const xvfb = new Xvfb({
// silent: true,
// reuse: true,
// xvfb_args: [':95'],
// });

// process.env.DISPLAY = ':95';

// xvfb.start((err) => {
// // eslint-disable-next-line no-console
// if (err) console.error(err);
// });

// reject cookie modal
await $`${cli} ${flags} yt-navigate --cookie-modal=reject --exit --headless=false`;

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

await $`echo ${yt_home_experiment_public_key}`;

// wait the parser to finish process metadata
await $`sleep 5`;

assert.strictEqual(yt_home_experiment_public_key, process.env.PUBLIC_KEY);
const metadata = await fetch(
`http://localhost:9000/api/v2/metadata?experimentId=${yt_home_experiment_id}`
).then((r) => r.json());

assert.strictEqual(metadata[0].experimentId, yt_home_experiment_id);
assert.strictEqual(metadata[0].type, 'home');

// xvfb.stop();
})();
3 changes: 3 additions & 0 deletions platforms/guardoni/scripts/cli-yt-test-videos.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ void (async function () {

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

// wait the parser to finish process metadata
await $`sleep 5`;

const metadata = await fetch(
`http://localhost:9000/api/v2/metadata?experimentId=${yt_video_experiment_id}`
).then((r) => r.json());
Expand Down
23 changes: 23 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14656,6 +14656,7 @@ __metadata:
webpack-cli: ^4.10.0
webpack-node-externals: ^3.0.0
ws: ^8.5.0
xvfb: ^0.4.0
yaml: ^1.10.2
yargs: ^17.5.1
bin:
Expand Down Expand Up @@ -24592,6 +24593,16 @@ __metadata:
languageName: node
linkType: hard

"sleep@npm:6.1.0":
version: 6.1.0
resolution: "sleep@npm:6.1.0"
dependencies:
nan: ^2.13.2
node-gyp: latest
checksum: 607465cdcfd630a80effcd44c887b29af7de061c5341ef99af064d6c08154d61bbb865626eb84868939cbcd668e9eb301a0ba320f5c2f5bc3f4b459492c6259e
languageName: node
linkType: hard

"slice-ansi@npm:^3.0.0":
version: 3.0.0
resolution: "slice-ansi@npm:3.0.0"
Expand Down Expand Up @@ -28296,6 +28307,18 @@ __metadata:
languageName: node
linkType: hard

"xvfb@npm:^0.4.0":
version: 0.4.0
resolution: "xvfb@npm:0.4.0"
dependencies:
sleep: 6.1.0
dependenciesMeta:
sleep:
optional: true
checksum: d8c446dd6e31a19067692b7ccd562758c855483b8e77275f95d77da136b5f94a1606b1b3f4e97fe85218f6a3ff8a39af05641c050c5396f4269f5914bd41eb65
languageName: node
linkType: hard

"y18n@npm:^4.0.0":
version: 4.0.3
resolution: "y18n@npm:4.0.3"
Expand Down

0 comments on commit cdfaf16

Please sign in to comment.