Skip to content

Commit

Permalink
Add back integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhollas committed Jul 18, 2024
1 parent dac6a81 commit e6edb50
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 88 deletions.
59 changes: 0 additions & 59 deletions .github/actions/integration-tests/action.yml

This file was deleted.

22 changes: 20 additions & 2 deletions .github/workflows/docker-build-test-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ on:

env:
FORCE_COLOR: 1
IMAGE: ghcr.io/aiidalab/qe
BUILDKIT_PROGRESS: plain

# https://docs.github.com/en/actions/using-jobs/using-concurrency
concurrency:
Expand Down Expand Up @@ -45,14 +47,14 @@ jobs:
uses: docker/metadata-action@v4
with:
images: |
name=ghcr.io/aiidalab/qe
name=${{ env.IMAGE }}
tags: |
type=edge,enable={{is_default_branch}}
type=ref,event=pr
type=match,pattern=v(\d{2}\.\d{2}.\d+.*),group=1
type=raw,value={{tag}},enable=${{ startsWith(github.ref, 'refs/tags/v') }}
- name: Build and load to Docker
- name: Build and push image
id: build-upload
uses: docker/build-push-action@v5
with:
Expand All @@ -73,3 +75,19 @@ jobs:

- name: Install Dev Dependencies 📦
run: pip install -r requirements-docker.txt

- name: Set jupyter token env
run: echo "JUPYTER_TOKEN=$(openssl rand -hex 32)" >> $GITHUB_ENV

- name: Run pytest for Chrome
run: pytest --driver Chrome tests_integration/
env:
QE_IMAGE: ${{ env.IMAGE }}@${{ steps.build-upload.outputs.digest }}

- name: Upload screenshots as artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: Screenshots
path: screenshots/
if-no-files-found: error
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# syntax=docker/dockerfile:1
FROM ghcr.io/astral-sh/uv:0.2.18 as uv
FROM ghcr.io/astral-sh/uv:0.2.18 AS uv
FROM ghcr.io/aiidalab/full-stack:2024.1019

# Copy whole repo and pre-install the dependencies and app to the tmp folder.
# In the before notebook scripts the app will be re-installed by moving it to the app folder.
ENV PREINSTALL_APP_FOLDER ${CONDA_DIR}/aiidalab-qe
ENV PREINSTALL_APP_FOLDER=${CONDA_DIR}/aiidalab-qe
COPY --chown=${NB_UID}:${NB_GID} . ${PREINSTALL_APP_FOLDER}

USER ${NB_USER}

# Using uv to speed up installation, per docs:
# https://github.com/astral-sh/uv/blob/main/docs/guides/docker.md#using-uv-temporarily
# Use the same constraint file as PIP
ENV UV_CONSTRAINT ${PIP_CONSTRAINT}
ENV UV_CONSTRAINT=${PIP_CONSTRAINT}
RUN --mount=from=uv,source=/uv,target=/bin/uv \
cd ${PREINSTALL_APP_FOLDER} && \
# Remove all untracked files and directories. For example the setup lock flag file.
Expand All @@ -39,7 +39,7 @@ RUN mamba create -p /opt/conda/envs/quantum-espresso --yes \
fix-permissions "/home/${NB_USER}"

# Download the QE pseudopotentials to the folder for afterware installation.
ENV PSEUDO_FOLDER ${CONDA_DIR}/pseudo
ENV PSEUDO_FOLDER=${CONDA_DIR}/pseudo
RUN mkdir -p ${PSEUDO_FOLDER} && \
python -m aiidalab_qe download-pseudos --dest ${PSEUDO_FOLDER}

Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,14 @@ pytest -sv tests
To run the integration tests, you need to build the Docker image first:

```
cd docker/
docker buildx bake -f build.json -f docker-bake.hcl --set "*.platform=linux/amd64" --load
docker build . -t aiidalab/qe
```

Then, you can run the integration tests with:

```bash
JUPYTER_TOKEN=max TAG=newly-baked pytest --driver Chrome tests_integration -sv
``````
pytest --driver Chrome tests_integration
```

## For maintainers

Expand All @@ -57,7 +56,7 @@ Additional notes:
- Use the `--dry` option to preview the release change.
- The release tag (e.g. a/b/rc) is determined from the last release.
Use the `--tag` option to switch the release tag.
- For making "outdate" release since we fix minor version to `2x.04.xx` and `2x.10.xx`, use e.g. `bumpver update --set-version v23.10.0rc4 --ignore-vcs-tag` to make the release.
- For making "outdated" release since we fix minor version to `2x.04.xx` and `2x.10.xx`, use e.g. `bumpver update --set-version v23.10.0rc4 --ignore-vcs-tag` to make the release.

## Acknowledgements
We acknowledge support from:
Expand Down
13 changes: 4 additions & 9 deletions requirements-docker.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
docker
requests
pre-commit
pytest
pytest-docker

# test dependencies
pytest-selenium
pytest-html<4.0
selenium~=4.9.0
webdriver-manager
pytest~=8.2.0
pytest-docker~=3.0
pytest-selenium~=4.1
selenium==4.20.0
10 changes: 2 additions & 8 deletions tests_integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pytest
import requests
import selenium.webdriver.support.expected_conditions as EC
import selenium.webdriver.support.expected_conditions as ec
from requests.exceptions import ConnectionError
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
Expand Down Expand Up @@ -85,7 +85,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")
WebDriverWait(selenium, 100).until(
EC.invisibility_of_element((By.ID, "appmode-busy"))
ec.invisibility_of_element((By.ID, "appmode-busy"))
)

return selenium
Expand Down Expand Up @@ -116,12 +116,6 @@ def screenshot_dir():
return sdir


@pytest.fixture
def firefox_options(firefox_options):
firefox_options.add_argument("--headless")
return firefox_options


@pytest.fixture
def chrome_options(chrome_options):
chrome_options.add_argument("--headless")
Expand Down
2 changes: 1 addition & 1 deletion tests_integration/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: '3.4'
services:

aiidalab:
image: ${REGISTRY:-}${QE_IMAGE:-aiidalab/qe}:${TAG:-newly-baked}
image: ${REGISTRY:-}${QE_IMAGE:-aiidalab/qe}${TAG}
environment:
TZ: Europe/Zurich
DOCKER_STACKS_JUPYTER_CMD: notebook
Expand Down

0 comments on commit e6edb50

Please sign in to comment.