Skip to content

Commit 333bdfe

Browse files
authored
create docker file for testing (#335)
1 parent 7b40835 commit 333bdfe

6 files changed

Lines changed: 140 additions & 4 deletions

File tree

.github/workflows/docker.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: docker
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
test_image:
11+
runs-on: ubuntu-22.04
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Set up Docker Buildx
16+
uses: docker/setup-buildx-action@v2
17+
18+
- uses: docker/login-action@v2
19+
with:
20+
registry: ghcr.io
21+
username: ${{ github.actor }}
22+
password: ${{ secrets.PAT_ANDIWAND }}
23+
24+
- name: Docker meta
25+
id: meta
26+
uses: docker/metadata-action@v5
27+
with:
28+
# list of Docker images to use as base name for tags
29+
images: |
30+
ghcr.io/${{ github.repository_owner }}/odr_core_test
31+
# generate Docker tags based on the following events/attributes
32+
tags: |
33+
type=schedule
34+
type=ref,event=branch
35+
type=ref,event=pr
36+
type=semver,pattern={{version}}
37+
type=semver,pattern={{major}}.{{minor}}
38+
type=semver,pattern={{major}}
39+
type=raw,value=latest,enable={{is_default_branch}}
40+
type=sha
41+
42+
- name: Build and push
43+
uses: docker/build-push-action@v5
44+
with:
45+
context: test/docker
46+
push: true
47+
tags: ${{ steps.meta.outputs.tags }}
48+
labels: ${{ steps.meta.outputs.labels }}
49+
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/odr_core_test:buildcache
50+
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/odr_core_test:buildcache,mode=max
51+
52+
# TODO try to run it

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
## OpenDocument.core
3838
build/
3939
cmake-build-*/
40+
venv/
4041

4142
*.zip
4243
*.svg

test/docker/Dockerfile

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
FROM ubuntu:22.04
2+
3+
ENV FIREFOX_VERSION="120.0"
4+
ENV CHROME_VERSION="119.0.6045.159-1"
5+
ENV PHANTOMJS_VERSION="2.1.1"
6+
ENV GECKODRIVER_VERSION="0.33.0"
7+
ENV CHROMEDRIVER_VERSION="119.0.6045.105"
8+
9+
ENV INSTALL="apt-get install -y --no-install-recommends"
10+
11+
RUN apt-get update
12+
13+
# install download and unpack utilities
14+
RUN $INSTALL wget ca-certificates bzip2 unzip
15+
16+
# firefox setup
17+
RUN $INSTALL libgtk-3-0 libasound2 libx11-xcb1
18+
19+
RUN wget https://download-installer.cdn.mozilla.net/pub/firefox/releases/${FIREFOX_VERSION}/linux-x86_64/en-US/firefox-${FIREFOX_VERSION}.tar.bz2
20+
RUN tar -xf firefox-${FIREFOX_VERSION}.tar.bz2
21+
RUN mv firefox /usr/local/share
22+
RUN ln -s /usr/local/share/firefox/firefox /usr/local/bin
23+
RUN rm firefox-${FIREFOX_VERSION}.tar.bz2
24+
25+
RUN firefox --version
26+
27+
# geckodriver setup
28+
RUN wget https://github.com/mozilla/geckodriver/releases/download/v${GECKODRIVER_VERSION}/geckodriver-v${GECKODRIVER_VERSION}-linux64.tar.gz
29+
RUN tar -xf geckodriver-v${GECKODRIVER_VERSION}-linux64.tar.gz
30+
RUN mv geckodriver /usr/local/bin
31+
RUN rm geckodriver-v${GECKODRIVER_VERSION}-linux64.tar.gz
32+
33+
RUN geckodriver --version
34+
35+
# chrome setup
36+
RUN wget https://dl.google.com/linux/deb/pool/main/g/google-chrome-stable/google-chrome-stable_${CHROME_VERSION}_amd64.deb
37+
RUN $INSTALL ./google-chrome-stable_${CHROME_VERSION}_amd64.deb
38+
RUN rm google-chrome-stable_${CHROME_VERSION}_amd64.deb
39+
40+
RUN google-chrome --version
41+
42+
# chromedirver setup
43+
RUN wget https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/${CHROMEDRIVER_VERSION}/linux64/chromedriver-linux64.zip
44+
RUN unzip chromedriver-linux64.zip
45+
RUN mv chromedriver-linux64/chromedriver /usr/local/bin
46+
RUN rm -rf chromedriver-linux64
47+
RUN rm chromedriver-linux64.zip
48+
49+
RUN geckodriver --version
50+
51+
# phantomjs setup
52+
RUN $INSTALL build-essential chrpath libssl-dev libxft-dev
53+
RUN $INSTALL libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev
54+
55+
RUN wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-${PHANTOMJS_VERSION}-linux-x86_64.tar.bz2
56+
RUN tar -xf phantomjs-${PHANTOMJS_VERSION}-linux-x86_64.tar.bz2
57+
RUN mv phantomjs-${PHANTOMJS_VERSION}-linux-x86_64/bin/phantomjs /usr/local/bin
58+
RUN rm -rf phantomjs-${PHANTOMJS_VERSION}-linux-x86_64
59+
RUN rm phantomjs-${PHANTOMJS_VERSION}-linux-x86_64.tar.bz2
60+
61+
# fix weird phantomjs issue
62+
ENV OPENSSL_CONF=/etc/ssl
63+
64+
RUN phantomjs --version
65+
66+
# install python dependencies
67+
ADD requirements.txt .
68+
RUN $INSTALL python3 python3-pip
69+
RUN pip install --upgrade pip
70+
RUN pip install -r requirements.txt
71+
RUN rm requirements.txt
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
REF="test/data/reference-output/"
4+
OBS="cmake-build-debug/test/output/"
5+
DRIVER="firefox"
6+
7+
docker build --tag odr_core_test test/docker
8+
docker run -ti -v $(pwd):/repo -p 5000:5000 odr_core_test python3 /repo/test/scripts/compare_output_server.py /repo/$REF /repo/$OBS --compare --driver $DRIVER

test/docker/requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Pillow==10.1.0
2+
selenium==4.15.2
3+
flask==2.3.3
4+
watchdog==2.3.1

test/scripts/requirements.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Pillow==9.2.0
2-
selenium==4.3.0
3-
flask==2.1.3
4-
watchdog==2.1.9
1+
Pillow==10.1.0
2+
selenium==4.15.2
3+
flask==2.3.3
4+
watchdog==2.3.1

0 commit comments

Comments
 (0)