Skip to content

Commit

Permalink
Update CI (#243)
Browse files Browse the repository at this point in the history
* Don't install firefox manually
* Don't install geckodriver manually
* Pin full-stack image
* Increase timeouts
* Update test dependencies
  • Loading branch information
danielhollas authored Jun 23, 2024
1 parent 1376374 commit fc6dd92
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 25 deletions.
22 changes: 6 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
- main
pull_request:

env:
FORCE_COLOR: 1

jobs:

pre-commit:
Expand Down Expand Up @@ -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:

Expand Down Expand Up @@ -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/

Expand Down
9 changes: 4 additions & 5 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -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
11 changes: 7 additions & 4 deletions tests/app/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -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
Expand All @@ -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

Expand Down

0 comments on commit fc6dd92

Please sign in to comment.