Skip to content

Commit 5de3214

Browse files
nzaytseveamodio
authored andcommitted
Adds docker config and test workflow
1 parent d005501 commit 5de3214

File tree

5 files changed

+170
-0
lines changed

5 files changed

+170
-0
lines changed

.github/workflows/unit-tests.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Unit tests
2+
3+
on:
4+
pull_request:
5+
branches: ['*']
6+
types:
7+
- opened
8+
- reopened
9+
- synchronize
10+
- ready_for_review
11+
12+
jobs:
13+
test:
14+
name: Run unit tests
15+
runs-on: ubuntu-latest
16+
if: ${{ !github.event.pull_request.draft }}
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v3
20+
- run: cd tests/docker && ./run-e2e-test-local.sh

tests/docker/Dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
FROM selenium/node-base:4.22.0
2+
3+
USER root
4+
5+
RUN apt-get update && \
6+
apt-get install -y \
7+
apt-transport-https \
8+
ca-certificates \
9+
software-properties-common \
10+
gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget libgbm-dev \
11+
git && \
12+
rm -rf /var/lib/apt/lists/*
13+
14+
RUN rm /etc/supervisor/conf.d/selenium.conf
15+
16+
COPY supervisor.conf /etc/supervisor/conf.d/supervisor.conf
17+
18+
# --- --- --- --- --- --- ---
19+
# Install Node/NPM
20+
# --- --- --- --- --- --- ---
21+
22+
# enable node source repo
23+
RUN curl -sL https://deb.nodesource.com/setup_20.x | bash -
24+
# enable yarn repo
25+
# RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
26+
# RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
27+
28+
# install node and pnpm
29+
RUN apt-get update && \
30+
apt-get install -y nodejs && \
31+
rm -rf /var/lib/apt/lists/*
32+
33+
RUN npm install -g pnpm@9

tests/docker/run-e2e-test-local.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
3+
docker build . -t e2e-test
4+
5+
cd ../../
6+
7+
npm install -g pnpm
8+
pnpm install
9+
mkdir -p out
10+
11+
CONTAINER_NAME=e2e-test
12+
13+
echo "Docker containers"
14+
docker ps -a
15+
16+
echo "Docker images"
17+
docker image list
18+
19+
docker rm -f e2e-test | true
20+
21+
LOG_ID=$(docker run \
22+
-e SCREEN_WIDTH=1680 -e SCREEN_HEIGHT=1050 \
23+
-e TZ="Etc/UTC" \
24+
-d --name=${CONTAINER_NAME} \
25+
-v /dev/shm:/dev/shm --privileged \
26+
-v /dev/snd:/dev/snd \
27+
-v /etc/localtime:/etc/localtime:ro \
28+
-v ./:/opt/vscode-gitlens \
29+
e2e-test)
30+
31+
echo "Run docker with id $LOG_ID"
32+
33+
EXIT_CODE=$(docker wait $LOG_ID)
34+
35+
echo "Exited with code $EXIT_CODE"
36+
37+
docker logs e2e-test
38+
39+
exit $EXIT_CODE
40+
41+
# Add following options to get an access from host:
42+
# -p 5900:25900 \ - to VNC

tests/docker/run-unit-tests.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
pnpm run test;
2+
EXIT_CODE=$?;
3+
if [[ "$EXIT_CODE" == "0" ]]; then
4+
kill -s SIGINT `cat /var/run/supervisor/supervisord.pid`;
5+
else
6+
kill -s SIGKILL `cat /var/run/supervisor/supervisord.pid`;
7+
fi

tests/docker/supervisor.conf

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
; Documentation of this file format -> http://supervisord.org/configuration.html
2+
3+
; Priority 0 - xvfb & fluxbox, 5 - x11vnc, 10 - noVNC, 15 - selenium-node
4+
5+
[program:xvfb]
6+
priority=0
7+
command=/opt/bin/start-xvfb.sh
8+
autostart=true
9+
autorestart=true
10+
11+
;Logs
12+
redirect_stderr=false
13+
stdout_logfile=/var/log/supervisor/xvfb-stdout.log
14+
stderr_logfile=/var/log/supervisor/xvfb-stderr.log
15+
stdout_logfile_maxbytes=50MB
16+
stderr_logfile_maxbytes=50MB
17+
stdout_logfile_backups=5
18+
stderr_logfile_backups=5
19+
stdout_capture_maxbytes=50MB
20+
stderr_capture_maxbytes=50MB
21+
22+
[program:vnc]
23+
priority=5
24+
command=/opt/bin/start-vnc.sh
25+
autostart=true
26+
autorestart=true
27+
28+
;Logs
29+
redirect_stderr=false
30+
stdout_logfile=/var/log/supervisor/vnc-stdout.log
31+
stderr_logfile=/var/log/supervisor/vnc-stderr.log
32+
stdout_logfile_maxbytes=50MB
33+
stderr_logfile_maxbytes=50MB
34+
stdout_logfile_backups=5
35+
stderr_logfile_backups=5
36+
stdout_capture_maxbytes=50MB
37+
stderr_capture_maxbytes=50MB
38+
39+
[program:novnc]
40+
priority=10
41+
command=/opt/bin/start-novnc.sh
42+
autostart=true
43+
autorestart=true
44+
45+
;Logs
46+
redirect_stderr=false
47+
stdout_logfile=/var/log/supervisor/novnc-stdout.log
48+
stderr_logfile=/var/log/supervisor/novnc-stderr.log
49+
stdout_logfile_maxbytes=50MB
50+
stderr_logfile_maxbytes=50MB
51+
stdout_logfile_backups=5
52+
stderr_logfile_backups=5
53+
stdout_capture_maxbytes=50MB
54+
stderr_capture_maxbytes=50MB
55+
56+
[program:selenium-node]
57+
priority=15
58+
command=bash -c "cd /opt/vscode-gitlens && ./tests/docker/run-unit-tests.sh"
59+
stopasgroup = true
60+
autostart=true
61+
autorestart=false
62+
startsecs=0
63+
startretries=0
64+
65+
;Logs (all Hub activity redirected to stdout so it can be seen through "docker logs"
66+
redirect_stderr=true
67+
stdout_logfile=/dev/stdout
68+
stdout_logfile_maxbytes=0

0 commit comments

Comments
 (0)