Skip to content

Commit ad8e533

Browse files
committed
fix(ci): Update ci to work with last version of puppeteer
1 parent a923912 commit ad8e533

File tree

7 files changed

+193
-82
lines changed

7 files changed

+193
-82
lines changed

.ci/doc/Dockerfile

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
FROM node:20-bookworm-slim
2+
3+
USER root
4+
5+
RUN mkdir -p /home/node/.cache/puppeteer
6+
7+
# Puppeteer Chrome headless dependencies
8+
RUN apt-get update && apt-get install -y \
9+
ca-certificates \
10+
curl \
11+
fonts-liberation \
12+
libasound2 \
13+
libatk-bridge2.0-0 \
14+
libatk1.0-0 \
15+
libc6 \
16+
libcairo2 \
17+
libcups2 \
18+
libdbus-1-3 \
19+
libexpat1 \
20+
libfontconfig1 \
21+
libgbm1 \
22+
libgcc1 \
23+
libglib2.0-0 \
24+
libgtk-3-0 \
25+
libnspr4 \
26+
libnss3 \
27+
libpango-1.0-0 \
28+
libpangocairo-1.0-0 \
29+
libstdc++6 \
30+
libx11-6 \
31+
libx11-xcb1 \
32+
libxcb1 \
33+
libxcomposite1 \
34+
libxcursor1 \
35+
libxdamage1 \
36+
libxext6 \
37+
libxfixes3 \
38+
libxi6 \
39+
libxrandr2 \
40+
libxrender1 \
41+
libxss1 \
42+
libxtst6 \
43+
lsb-release \
44+
wget \
45+
xdg-utils \
46+
&& rm -rf /var/lib/apt/lists/*
47+
48+
# Install all dependencies needed for both services
49+
RUN npm install -g \
50+
puppeteer \
51+
52+
eslint-plugin-html \
53+
eslint-plugin-import \
54+
eslint-plugin-node \
55+
eslint-plugin-promise \
56+
eslint-plugin-standard \
57+
babel-loader \
58+
@babel/core \
59+
html-webpack-plugin \
60+
webpack \
61+
webpack-cli
62+
63+
RUN usermod -a -G video,audio node
64+
65+
# Create working directories for snippets
66+
RUN mkdir -p /var/snippets/web && \
67+
mkdir -p /var/snippets/webpack
68+
69+
# Set proper permissions
70+
RUN chown -R node:node /var/snippets/
71+
RUN chown -R node:node /home/node/.cache/puppeteer
72+
73+
USER node
74+
75+
# Keep container running
76+
CMD ["tail", "-f", "/dev/null"]

.ci/doc/config.yml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,40 @@ snippets:
55
templates: /mnt/.ci/doc/templates
66

77
runners:
8-
default: node
8+
default: web
99

10-
node:
11-
service: doc-runner-node
12-
path: /var/snippets/node
13-
lint:
14-
global: true
15-
cmd: eslint -c /mnt/.ci/doc/eslint.json {{ snippet.dir }}
16-
before: timeout 600 ash -c 'until stat /tmp/runner_ready_to_lint; do sleep 1; done'
17-
run:
18-
cmd: node {{ snippet.source }}
19-
before: timeout 600 ash -c 'until stat /tmp/runner_is_ready && curl -f -s -o /dev/null http://kuzzle:7512/_now; do sleep 1; done'
10+
# node:
11+
# service: doc-runner-node
12+
# path: /var/snippets/node
13+
# lint:
14+
# global: true
15+
# cmd: npx eslint@8.38.0 -c /mnt/.ci/doc/eslint.json {{ snippet.dir }}
16+
# before: timeout 600 ash -c 'until stat /home/node/runner_ready_to_lint; do sleep 1; done'
17+
# run:
18+
# cmd: node {{ snippet.source }}
19+
# before: timeout 600 ash -c 'until stat /home/node/runner_is_ready && curl -f -s -o /dev/null http://kuzzle:7512/_now; do sleep 1; done'
2020

2121
web:
2222
service: doc-runner-web
2323
path: /var/snippets/web
2424
lint:
2525
global: true
26-
cmd: eslint -c /mnt/.ci/doc/eslint.json --parser-options ecmaVersion:12 {{ snippet.dir }}/*.html
27-
before: timeout 600 bash -c 'until stat /tmp/runner_ready_to_lint; do sleep 1; done'
26+
cmd: npx eslint@8.38.0 -c /mnt/.ci/doc/eslint.json --parser-options ecmaVersion:12 {{ snippet.dir }}/*.html
27+
before: timeout 600 bash -c 'until stat /home/node/runner_ready_to_lint; do sleep 1; done'
2828
run:
2929
cmd: node puppeteer.js {{ snippet.dir }}/{{ snippet.source }}
30-
before: timeout 600 bash -c 'until stat /tmp/runner_is_ready && curl -f -s -o /dev/null http://kuzzle:7512/_now; do sleep 1; done'
30+
before: timeout 600 bash -c 'until stat /home/node/runner_is_ready && curl -f -s -o /dev/null http://kuzzle:7512/_now; do sleep 1; done'
3131

3232
webpack:
3333
service: doc-runner-webpack
3434
path: /var/snippets/webpack
3535
lint:
3636
global: true
37-
cmd: eslint -c /mnt/.ci/doc/eslint.json {{ snippet.dir }}
38-
before: timeout 600 bash -c 'until stat /tmp/runner_ready_to_lint; do sleep 1; done'
37+
cmd: npx eslint8.38.0 -c /mnt/.ci/doc/eslint.json {{ snippet.dir }}
38+
before: timeout 600 bash -c 'until stat /home/node/runner_ready_to_lint; do sleep 1; done'
3939
build:
4040
cmd: node webpackBuild.js {{ snippet.dir }}/{{ snippet.source }}
41-
before: timeout 600 bash -c 'until stat /tmp/runner_is_ready; do sleep 1; done'
41+
before: timeout 600 bash -c 'until stat /home/node/runner_is_ready; do sleep 1; done'
4242
run:
4343
cmd: node puppeteer.js /tmp/{{ snippet.name }}/index.html
4444
before: timeout 600 bash -c 'until curl -f -s -o /dev/null http://kuzzle:7512/_now; do sleep 1; done'

.ci/doc/docker-compose.yml

Lines changed: 21 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,11 @@ services:
4747
ash -c '
4848
mkdir -p /var/snippets/node;
4949
apk add --no-cache curl;
50-
npm install -g [email protected];
5150
cd /var/snippets/node;
5251
npm install \
5352
bluebird \
5453
/mnt/ \
55-
eslint \
54+
eslint@8.38.0 \
5655
eslint-plugin-html \
5756
eslint-plugin-import \
5857
eslint-plugin-node \
@@ -67,68 +66,40 @@ services:
6766
- snippets:/var/snippets
6867

6968
doc-runner-web:
70-
image: ghcr.io/puppeteer/puppeteer:23.5.1
71-
user: root
69+
build: .
70+
volumes:
71+
- ../..:/mnt
72+
- snippets:/var/snippets
73+
working_dir: /var/snippets/web
7274
command: >
7375
bash -c '
74-
mkdir -p /var/snippets/web;
75-
apt-get update;
76-
apt-get install -y curl;
77-
npm install -g \
78-
79-
cd /var/snippets/web;
8076
cp /mnt/.ci/doc/puppeteer.js /var/snippets/web/;
81-
npm install \
82-
/mnt/ \
83-
puppeteer \
84-
eslint \
85-
eslint-plugin-html \
86-
eslint-plugin-import \
87-
eslint-plugin-node \
88-
eslint-plugin-promise \
89-
eslint-plugin-standard;
90-
touch /tmp/runner_ready_to_lint;
91-
touch /tmp/runner_is_ready;
77+
npm install /mnt/;
78+
cp -fr /usr/local/lib/node_modules/* /var/snippets/web/node_modules;
79+
cp -fr /usr/local/lib/node_modules/* /var/snippets/webpack/node_modules;
80+
touch /home/node/runner_ready_to_lint;
81+
touch /home/node/runner_is_ready;
9282
tail -f /dev/null
9383
'
84+
85+
doc-runner-webpack:
86+
build: .
9487
volumes:
9588
- ../..:/mnt
9689
- snippets:/var/snippets
97-
98-
doc-runner-webpack:
99-
image: ghcr.io/puppeteer/puppeteer:23.5.1
100-
user: root
90+
working_dir: /var/snippets/webpack
10191
command: >
10292
bash -c '
103-
mkdir -p /var/snippets/webpack;
104-
apt-get update;
105-
apt-get install -y curl;
106-
npm install -g \
107-
108-
cd /var/snippets/webpack;
10993
cp /mnt/.ci/doc/puppeteer.js /var/snippets/webpack/;
11094
cp /mnt/.ci/doc/webpackBuild.js /var/snippets/webpack/;
111-
npm install \
112-
/mnt/ \
113-
puppeteer \
114-
babel-loader \
115-
@babel/core \
116-
html-webpack-plugin \
117-
webpack \
118-
webpack-cli \
119-
eslint \
120-
eslint-plugin-html \
121-
eslint-plugin-import \
122-
eslint-plugin-node \
123-
eslint-plugin-promise \
124-
eslint-plugin-standard;
125-
touch /tmp/runner_ready_to_lint;
126-
touch /tmp/runner_is_ready;
95+
npm install /mnt/;
96+
cp -fr /usr/local/lib/node_modules/* /var/snippets/web/node_modules;
97+
cp -fr /usr/local/lib/node_modules/* /var/snippets/webpack/node_modules;
98+
touch /home/node/runner_ready_to_lint;
99+
touch /home/node/runner_is_ready;
127100
tail -f /dev/null
128101
'
129-
volumes:
130-
- ../..:/mnt
131-
- snippets:/var/snippets
102+
132103
133104
volumes:
134105
snippets:

.ci/doc/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "1.0.0",
44
"description": "docs for kuzzle-sdk",
55
"author": "The Kuzzle Team <[email protected]>",
6+
"main": "index.js",
67
"scripts": {},
78
"dependencies": {},
89
"devDependencies": {}

.ci/doc/puppeteer.js

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,60 @@
1-
const puppeteer = require('puppeteer');
1+
const puppeteer = require("puppeteer");
22
const renderedSnippetPath = process.argv[2];
33

4-
const runInBrowser = async snippetPath => {
4+
const runInBrowser = async (snippetPath) => {
55
let browser;
6-
76
try {
7+
// Install Chrome browser first
8+
const { execSync } = require('child_process');
9+
execSync('npx puppeteer browsers install chrome', { stdio: 'inherit' });
10+
811
browser = await puppeteer.launch({
912
dumpio: true,
10-
args: ['--no-sandbox']
13+
headless: "new",
14+
// Remove executablePath to use the bundled Chromium
15+
args: [
16+
"--no-sandbox",
17+
"--disable-setuid-sandbox",
18+
"--disable-gpu",
19+
"--disable-dev-shm-usage",
20+
],
1121
});
1222
} catch (error) {
13-
console.error(error);
14-
return;
23+
console.error('Browser launch error:', error);
24+
process.exit(1);
1525
}
1626

1727
try {
1828
const page = await browser.newPage();
1929

20-
page.on('error', err => {
21-
console.error(err);
30+
page.on("error", (err) => {
31+
console.error('Page error:', err);
2232
});
2333

24-
page.on('pageerror', err => {
25-
console.error(err);
34+
page.on("pageerror", (err) => {
35+
console.error('Page error:', err);
36+
});
37+
38+
page.on('console', msg => {
39+
console.log('Page console:', msg.text());
2640
});
2741

2842
await page.goto(`file:${snippetPath}`, {
29-
waitUntil: 'networkidle0'
43+
waitUntil: "networkidle0",
44+
timeout: 30000,
3045
});
3146
} catch (error) {
32-
console.error(error);
47+
console.error('Page processing error:', error);
3348
} finally {
34-
await browser.close();
49+
if (browser) {
50+
await browser.close();
51+
}
3552
}
3653
};
3754

38-
runInBrowser(renderedSnippetPath);
55+
if (!renderedSnippetPath) {
56+
console.error('Please provide a path to the snippet file');
57+
process.exit(1);
58+
}
59+
60+
runInBrowser(renderedSnippetPath);

.ci/test-docs.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ set -ex
55
here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
66
cd "$here"
77

8+
docker compose -f ./doc/docker-compose.yml build
89
docker compose -f ./doc/docker-compose.yml pull
910
docker compose -f ./doc/docker-compose.yml run doc-tests node index
1011
EXIT=$?
11-
docker compose -f ./doc/docker-compose.yml down
12+
# docker compose -f ./doc/docker-compose.yml down

src/utils/browser.js

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)