From fc6dd92255612cb50c0970379f095abc02e0c0af Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Mon, 24 Jun 2024 00:21:51 +0200 Subject: [PATCH] Update CI (#243) * Don't install firefox manually * Don't install geckodriver manually * Pin full-stack image * Increase timeouts * Update test dependencies --- .github/workflows/ci.yml | 22 ++++++---------------- requirements-test.txt | 9 ++++----- tests/app/conftest.py | 11 +++++++---- 3 files changed, 17 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eef36cc..6731a5e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,9 @@ on: - main pull_request: +env: + FORCE_COLOR: 1 + jobs: pre-commit: @@ -35,12 +38,13 @@ jobs: strategy: matrix: tag: [latest] - image: ["aiidalab/full-stack", "ghcr.io/ispg-group/atmospec"] + image: ["ghcr.io/aiidalab/full-stack", "ghcr.io/ispg-group/atmospec"] browser: [Firefox, Chrome] fail-fast: false env: IMAGE: ${{ matrix.image }} - TAG: ${{ matrix.tag }} + # Right now due to old AWB version we do not support the latest image with aiida-core=2.5.1 + TAG: ${{ matrix.image == 'ghcr.io/aiidalab/full-stack' && 'aiida-2.4.3' || 'latest' }} steps: @@ -70,20 +74,6 @@ jobs: - name: Set jupyter token env run: echo "JUPYTER_TOKEN=$(openssl rand -hex 32)" >> $GITHUB_ENV - # The Firefox and its engine geckodrive need do be installed manually to run - # selenium tests. - - name: Install Firefox - if: matrix.browser == 'Firefox' - uses: browser-actions/setup-firefox@latest - with: - firefox-version: "96.0" - - - name: Install geckodriver - if: matrix.browser == 'Firefox' - run: | - wget -c https://github.com/mozilla/geckodriver/releases/download/v0.30.0/geckodriver-v0.30.0-linux64.tar.gz - tar xf geckodriver-v0.30.0-linux64.tar.gz -C /usr/local/bin - - name: Run pytest run: pytest -sv --driver ${{ matrix.browser }} -o cache_dir=$PYTEST_CACHE_DIR tests/app/ diff --git a/requirements-test.txt b/requirements-test.txt index bab7a8f..fd84bab 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,5 +1,4 @@ -pytest~=6.2 -pytest-docker~=1.0 -pytest-selenium~=4.0 -webdriver-manager~=3.8 -selenium~=4.7.0 +pytest~=8.2.0 +pytest-docker~=3.0 +pytest-selenium~=4.1 +selenium==4.20.0 diff --git a/tests/app/conftest.py b/tests/app/conftest.py index 60d774a..dbd9087 100644 --- a/tests/app/conftest.py +++ b/tests/app/conftest.py @@ -72,14 +72,14 @@ def notebook_service(docker_ip, docker_services, aiidalab_exec, nb_user, appdir) url = f"http://{docker_ip}:{port}" token = os.environ["JUPYTER_TOKEN"] docker_services.wait_until_responsive( - timeout=30.0, pause=0.1, check=lambda: is_responsive(url) + timeout=30.0, pause=0.5, check=lambda: is_responsive(url) ) return url, token @pytest.fixture() def selenium_driver(selenium, notebook_service): - def _selenium_driver(nb_path, wait_time=5.0): + def _selenium_driver(nb_path, wait_time=30.0): url, token = notebook_service url_with_token = urljoin( url, f"apps/apps/aiidalab-ispg/notebooks/{nb_path}?token={token}" @@ -90,7 +90,7 @@ def _selenium_driver(nb_path, wait_time=5.0): selenium.find_element(By.ID, "ipython-main-app") selenium.find_element(By.ID, "notebook-container") selenium.find_element(By.CLASS_NAME, "jupyter-widgets-view") - WebDriverWait(selenium, 20).until( + WebDriverWait(selenium, timeout=20, poll_frequency=0.5).until( EC.invisibility_of_element((By.ID, "appmode-busy")) ) return selenium @@ -109,7 +109,10 @@ def _generate_mol(smiles): (By.XPATH, "//button[text()='Generate molecule']") ) ).click() - time.sleep(3) + WebDriverWait(selenium, timeout=20, poll_frequency=0.5).until( + EC.invisibility_of_element((By.ID, "appmode-busy")) + ) + time.sleep(3.0) return _generate_mol