diff --git a/.ci/bears.prune.sh b/.ci/bears.prune.sh new file mode 100644 index 0000000000..63187b02ac --- /dev/null +++ b/.ci/bears.prune.sh @@ -0,0 +1,7 @@ +# Delete empty bear directories + +for dir in bears/*/; do + if [[ -z "$(ls $dir/ 2>/dev/null | egrep -v '(__|.xml)')" ]]; then + rm -rf $dir + fi +done diff --git a/.ci/generate_bear_requirements.py b/.ci/generate_bear_requirements.py index a4b6493acf..ec3c5d673f 100755 --- a/.ci/generate_bear_requirements.py +++ b/.ci/generate_bear_requirements.py @@ -17,6 +17,7 @@ import itertools import json import os +import re import sys from jinja2 import Environment, FileSystemLoader @@ -81,6 +82,15 @@ def get_inherited_requirements(): in_inherited = False with open(os.path.join(PROJECT_DIR, 'requirements.txt'), 'r') as file: for line in file.read().splitlines(): + line = line.strip() + if not line.startswith('#'): + m = re.match('^[A-Za-z._-]+', line) + if m: + requirement = m.group(0) + inherited_requirements.add(requirement.replace('-', '_')) + inherited_requirements.add(requirement.replace('_', '-')) + continue + if 'inherited' in line: in_inherited = True continue diff --git a/.ci/tests.prune.sh b/.ci/tests.prune.sh new file mode 100644 index 0000000000..bb5404edef --- /dev/null +++ b/.ci/tests.prune.sh @@ -0,0 +1,11 @@ +# Delete tests for bears that have been removed +set -e + +for test in tests/*/[A-Za-z]*.py; do + bear=${test/Test.py/.py} + bear=${bear/tests/bears} + if [[ ! -f $bear ]]; then + echo Removing $test + rm $test + fi +done diff --git a/.travis.yml b/.travis.yml index f6643bfdc7..1f54b87b43 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,18 @@ -sudo: required +sudo: false language: python python: # 2.7 is rejected by dependency mypy-lang - - 3.3 - 3.4 - - 3.5 - - 3.6-dev + - 3.6 + +matrix: + include: + - python: 3.5 + sudo: required + env: BEARS=all + - python: 3.3 + env: UNSUPPORTED=true dist: trusty @@ -81,8 +87,8 @@ before_install: # Remove Ruby directive from Gemfile as this image has 2.2.5 - sed -i '/^ruby/d' Gemfile - mkdir -p ~/.apt-cache - - if [[ "$UNSUPPORTED" != true ]]; then bash .ci/deps.sh; fi - - if [[ "$UNSUPPORTED" != true ]]; then bash .ci/deps.shellcheck.sh; fi + - if [[ "$BEARS" == "all" ]]; then bash .ci/deps.sh; fi + - if [[ "$BEARS" == "all" ]]; then bash .ci/deps.shellcheck.sh; fi # https://github.com/coala/coala/issues/3183 - cp requirements.txt requirements.orig - cat test-requirements.txt docs-requirements.txt bear-requirements.txt >> requirements.txt @@ -101,6 +107,17 @@ before_script: if [[ "$TRAVIS_PYTHON_VERSION" != "3.3" ]]; then python -m nltk.downloader punkt maxent_treebank_pos_tagger averaged_perceptron_tagger fi + # Only keep non-Python bears on Python 3.4 + - > + if [[ "$BEARS" != "all" ]]; then + rm $(comm -23 <(ls bears/*/[A-Za-z]*.py | grep -v general | sort) <(grep -l PipRequirement bears/*/*.py | sort)) + rm bears/general/CPDBear.py + rm bears/generate_package.py tests/generate_packageTest.py + fi + # Delete empty bear directories + - bash .ci/bears.prune.sh + # Delete tests for removed bears + - bash .ci/tests.prune.sh script: - > @@ -118,7 +135,12 @@ script: - bash .ci/tests.sh # Ensure bear requirements are in sync with the bear PipRequirement - .ci/generate_bear_requirements.py - - git diff --exit-code bear-requirements.txt Gemfile package.json + - > + if [[ "$BEARS" == "all" ]]; then + git diff --exit-code bear-requirements.txt Gemfile package.json + else + git diff --exit-code bear-requirements.txt + fi # https://github.com/coala/coala-bears/issues/1037 - > if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then diff --git a/bear-requirements.txt b/bear-requirements.txt index 5a6e5f2c76..eb078f0d94 100644 --- a/bear-requirements.txt +++ b/bear-requirements.txt @@ -21,7 +21,6 @@ pydocstyle~=1.1 pyflakes~=1.4.0 pylint~=1.6 pyroma~=2.2.0 -pyyaml~=3.12 radon==1.4.0 restructuredtext-lint~=0.17.2 rstcheck~=2.2 diff --git a/bears/ruby/RuboCopBear.py b/bears/ruby/RuboCopBear.py index 877506db18..0d3347df47 100644 --- a/bears/ruby/RuboCopBear.py +++ b/bears/ruby/RuboCopBear.py @@ -1,10 +1,10 @@ import json + import yaml from coalib.bearlib import deprecate_settings from coalib.bearlib.abstractions.Linter import linter from dependency_management.requirements.GemRequirement import GemRequirement -from dependency_management.requirements.PipRequirement import PipRequirement from coalib.results.RESULT_SEVERITY import RESULT_SEVERITY from coalib.results.Result import Result @@ -19,8 +19,7 @@ class RuboCopBear: """ LANGUAGES = {'Ruby'} - REQUIREMENTS = {GemRequirement('rubocop'), - PipRequirement('pyyaml', '3.12')} + REQUIREMENTS = {GemRequirement('rubocop')} AUTHORS = {'The coala developers'} AUTHORS_EMAILS = {'coala-devel@googlegroups.com'} LICENSE = 'AGPL-3.0' diff --git a/bears/scss/SCSSLintBear.py b/bears/scss/SCSSLintBear.py index 3231a7f20c..fffdea5ff4 100644 --- a/bears/scss/SCSSLintBear.py +++ b/bears/scss/SCSSLintBear.py @@ -2,7 +2,6 @@ from coalib.bearlib.abstractions.Linter import linter from dependency_management.requirements.GemRequirement import GemRequirement -from dependency_management.requirements.PipRequirement import PipRequirement @linter(executable='scss-lint', output_format='regex', @@ -18,8 +17,7 @@ class SCSSLintBear: LANGUAGES = {'SCSS'} # require flag is necessary for 'scss_lint' # https://github.com/brigade/scss-lint#installation - REQUIREMENTS = {GemRequirement('scss_lint', '', 'false'), - PipRequirement('pyyaml', '3.12')} + REQUIREMENTS = {GemRequirement('scss_lint', '', 'false')} AUTHORS = {'The coala developers'} AUTHORS_EMAILS = {'coala-devel@googlegroups.com'} LICENSE = 'AGPL-3.0' diff --git a/requirements.txt b/requirements.txt index 09134b290f..3a6288b085 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ # NOTE: This file is parsed by .ci/generate_bear_requirements.py # Use >= for development versions so that source builds always work coala>=0.10.0.dev20170127183105 +pyyaml~=3.12 # Dependencies inherited from coala # libclang-py3 # coala_utils