forked from coala/coala-bears
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ gem "reek" | |
gem "rubocop", "0.47.1" | ||
gem "scss_lint", require: false | ||
gem "sqlint" | ||
gem "travis", "1.8.8" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from coalib.bearlib.abstractions.Linter import linter | ||
|
||
from dependency_management.requirements.GemRequirement import GemRequirement | ||
|
||
|
||
@linter(executable='travis', | ||
output_format='regex', | ||
output_regex=r'\[x\]\s+(?P<message>.+)') | ||
class TravisLintBear: | ||
""" | ||
A validator for your ``.travis.yml`` that attempts to reduce common build | ||
errors such as: | ||
- invalid YAML | ||
- missing language key | ||
- unsupported runtime versions of Ruby, PHP, OTP, etc. | ||
- deprecated features or runtime aliases | ||
""" | ||
|
||
LANGUAGES = {'YAML'} | ||
REQUIREMENTS = {GemRequirement('travis', '1.8.8')} | ||
AUTHORS = {'The coala developers'} | ||
AUTHORS_EMAILS = {'[email protected]'} | ||
LICENSE = 'AGPL-3.0' | ||
CAN_DETECT = {'Formatting', 'Syntax'} | ||
SEE_MORE = 'https://docs.travis-ci.com/user/travis-lint' | ||
|
||
@staticmethod | ||
def create_arguments(filename, file, config_file): | ||
return 'lint', filename |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import os | ||
from queue import Queue | ||
|
||
from coalib.results.Result import Result | ||
from coalib.results.RESULT_SEVERITY import RESULT_SEVERITY | ||
from coalib.settings.Section import Section | ||
from coalib.testing.LocalBearTestHelper import LocalBearTestHelper | ||
from coalib.testing.BearTestHelper import generate_skip_decorator | ||
|
||
from bears.yaml.TravisLintBear import TravisLintBear | ||
|
||
|
||
def get_testfile_path(name): | ||
return os.path.join(os.path.dirname(__file__), | ||
'travislint_test_files', | ||
name) | ||
|
||
|
||
def load_testfile(name): | ||
return open(get_testfile_path(name)).readlines() | ||
|
||
|
||
@generate_skip_decorator(TravisLintBear) | ||
class TravisLintBearTest(LocalBearTestHelper): | ||
|
||
def setUp(self): | ||
self.uut = TravisLintBear(Section('name'), Queue()) | ||
|
||
def test_good_file(self): | ||
file_name = '.good_travis.yml' | ||
file_contents = load_testfile(file_name) | ||
self.check_results( | ||
self.uut, | ||
file_contents, | ||
[], | ||
filename=get_testfile_path(file_name)) | ||
|
||
def test_bad_file(self): | ||
file_name = '.bad_travis.yml' | ||
file_contents = load_testfile(file_name) | ||
self.check_results( | ||
self.uut, | ||
file_contents, | ||
[Result.from_values('TravisLintBear', | ||
message='in matrix.exclude section: ' | ||
'specified ruby, but setting is ' | ||
'not relevant for python', | ||
file=get_testfile_path(file_name), | ||
severity=RESULT_SEVERITY.NORMAL), | ||
Result.from_values('TravisLintBear', | ||
message='in os section: dropping osx, does' | ||
' not support python', | ||
file=get_testfile_path(file_name), | ||
severity=RESULT_SEVERITY.NORMAL), | ||
Result.from_values('TravisLintBear', | ||
message='specified ruby, but setting is ' | ||
'not relevant for python', | ||
file=get_testfile_path(file_name), | ||
severity=RESULT_SEVERITY.NORMAL)], | ||
filename=get_testfile_path(file_name)) | ||
|
||
def test_empty_file(self): | ||
file_name = '.empty_travis.yml' | ||
file_contents = load_testfile(file_name) | ||
self.check_results( | ||
self.uut, | ||
file_contents, | ||
[Result.from_values('TravisLintBear', | ||
message='missing key language, defaulting ' | ||
'to ruby', | ||
file=get_testfile_path(file_name), | ||
severity=RESULT_SEVERITY.NORMAL)], | ||
filename=get_testfile_path(file_name)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
language: python | ||
sudo: false | ||
cache: bundler | ||
rvm: | ||
- 1.9.2 | ||
- 1.9.3 | ||
- 2.0.0 | ||
- 2.1.0 | ||
- 2.1.3 | ||
- jruby | ||
os: | ||
- linux | ||
- osx | ||
matrix: | ||
exclude: | ||
- rvm: 1.8.7 | ||
os: osx | ||
- rvm: 1.9.2 | ||
os: osx | ||
- rvm: 2.1.0 | ||
os: osx | ||
- rvm: jruby | ||
os: osx | ||
deploy: | ||
provider: rubygems | ||
api_key: | ||
secure: abcdef | ||
gem: travis |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
language: ruby | ||
sudo: false | ||
cache: bundler | ||
rvm: | ||
- 1.9.2 | ||
- 1.9.3 | ||
- 2.0.0 | ||
- 2.1.0 | ||
- 2.1.3 | ||
- jruby | ||
os: | ||
- linux | ||
- osx | ||
matrix: | ||
exclude: | ||
- rvm: 1.8.7 | ||
os: osx | ||
- rvm: 1.9.2 | ||
os: osx | ||
- rvm: 2.1.0 | ||
os: osx | ||
- rvm: jruby | ||
os: osx | ||
deploy: | ||
provider: rubygems | ||
api_key: | ||
secure: abcdef | ||
gem: travis |