diff --git a/.moban.dt/local-travis.yml.jj2 b/.moban.dt/local-travis.yml.jj2 new file mode 100644 index 0000000..17e2140 --- /dev/null +++ b/.moban.dt/local-travis.yml.jj2 @@ -0,0 +1,24 @@ +{% extends 'travis.yml.jj2' %} + +{% block custom_python_versions %} +python: + - 3.7 + - 2.7 +{% endblock %} + +{% block extra_jobs %} + allow_failures: + - stage: test +{% endblock %} + +{% block before_script %} +before_script: + - find templates/ -type f -name '*.jj2' -exec echo '{}' \; |{% raw %} + sed -e "s/templates\//{%include \"/" -e "s/$/\" %}/" > test.file +{% endraw %} +{% endblock %} + +{% block script %} + - moban -c config/data.yml -t test.file -td templates . + - {{ test_command }} +{% endblock %} diff --git a/.travis.yml b/.travis.yml index 4a8a46f..63568c5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,38 +1,45 @@ sudo: false +dist: xenial language: python -python: - - 2.7 - - 3.6 notifications: email: false -install: - - pip install -r test_requirements.txt -r tests/requirements.txt +python: + - 3.7 + - 2.7 + stages: - test - - moban - lint + - moban .disable_global: &disable_global + addons: false + cache: false + env: {} + python: false before_install: false - install: true + install: false before_script: false + script: false after_success: false after_failure: false + before_deploy: false + deploy: false .lint: &lint <<: *disable_global + git: + submodules: false python: 3.6 stage: lint - install: pip install flake8 - script: flake8 + script: make install_test lint .moban: &moban <<: *disable_global python: 3.6 stage: moban install: pip install moban>=0.0.4 - script: - - make + script: make upstreaming git-diff-check jobs: include: @@ -43,7 +50,19 @@ jobs: stage: test +before_install: + - if [[ -f min_requirements.txt && "$MINREQ" -eq 1 ]]; then + mv min_requirements.txt requirements.txt ; + fi + - test ! -f rnd_requirements.txt || + pip install --no-deps -r rnd_requirements.txt + - test ! -f rnd_requirements.txt || pip install -r rnd_requirements.txt ; + - pip install -r tests/requirements.txt +before_script: + - find templates/ -type f -name '*.jj2' -exec echo '{}' \; | + sed -e "s/templates\//{%include \"/" -e "s/$/\" %}/" > test.file script: - - find templates/ -type f -name '*.jj2' -exec echo '{}' \;|sed -e "s/templates\//{%include \"/" -e "s/$/\" %}/" > test.file - moban -c config/data.yml -t test.file -td templates . - pytest +after_success: + codecov diff --git a/Makefile b/Makefile index c19c6eb..34e3234 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,16 @@ -all: upstreaming - upstreaming: moban -m mobanfile + +git-diff-check: git diff git diff --ignore-blank-lines | while read line; do if [ "$line" ]; then exit 1; fi; done -lint: flake8 . --exclude=.moban.d,docs --builtins=unicode,xrange,long +install_test: + pip install -r tests/requirements.txt + +lint: + flake8 . --exclude=.moban.d,docs --builtins=unicode,xrange,long + yamllint . push: git config user.email "travis@travis-ci.org" diff --git a/config/data.yml b/config/data.yml index 4f4b0a3..32248d7 100644 --- a/config/data.yml +++ b/config/data.yml @@ -16,3 +16,6 @@ rsrcdir: docs/source rbuilddir: docs/_build version: 0.1.1rc3 mastertocmaxdepth: 3 +lint_command: make install_test lint +moban_command: make upstreaming git-diff-check +test_command: pytest diff --git a/mobanfile b/mobanfile index decc755..feb9b47 100644 --- a/mobanfile +++ b/mobanfile @@ -8,6 +8,7 @@ configuration: - sphinx:sphinx/templates/quickstart targets: - .gitignore: gitignore.jj2 + - .travis.yml: local-travis.yml.jj2 - LICENSE: NEW_BSD_LICENSE.jj2 - README.rst: local-README.rst.jj2 - output: CHANGELOG.rst diff --git a/templates/travis.yml.jj2 b/templates/travis.yml.jj2 index 3344ccf..6d28505 100644 --- a/templates/travis.yml.jj2 +++ b/templates/travis.yml.jj2 @@ -1,11 +1,15 @@ -{% if lint_command %} -{% set lint = lint_command%} -{% else %} -{% set lint = 'flake8' %} +{% if not lint_command and lint_command != False %} +{% set lint_command = 'flake8' %} +{% endif %} +{% if not moban_command and moban_command != False %} +{% if mobanfile %} +{% set moban_command = 'moban -m ' + mobanfile %} +{% else %} +{% set moban_command = 'moban' %} +{% endif %} {% endif %} - sudo: false -dist: xenial +dist: {{ travis_dist | default('xenial') }} language: python notifications: email: false @@ -26,42 +30,97 @@ python: {%block extra_matrix%} {%endblock%} +{% block stages %} stages: - test +{% if lint_command != False %} - lint +{% endif %} +{% if moban_command != False %} + - moban +{% endif %} +{% endblock %} .disable_global: &disable_global + addons: false + cache: false + env: {} + python: false before_install: false - install: true + install: false before_script: false + script: false after_success: false after_failure: false + before_deploy: false + deploy: false +{% if lint_command != False %} .lint: &lint <<: *disable_global + git: + submodules: false python: 3.6 stage: lint +{% if lint_command == 'flake8' %} install: pip install flake8 - script: {{ lint }} +{% endif %} + script: {{ lint_command }} + +{% endif %} +{% if moban_command != False %} +.moban: &moban + <<: *disable_global + python: 3.6 + stage: moban + install: pip install moban>=0.0.4 +{% if moban_command.startswith('moban') and 'exit-code' not in moban_command %} + script: + - {{ moban_command }} +{% if moban_allow_trailing_whitespace %} + - git diff + - git diff --ignore-blank-lines | + while read line; do if [ "$line" ]; then exit 1; fi; done +{% else %} + - git diff --exit-code +{% endif %} +{% else %} + script: {{ moban_command }} +{% endif %} +{% endif %} +{% block extra_dot_blocks %} +{% endblock %} +{% block jobs %} jobs: include: + - *moban - *lint +{% block extra_jobs %} +{% endblock %} +{% endblock %} stage: test -script: make test - +{% block before_install %} before_install: {% block custom_install %} {% endblock%} - if [[ -f min_requirements.txt && "$MINREQ" -eq 1 ]]; then mv min_requirements.txt requirements.txt ; fi - - test ! -f rnd_requirements.txt || pip install --no-deps -r rnd_requirements.txt + - test ! -f rnd_requirements.txt || + pip install --no-deps -r rnd_requirements.txt - test ! -f rnd_requirements.txt || pip install -r rnd_requirements.txt ; - pip install -r tests/requirements.txt +{% endblock %} +{% block before_script %} +{% endblock %} script: - - make test +{% block script %} + - {{ test_command | default('make test') }} +{% endblock %} +{% block end %} after_success: codecov +{% endblock %} diff --git a/test_requirements.txt b/test_requirements.txt deleted file mode 100644 index 9ddf86d..0000000 --- a/test_requirements.txt +++ /dev/null @@ -1 +0,0 @@ -moban>=0.0.4 diff --git a/tests/requirements.txt b/tests/requirements.txt index 67b7158..13d3714 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,2 +1,5 @@ +codecov +moban>=0.0.4 pytest~=3.6.1 flake8 +yamllint