Skip to content

Commit

Permalink
Merge pull request #93 from pyomeca/dev
Browse files Browse the repository at this point in the history
Merge dev to master
  • Loading branch information
romainmartinez committed May 31, 2020
2 parents ae52134 + 5135540 commit d5b4117
Show file tree
Hide file tree
Showing 86 changed files with 95,373 additions and 3,281 deletions.
5 changes: 0 additions & 5 deletions .codacy.yml

This file was deleted.

4 changes: 0 additions & 4 deletions .coveragerc

This file was deleted.

58 changes: 58 additions & 0 deletions .github/workflows/conda-package.yml
@@ -0,0 +1,58 @@
name: CI

on:
push:
branches:
- master
pull_request:
branches:
- master
schedule:
# every sunday at 14:00 UTC
- cron: '0 14 * * SUN'

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.6, 3.7, 3.8]
name: ${{ matrix.os }} - Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@master

- name: Setup conda
uses: s-weigand/setup-conda@v1
with:
activate-conda: true
update-conda: true
python-version: ${{ matrix.python-version }}
conda-channels: conda-forge

- name: Add path DLL to windows path (windows only)
if: startsWith(matrix.os, 'windows')
run: echo "##[add-path]C:\Miniconda\Library\bin"

- name: Install Dependencies
run: |
conda env update -f environment.yml -n base
pip install -r requirements-dev.txt
conda info -a
- name: Lint (ubuntu only)
if: startsWith(matrix.os, 'ubuntu')
run: black --check .

- name: Test
run: |
cp README.md docs/index.md
python -m pytest --cov-report term-missing --color=yes --cov=pyomeca tests
- name: Coverage (ubuntu only)
if: startsWith(matrix.os, 'ubuntu')
env:
COVERALLS_REPO_TOKEN: PZM3oz4Z1NbKgI9rvS7Of89vA7KdHsDAE
run: |
pip install coveralls
coveralls
67 changes: 61 additions & 6 deletions .gitignore
@@ -1,3 +1,5 @@
# Created by .ignore support plugin (hsz.mobi)
### Python template
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand All @@ -8,7 +10,6 @@ __pycache__/

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
Expand All @@ -20,9 +21,13 @@ lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
Expand All @@ -37,21 +42,32 @@ pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
*.cover
.hypothesis/
.pytest_cache
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/
Expand All @@ -62,9 +78,30 @@ target/
# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
Expand All @@ -82,11 +119,29 @@ venv.bak/

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

misc

# pycharm
.idea

# Personnal stuff
Misc/
site/

todo.txt

temp.*

docs/api/api.json

/docs/images/api/*.svg
/docs/getting-started.md
/docs/*_files
/docs/index.md

emg.*
trials.nc
.vscode
27 changes: 0 additions & 27 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE → LICENSE.md
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright Romain Martinez & Benjamin Michaud, 2020

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
124 changes: 19 additions & 105 deletions Makefile
@@ -1,112 +1,26 @@
.PHONY: test cover clean lint create_env
.PHONY : test lint doc nb_to_md clean all

#################################################################################
# GLOBALS #
#################################################################################

REPO_NAME = pyomeca
EXCLUDES_LINT = --exclude=bin/,src/rebuydsutils/,docs/conf.py
EXCLUDES_PYTEST = --ignore src/rebuydsutils
SHELL=/bin/bash

ifeq (,$(shell which conda))
$(error conda must be installed)
endif

# Define utility variable to help calling Python from the virtual environment
ifeq ($(CONDA_DEFAULT_ENV),$(REPO_NAME))
ACTIVATE_ENV := true
else
ACTIVATE_ENV := source activate $(REPO_NAME)
endif

# Execute python related functionalities from within the project's environment
define execute_in_env
$(ACTIVATE_ENV) && $1
endef

#################################################################################
# PROJECT RULES #
#################################################################################
lint:
isort -rc . ;\
autoflake -r --in-place --remove-unused-variables . ;\
black .

## Run pytest on the project
test:
$(call execute_in_env, python -m pytest --color=yes tests $(EXCLUDES_PYTEST))
pytest --cov-report term-missing --color=yes --cov=pyomeca tests -rxXs

## Run coverage test on the project
cover:
$(call execute_in_env, python -m pytest --color=yes --cov=pyomeca tests $(EXCLUDES_PYTEST))
nb_to_md:
jupyter nbconvert --to markdown notebooks/getting-started.ipynb --output-dir='./docs' --template=docs/nbconvert.tpl

## Delete all compiled Python files
clean:
find . -name "*.pyc" -exec rm {} \;

## Lint using flake8; Excluding $EXCLUDES_LINT
lint:
$(call execute_in_env, flake8 $(EXCLUDES_LINT) .)
doc:
# copy readme, correct path and delete link to documentation
sed 's,docs/,,g' README.md > docs/index.md; \
sed -i -z "s,\n## Pyomeca documentation\n\nSee Pyomeca's \[documentation site\](https://pyomeca.github.io).\n,,g" docs/index.md; \
sed -i -z "s,\nSee \[the documentation\](https://pyomeca.github.io) for more details and examples.\n,,g" docs/index.md; \
cd ../pyomeca.github.io; \
mkdocs gh-deploy --config-file ../pyomeca/mkdocs.yml --remote-branch master
rm -rf site

## Set up python interpreter environment
create_env:
conda env create -n $(REPO_NAME) -f environment.yml
rm -rf *.egg-info

#################################################################################
# Self Documenting Commands #
#################################################################################

.DEFAULT_GOAL := help
clean:
rm -rf .pytest_cache .coverage site notebooks/.ipynb_checkpoints

# Inspired by <http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html>
# sed script explained:
# /^##/:
# * save line in hold space
# * purge line
# * Loop:
# * append newline + line to hold space
# * go to next line
# * if line starts with doc comment, strip comment character off and loop
# * remove target prerequisites
# * append hold space (+ newline) to line
# * replace newline plus comments by `---`
# * print line
# Separate expressions are necessary because labels cannot be delimited by
# semicolon; see <http://stackoverflow.com/a/11799865/1968>
.PHONY: help
help:
@echo "$$(tput bold)Available rules:$$(tput sgr0)"
@echo
@sed -n -e "/^## / { \
h; \
s/.*//; \
:doc" \
-e "H; \
n; \
s/^## //; \
t doc" \
-e "s/:.*//; \
G; \
s/\\n## /---/; \
s/\\n/ /g; \
p; \
}" ${MAKEFILE_LIST} \
| LC_ALL='C' sort --ignore-case \
| awk -F '---' \
-v ncol=$$(tput cols) \
-v indent=19 \
-v col_on="$$(tput setaf 6)" \
-v col_off="$$(tput sgr0)" \
'{ \
printf "%s%*s%s ", col_on, -indent, $$1, col_off; \
n = split($$2, words, " "); \
line_length = ncol - indent; \
for (i = 1; i <= n; i++) { \
line_length -= length(words[i]) + 1; \
if (line_length <= 0) { \
line_length = ncol - indent - length(words[i]) - 1; \
printf "\n%*s ", -indent, " "; \
} \
printf "%s ", words[i]; \
} \
printf "\n"; \
}' \
| more $(shell test $(shell uname) = Darwin && echo '--no-init --raw-control-chars')
all: lint nb_to_md test doc clean

0 comments on commit d5b4117

Please sign in to comment.