Fix notebook tests #3230
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
# Run unit tests and notebook tests on the latest aiidalab-docker image. | |
name: CI | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
env: | |
FORCE_COLOR: "1" | |
UV_VERSION: "0.2.17" | |
# https://docs.github.com/en/actions/using-jobs/using-concurrency | |
concurrency: | |
# only cancel in-progress jobs or runs for the current workflow - matches against branch & tags | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
test-notebooks: | |
strategy: | |
matrix: | |
browser: [Chrome, Firefox] | |
# test on the latest and the oldest supported version | |
aiida-core-version: [2.1.2, 2.5.1] | |
fail-fast: false | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
steps: | |
- name: Check out app | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
- name: Install uv | |
run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/astral-sh/uv/releases/download/${UV_VERSION}/uv-installer.sh | sh | |
- name: Install package test dependencies | |
# Notebook tests happen in the container, here we only need to install | |
# the pytest-docker dependency. Unfortunately, uv/pip does not allow to | |
# only install [dev] dependencies so we end up installing all the rest as well. | |
run: uv pip install --system .[dev] | |
- 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 | |
uses: browser-actions/setup-firefox@latest | |
with: | |
firefox-version: '96.0' | |
if: matrix.browser == 'Firefox' | |
- name: Install geckodriver | |
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 | |
if: matrix.browser == 'Firefox' | |
- name: Run pytest | |
run: pytest -v --driver ${{ matrix.browser }} tests_notebooks | |
env: | |
TAG: aiida-${{ matrix.aiida-core-version }} | |
- name: Upload screenshots as artifacts | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Screenshots-aiida-${{ matrix.aiida-core-version }}-${{ matrix.browser }} | |
path: screenshots/ | |
if-no-files-found: error | |
test-package: | |
strategy: | |
matrix: | |
python-version: ['3.9', '3.11'] | |
# Test on the latest and oldest supported version | |
aiida-core-version: [2.2.2, 2.5.1] | |
fail-fast: false | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
services: | |
rabbitmq: | |
image: rabbitmq:latest | |
ports: | |
- 5672:5672 | |
steps: | |
- name: Check out app | |
uses: actions/checkout@v4 | |
- name: Install povray | |
run: sudo apt-get update && sudo apt-get install povray | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install uv | |
run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/astral-sh/uv/releases/download/${UV_VERSION}/uv-installer.sh | sh | |
- name: Install package | |
# NOTE: uv (unlike pip) does not compile python to bytecode after install. | |
# This uncovered a lot of SyntaxError(s) in the vapory package, | |
# since pip swallows these by default (WTH?). | |
# Ideally, these would be fixed, but vapory is largely unmaintained, | |
# so here we simply keep the pip behaviour with the --compile flag. | |
# See https://github.com/astral-sh/uv/issues/1928#issuecomment-1968857514 | |
run: uv pip install --compile --system -e .[dev,smiles,optimade,eln] aiida-core==${{ matrix.aiida-core-version }} | |
- name: Run pytest | |
run: pytest -v tests --cov=aiidalab_widgets_base | |
- name: Upload coverage reports to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
flags: python-${{ matrix.python-version }} | |
token: ${{ secrets.CODECOV_TOKEN }} |