Skip to content

Commit

Permalink
Merge pull request #1 from ericpre/add_github_actions
Browse files Browse the repository at this point in the history
Add GitHub actions
  • Loading branch information
jlaehne authored Jul 23, 2022
2 parents b43c8b2 + 44c32a3 commit a3539d5
Show file tree
Hide file tree
Showing 6 changed files with 171 additions and 12 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Docs

on: [push, pull_request]

jobs:
build_doc:
name: Build docs
runs-on: ubuntu-latest
env:
BUILD_DEPS: python3-dev build-essential graphviz
LATEX_DEPS: dvipng latexmk texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended

steps:
- uses: actions/checkout@v3

- uses: ericpre/sphinx-action@latest_sphinx
with:
pre-build-command: "apt-get update -y && apt-get install -y ${{ env.BUILD_DEPS }} ${{ env.LATEX_DEPS }} && pip install .'[all, docs]'"
build-command: make html
docs-folder: docs/

- uses: actions/upload-artifact@v3
with:
path: ./docs/_build/html/
name: docs_build
77 changes: 77 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Tests

on: [push, pull_request]

jobs:
run_test_site:
name: ${{ matrix.os }}-py${{ matrix.PYTHON_VERSION }}${{ matrix.LABEL }}
runs-on: ${{ matrix.os }}-latest
timeout-minutes: 30
env:
MPLBACKEND: agg
strategy:
fail-fast: false
matrix:
os: [ubuntu, windows, macos]
PYTHON_VERSION: ['3.8', '3.9']
PIP_SELECTOR: ['[all, tests]']
include:
# test oldest supported version of main dependencies on python 3.6
- os: ubuntu
PYTHON_VERSION: '3.7'
OLDEST_SUPPORTED_VERSION: true
DEPENDENCIES: matplotlib==3.1.3 numpy==1.17.1 scipy==1.1 imagecodecs==2020.1.31 tifffile==2020.2.16 dask==2.11.0 distributed==2.11.0 numba==0.52
PIP_SELECTOR: '[all, tests]'
LABEL: -oldest
# test minimum requirement
- os: ubuntu
PYTHON_VERSION: '3.8'
PIP_SELECTOR: '[tests]'
LABEL: -minimum
- os: ubuntu
PYTHON_VERSION: '3.7'
PIP_SELECTOR: '[all, tests]'
- os: ubuntu
PYTHON_VERSION: '3.10'
PIP_SELECTOR: '[all, tests]'

steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v3
name: Install Python
with:
python-version: ${{ matrix.PYTHON_VERSION }}

- name: Display version
run: |
python --version
pip --version
- name: Install oldest supported version
if: ${{ matrix.OLDEST_SUPPORTED_VERSION }}
run: |
pip install ${{ matrix.DEPENDENCIES }}
- name: Install
shell: bash
run: |
pip install --upgrade -e .'${{ matrix.PIP_SELECTOR }}'
- name: Install (HyperSpy dev)
# Need to install hyperspy dev until hyperspy 2.0 is released
shell: bash
run: |
pip install https://github.com/hyperspy/hyperspy/archive/refs/heads/RELEASE_next_major.zip
- name: Pip list
run: |
pip list
- name: Run test suite
run: |
pytest --pyargs rsciio --reruns 3 -n 2 --cov=. --cov-report=xml
- name: Upload coverage to Codecov
if: ${{ always() }}
uses: codecov/codecov-action@v2
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
/docs/_build/*
/docs/_build/*
/build/*
/RosettaSciIO.egg-info/*
*__pycache__*
*test_compilers.obj
*pyd
22 changes: 22 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py

# Optionally build your docs in additional formats such as PDF and ePub
formats:
- htmlzip

python:
version: 3.10
install:
- method: pip
path: .
extra_requirements:
- docs
12 changes: 12 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[build-system]
requires = ["setuptools>=49.0", "wheel", "cython", "pyyaml"]
build-backend = "setuptools.build_meta:__legacy__"

[tool.pytest.ini_options]
# Note we may need to use `-n 2` argument for pytest-xdist on CI
# due to https://github.com/pytest-dev/pytest-xdist/issues/9.
addopts = "-ra -n auto --dist loadfile"
minversion = "6.0"
testpaths = [
"rsciio/tests",
]
40 changes: 29 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import distutils.ccompiler
from distutils.errors import CompileError, DistutilsPlatformError

import itertools

from rsciio.version import __version__

setup_path = path.abspath(path.dirname(__file__))
Expand Down Expand Up @@ -139,6 +141,24 @@ def run(self):
cythonize(extensions)


extras_require = {
"mrcz": ["blosc>=1.5", 'mrcz>=0.3.6'],
"scalebar_export": ["matplotlib>=3.1.3"],
"tiff": ["tifffile>=2020.2.16", "imagecodecs>=2020.1.31"],
"tests": ["pytest>=3.6", "pytest-xdist", "pytest-rerunfailures", "pytest-cov"], # for testing
"docs": ["pydata-sphinx-theme"], # for building the docs
}

# Don't include "tests" and "docs" requirements since "all" is designed to be
# used for user installation.
runtime_extras_require = {x: extras_require[x] for x in extras_require.keys()
if x not in ["tests", "coverage", "build-doc"]}
extras_require["all"] = list(itertools.chain(*list(
runtime_extras_require.values())))

extras_require["dev"] = list(itertools.chain(*list(extras_require.values())))


# Arguments marked as "Required" below must be included for upload to PyPI.
# Fields marked as "Optional" may be commented out.

Expand Down Expand Up @@ -268,14 +288,16 @@ def run(self):
# For an analysis of "install_requires" vs pip's requirements files see:
# https://packaging.python.org/en/latest/requirements.html
install_requires=[
"scipy",
'numpy>=1.10, !=1.13.0',
'h5py',
'pint>=0.8',
'sparse',
'dask[array]>=2.11',
'h5py>=2.3',
'imageio',
'dask[array]>=0.18',
'numba>=0.52',
'numpy>=1.17.1',
'pint>=0.8',
'python-box>=6.0',
'pyyaml',
'sparse',
'scipy>=1.1',
], # Optional

# List additional groups of dependencies here (e.g. development
Expand All @@ -286,11 +308,7 @@ def run(self):
#
# Similar to `install_requires` above, these must be valid existing
# projects.
extras_require={ # Optional
"mrcz": ["blosc>=1.5", 'mrcz>=0.3.6'],
"tests": ["pytest>=3.6", ], # for testing
"docs": ["pydata-sphinx-theme"], # for building the docs
},
extras_require=extras_require,

# If there are data files included in your packages that need to be
# installed, specify them here.
Expand Down

0 comments on commit a3539d5

Please sign in to comment.