From 95c28f30ad7b92bba82d5bcfd29e8693de328312 Mon Sep 17 00:00:00 2001 From: Kristjan Eimre Date: Fri, 12 Jul 2024 00:18:26 +0300 Subject: [PATCH] merge testing GH workflows; small test cleanup --- .github/workflows/screenshot-comparison.yml | 19 ++++++-- .github/workflows/widget-test.yml | 53 --------------------- test/test.py | 10 ++-- test/test_figures.py | 4 +- 4 files changed, 19 insertions(+), 67 deletions(-) delete mode 100644 .github/workflows/widget-test.yml diff --git a/.github/workflows/screenshot-comparison.yml b/.github/workflows/screenshot-comparison.yml index e41ebba..8aef731 100644 --- a/.github/workflows/screenshot-comparison.yml +++ b/.github/workflows/screenshot-comparison.yml @@ -1,4 +1,4 @@ -name: screenshot comparison +name: Screenshot comparison on: push: @@ -31,19 +31,28 @@ jobs: pip install --upgrade voila pip install --upgrade voila-osscar-template pip install -e . + pip install --upgrade selenium + pip install --upgrade Pillow - name: Run the voila server run: | voila --template=osscar --enable_nbextensions=True example/ --port 8383 --no-browser & - pip install --upgrade pytest - pip install --upgrade selenium - pip install --upgrade Pillow - uses: nanasess/setup-chromedriver@master - - run: | + - name: Generate the screenshots + run: | export DISPLAY=:99 chromedriver --url-base=/wd/hub & sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & # optional python3 $GITHUB_WORKSPACE/test/test.py + + - name: Upload screenshots + uses: actions/upload-artifact@v4 + with: + name: artifact + path: './*.png' + + - name: Compare the screenshots to the reference one + run: | python3 $GITHUB_WORKSPACE/test/test_figures.py diff --git a/.github/workflows/widget-test.yml b/.github/workflows/widget-test.yml deleted file mode 100644 index df7a0be..0000000 --- a/.github/workflows/widget-test.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: widget test - -on: - push: - branches: - - '*' - pull_request: - branches: - - '*' - -jobs: - check-elements: - name: Check Element - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Install node - uses: actions/setup-node@v4 - with: - node-version: '21.x' - - name: Install Python - uses: actions/setup-python@v5 - with: - python-version: '3.11' - architecture: 'x64' - - name: Install dependencies - run: - pip install --upgrade pip - pip install --upgrade jupyterlab - pip install --upgrade voila - pip install --upgrade voila-osscar-template - pip install -e . - - - name: Run the voila server - run: | - voila --template=osscar --enable_nbextensions=True example/ --port 8383 --no-browser & - pip install --upgrade pytest - pip install --upgrade selenium - pip install --upgrade Pillow - - - uses: nanasess/setup-chromedriver@master - - run: | - export DISPLAY=:99 - chromedriver --url-base=/wd/hub & - sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & # optional - python3 $GITHUB_WORKSPACE/test/test.py - - - uses: actions/upload-artifact@v4 - with: - name: artifact - path: './*.png' - diff --git a/test/test.py b/test/test.py index aef5ae0..fa07e21 100644 --- a/test/test.py +++ b/test/test.py @@ -1,16 +1,12 @@ # Generated by Selenium IDE -import pytest -import time -import json import os +import time + from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.by import By -from selenium.webdriver.common.action_chains import ActionChains -from selenium.webdriver.support import expected_conditions -from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.common.keys import Keys -from selenium.webdriver.common.desired_capabilities import DesiredCapabilities + class test_widget(): def setup_method(self, method): diff --git a/test/test_figures.py b/test/test_figures.py index b1e208d..1024362 100644 --- a/test/test_figures.py +++ b/test/test_figures.py @@ -7,6 +7,6 @@ stat = ImageStat.Stat(diff) if sum(stat.mean) == 0: - print('images are the same') + print('Images are the same!') else: - raise Exception("The result is NOT the same as expected. Please check matplotlib version.") + raise Exception("The result is NOT the same as expected.")