From 7798a71009f9871a574002e513f790748830e471 Mon Sep 17 00:00:00 2001 From: Satoru SATOH Date: Sat, 12 Sep 2020 00:37:38 +0900 Subject: [PATCH 1/3] enhancement: make possible to run tests and related stuff using tox Make possible to run tests (python setup.py test) and other related stuff (flake8, doc8 and yamllint) using tox. Signed-off-by: Satoru SATOH --- requirements.txt | 3 +++ tests/requirements.txt | 6 ++++++ tox.ini | 30 ++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 requirements.txt create mode 100644 tests/requirements.txt create mode 100644 tox.ini diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..a4b561c --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +pathspec >= 0.5.3 +pyyaml +setuptools diff --git a/tests/requirements.txt b/tests/requirements.txt new file mode 100644 index 0000000..2949646 --- /dev/null +++ b/tests/requirements.txt @@ -0,0 +1,6 @@ +pyyaml +coveralls +flake8 +flake8-import-order +doc8 +sphinx; python_version > '2.7' diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..50d5ca2 --- /dev/null +++ b/tox.ini @@ -0,0 +1,30 @@ +[tox] +envlist = py27, py34, py35, py36, py37, py38, nightly +minversion = 3.15 + +[base] +commands = + - /bin/sh -c 'yamllint -c {toxinidir}/yamllint/conf/default.yaml --strict `git ls-files \*.yaml \*.yml`' + coverage run --source=yamllint setup.py test + +[testenv] +deps = + -r {toxinidir}/requirements.txt + -r {toxinidir}/tests/requirements.txt + +# https://tox.readthedocs.io/en/latest/config.html#substitution-for-values-from-other-sections +commands = + /bin/sh -c 'doc8 `git ls-files \*.rst`' + {[base]commands} + python setup.py build_sphinx + +[testenv:py27] +commands = + flake8 . + {[base]commands} + +# https://tox.readthedocs.io/en/latest/config.html#generative-section-names +[testenv:py3{4,5,6,7,8}] +commands = + flake8 . + {[testenv]commands} From 61f606da8e27fa0971031089921141f3310430d0 Mon Sep 17 00:00:00 2001 From: Satoru SATOH Date: Sat, 12 Sep 2020 00:38:11 +0900 Subject: [PATCH 2/3] Utilize tox in travis-ci Utilize tox in travis-ci to simplify its configuration. Signed-off-by: Satoru SATOH --- .travis.yml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2f6b3ba..c0d0545 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,17 +12,9 @@ env: - REMOVE_LOCALES=false - REMOVE_LOCALES=true install: - - pip install pyyaml coveralls flake8 flake8-import-order doc8 - - if [[ $TRAVIS_PYTHON_VERSION != 2* ]]; then pip install sphinx; fi - - pip install . + - pip install tox-travis - if [[ $REMOVE_LOCALES = "true" ]]; then sudo rm -rf /usr/lib/locale/*; fi script: - - if [[ $TRAVIS_PYTHON_VERSION != nightly ]]; then flake8 .; fi - - if [[ $TRAVIS_PYTHON_VERSION != 2* ]]; then doc8 $(git ls-files '*.rst'); fi - - yamllint --strict $(git ls-files '*.yaml' '*.yml') - - coverage run --source=yamllint setup.py test - - if [[ $TRAVIS_PYTHON_VERSION != 2* ]]; then - python setup.py build_sphinx; - fi + - tox after_success: coveralls From a64b865fba95a8f72f4d8607e59b5d307854f29d Mon Sep 17 00:00:00 2001 From: Satoru SATOH Date: Sat, 12 Sep 2020 00:57:05 +0900 Subject: [PATCH 3/3] enhancement: add github actions configuration file Add github actions (gh) configuration file and update tox.ini to add gh related configurations. --- .github/workflows/tests.yml | 31 +++++++++++++++++++++++++++++++ tox.ini | 7 +++++++ 2 files changed, 38 insertions(+) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..8968958 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,31 @@ +--- +# .. seealso:: https://github.com/ymyzk/tox-gh-actions +# +name: Tests +# yamllint disable-line rule:truthy +on: + - push +jobs: + build: + runs-on: ubuntu-latest + strategy: + max-parallel: 10 + matrix: + python-version: + - 2.7 + - 3.6 + - 3.7 + - 3.8 + + steps: + - uses: actions/checkout@v1 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: pip install tox tox-gh-actions + - name: Test with tox + run: tox + +# vim:sw=2:ts=2:et: diff --git a/tox.ini b/tox.ini index 50d5ca2..acd79d5 100644 --- a/tox.ini +++ b/tox.ini @@ -2,6 +2,13 @@ envlist = py27, py34, py35, py36, py37, py38, nightly minversion = 3.15 +[gh-actions] +python = + 2.7: py27 + 3.6: py36 + 3.7: py37 + 3.8: py38 + [base] commands = - /bin/sh -c 'yamllint -c {toxinidir}/yamllint/conf/default.yaml --strict `git ls-files \*.yaml \*.yml`'