Skip to content

Commit

Permalink
Add test to latest and oldest supported aiida-core (aiidalab#558)
Browse files Browse the repository at this point in the history
The package used with aiida-core as base, so aiida-core is the very base dependency that should carefully test to not break the compatibility. We want to support a wide range of `aiida-core` version. 
The test CI added in this commit run both the unit test and the integration test with latest/oldest aiida-core version in the environment, to make sure the backward compatibility.
  • Loading branch information
unkcpz authored Feb 23, 2024
1 parent 8808a3c commit bd29d28
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
12 changes: 5 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ jobs:

strategy:
matrix:
tag: [latest]
browser: [Chrome, Firefox]
python-version: ['3.10']
aiida-core-version: [2.1.2, 2.4.3] # test on the latest and the oldest supported version
fail-fast: false

runs-on: ubuntu-latest
Expand Down Expand Up @@ -91,13 +91,13 @@ jobs:
- name: Run pytest
run: pytest -v --driver ${{ matrix.browser }} tests_notebooks
env:
TAG: ${{ matrix.tag }}
TAG: aiida-${{ matrix.aiida-core-version }}

- name: Upload screenshots as artifacts
if: always()
uses: actions/upload-artifact@v3
with:
name: Screenshots-${{ matrix.tag }}-${{ matrix.browser }}
name: Screenshots-aiida-${{ matrix.aiida-core-version }}-${{ matrix.browser }}
path: screenshots/
if-no-files-found: error

Expand All @@ -107,8 +107,8 @@ jobs:

strategy:
matrix:
tag: [latest]
python-version: ['3.9', '3.10']
aiida-core-version: [2.2.2, 2.4.3] # test on the latest and the oldest supported version
fail-fast: false

runs-on: ubuntu-latest
Expand Down Expand Up @@ -137,12 +137,10 @@ jobs:
**/requirements*.txt
- name: Install package
run: pip install -e .[dev,smiles,optimade]
run: pip install -e .[dev,smiles,optimade] aiida-core==${{ matrix.aiida-core-version }}

- name: Run pytest
run: pytest -v tests --cov
env:
TAG: ${{ matrix.tag }}

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
Expand Down
18 changes: 18 additions & 0 deletions tests_notebooks/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,27 @@ def notebook_service(docker_ip, docker_services, aiidalab_exec):
# make it writeable for jovyan user, needed for `pip install`
aiidalab_exec("chmod -R a+rw /home/jovyan/apps/aiidalab-widgets-base", user="root")

# The aiida-core version is pinned in the requirements.txt file only after
# we release the docker stack with aiida-core v2.4.0 in:
# https://github.com/aiidalab/aiidalab-docker-stack/commit/dfa65151017362fefeb56d97fed3c1b8f25537c5
# There is a possibility that aiida-core version will be overwritten by the installation of AWB.
# TODO: We can move this before/after version check after the lowest supported aiida-core version is 2.4.0.

# Get the aiida-core version before installing AWB
output = aiidalab_exec("verdi --version").decode("utf-8").strip()
before_version = output.split(" ")[-1]

# Install AWB with extra dependencies for SmilesWidget
aiidalab_exec("pip install --no-cache-dir .[smiles,optimade]")

# Get the aiida-core version before installing AWB
output = aiidalab_exec("verdi --version").decode("utf-8").strip()
after_version = output.split(" ")[-1]

assert (
before_version == after_version
), f"aiida-core version was changed from {before_version} to {after_version}."

# `port_for` takes a container port and returns the corresponding host port
port = docker_services.port_for("aiidalab", 8888)
url = f"http://{docker_ip}:{port}"
Expand Down
7 changes: 6 additions & 1 deletion tests_notebooks/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ version: '3.4'
services:

aiidalab:
image: ghcr.io/aiidalab/full-stack:${TAG:-latest}
# TODO: When we drop support of images with aiida-core<2.4.0, we should go back to using
# the ghcr.io registry to pull the image,
# since the dockerhub registry has a rate limit of 100 pulls per 6 hours.
# Images with aiida-core<2.4.0 were not pushed to ghcr.io because of CI issues,
# which were fixed in https://github.com/aiidalab/aiidalab-docker-stack/pull/390
image: aiidalab/full-stack:${TAG:-latest}
environment:
RMQHOST: messaging
TZ: Europe/Zurich
Expand Down

0 comments on commit bd29d28

Please sign in to comment.