From ce2908fd5c8d5a63541c7396528e2efb2f106f81 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sat, 3 Dec 2022 14:38:42 +0000 Subject: [PATCH 01/24] CI fixes and improvements --- .github/workflows/di.yml | 33 ++++++++++++++++++--------------- setup.cfg | 3 +-- tests/conftest.py | 8 ++++++++ tests/test_qe_app.py | 11 ++++++----- 4 files changed, 33 insertions(+), 22 deletions(-) diff --git a/.github/workflows/di.yml b/.github/workflows/di.yml index 56aa65b85..8b20ac153 100644 --- a/.github/workflows/di.yml +++ b/.github/workflows/di.yml @@ -17,8 +17,6 @@ jobs: matrix: tag: [latest] browser: [Chrome, Firefox] - python-version: ['3.8', '3.10'] - firefox: ['96.0'] fail-fast: false runs-on: ubuntu-latest @@ -28,21 +26,18 @@ jobs: - name: Check out app uses: actions/checkout@v2 - - name: Cache Python dependencies - uses: actions/cache@v1 + - name: Set up Python + uses: actions/setup-python@v4 with: - path: ~/.cache/pip - key: pip-${{ matrix.python-version }}-tests-${{ hashFiles('**/setup.json') }} - restore-keys: pip-${{ matrix.python-version }}-tests - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} + python-version: "3.10" + cache: pip + cache-dependency-path: | + **/setup.cfg + **/pyproject.toml + **/requirements*.txt - name: Install dependencies for test - run: | - pip install -U -r requirements_test.txt + run: pip install -U -r requirements_test.txt - name: Set jupyter token env run: echo "JUPYTER_TOKEN=$(openssl rand -hex 32)" >> $GITHUB_ENV @@ -52,7 +47,7 @@ jobs: - name: Install Firefox uses: browser-actions/setup-firefox@latest with: - firefox-version: ${{ matrix.firefox }} + firefox-version: latest if: matrix.browser == 'Firefox' - name: Install geckodriver @@ -65,3 +60,11 @@ jobs: run: pytest --driver ${{ matrix.browser }} env: TAG: ${{ matrix.tag }} + + - name: Upload screenshots as artifacts + if: always() + uses: actions/upload-artifact@v3 + with: + name: Screenshots-${{ matrix.tag }}-${{ matrix.browser }} + path: '~/screenshots/' + if-no-files-found: error diff --git a/setup.cfg b/setup.cfg index be0d8e0b8..b1c593cd6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -37,8 +37,7 @@ python_requires = >=3.8 dev = bumpver==2022.1119 pre-commit==2.11.1 -test = - requirements-test.txt +test = file: requirements_test.txt [options.package_data] aiidalab_qe.parameters = qeapp.yaml diff --git a/tests/conftest.py b/tests/conftest.py index de7ff6347..e3e99ecfc 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,5 @@ import os +from pathlib import Path from urllib.parse import urljoin import pytest @@ -62,6 +63,13 @@ def _selenium_driver(nb_path, wait_time=5.0): return _selenium_driver +@pytest.fixture(scope="session") +def screenshot_dir(): + sdir = Path.joinpath(Path.home(), "screenshots") + os.mkdir(sdir) + return sdir + + @pytest.fixture def firefox_options(firefox_options): firefox_options.add_argument("--headless") diff --git a/tests/test_qe_app.py b/tests/test_qe_app.py index 7af7f747d..614d4da50 100755 --- a/tests/test_qe_app.py +++ b/tests/test_qe_app.py @@ -1,3 +1,4 @@ +from pathlib import Path import requests from selenium.webdriver.common.by import By @@ -8,21 +9,21 @@ def test_notebook_service_available(notebook_service): assert response.status_code == 200 -def test_qe_app_take_screenshot(selenium_driver): +def test_qe_app_take_screenshot(selenium_driver, screenshot_dir): driver = selenium_driver("qe.ipynb", wait_time=30.0) driver.set_window_size(1920, 985) - driver.get_screenshot_as_file("screenshots/qe-app.png") + driver.get_screenshot_as_file(Path.joinpath(screenshot_dir, "qe-app.png")) -def test_qe_app_select_silicon(selenium_driver): +def test_qe_app_select_silicon(selenium_driver, screenshot_dir): driver = selenium_driver("qe.ipynb", wait_time=30.0) driver.set_window_size(1920, 985) driver.find_element( By.XPATH, "//*[text()='From Examples']" ).click() # click `From Examples` tab for input structure driver.find_element(By.XPATH, "//option[@value='Diamond']").click() - driver.get_screenshot_as_file("screenshots/qe-app-select-diamond-selected.png") + driver.get_screenshot_as_file(Path.joinpath(screenshot_dir, "qe-app-select-diamond-selected.png")) confirm_button = driver.find_element(By.XPATH, "//button[text()='Confirm']") confirm_button.location_once_scrolled_into_view # scroll into view confirm_button.click() - driver.get_screenshot_as_file("screenshots/qe-app-select-diamond-confirmed.png") + driver.get_screenshot_as_file(Path.joinpath(screenshot_dir, "qe-app-select-diamond-confirmed.png")) From 3435fcc65fb2adea00170f60cfcd38567652a7dc Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sat, 3 Dec 2022 14:58:12 +0000 Subject: [PATCH 02/24] Fix screenshots and pre-commit --- .github/workflows/di.yml | 14 +++++++------- setup.cfg | 9 +++++---- tests/test_qe_app.py | 11 ++++++++--- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/.github/workflows/di.yml b/.github/workflows/di.yml index 8b20ac153..08b8324f2 100644 --- a/.github/workflows/di.yml +++ b/.github/workflows/di.yml @@ -29,12 +29,12 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: '3.10' cache: pip cache-dependency-path: | - **/setup.cfg - **/pyproject.toml - **/requirements*.txt + **/setup.cfg + **/pyproject.toml + **/requirements*.txt - name: Install dependencies for test run: pip install -U -r requirements_test.txt @@ -65,6 +65,6 @@ jobs: if: always() uses: actions/upload-artifact@v3 with: - name: Screenshots-${{ matrix.tag }}-${{ matrix.browser }} - path: '~/screenshots/' - if-no-files-found: error + name: Screenshots-${{ matrix.tag }}-${{ matrix.browser }} + path: ~/screenshots/ + if-no-files-found: error diff --git a/setup.cfg b/setup.cfg index b1c593cd6..986fb1989 100644 --- a/setup.cfg +++ b/setup.cfg @@ -37,7 +37,8 @@ python_requires = >=3.8 dev = bumpver==2022.1119 pre-commit==2.11.1 -test = file: requirements_test.txt +test = + file: [options.package_data] aiidalab_qe.parameters = qeapp.yaml @@ -50,9 +51,9 @@ categories = [flake8] ignore = - E501 # Line length handled by black. - W503 # Line break before binary operator, preferred formatting for black. - E203 # Whitespace before ':', preferred formatting for black. + E501 + W503 + E203 [bumpver] current_version = "v22.12.0" diff --git a/tests/test_qe_app.py b/tests/test_qe_app.py index 614d4da50..1d6794ab4 100755 --- a/tests/test_qe_app.py +++ b/tests/test_qe_app.py @@ -1,4 +1,5 @@ from pathlib import Path + import requests from selenium.webdriver.common.by import By @@ -12,7 +13,7 @@ def test_notebook_service_available(notebook_service): def test_qe_app_take_screenshot(selenium_driver, screenshot_dir): driver = selenium_driver("qe.ipynb", wait_time=30.0) driver.set_window_size(1920, 985) - driver.get_screenshot_as_file(Path.joinpath(screenshot_dir, "qe-app.png")) + driver.get_screenshot_as_file(str(Path.joinpath(screenshot_dir, "qe-app.png"))) def test_qe_app_select_silicon(selenium_driver, screenshot_dir): @@ -22,8 +23,12 @@ def test_qe_app_select_silicon(selenium_driver, screenshot_dir): By.XPATH, "//*[text()='From Examples']" ).click() # click `From Examples` tab for input structure driver.find_element(By.XPATH, "//option[@value='Diamond']").click() - driver.get_screenshot_as_file(Path.joinpath(screenshot_dir, "qe-app-select-diamond-selected.png")) + driver.get_screenshot_as_file( + str(Path.joinpath(screenshot_dir, "qe-app-select-diamond-selected.png")) + ) confirm_button = driver.find_element(By.XPATH, "//button[text()='Confirm']") confirm_button.location_once_scrolled_into_view # scroll into view confirm_button.click() - driver.get_screenshot_as_file(Path.joinpath(screenshot_dir, "qe-app-select-diamond-confirmed.png")) + driver.get_screenshot_as_file( + str(Path.joinpath(screenshot_dir, "qe-app-select-diamond-confirmed.png")) + ) From e5e40e60824d8d88e331003e2e0c0ff4142d374a Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sat, 3 Dec 2022 15:20:08 +0000 Subject: [PATCH 03/24] Remove setup-cfg-fmt formatter Conflicts with current setup.cfg due to https://github.com/asottile/setup-cfg-fmt/issues/161 --- .pre-commit-config.yaml | 5 ----- setup.cfg | 3 +-- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ca0e05cc5..ddc3fc694 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -35,11 +35,6 @@ repos: - id: isort args: [--profile, black, --filter-files] - - repo: https://github.com/asottile/setup-cfg-fmt - rev: v2.2.0 - hooks: - - id: setup-cfg-fmt - - repo: https://github.com/sirosen/check-jsonschema rev: 0.19.2 hooks: diff --git a/setup.cfg b/setup.cfg index 986fb1989..714087745 100644 --- a/setup.cfg +++ b/setup.cfg @@ -37,8 +37,7 @@ python_requires = >=3.8 dev = bumpver==2022.1119 pre-commit==2.11.1 -test = - file: +test = file: requirements_test.txt [options.package_data] aiidalab_qe.parameters = qeapp.yaml From ab1389301e6e256c5f97a46f3d124fde8e651e80 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sat, 3 Dec 2022 15:24:40 +0000 Subject: [PATCH 04/24] Add sleeps after button clicks --- tests/test_qe_app.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_qe_app.py b/tests/test_qe_app.py index 1d6794ab4..1a2bc9159 100755 --- a/tests/test_qe_app.py +++ b/tests/test_qe_app.py @@ -1,3 +1,4 @@ +import time from pathlib import Path import requests @@ -23,12 +24,14 @@ def test_qe_app_select_silicon(selenium_driver, screenshot_dir): By.XPATH, "//*[text()='From Examples']" ).click() # click `From Examples` tab for input structure driver.find_element(By.XPATH, "//option[@value='Diamond']").click() + time.sleep(2) driver.get_screenshot_as_file( str(Path.joinpath(screenshot_dir, "qe-app-select-diamond-selected.png")) ) confirm_button = driver.find_element(By.XPATH, "//button[text()='Confirm']") confirm_button.location_once_scrolled_into_view # scroll into view confirm_button.click() + time.sleep(2) driver.get_screenshot_as_file( str(Path.joinpath(screenshot_dir, "qe-app-select-diamond-confirmed.png")) ) From 6ad4de68c8d049f17de3ed393c19251d9994bff6 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sat, 3 Dec 2022 15:59:26 +0000 Subject: [PATCH 05/24] Bump test dependencies --- .github/workflows/ci.yml | 17 +++++++++++------ .github/workflows/di.yml | 2 +- requirements_test.txt | 4 ++-- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e16fc2478..f111a93e5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,5 @@ --- -# Run basic tests for this app on the latest aiidalab-docker image. +# Run basic tests for this app name: continuous-integration @@ -13,16 +13,21 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: - python-version: 3.8 + python-version: 3.10 + cache: pip + cache-dependency-path: | + .pre-commit-config.yaml + **/setup.cfg + **/pyproject.toml + **/requirements*.txt - name: Install dependencies - run: | - python -m pip install pre-commit==2.11.1 + run: python -m pip install pre-commit~=2.20 - name: Run pre-commit run: pre-commit run --all-files || ( git status --short ; git diff ; exit 1 ) diff --git a/.github/workflows/di.yml b/.github/workflows/di.yml index 08b8324f2..038a17a25 100644 --- a/.github/workflows/di.yml +++ b/.github/workflows/di.yml @@ -24,7 +24,7 @@ jobs: steps: - name: Check out app - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v4 diff --git a/requirements_test.txt b/requirements_test.txt index 5c92ac0cd..bab7a8fef 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -1,5 +1,5 @@ -pytest~=6.0 +pytest~=6.2 pytest-docker~=1.0 pytest-selenium~=4.0 webdriver-manager~=3.8 -selenium==4.1.0 +selenium~=4.7.0 From 180929e1bca253235f09b75bf215b08e7ba56244 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sat, 3 Dec 2022 16:31:09 +0000 Subject: [PATCH 06/24] Update pre-commit hooks manually --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ddc3fc694..6e1b81be7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v4.4.0 hooks: - id: check-json - id: check-yaml @@ -22,7 +22,7 @@ repos: language_version: python3 # Should be a command that runs python3.6+ - repo: https://github.com/PyCQA/flake8 - rev: 5.0.4 + rev: 6.0.0 hooks: - id: flake8 args: [--count, --show-source, --statistics] @@ -41,6 +41,6 @@ repos: - id: check-github-workflows - repo: https://github.com/kynan/nbstripout - rev: 0.5.0 + rev: 0.6.1 hooks: - id: nbstripout From 018415e2f04b9f1f8bb598d472996ff138e1994f Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sat, 3 Dec 2022 16:32:32 +0000 Subject: [PATCH 07/24] Fix Python version in ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f111a93e5..b17a01329 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v4 with: - python-version: 3.10 + python-version: '3.10' cache: pip cache-dependency-path: | .pre-commit-config.yaml From 80f9b85828efcf07fee39b75b4b0e812ba1bdb74 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sun, 4 Dec 2022 00:14:21 +0000 Subject: [PATCH 08/24] Image name as ENV variable --- .github/workflows/di.yml | 2 ++ tests/docker-compose.yml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/di.yml b/.github/workflows/di.yml index 038a17a25..a54e2f2b4 100644 --- a/.github/workflows/di.yml +++ b/.github/workflows/di.yml @@ -16,6 +16,7 @@ jobs: strategy: matrix: tag: [latest] + image: [aiidalab/full-stack] browser: [Chrome, Firefox] fail-fast: false @@ -60,6 +61,7 @@ jobs: run: pytest --driver ${{ matrix.browser }} env: TAG: ${{ matrix.tag }} + AIIDALAB_IMAGE: ${{ matrix.image }} - name: Upload screenshots as artifacts if: always() diff --git a/tests/docker-compose.yml b/tests/docker-compose.yml index 4f0442961..48da72e36 100644 --- a/tests/docker-compose.yml +++ b/tests/docker-compose.yml @@ -4,7 +4,7 @@ version: '3.4' services: aiidalab: - image: aiidalab/full-stack:${TAG:-latest} + image: ${AIIDALAB_IMAGE:-aiidalab/full-stack}:${TAG:-latest} environment: RMQHOST: messaging TZ: Europe/Zurich From d20effad3d78e8fa96855a748d6981b88d048517 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sun, 4 Dec 2022 02:09:26 +0000 Subject: [PATCH 09/24] Improve test --- tests/test_qe_app.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/test_qe_app.py b/tests/test_qe_app.py index 1a2bc9159..42c3268cc 100755 --- a/tests/test_qe_app.py +++ b/tests/test_qe_app.py @@ -13,13 +13,14 @@ def test_notebook_service_available(notebook_service): def test_qe_app_take_screenshot(selenium_driver, screenshot_dir): driver = selenium_driver("qe.ipynb", wait_time=30.0) - driver.set_window_size(1920, 985) + driver.set_window_size(1920, 1485) + time.sleep(10) driver.get_screenshot_as_file(str(Path.joinpath(screenshot_dir, "qe-app.png"))) def test_qe_app_select_silicon(selenium_driver, screenshot_dir): driver = selenium_driver("qe.ipynb", wait_time=30.0) - driver.set_window_size(1920, 985) + driver.set_window_size(1920, 1485) driver.find_element( By.XPATH, "//*[text()='From Examples']" ).click() # click `From Examples` tab for input structure @@ -32,6 +33,8 @@ def test_qe_app_select_silicon(selenium_driver, screenshot_dir): confirm_button.location_once_scrolled_into_view # scroll into view confirm_button.click() time.sleep(2) + # Test that we have indeed proceeded to the next step + driver.find_element(By.XPATH, "//span[contains(.,'✓ Step 1')]") driver.get_screenshot_as_file( str(Path.joinpath(screenshot_dir, "qe-app-select-diamond-confirmed.png")) ) From d1dd876e87677de97856afab542991c1615e650d Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sun, 4 Dec 2022 02:47:22 +0000 Subject: [PATCH 10/24] More sleep --- tests/test_qe_app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_qe_app.py b/tests/test_qe_app.py index 42c3268cc..ec49fb221 100755 --- a/tests/test_qe_app.py +++ b/tests/test_qe_app.py @@ -14,7 +14,7 @@ def test_notebook_service_available(notebook_service): def test_qe_app_take_screenshot(selenium_driver, screenshot_dir): driver = selenium_driver("qe.ipynb", wait_time=30.0) driver.set_window_size(1920, 1485) - time.sleep(10) + time.sleep(15) driver.get_screenshot_as_file(str(Path.joinpath(screenshot_dir, "qe-app.png"))) From a73007adc38f4369701bf7f50ca5b8456ca4cd6e Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sun, 11 Dec 2022 15:10:23 +0000 Subject: [PATCH 11/24] require recent setuptools --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 374b58cbf..1eb0ca77d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [build-system] requires = [ - "setuptools>=42", + "setuptools>=62.6", "wheel" ] build-backend = "setuptools.build_meta" From 514e0b21671bf7eb5aee341b4502e54ff743aba1 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sun, 11 Dec 2022 15:15:20 +0000 Subject: [PATCH 12/24] Put back fixed Firefox version --- .github/workflows/di.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/di.yml b/.github/workflows/di.yml index a54e2f2b4..0f0e83d20 100644 --- a/.github/workflows/di.yml +++ b/.github/workflows/di.yml @@ -48,7 +48,7 @@ jobs: - name: Install Firefox uses: browser-actions/setup-firefox@latest with: - firefox-version: latest + firefox-version: '90.0' if: matrix.browser == 'Firefox' - name: Install geckodriver From a0f1148e5f071c20ace1d6b6cff66c0ac530ba7f Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sun, 11 Dec 2022 15:22:59 +0000 Subject: [PATCH 13/24] Use chown --- .github/workflows/di.yml | 2 +- tests/conftest.py | 16 ++++++++++------ tests/test_qe_app.py | 1 - 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.github/workflows/di.yml b/.github/workflows/di.yml index 0f0e83d20..69638559b 100644 --- a/.github/workflows/di.yml +++ b/.github/workflows/di.yml @@ -68,5 +68,5 @@ jobs: uses: actions/upload-artifact@v3 with: name: Screenshots-${{ matrix.tag }}-${{ matrix.browser }} - path: ~/screenshots/ + path: screenshots/ if-no-files-found: error diff --git a/tests/conftest.py b/tests/conftest.py index e3e99ecfc..e3b315985 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -23,15 +23,16 @@ def notebook_service(docker_ip, docker_services): docker_compose = docker_services._docker_compose - # assurance for host user UID other that 1000 - chown_command = "exec -T -u root aiidalab bash -c 'chown -R jovyan:users /home/jovyan/apps/aiidalab-qe'" + # Directory ~/apps/aiidalab-widgets-base/ is mounted by docker, + # make it writeable for jovyan user, needed for `pip install` + chown_command = "exec -T -u root aiidalab bash -c 'chown -R a+rw /home/jovyan/apps/aiidalab-qe'" docker_compose.execute(chown_command) - install_command = "bash -c 'pip install -U .'" + install_command = "bash -c 'pip install .'" command = f"exec --workdir /home/jovyan/apps/aiidalab-qe/src -T aiidalab {install_command}" docker_compose.execute(command) - install_command = "bash -c 'python tests/helper_dep_requirements.py && pip install -U -r /tmp/requirements.txt'" + install_command = "bash -c 'python tests/helper_dep_requirements.py && pip install -r /tmp/requirements.txt'" command = ( f"exec --workdir /home/jovyan/apps/aiidalab-qe -T aiidalab {install_command}" ) @@ -65,8 +66,11 @@ def _selenium_driver(nb_path, wait_time=5.0): @pytest.fixture(scope="session") def screenshot_dir(): - sdir = Path.joinpath(Path.home(), "screenshots") - os.mkdir(sdir) + sdir = Path.joinpath(Path.cwd(), "screenshots") + try: + os.mkdir(sdir) + except FileExistsError: + pass return sdir diff --git a/tests/test_qe_app.py b/tests/test_qe_app.py index ec49fb221..27bc0e1e0 100755 --- a/tests/test_qe_app.py +++ b/tests/test_qe_app.py @@ -32,7 +32,6 @@ def test_qe_app_select_silicon(selenium_driver, screenshot_dir): confirm_button = driver.find_element(By.XPATH, "//button[text()='Confirm']") confirm_button.location_once_scrolled_into_view # scroll into view confirm_button.click() - time.sleep(2) # Test that we have indeed proceeded to the next step driver.find_element(By.XPATH, "//span[contains(.,'✓ Step 1')]") driver.get_screenshot_as_file( From 5f7082a2f71ef88666a7deb7a6bc41028e613338 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 11 Dec 2022 15:23:17 +0000 Subject: [PATCH 14/24] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/conftest.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index e3b315985..2f714095f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -25,7 +25,9 @@ def notebook_service(docker_ip, docker_services): # Directory ~/apps/aiidalab-widgets-base/ is mounted by docker, # make it writeable for jovyan user, needed for `pip install` - chown_command = "exec -T -u root aiidalab bash -c 'chown -R a+rw /home/jovyan/apps/aiidalab-qe'" + chown_command = ( + "exec -T -u root aiidalab bash -c 'chown -R a+rw /home/jovyan/apps/aiidalab-qe'" + ) docker_compose.execute(chown_command) install_command = "bash -c 'pip install .'" From 875b48289b9cd742891422913bddad8e79881e76 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sun, 11 Dec 2022 15:33:48 +0000 Subject: [PATCH 15/24] chmod --- tests/conftest.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 2f714095f..90b28736c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -25,10 +25,10 @@ def notebook_service(docker_ip, docker_services): # Directory ~/apps/aiidalab-widgets-base/ is mounted by docker, # make it writeable for jovyan user, needed for `pip install` - chown_command = ( - "exec -T -u root aiidalab bash -c 'chown -R a+rw /home/jovyan/apps/aiidalab-qe'" + chmod_command = ( + "exec -T -u root aiidalab bash -c 'chmod -R a+rw /home/jovyan/apps/aiidalab-qe'" ) - docker_compose.execute(chown_command) + docker_compose.execute(chmod_command) install_command = "bash -c 'pip install .'" command = f"exec --workdir /home/jovyan/apps/aiidalab-qe/src -T aiidalab {install_command}" From f4e6cb2a0f389723ba4153cc24c007dde4a2fc97 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sun, 11 Dec 2022 17:43:22 +0000 Subject: [PATCH 16/24] Bump Firefox version --- .github/workflows/di.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/di.yml b/.github/workflows/di.yml index 69638559b..9fd7136d7 100644 --- a/.github/workflows/di.yml +++ b/.github/workflows/di.yml @@ -48,7 +48,7 @@ jobs: - name: Install Firefox uses: browser-actions/setup-firefox@latest with: - firefox-version: '90.0' + firefox-version: '96.0' if: matrix.browser == 'Firefox' - name: Install geckodriver From ebaad2211bcfabe7d1874d49b63d40f4e96fa6f8 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sun, 11 Dec 2022 18:00:34 +0000 Subject: [PATCH 17/24] aiidalab_exec fixture --- tests/conftest.py | 50 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 90b28736c..7d71f1c58 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -18,27 +18,45 @@ def is_responsive(url): @pytest.fixture(scope="session") -def notebook_service(docker_ip, docker_services): - """Ensure that HTTP service is up and responsive.""" +def docker_compose(docker_services): + return docker_services._docker_compose + + +@pytest.fixture(scope="session") +def aiidalab_exec(docker_compose): + def execute(command, user=None, workdir=None, **kwargs): + opts = "-T" + if user: + opts = f"{opts} --user={user}" + if workdir: + opts = f"{opts} --workdir={workdir}" + command = f"exec {opts} aiidalab {command}" + + return docker_compose.execute(command, **kwargs) + + return execute + + +@pytest.fixture +def nb_user(aiidalab_exec): + return aiidalab_exec("bash -c 'echo \"${NB_USER}\"'").decode().strip() - docker_compose = docker_services._docker_compose - # Directory ~/apps/aiidalab-widgets-base/ is mounted by docker, +@pytest.fixture(scope="session") +def notebook_service(docker_ip, docker_services, nb_user): + """Ensure that HTTP service is up and responsive.""" + + # Directory ~/apps/aiidalab-qe/ is mounted by docker, # make it writeable for jovyan user, needed for `pip install` - chmod_command = ( - "exec -T -u root aiidalab bash -c 'chmod -R a+rw /home/jovyan/apps/aiidalab-qe'" - ) - docker_compose.execute(chmod_command) + appdir = f"/home/{nb_user}/apps/aiidalab-qe" + aiidalab_exec(f"chmod -R a+rw {appdir}", user="root") - install_command = "bash -c 'pip install .'" - command = f"exec --workdir /home/jovyan/apps/aiidalab-qe/src -T aiidalab {install_command}" - docker_compose.execute(command) + # Install workchains + aiidalab_exec("pip install .", workdir=f"{appdir}/src", user=nb_user) - install_command = "bash -c 'python tests/helper_dep_requirements.py && pip install -r /tmp/requirements.txt'" - command = ( - f"exec --workdir /home/jovyan/apps/aiidalab-qe -T aiidalab {install_command}" - ) - docker_compose.execute(command) + # Install App + install_command = "python tests/helper_dep_requirements.py && pip install -r /tmp/requirements.txt" + aiidalab_exec(install_command, workdir=appdir, user=nb_user) # `port_for` takes a container port and returns the corresponding host port port = docker_services.port_for("aiidalab", 8888) From 0164feb5b05e9e46e16deb436dd23beae256f33b Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sun, 11 Dec 2022 18:06:09 +0000 Subject: [PATCH 18/24] session scope --- tests/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index 7d71f1c58..7de68595d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -37,7 +37,7 @@ def execute(command, user=None, workdir=None, **kwargs): return execute -@pytest.fixture +@pytest.fixture(scope="session") def nb_user(aiidalab_exec): return aiidalab_exec("bash -c 'echo \"${NB_USER}\"'").decode().strip() From 891a9e8e5495b62819f3d809199aa34ddf7191b6 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sun, 11 Dec 2022 18:13:28 +0000 Subject: [PATCH 19/24] add missing fixture --- tests/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index 7de68595d..f0eb4fe55 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -43,7 +43,7 @@ def nb_user(aiidalab_exec): @pytest.fixture(scope="session") -def notebook_service(docker_ip, docker_services, nb_user): +def notebook_service(docker_ip, docker_services, aiidalab_exec, nb_user): """Ensure that HTTP service is up and responsive.""" # Directory ~/apps/aiidalab-qe/ is mounted by docker, From f2b05ae115abb85dc972385622e03a47148989ad Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sun, 11 Dec 2022 18:39:22 +0000 Subject: [PATCH 20/24] debug --- tests/conftest.py | 3 ++- tests/helper_dep_requirements.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index f0eb4fe55..1a765abd0 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -55,7 +55,8 @@ def notebook_service(docker_ip, docker_services, aiidalab_exec, nb_user): aiidalab_exec("pip install .", workdir=f"{appdir}/src", user=nb_user) # Install App - install_command = "python tests/helper_dep_requirements.py && pip install -r /tmp/requirements.txt" + # install_command = "python tests/helper_dep_requirements.py && pip install -r /tmp/requirements.txt" + install_command = "pip install ." aiidalab_exec(install_command, workdir=appdir, user=nb_user) # `port_for` takes a container port and returns the corresponding host port diff --git a/tests/helper_dep_requirements.py b/tests/helper_dep_requirements.py index 8b0647034..969f8ad40 100644 --- a/tests/helper_dep_requirements.py +++ b/tests/helper_dep_requirements.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 -"""This helper script is for temporarily remove the -`aiidalab-qe-workchain` package from dependencies list so that +"""This helper script removes the `aiidalab-qe-workchain` package +from dependencies list so that in the test it will not use the remote released source. """ From 1f1718a1ccfd54cc4ca10b77df44c9cfa6c6ef0c Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sun, 11 Dec 2022 18:48:01 +0000 Subject: [PATCH 21/24] One more try --- tests/conftest.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 1a765abd0..6eb77e927 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -55,8 +55,7 @@ def notebook_service(docker_ip, docker_services, aiidalab_exec, nb_user): aiidalab_exec("pip install .", workdir=f"{appdir}/src", user=nb_user) # Install App - # install_command = "python tests/helper_dep_requirements.py && pip install -r /tmp/requirements.txt" - install_command = "pip install ." + install_command = "bash -c 'python tests/helper_dep_requirements.py && pip install -r /tmp/requirements.txt'" aiidalab_exec(install_command, workdir=appdir, user=nb_user) # `port_for` takes a container port and returns the corresponding host port From 3a3a404d3f6c4704727f71da1bac4870677f7924 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sun, 11 Dec 2022 21:03:26 +0000 Subject: [PATCH 22/24] update pre-commit in setup.cfg --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 714087745..de7912afc 100644 --- a/setup.cfg +++ b/setup.cfg @@ -36,7 +36,7 @@ python_requires = >=3.8 [options.extras_require] dev = bumpver==2022.1119 - pre-commit==2.11.1 + pre-commit~=2.20 test = file: requirements_test.txt [options.package_data] From 006613d6ddd86f700e7fa6d04a55a9413a846c3a Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sun, 11 Dec 2022 21:06:31 +0000 Subject: [PATCH 23/24] Alternative approach to workchain package --- tests/conftest.py | 10 +++++----- tests/helper_dep_requirements.py | 16 ---------------- 2 files changed, 5 insertions(+), 21 deletions(-) delete mode 100644 tests/helper_dep_requirements.py diff --git a/tests/conftest.py b/tests/conftest.py index 6eb77e927..2a705ea23 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -51,12 +51,12 @@ def notebook_service(docker_ip, docker_services, aiidalab_exec, nb_user): appdir = f"/home/{nb_user}/apps/aiidalab-qe" aiidalab_exec(f"chmod -R a+rw {appdir}", user="root") - # Install workchains - aiidalab_exec("pip install .", workdir=f"{appdir}/src", user=nb_user) - # Install App - install_command = "bash -c 'python tests/helper_dep_requirements.py && pip install -r /tmp/requirements.txt'" - aiidalab_exec(install_command, workdir=appdir, user=nb_user) + aiidalab_exec("pip install .", workdir=appdir, user=nb_user) + + # Install workchains, we use editable install to make sure + # we overwrite the package that was installed above. + aiidalab_exec("pip install -e .", workdir=f"{appdir}/src", user=nb_user) # `port_for` takes a container port and returns the corresponding host port port = docker_services.port_for("aiidalab", 8888) diff --git a/tests/helper_dep_requirements.py b/tests/helper_dep_requirements.py deleted file mode 100644 index 969f8ad40..000000000 --- a/tests/helper_dep_requirements.py +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env python3 - -"""This helper script removes the `aiidalab-qe-workchain` package -from dependencies list so that -in the test it will not use the remote released source. -""" - -from configparser import ConfigParser - -cf = ConfigParser() -cf.read("setup.cfg") -lst = cf["options"]["install_requires"].split("\n") -requirements_lst = [i for i in lst if not i.startswith("aiidalab-qe-workchain")] - -with open("/tmp/requirements.txt", "w") as fh: - fh.write("\n".join(requirements_lst[1:])) From b25930259ed043a6e292e62251cb865d75d0070b Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sun, 11 Dec 2022 22:10:04 +0000 Subject: [PATCH 24/24] Revert "Alternative approach to workchain package" This reverts commit 006613d6ddd86f700e7fa6d04a55a9413a846c3a. --- tests/conftest.py | 10 +++++----- tests/helper_dep_requirements.py | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 tests/helper_dep_requirements.py diff --git a/tests/conftest.py b/tests/conftest.py index 2a705ea23..6eb77e927 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -51,12 +51,12 @@ def notebook_service(docker_ip, docker_services, aiidalab_exec, nb_user): appdir = f"/home/{nb_user}/apps/aiidalab-qe" aiidalab_exec(f"chmod -R a+rw {appdir}", user="root") - # Install App - aiidalab_exec("pip install .", workdir=appdir, user=nb_user) + # Install workchains + aiidalab_exec("pip install .", workdir=f"{appdir}/src", user=nb_user) - # Install workchains, we use editable install to make sure - # we overwrite the package that was installed above. - aiidalab_exec("pip install -e .", workdir=f"{appdir}/src", user=nb_user) + # Install App + install_command = "bash -c 'python tests/helper_dep_requirements.py && pip install -r /tmp/requirements.txt'" + aiidalab_exec(install_command, workdir=appdir, user=nb_user) # `port_for` takes a container port and returns the corresponding host port port = docker_services.port_for("aiidalab", 8888) diff --git a/tests/helper_dep_requirements.py b/tests/helper_dep_requirements.py new file mode 100644 index 000000000..969f8ad40 --- /dev/null +++ b/tests/helper_dep_requirements.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python3 + +"""This helper script removes the `aiidalab-qe-workchain` package +from dependencies list so that +in the test it will not use the remote released source. +""" + +from configparser import ConfigParser + +cf = ConfigParser() +cf.read("setup.cfg") +lst = cf["options"]["install_requires"].split("\n") +requirements_lst = [i for i in lst if not i.startswith("aiidalab-qe-workchain")] + +with open("/tmp/requirements.txt", "w") as fh: + fh.write("\n".join(requirements_lst[1:]))