Merge pull request #110 from paxtonfitzpatrick/rev-1 #90
Workflow file for this run
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
name: CI Tests (Jupyter) | |
on: | |
push: | |
paths-ignore: | |
- 'paper/**' | |
- '.gitattributes' | |
- '.gitmodules' | |
- 'CITATION.cff' | |
- 'LICENSE' | |
- 'README.md' | |
pull_request: | |
paths-ignore: | |
- 'paper/**' | |
- '.gitattributes' | |
- '.gitmodules' | |
- 'CITATION.cff' | |
- 'LICENSE' | |
- 'README.md' | |
workflow_dispatch: | |
inputs: | |
debug_enabled: | |
description: 'Pause before tests for tmate debugging' | |
required: false | |
default: 'false' | |
defaults: | |
run: | |
shell: bash -leo pipefail {0} | |
jobs: | |
run-tests: | |
name: "Run Jupyter CI tests (Python ${{ matrix.python-version }}, IPython ${{ matrix.ipython-version }})" | |
runs-on: ubuntu-latest | |
# only run on pull requests between forks to avoid duplicate runs with 'push' event | |
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
# for each Python version, test with earliest and latest supported IPython version | |
- python-version: 3.6 | |
ipython-version: 5.5.0 # earliest version supported by davos | |
- python-version: 3.6 | |
ipython-version: 7.16 # latest version to support Python 3.6 | |
- python-version: 3.7 | |
ipython-version: 5.5.0 # earliest version supported by davos | |
- python-version: 3.7 | |
ipython-version: 7.31 # latest version to support Python 3.7 | |
- python-version: 3.8 | |
ipython-version: 7.3.0 # earliest version to support Python 3.8 | |
- python-version: 3.8 | |
ipython-version: 8.12.2 # latest version to support Python 3.8 | |
- python-version: 3.9 | |
ipython-version: 7.15 # earliest version to support Python 3.9 | |
- python-version: 3.9 | |
ipython-version: latest | |
- python-version: '3.10' | |
ipython-version: 8.0 # earliest version to support Python 3.10 | |
- python-version: '3.10' | |
ipython-version: latest | |
- python-version: 3.11 | |
ipython-version: 8.8.0 # earliest version to support Python 3.11 | |
- python-version: 3.11 | |
ipython-version: latest | |
env: | |
HEAD_FORK: ${{ github.repository_owner }} | |
HEAD_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} | |
IPYTHON_VERSION: ${{ matrix.ipython-version }} | |
# MAMBA_NO_BANNER: 1 | |
NOTEBOOK_TYPE: jupyter | |
PYTHON_VERSION: ${{ matrix.python-version }} | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
ref: ${{ env.HEAD_SHA }} | |
- name: install miniconda | |
uses: conda-incubator/setup-miniconda@v2 | |
with: | |
auto-update-conda: true | |
# miniforge-variant: Mambaforge | |
# miniforge-version: 4.13.0-1 | |
# use-mamba: true | |
# channels: conda-forge,defaults | |
# channel-priority: strict | |
auto-activate-base: true | |
activate-environment: "" | |
- name: setup base environment | |
run: | | |
# install Python 3.9 (used to run notebooks via selenium, not the tests themselves) | |
conda install python=3.9 | |
# install Firefox browser: | |
# - remove pre-installed snap package | |
[[ -x "$(command -v snap)" ]] && sudo snap remove firefox | |
# - add Mozilla PPA as a repository | |
sudo add-apt-repository -y ppa:mozillateam/ppa | |
# - alter Firefox package priority to prefer the deb package from the PPA | |
echo ' | |
Package: * | |
Pin: release o=LP-PPA-mozillateam | |
Pin-Priority: 1001 | |
' | sudo tee /etc/apt/preferences.d/mozilla-firefox | |
# - install the proper version | |
sudo apt install -y --allow-downgrades firefox | |
# install python packages | |
pip install notebook \ | |
pytest==6.2 \ | |
selenium==3.141 \ | |
geckodriver-autoinstaller \ | |
ipykernel==5.0.0 \ | |
"jupyter_client<=7.3.2" \ | |
"tornado<=6.1" \ | |
"urllib3<2.0" | |
# install geckodriver | |
driver_path=$(python -c ' | |
from pathlib import Path | |
import geckodriver_autoinstaller | |
driver_src = Path(geckodriver_autoinstaller.install(cwd=True)) | |
driver_dest = driver_src.rename(driver_src.parents[1].joinpath(driver_src.name)) | |
driver_src.parent.rmdir() | |
print(driver_dest) | |
') | |
# export path to driver as environment variable | |
echo "DRIVER_PATH=$driver_path" >> $GITHUB_ENV | |
- name: setup notebook kernel environment | |
run: | | |
# create & activate kernel environment | |
conda create -n kernel-env python=$PYTHON_VERSION | |
conda activate kernel-env | |
# install davos & various test requirements in kernel environment | |
[[ "$PYTHON_VERSION" =~ ^3.(6|7)$ ]] && pip install typing-extensions | |
pip install "ipykernel==5.0.0" \ | |
ipython-genutils \ | |
requests \ | |
fastdtw==0.3.4 \ | |
tqdm==4.41.1 \ | |
"numpy<=1.23.5" | |
[[ "$PYTHON_VERSION" =~ ^3.11$ ]] && pip install scipy==1.11.1 || pip install "scipy<=1.7.3" | |
if [[ "$IPYTHON_VERSION" == "latest" ]]; then | |
pip install --upgrade IPython | |
else | |
pip install IPython==$IPYTHON_VERSION | |
fi | |
pip install . | |
# make environment available as a jupyter kernel | |
python -m ipykernel install --prefix=/usr/share/miniconda --name=kernel-env | |
conda deactivate | |
- name: record environment | |
run: | | |
{ | |
# get packages in base environment | |
printf '=%.0s' {1..20}; printf ' base '; printf '=%.0s' {1..20}; printf '\n' | |
conda env export -n base | |
# get packages in kernel environment | |
printf '=%.0s' {1..20}; printf ' kernel-env '; printf '=%.0s' {1..20}; printf '\n' | |
conda env export -n kernel-env | |
# get firefox browser & webdriver version | |
printf '=%.0s' {1..20}; printf ' firefox '; printf '=%.0s' {1..20}; printf '\n' | |
firefox --full-version | |
$DRIVER_PATH --version | |
# get jupyter kernels available in base environment | |
printf '=%.0s' {1..20}; printf ' jupyter kernels '; printf '=%.0s' {1..20}; printf '\n' | |
jupyter kernelspec list | |
} > ${{ github.workspace }}/environment-info.txt | |
cat ${{ github.workspace }}/environment-info.txt | |
- name: launch Jupyter server | |
run: jupyter notebook --no-browser --port=8888 --NotebookApp.token= & | |
- name: debug runner | |
if: | | |
github.event_name == 'workflow_dispatch' | |
&& github.event.inputs.debug_enabled == 'true' | |
uses: mxschmitt/action-tmate@v3 | |
- name: run pytest | |
id: run-pytest | |
run: pytest -sv tests/ | |
- name: upload artifacts on failure | |
uses: actions/upload-artifact@v3 | |
if: failure() | |
with: | |
name: artifacts-python${{ matrix.python-version }}-ipython${{ matrix.ipython-version }} | |
path: | | |
${{ github.workspace }}/tests/*.ipynb | |
${{ github.workspace }}/environment-info.txt |