diff --git a/.ci/bears.dirs.prune.sh b/.ci/bears.dirs.prune.sh new file mode 100644 index 0000000000..c28ff7bd47 --- /dev/null +++ b/.ci/bears.dirs.prune.sh @@ -0,0 +1,13 @@ +# Delete empty bear directories +set -e + +dirs=$(find bears -depth -type d -and -not -name '__pycache__') + +for dir in $dirs; do + bears=$(ls $dir/*Bear.py 2>/dev/null || true) + subdirs=$(ls -d $dir/*/ 2>/dev/null || true) + if [[ -z "$bears""$subdirs" ]]; then + echo Removing $dir + rm -rf $dir + fi +done diff --git a/.ci/bears.prune.sh b/.ci/bears.prune.sh new file mode 100644 index 0000000000..1499e4e60a --- /dev/null +++ b/.ci/bears.prune.sh @@ -0,0 +1,160 @@ +# Delete bears +set -e -x + +if [[ "$BEARS" == "all" ]]; then + echo "No bears pruned." + exit 0 +fi + +if [[ -z "$BEARS" ]]; then + if [[ -n "$TRAVIS_LANGUAGE" ]]; then + BEARS=$TRAVIS_LANGUAGE + fi +fi + +if [[ "$BEARS" == "haskell" || "$BEARS" == "ghc" ]]; then + BEARS=cabal +elif [[ "$BEARS" == "ruby" ]]; then + BEARS=gem +elif [[ "${BEARS/node/}" != "$BEARS" ]]; then + BEARS=npm +elif [[ "$BEARS" == "r" ]]; then + BEARS=rscript +elif [[ "$BEARS" == "generic" ]]; then + BEARS=apt-get +fi + +bears=$(find bears -type f -and -name '*Bear.py' | sort) + +yield_result_bears=$(grep -m 1 -l 'yield Result' $bears) + +non_yield_result_bears=$(comm -23 <(ls $bears) <(ls $yield_result_bears)) + +requirement_bears=$(grep -m 1 -l 'Requirement(' $bears) + +cabal_requirement_bears=$(grep -m 1 -l CabalRequirement $requirement_bears) +gem_requirement_bears=$(grep -m 1 -l GemRequirement $requirement_bears) +go_requirement_bears=$(grep -m 1 -l GoRequirement $requirement_bears) +npm_requirement_bears=$(grep -m 1 -l NpmRequirement $requirement_bears) +rscript_requirement_bears=$(grep -m 1 -l RscriptRequirement $requirement_bears) + +pip_requirement_bears=$(grep -m 1 -l PipRequirement $requirement_bears) + +non_pip_runtime_requirement_bears="$cabal_requirement_bears $gem_requirement_bears $go_requirement_bears $npm_requirement_bears $rscript_requirement_bears" + +other_requirement_bears=$(comm -23 <(ls $requirement_bears) <(ls $non_pip_runtime_requirement_bears $pip_requirement_bears)) + +distribution_requirement_bears=$(grep -m 1 -l 'DistributionRequirement(' $requirement_bears) + +apt_get_requirement_bears=$(grep -m 1 -l 'apt_get' $distribution_requirement_bears) + +# Verify that DistributionRequirement is the only other Requirement subclass used +unknown_requirement_bears=$(grep -m 1 -Pl '(? + if [[ "$DIST" != "" && "$DIST" != "precise" && "$DIST" != "trusty" && "$DIST" != "debian-sid" ]]; then + echo "deb http://archive.ubuntu.com/ubuntu/ $DIST main universe" | sudo tee -a /etc/apt/sources.list.d/$DIST.list > /dev/null + echo "deb http://archive.ubuntu.com/ubuntu/ $DIST-updates main universe" | sudo tee -a /etc/apt/sources.list.d/$DIST.list > /dev/null + echo "deb http://archive.ubuntu.com/ubuntu/ $DIST-backports main universe" | sudo tee -a /etc/apt/sources.list.d/$DIST.list > /dev/null + sudo apt-get -y update + sudo apt-get -y --no-install-recommends install chktex cppcheck default-jre flawfinder indent libperl-critic-perl libxml2-utils mono-mcs php7.0-cli php-codesniffer verilator + fi + - if [[ "$DIST" == "trusty" || "$DIST" == "debian-sid" ]]; then ls /usr/bin/php $HOME/bin/; fi + + - > + if [[ -z "$TRAVIS_PYTHON_VERSION" ]]; then + echo pip3.4 is $(which pip3.4) + echo python3.4 is $(which python3.4) + if [[ -n "$(which pip3.4)" ]]; then ln -sf $(which pip3.4) $HOME/bin/pip3; fi + if [[ -n "$(which python3.4)" ]]; then ln -sf $(which python3.4) $HOME/bin/python3; fi + echo pip3.5 is $(which pip3.5) + echo python3.5 is $(which python3.5) + if [[ -n "$(which pip3.5)" ]]; then ln -sf $(which pip3.5) $HOME/bin/pip3; fi + if [[ -n "$(which python3.5)" ]]; then ln -sf $(which python3.5) $HOME/bin/python3; fi + echo pip3 is $(which pip3) + echo python3 is $(which python3) + if [[ -n "$(which python3)" ]]; then ln -sf $(which python3) $HOME/bin/python; fi + python --version + # Needed as some hosts may be providing python 3.2 + wget https://bootstrap.pypa.io/get-pip.py + python get-pip.py --user + rm get-pip.py + cp $HOME/.local/bin/pip $HOME/.local/bin/pip3 + cp $HOME/.local/bin/pip $HOME/bin/pip + cp $HOME/.local/bin/pip $HOME/bin/pip3 + pip --version + fi + + # Change environment for flawfinder from python to python2 + - if [[ -n "$(which flawfinder)" ]]; then + sed -e '1s/.*/#!\/usr\/bin\/env python2/' $(which flawfinder) > $HOME/bin/flawfinder; + chmod a+x $HOME/bin/flawfinder; + fi + + # Remove Ruby directive from Gemfile as this image has 2.2.5 + - sed -i '/^ruby/d' Gemfile + - if [[ "$BEARS" == "all" ]]; then nvm install 4; nvm use 4; bash .ci/deps.sh; fi + - if [[ "$BEARS" == "all" ]]; then bash .ci/deps.cabal.sh; fi # https://github.com/coala/coala/issues/3183 - cp requirements.txt requirements.orig - printf '%s\n%s\n%s\n' "$(cat test-requirements.txt)" "$(grep -v '^-r' docs-requirements.txt)" - "$(cat bear-requirements.txt requirements.txt)" + "$(cat requirements.txt)" > requirements.txt + - > + if [[ "$TRAVIS_LANGUAGE" == "python" ]]; then + cat bear-requirements.txt >> requirements.txt; + elif [[ "$TRAVIS_LANGUAGE" == "ruby" ]]; then + echo 'pyyaml' > bear-requirements.txt; + else + rm bear-requirements.txt; touch bear-requirements.txt; + fi + - sed -i '/^-r/d' requirements.txt + - if [[ -z "$TRAVIS_PYTHON_VERSION" ]]; then pip install --user -r requirements.txt; fi before_script: + - if [[ "$TRAVIS_LANGUAGE" == "go" ]]; then + grep ImportPath Godeps/Godeps.json | cut -d '"' -f 4 | grep '[a-z]' | xargs go get; + fi + - if [[ "$TRAVIS_LANGUAGE" == "php" ]]; then + pear install pear/PHP_CodeSniffer; + phpenv rehash; + fi + # Force ghc-mod to resolve its Cabal version + - if [[ "$TRAVIS_LANGUAGE" == "haskell" ]]; then + ~/.cabal/bin/ghc-mod modules ; + fi + - if [[ "$TRAVIS_LANGUAGE" == "julia" ]]; then + julia -e "Pkg.add(\"Lint\")"; + fi + - if [[ "$TRAVIS_LANGUAGE" == "java" ]]; then + bash .ci/deps.java.sh; + fi + - if [[ "$BEARS" == "opam" ]]; then + bash .ci/deps.opam.sh; + fi + - if [[ "$BEARS" == "lua" ]]; then + luarocks install --local --deps-mode=none luacheck; + fi + - if [[ "$TRAVIS_LANGUAGE" == "perl" ]]; then + wget "http://downloads.sourceforge.net/project/fpgalibre/bakalint/0.4.0/bakalint-0.4.0.tar.gz?r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Ffpgalibre%2Ffiles%2Fbakalint%2F0.4.0%2F&ts=1461844926&use_mirror=netcologne" -O ~/bl.tar.gz ; + tar xf ~/bl.tar.gz -C /tmp ; + mv /tmp/bakalint-0.4.0/bakalint.pl $HOME/bin ; + fi - mv requirements.orig requirements.txt - .ci/deps.coala-bears.sh + # nltk 3.2.2 dropped support for Python 3.3 + - > + if [[ -n "$TRAVIS_PYTHON_VERSION" && "$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 + - bash .ci/bears.prune.sh + # Delete tests for removed bears + - bash .ci/tests.prune.sh script: - python setup.py bdist_wheel - - pip install $(ls ./dist/*.whl)"[alldeps]" + - > + if [[ "$TRAVIS_LANGUAGE" == "python" ]]; then + pip install $(ls ./dist/*.whl)"[alldeps]" + else + pip install --user $(ls ./dist/*.whl) + fi - pytest # Ensure bear requirements are in sync with the bear PipRequirement - .ci/generate_bear_requirements.py --check --update + - > + if [[ "$TRAVIS_LANGUAGE" == "python" ]]; then + (cat bear-requirements.txt; echo "pyyaml~=3.12") | sort -u > bear-requirements.tmp + mv bear-requirements.tmp bear-requirements.txt + git diff --exit-code bear-requirements.txt + fi + - > + if [[ "$TRAVIS_LANGUAGE" == "ruby" ]]; then + git diff --exit-code Gemfile + fi + - > + if [[ "$TRAVIS_LANGUAGE" == "node_js" ]]; then + git diff --exit-code package.json + fi - coala --non-interactive - codecov - python setup.py docs diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json new file mode 100644 index 0000000000..ff7bcfea85 --- /dev/null +++ b/Godeps/Godeps.json @@ -0,0 +1,25 @@ +{ + "ImportPath": ".", + "GoVersion": "go1.5", + "GodepVersion": "v62", + "Deps": [ + { + "ImportPath": "github.com/golang/lint/golint" + }, + { + "ImportPath": "golang.org/x/tools/cmd/goimports" + }, + { + "ImportPath": "sourcegraph.com/sqs/goreturns" + }, + { + "ImportPath": "golang.org/x/tools/cmd/gotype" + }, + { + "ImportPath": "github.com/kisielk/gotool" + }, + { + "ImportPath": "github.com/kisielk/errcheck" + } + ] +} diff --git a/Makefile.PL b/Makefile.PL new file mode 100644 index 0000000000..e889d73de6 --- /dev/null +++ b/Makefile.PL @@ -0,0 +1,6 @@ +use ExtUtils::MakeMaker; +WriteMakefile( + NAME => 'Coala::Bears', + VERSION => '0.10', + PREREQ_PM => {Perl::Critic => 1.126}, +); diff --git a/makefile b/makefile new file mode 100644 index 0000000000..e69de29bb2 diff --git a/setup.cfg b/setup.cfg index d9a43ec6b7..098de2f397 100644 --- a/setup.cfg +++ b/setup.cfg @@ -19,6 +19,7 @@ addopts = --doctest-modules --doctest-ignore-import-error --cov + --cov-append --instafail --profile --reorder 'requirements.txt' 'test-requirements.txt' '*' diff --git a/setup.py b/setup.py index 0636a55722..3c1d3a1baf 100755 --- a/setup.py +++ b/setup.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 +import configparser import locale import os import platform @@ -413,6 +414,18 @@ def read_requirements(filename): if not any(req.startswith(ignore) for ignore in ignore_requirements)] +python_bears_deps = True + +config = configparser.ConfigParser() +config.read('setup.cfg') +if 'setup:custom' in config.sections(): + if config['setup:custom']['python-bears'] == 'False': + python_bears_deps = False + +if python_bears_deps: + required += [req for req in bear_required + if not req.startswith('language-check')] + if extras_require: EXTRAS_REQUIRE = extras_require SETUP_COMMANDS.update({