Skip to content

Commit

Permalink
Feature: CI with GitHub actions (#451)
Browse files Browse the repository at this point in the history
* added CI.yml containing workflows

* added badge for CI tests to README.md

* restructured requirements, environment.yml refactored to environment-docs.yml and environment-tests.yml.

* adapted runners according to new new .yml files

* update requirements in environment-*.yml to neo>=0.10.0
  • Loading branch information
Moritz-Alexander-Kern authored Mar 14, 2022
1 parent 854a5ca commit 67dd3f3
Show file tree
Hide file tree
Showing 6 changed files with 359 additions and 6 deletions.
316 changes: 316 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,316 @@
# This workflow will setup GitHub-hosted runners and install the required dependencies for elephant tests.
# On a pull requests and on pushes to master it will run different tests for elephant.

name: tests
# define events that trigger workflow 'tests'
on:
workflow_dispatch: # enables manual triggering of workflow
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
type: choice
options:
- info
- warning
- debug
pull_request:
branches:
- master
types:
#- assigned
#- unassigned
- labeled
#- unlabeled
- opened
#- edited
#- closed
#- reopened
#- synchronize
#- converted_to_draft
#- ready_for_review
#- locked
#- unlocked
#- review_requested
#- review_request_removed
#- auto_merge_enabled
#- auto_merge_disabled

# jobs define the steps that will be executed on the runner
jobs:
# install dependencies and elephant with pip and run tests with pytest
build-and-test-pip:
runs-on: ${{ matrix.os }}
strategy:
matrix:
# python versions for elephant: [3.6, 3.7, 3.8, 3.9]
python-version: [3.6, 3.7, 3.8, 3.9]
# OS [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest]

# do not cancel all in-progress jobs if any matrix job fails
fail-fast: false

steps:
# used to reset cache every month
- name: Get current year-month
id: date
run: echo "::set-output name=date::$(date +'%Y-%m')"
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Cache test_env
uses: actions/cache@v2
with:
path: ~/test_env
# Look to see if there is a cache hit for the corresponding requirements files
# cache will be reset on changes to any requirements or every month
key: ${{ runner.os }}-venv-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/requirements-tests.txt') }}
-${{ hashFiles('**/requirements-extras.txt') }}-${{ hashFiles('setup.py') }} -${{ steps.date.outputs.date }}

- name: Install dependencies
run: |
# create an environment and install everything
python -m venv ~/test_env
source ~/test_env/bin/activate
python -m pip install --upgrade pip
pip install -r requirements/requirements-tests.txt
pip install -r requirements/requirements.txt
pip install -r requirements/requirements-extras.txt
pip install pytest-cov coveralls
pip install -e .
- name: Build
run: |
source ~/test_env/bin/activate
python setup.py install
- name: List packages
run: |
source ~/test_env/bin/activate
pip list
python --version
- name: Test with pytest
run: |
source ~/test_env/bin/activate
pytest --cov=elephant
# install dependencies with conda and run tests with pytest
test-conda:
runs-on: ${{ matrix.os }}
strategy:
matrix:
# OS [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest]

# do not cancel all in-progress jobs if any matrix job fails
fail-fast: false

steps:
- uses: actions/checkout@v2

- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{hashFiles('requirements/environment-tests.yml') }}-${{ steps.date.outputs.date }}

- name: Add conda to system path
run: |
# $CONDA is an environment variable pointing to the root of the miniconda directory
echo $CONDA/bin >> $GITHUB_PATH
- name: Install dependencies
run: |
conda update conda
conda env update --file requirements/environment-tests.yml --name base
activate base
conda install -c conda-forge openmpi
pip install -r requirements/requirements-tests.txt
pip install pytest==6.2.5 # hotfix for pytest 7.0.0, remove once fixed
pip install pytest-cov coveralls
pip install .
- name: List packages
run: |
activate base
pip list
conda list
python --version
- name: Test with pytest
run: |
activate base
pytest --cov=elephant --import-mode=importlib
# install dependencies with pip and run tests with pytest
test-pip:
runs-on: ${{ matrix.os }}
strategy:
matrix:
# python versions for elephant: [3.6, 3.7, 3.8, 3.9]
python-version: [3.8,]
# OS [ubuntu-latest, macos-latest, windows-latest]
os: [windows-latest]
include:
# - os: ubuntu-latest
# path: ~/.cache/pip
# - os: macos-latest
# path: ~/Library/Caches/pip
- os: windows-latest
path: ~\AppData\Local\pip\Cache
# do not cancel all in-progress jobs if any matrix job fails
fail-fast: false

steps:
- name: Get current year-month
id: date
run: echo "::set-output name=date::$(date +'%Y-%m')"

- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Cache pip
uses: actions/cache@v2
with:
path: ${{ matrix.path }}
# Look to see if there is a cache hit for the corresponding requirements files
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/requirements-tests.txt') }}
-${{ hashFiles('**/requirements-extras.txt') }}-${{ hashFiles('setup.py') }} -${{ steps.date.outputs.date }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements/requirements-tests.txt
pip install -r requirements/requirements.txt
pip install -r requirements/requirements-extras.txt
pip install pytest-cov coveralls
pip install -e .
- name: List packages
run: |
pip list
python --version
- name: Test with pytest
run: |
python --version
pytest --cov=elephant
# install dependencies and elephant with pip and run MPI
test-pip-MPI:
runs-on: ${{ matrix.os }}
strategy:
matrix:
# python versions for elephant: [3.6, 3.7, 3.8, 3.9]
python-version: [3.6]
# OS [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest]

# do not cancel all in-progress jobs if any matrix job fails
fail-fast: false

steps:
- name: Get current year-month
id: date
run: echo "::set-output name=date::$(date +'%Y-%m')"
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Cache test_env
uses: actions/cache@v2
with:
path: ~/.cache/pip
# Look to see if there is a cache hit for the corresponding requirements files
# cache will be reset on changes to any requirements or every month
key: ${{ runner.os }}-venv-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/requirements-tests.txt') }}
-${{ hashFiles('**/requirements-extras.txt') }}-${{ hashFiles('setup.py') }} -${{ steps.date.outputs.date }}

- name: Setup enviroment
run: |
sudo apt install -y libopenmpi-dev openmpi-bin
python -m pip install --upgrade pip
pip install mpi4py
pip install -r requirements/requirements-tests.txt
pip install -r requirements/requirements.txt
pip install -r requirements/requirements-extras.txt
pip install pytest-cov coveralls
pip install -e .
- name: List packages
run: |
pip list
python --version
- name: Test with pytest
run: |
mpiexec -n 1 python -m mpi4py -m pytest --cov=elephant
# install dependencies for the documentation and build .html
docs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
# OS [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest]

steps:

- name: Get current year-month
id: date
run: echo "::set-output name=date::$(date +'%Y-%m')"

- uses: actions/checkout@v2

- name: Add conda to system path
run: |
# $CONDA is an environment variable pointing to the root of the miniconda directory
echo $CONDA/bin >> $GITHUB_PATH
sudo apt install -y libopenmpi-dev openmpi-bin
- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
# Look to see if there is a cache hit for the corresponding requirements files
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements-docs.txt') }}-${{ hashFiles('**/requirements-tutorials.txt') }}-${{ hashFiles('**/environment-docs.yml') }}-${{ steps.date.outputs.date }}

- name: Install dependencies
run: |
sudo apt install -y libopenmpi-dev openmpi-bin
python -m pip install --upgrade pip
pip install -r requirements/requirements-docs.txt
pip install -r requirements/requirements-tutorials.txt
conda update conda
conda env update --file requirements/environment-docs.yml --name base
conda install -c conda-forge openmpi
conda install -c conda-forge pandoc
# run notebooks
sed -i -E "s/nbsphinx_execute *=.*/nbsphinx_execute = 'always'/g" doc/conf.py
- name: List packages
run: |
pip list
conda list
python --version
- name: make html
run: |
cd doc
make html
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[![Statistics](https://img.shields.io/pypi/dm/elephant)](https://seladb.github.io/StarTrack-js/#/preload?r=neuralensemble,elephant)
[![Gitter](https://badges.gitter.im/python-elephant/community.svg)](https://gitter.im/python-elephant/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
[![DOI Latest Release](https://zenodo.org/badge/10311278.svg)](https://zenodo.org/badge/latestdoi/10311278)

[![tests](https://github.com/NeuralEnsemble/elephant/actions/workflows/CI.yml/badge.svg)](https://github.com/NeuralEnsemble/elephant/actions/workflows/CI.yml)

*Elephant* package analyses all sorts of neurophysiological data:
spike trains, LFP, analog signals. The input-output data format is either
Expand Down Expand Up @@ -44,5 +44,4 @@ See [acknowledgments](doc/acknowledgments.rst).

#### Citation

See [citations](doc/citation.rst).

See [citations](doc/citation.rst).
4 changes: 2 additions & 2 deletions readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ sphinx:
configuration: doc/conf.py

conda:
environment: requirements/environment.yml
environment: requirements/environment-docs.yml

python:
install:
Expand All @@ -18,4 +18,4 @@ python:
extra_requirements:
- docs
- extras
- tutorials
- tutorials
19 changes: 19 additions & 0 deletions requirements/environment-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: elephant

channels:
- conda-forge # required for MPI

dependencies:
- python>=3.6
- mpi4py
- numpy
- scipy
- tqdm
- pandas
- scikit-learn
- statsmodels
- jinja2
- pip:
- neo>=0.10.0
- viziphant
# neo, viziphant can be removed once it is integrated into requirements-tutorials.txt
19 changes: 19 additions & 0 deletions requirements/environment-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: elephant

channels:
- conda-forge # required for MPI

dependencies:
- python>=3.6
- mpi4py
- numpy
- scipy
- tqdm
- pandas
- scikit-learn
- statsmodels
- jinja2
- pip:
- neo>=0.10.0
- viziphant
# neo, viziphant can be removed once it is integrated into requirements-tutorials.txt
2 changes: 1 addition & 1 deletion requirements/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ dependencies:
- statsmodels
- jinja2
- pip:
- neo>=0.9.0,<0.10.0
- neo>=0.10.0
- viziphant
# neo, viziphant can be removed once it is integrated into requirements-tutorials.txt

0 comments on commit 67dd3f3

Please sign in to comment.