From 333bdfea9751e1b683d59c50da2c6822f2ffc614 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Sun, 26 Nov 2023 14:52:31 +0100 Subject: [PATCH] create docker file for testing (#335) --- .github/workflows/docker.yml | 52 ++++++++++++++++++++ .gitignore | 1 + test/docker/Dockerfile | 71 ++++++++++++++++++++++++++++ test/docker/compare_output_server.sh | 8 ++++ test/docker/requirements.txt | 4 ++ test/scripts/requirements.txt | 8 ++-- 6 files changed, 140 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/docker.yml create mode 100644 test/docker/Dockerfile create mode 100755 test/docker/compare_output_server.sh create mode 100644 test/docker/requirements.txt diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 000000000..ced97fd69 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,52 @@ +name: docker + +on: + push: + branches: + - main + pull_request: + +jobs: + test_image: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.PAT_ANDIWAND }} + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + # list of Docker images to use as base name for tags + images: | + ghcr.io/${{ github.repository_owner }}/odr_core_test + # generate Docker tags based on the following events/attributes + tags: | + type=schedule + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=raw,value=latest,enable={{is_default_branch}} + type=sha + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: test/docker + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/odr_core_test:buildcache + cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/odr_core_test:buildcache,mode=max + + # TODO try to run it diff --git a/.gitignore b/.gitignore index 01351b5d0..7c37ea8cd 100644 --- a/.gitignore +++ b/.gitignore @@ -37,6 +37,7 @@ ## OpenDocument.core build/ cmake-build-*/ +venv/ *.zip *.svg diff --git a/test/docker/Dockerfile b/test/docker/Dockerfile new file mode 100644 index 000000000..34c259ea7 --- /dev/null +++ b/test/docker/Dockerfile @@ -0,0 +1,71 @@ +FROM ubuntu:22.04 + +ENV FIREFOX_VERSION="120.0" +ENV CHROME_VERSION="119.0.6045.159-1" +ENV PHANTOMJS_VERSION="2.1.1" +ENV GECKODRIVER_VERSION="0.33.0" +ENV CHROMEDRIVER_VERSION="119.0.6045.105" + +ENV INSTALL="apt-get install -y --no-install-recommends" + +RUN apt-get update + +# install download and unpack utilities +RUN $INSTALL wget ca-certificates bzip2 unzip + +# firefox setup +RUN $INSTALL libgtk-3-0 libasound2 libx11-xcb1 + +RUN wget https://download-installer.cdn.mozilla.net/pub/firefox/releases/${FIREFOX_VERSION}/linux-x86_64/en-US/firefox-${FIREFOX_VERSION}.tar.bz2 +RUN tar -xf firefox-${FIREFOX_VERSION}.tar.bz2 +RUN mv firefox /usr/local/share +RUN ln -s /usr/local/share/firefox/firefox /usr/local/bin +RUN rm firefox-${FIREFOX_VERSION}.tar.bz2 + +RUN firefox --version + +# geckodriver setup +RUN wget https://github.com/mozilla/geckodriver/releases/download/v${GECKODRIVER_VERSION}/geckodriver-v${GECKODRIVER_VERSION}-linux64.tar.gz +RUN tar -xf geckodriver-v${GECKODRIVER_VERSION}-linux64.tar.gz +RUN mv geckodriver /usr/local/bin +RUN rm geckodriver-v${GECKODRIVER_VERSION}-linux64.tar.gz + +RUN geckodriver --version + +# chrome setup +RUN wget https://dl.google.com/linux/deb/pool/main/g/google-chrome-stable/google-chrome-stable_${CHROME_VERSION}_amd64.deb +RUN $INSTALL ./google-chrome-stable_${CHROME_VERSION}_amd64.deb +RUN rm google-chrome-stable_${CHROME_VERSION}_amd64.deb + +RUN google-chrome --version + +# chromedirver setup +RUN wget https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/${CHROMEDRIVER_VERSION}/linux64/chromedriver-linux64.zip +RUN unzip chromedriver-linux64.zip +RUN mv chromedriver-linux64/chromedriver /usr/local/bin +RUN rm -rf chromedriver-linux64 +RUN rm chromedriver-linux64.zip + +RUN geckodriver --version + +# phantomjs setup +RUN $INSTALL build-essential chrpath libssl-dev libxft-dev +RUN $INSTALL libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev + +RUN wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-${PHANTOMJS_VERSION}-linux-x86_64.tar.bz2 +RUN tar -xf phantomjs-${PHANTOMJS_VERSION}-linux-x86_64.tar.bz2 +RUN mv phantomjs-${PHANTOMJS_VERSION}-linux-x86_64/bin/phantomjs /usr/local/bin +RUN rm -rf phantomjs-${PHANTOMJS_VERSION}-linux-x86_64 +RUN rm phantomjs-${PHANTOMJS_VERSION}-linux-x86_64.tar.bz2 + +# fix weird phantomjs issue +ENV OPENSSL_CONF=/etc/ssl + +RUN phantomjs --version + +# install python dependencies +ADD requirements.txt . +RUN $INSTALL python3 python3-pip +RUN pip install --upgrade pip +RUN pip install -r requirements.txt +RUN rm requirements.txt diff --git a/test/docker/compare_output_server.sh b/test/docker/compare_output_server.sh new file mode 100755 index 000000000..1b4644753 --- /dev/null +++ b/test/docker/compare_output_server.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +REF="test/data/reference-output/" +OBS="cmake-build-debug/test/output/" +DRIVER="firefox" + +docker build --tag odr_core_test test/docker +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 diff --git a/test/docker/requirements.txt b/test/docker/requirements.txt new file mode 100644 index 000000000..2bdc3e83c --- /dev/null +++ b/test/docker/requirements.txt @@ -0,0 +1,4 @@ +Pillow==10.1.0 +selenium==4.15.2 +flask==2.3.3 +watchdog==2.3.1 \ No newline at end of file diff --git a/test/scripts/requirements.txt b/test/scripts/requirements.txt index e52225ef4..2bdc3e83c 100644 --- a/test/scripts/requirements.txt +++ b/test/scripts/requirements.txt @@ -1,4 +1,4 @@ -Pillow==9.2.0 -selenium==4.3.0 -flask==2.1.3 -watchdog==2.1.9 \ No newline at end of file +Pillow==10.1.0 +selenium==4.15.2 +flask==2.3.3 +watchdog==2.3.1 \ No newline at end of file