Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streamline CI #37

Merged
merged 19 commits into from
Apr 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
195 changes: 96 additions & 99 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,130 +1,127 @@
version: 2.1

orbs:
codecov: codecov/codecov@3.2.2

references:
imtox: &imtox
docker:
- image: cimg/python:3.8
install_dependencies: &install_dependencies
name: Install dependencies
command: |
python -m pip install --progress-bar off -U virtualenv --user
mkdir -p ./venv
python -m virtualenv ./venv --clear
. venv/bin/activate
python -m pip install --progress-bar off -U -r requirements/requirements-testing.txt

wd: &wd
working_directory: ~/repo
run_tests: &run_tests
name: run tests
command: |
# Run with coverage
. venv/bin/activate
python -m pytest -v --cov=rowan/ --cov-report=xml

runall: &runall
jobs:
linux-python-37:
docker:
- image: cimg/python:3.7
working_directory: ~/repo
steps:
- checkout

- restore_cache:
keys:
- v1-dependencies-{{ checksum "requirements.txt" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- run:
name: run tests
command: |
# Faster to just test one env first
pip3.8 install --progress-bar off --user -U flake8 flake8-black flake8-bugbear flake8-docstrings flake8-rst-docstrings pep8-naming flake8-isort numpy scipy
python3.8 -m flake8 --show-source rowan
# Ignore isort errors in tests that are due to ambiguity over whether or not rowan is third party.
python3.8 -m flake8 --extend-ignore=I001,I004 --show-source tests/
python3.8 -m unittest discover tests -v

## Test python-dependency matrix with tox
#pip3.8 install --progress-bar off --user tox
#tox
#
# Run with coverage
pip3.8 install --progress-bar off --user coverage
export PATH=~/.local/bin:${PATH}
coverage run -m unittest discover tests
apt-get -yq update
apt-get -yq install curl
bash <(curl -s https://codecov.io/bash)
coverage xml
<<: *install_dependencies
- run:
<<: *run_tests

- save_cache:
paths:
- ~/.local
key: v1-dependencies-{{ checksum "requirements.txt" }}
linux-python-38:
docker:
- image: cimg/python:3.8
working_directory: ~/repo
steps:
- checkout
- run:
<<: *install_dependencies
- run:
<<: *run_tests

run_tests_only: &run_tests_only
linux-python-39:
docker:
- image: cimg/python:3.9
working_directory: ~/repo
steps:
- checkout
- run:
<<: *install_dependencies
- run:
<<: *run_tests

- restore_cache:
keys:
- v1-dependencies-{{ checksum "requirements.txt" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
linux-python-310:
docker:
- image: cimg/python:3.10
working_directory: ~/repo
steps:
- checkout
- run:
<<: *install_dependencies
- run:
<<: *run_tests

linux-oldest:
# Run tests against a set of the oldest dependencies we support.
docker:
- image: cimg/python:3.6
working_directory: ~/repo
steps:
- checkout
- run:
name: Install oldest dependencies
command: |
python -m pip install --progress-bar off -U virtualenv --user
mkdir -p ./venv
python -m virtualenv ./venv --clear
. venv/bin/activate
python -m pip install --progress-bar off -U -r requirements/requirements-oldest.txt
python -m pip install --progress-bar off -U pytest
- run:
name: run tests
command: |
# Faster to just test one env first
pip3.8 install --progress-bar off --user -U flake8 flake8-black flake8-bugbear flake8-docstrings flake8-rst-docstrings pep8-naming flake8-isort numpy scipy
python3.8 -m flake8 --show-source rowan
# Ignore isort errors in tests that are due to ambiguity over whether or not rowan is third party.
python3.8 -m flake8 --extend-ignore=I001,I004 --show-source tests/
python3.8 -m unittest discover tests -v
. venv/bin/activate
python -m pytest -v tests

- save_cache:
paths:
- ~/.local
key: v1-dependencies-{{ checksum "requirements.txt" }}

pypi_wheels: &pypi_wheels
build_and_deploy:
docker:
- image: cimg/python:3.8
working_directory: ~/repo
steps:
- checkout

- run:
<<: *install_dependencies
- run:
<<: *run_tests
- run:
name: Deploy dist and wheels
command: |
pip3.8 install --progress-bar off --user -U flake8 flake8-black flake8-bugbear flake8-docstrings flake8-rst-docstrings pep8-naming flake8-isort numpy scipy
python3.8 -m flake8 --show-source rowan
# Ignore isort errors in tests that are due to ambiguity over whether or not rowan is third party.
python3.8 -m flake8 --extend-ignore=I001,I004 --show-source tests/
python3.8 -m unittest discover tests -v
python3.8 --version
pip3.8 --version
pip3.8 install --progress-bar off --user -U twine wheel setuptools
export PATH=~/.local/bin:${PATH}
twine --version
wheel version
python3.8 setup.py sdist
python3.8 setup.py bdist_wheel
twine upload --username vramasub --password ${PYPI_PASSWORD} dist/*

jobs:
complete:
<<: *imtox
<<: *wd
<<: *runall
test_only:
<<: *imtox
<<: *wd
<<: *run_tests_only
build_and_deploy:
<<: *imtox
<<: *wd
<<: *pypi_wheels
. venv/bin/activate
python -m unittest discover tests -v
python --version
python -m pip --version
python -m pip install --progress-bar off --user -U twine wheel setuptools
python -m twine --version
python -m wheel version
python setup.py sdist
python setup.py bdist_wheel
twine upload --username ${PYPI_USERNAME} --password ${PYPI_PASSWORD} dist/*

workflows:
version: 2
testing:
jobs:
- complete:
filters:
branches:
only:
- master
- develop
- /release-.*/
- test_only:
filters:
branches:
ignore:
- master
- develop
- /release-.*/
- linux-python-37
- linux-python-38
- linux-python-39
- linux-python-310:
post-steps:
- codecov/upload
- linux-oldest
deploy:
jobs:
- build_and_deploy:
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ci:
autoupdate_schedule: quarterly

# TODO: Add mypy, pyupgrade, and check-yaml
# TODO: Add mypy, pyupgrade
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 'v4.1.0'
Expand All @@ -13,7 +13,7 @@ repos:
- id: check-builtin-literals
- id: check-executables-have-shebangs
- id: check-json
#- id: check-yaml
- id: check-yaml
- id: debug-statements
- id: requirements-txt-fixer
- repo: https://github.com/PyCQA/isort
Expand Down
6 changes: 5 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ To install the package from PyPI, execute:

.. code-block:: bash

$ pip install rowan --user
$ pip install rowan

To install the package from conda, first add the **conda-forge** channel and
then install rowan:
Expand All @@ -89,6 +89,10 @@ The minimum requirements for using rowan are:
* Python >= 3.6
* NumPy >= 1.15

To use the mapping subpackage, rowan also requires

* SciPy >= 1.0

Quickstart
----------

Expand Down
27 changes: 8 additions & 19 deletions doc/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,24 @@ Code contributions should keep these ideals in mind and adhere to the following
* Preserve backwards-compatibility whenever possible. Make clear if something must change, and notify package maintainers that merging such changes will require a major release.
* Enable broadcasting if at all possible. Functions for which broadcasting is not available must be documented as such.

To provide a reasonable balance between a high level of backwards compatibility and a reasonable maintenance burden, **rowan** has adopted `NEP 29`_ to limit the Python and NumPy versions that will be supported.


.. _github: https://github.com/glotzerlab/rowan
.. _OneFlow: https://www.endoflineblog.com/oneflow-a-git-branching-model-and-workflow
.. _NEP 29: https://numpy.org/neps/nep-0029-deprecation_policy.html

.. tip::

During continuous integration, the code is checked automatically with `Flake8`_.
To ensure your code is compliant before committing, you can set up a pre-commit hook using `pre-commit`_ (recommended) or use flake8's built-in hooks installation:
During continuous integration, the code is checked automatically with `pre-commit`_.
To run these checks locally, you can install and run pre-commit like so:

.. code-block:: bash

flake8 --install-hook git
git config --bool flake8.strict true
python -m pip install pre-commit
pre-commit run --all-files

To avoid having commits fail in case you forget to run this, you can set up a git pre-commit hook using `pre-commit`_:

.. code-block:: bash
pre-commit install

.. _Flake8: http://flake8.pycqa.org/en/latest/
.. _pre-commit: https://pre-commit.com/
Expand All @@ -59,7 +60,6 @@ To provide a reasonable balance between a high level of backwards compatibility
Source Code Conventions
-----------------------


The **rowan** package adheres to a relatively strict set of style guidelines.
All code in **rowan** should be formatted using `black`_; a notable consequence of this is that the recommended max line length is 88, not the more common 80.
Imports should be formatted using `isort`_.
Expand All @@ -68,17 +68,6 @@ All code should also follow the principles in `PEP 20 <https://www.python.org/de
In particular, always prefer simple, explicit code where possible, avoiding unnecessary convolution or complicated code that could be written more simply.
Avoid writing code in a manner that will be difficult for others to understand.

.. tip::

Developers should format their code using black and isort locally using the commands:

.. code-block:: bash

black --exclude "coxeter/[polytri|bentley_ottman]" coxeter/ tests/
isort -rc coxeter/ tests/

.. _black: https://black.readthedocs.io/
.. _isort: https://timothycrosley.github.io/isort/

Documentation
-------------
Expand Down
5 changes: 1 addition & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
###### Requirements without Version Specifiers ######

###### Requirements with Version Specifiers ######
numpy>=1.15
numpy>=1.15.0
2 changes: 2 additions & 0 deletions requirements/requirements-oldest.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
numpy==1.15.0
scipy==1.0.0
5 changes: 5 additions & 0 deletions requirements/requirements-testing.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
coverage==6.3.2
numpy>=1.15.0
pytest==7.0.1
pytest-cov==3.0.0
scipy>=1.0.0
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@
zip_safe=True,
install_requires=["numpy>=1.15"],
python_requires=">=3.6, <4",
extras_require={"mapping": "scipy>=1.0.0"},
classifiers=[
"Development Status :: 6 - Mature",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Topic :: Scientific/Engineering :: Mathematics",
],
)