Skip to content

Commit

Permalink
Only test non-Python bears on Python 3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
jayvdb committed Feb 1, 2017
1 parent 55c8ce7 commit 4474917
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 14 deletions.
7 changes: 7 additions & 0 deletions .ci/bears.prune.sh
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions .ci/generate_bear_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import itertools
import json
import os
import re
import sys

from jinja2 import Environment, FileSystemLoader
Expand Down Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions .ci/tests.prune.sh
Original file line number Diff line number Diff line change
@@ -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
36 changes: 29 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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:
- >
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion bear-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions bears/ruby/RuboCopBear.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -19,8 +19,7 @@ class RuboCopBear:
"""

LANGUAGES = {'Ruby'}
REQUIREMENTS = {GemRequirement('rubocop'),
PipRequirement('pyyaml', '3.12')}
REQUIREMENTS = {GemRequirement('rubocop')}
AUTHORS = {'The coala developers'}
AUTHORS_EMAILS = {'[email protected]'}
LICENSE = 'AGPL-3.0'
Expand Down
4 changes: 1 addition & 3 deletions bears/scss/SCSSLintBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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 = {'[email protected]'}
LICENSE = 'AGPL-3.0'
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 4474917

Please sign in to comment.