Merge pull request #123 from travis-ci/rkh-lint
add endpoint for .travis.yml linting
This commit is contained in:
commit
0145236b30
1
Gemfile
1
Gemfile
|
@ -6,6 +6,7 @@ gemspec
|
|||
gem 'travis-core', github: 'travis-ci/travis-core'
|
||||
gem 'travis-support', github: 'travis-ci/travis-support'
|
||||
gem 'travis-sidekiqs', github: 'travis-ci/travis-sidekiqs', require: nil, ref: 'cde9741'
|
||||
gem 'travis-yaml', github: 'travis-ci/travis-yaml'
|
||||
gem 'sinatra'
|
||||
gem 'sinatra-contrib', require: nil #github: 'sinatra/sinatra-contrib', require: nil
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ GIT
|
|||
|
||||
GIT
|
||||
remote: git://github.com/travis-ci/travis-core.git
|
||||
revision: 1cb24ef805fb820993b3a052a2b293010eea1dc0
|
||||
revision: 111ae389e611157d48177ed732c1822d98fe3059
|
||||
specs:
|
||||
travis-core (0.0.1)
|
||||
actionmailer (~> 3.2.12)
|
||||
|
@ -80,6 +80,12 @@ GIT
|
|||
specs:
|
||||
travis-support (0.0.1)
|
||||
|
||||
GIT
|
||||
remote: git://github.com/travis-ci/travis-yaml.git
|
||||
revision: 7e6e31e82240e170ffc20dfd02c0353b3bd5d33b
|
||||
specs:
|
||||
travis-yaml (0.1.0)
|
||||
|
||||
GIT
|
||||
remote: https://gist.github.com/4269321.git
|
||||
revision: 8e2d21b924a69dd48191df6a18e51769f5a88614
|
||||
|
@ -332,5 +338,6 @@ DEPENDENCIES
|
|||
travis-core!
|
||||
travis-sidekiqs!
|
||||
travis-support!
|
||||
travis-yaml!
|
||||
unicorn
|
||||
yard-sinatra!
|
||||
|
|
19
lib/travis/api/app/endpoint/lint.rb
Normal file
19
lib/travis/api/app/endpoint/lint.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
require 'travis/api/app'
|
||||
require 'travis/yaml'
|
||||
|
||||
class Travis::Api::App
|
||||
class Endpoint
|
||||
class Lint < Endpoint
|
||||
def lint
|
||||
request.body.rewind
|
||||
content = params[:content] || request.body.read
|
||||
parsed = Travis::Yaml.parse(content)
|
||||
warnings = parsed.nested_warnings.map { |k, m| { key: k, message: m } }
|
||||
{ lint: { warnings: warnings } }.to_json
|
||||
end
|
||||
|
||||
post('/', scope: :public) { lint }
|
||||
put('/', scope: :public) { lint }
|
||||
end
|
||||
end
|
||||
end
|
18
spec/unit/endpoint/lint_spec.rb
Normal file
18
spec/unit/endpoint/lint_spec.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Travis::Api::App::Endpoint::Lint do
|
||||
let(:content) { "foo: bar" }
|
||||
let(:body) { "{\"lint\":{\"warnings\":[{\"key\":[],\"message\":\"unexpected key \\\"foo\\\", dropping\"},{\"key\":[],\"message\":\"missing key \\\"language\\\", defaulting to \\\"ruby\\\"\"}]}}" }
|
||||
|
||||
it "accepts content in parameter" do
|
||||
response = post('/lint', content: content)
|
||||
response.should be_ok
|
||||
response.body.should be == body
|
||||
end
|
||||
|
||||
it "accepts content as body" do
|
||||
response = put('/lint', content)
|
||||
response.should be_ok
|
||||
response.body.should be == body
|
||||
end
|
||||
end
|
|
@ -12,39 +12,47 @@ Gem::Specification.new do |s|
|
|||
"Piotr Sarnacki",
|
||||
"Konstantin Haase",
|
||||
"Sven Fuchs",
|
||||
"Josh Kalderimis",
|
||||
"Mathias Meyer",
|
||||
"Josh Kalderimis",
|
||||
"Henrik Hodne",
|
||||
"Hiro Asari",
|
||||
"Andre Arko",
|
||||
"Erik Michaels-Ober",
|
||||
"Steve Richert",
|
||||
"Brian Ford",
|
||||
"Steve Richert",
|
||||
"rainsun",
|
||||
"James Dennes",
|
||||
"Nick Schonning",
|
||||
"Patrick Williams",
|
||||
"James Dennes",
|
||||
"Tim Carey-Smith"
|
||||
"Puneeth Chaganti",
|
||||
"Thais Camilo and Konstantin Haase",
|
||||
"Tim Carey-Smith",
|
||||
"Zachary Scott"
|
||||
]
|
||||
|
||||
s.email = [
|
||||
"drogus@gmail.com",
|
||||
"konstantin.mailinglists@googlemail.com",
|
||||
"me@svenfuchs.com",
|
||||
"josh.kalderimis@gmail.com",
|
||||
"meyer@paperplanes.de",
|
||||
"me@henrikhodne.com",
|
||||
"josh.kalderimis@gmail.com",
|
||||
"asari.ruby@gmail.com",
|
||||
"konstantin.haase@gmail.com",
|
||||
"me@henrikhodne.com",
|
||||
"henrik@hodne.io",
|
||||
"andre@arko.net",
|
||||
"konstantin.haase@gmail.com",
|
||||
"svenfuchs@artweb-design.de",
|
||||
"andre@arko.net",
|
||||
"sferik@gmail.com",
|
||||
"steve.richert@gmail.com",
|
||||
"bford@engineyard.com",
|
||||
"nschonni@gmail.com",
|
||||
"steve.richert@gmail.com",
|
||||
"rainsuner@gmail.com",
|
||||
"jdennes@gmail.com",
|
||||
"nschonni@gmail.com",
|
||||
"patrick@bittorrent.com",
|
||||
"punchagan@muse-amuse.in",
|
||||
"dev+narwen+rkh@rkh.im",
|
||||
"tim@spork.in",
|
||||
"patrick@bittorrent.com"
|
||||
"e@zzak.io"
|
||||
]
|
||||
|
||||
s.files = [
|
||||
|
@ -58,8 +66,6 @@ Gem::Specification.new do |s|
|
|||
"config/nginx.conf.erb",
|
||||
"config/puma-config.rb",
|
||||
"config/unicorn.rb",
|
||||
"docs/00_overview.md",
|
||||
"docs/01_cross_origin.md",
|
||||
"lib/tasks/build_update_branch.rake",
|
||||
"lib/tasks/build_update_pull_request_data.rake",
|
||||
"lib/tasks/encyrpt_all_data.rake",
|
||||
|
@ -74,8 +80,6 @@ Gem::Specification.new do |s|
|
|||
"lib/travis/api/app/endpoint/broadcasts.rb",
|
||||
"lib/travis/api/app/endpoint/builds.rb",
|
||||
"lib/travis/api/app/endpoint/documentation.rb",
|
||||
"lib/travis/api/app/endpoint/documentation/css/style.css",
|
||||
"lib/travis/api/app/endpoint/documentation/resources.rb",
|
||||
"lib/travis/api/app/endpoint/endpoints.rb",
|
||||
"lib/travis/api/app/endpoint/home.rb",
|
||||
"lib/travis/api/app/endpoint/hooks.rb",
|
||||
|
@ -83,6 +87,7 @@ Gem::Specification.new do |s|
|
|||
"lib/travis/api/app/endpoint/logs.rb",
|
||||
"lib/travis/api/app/endpoint/repos.rb",
|
||||
"lib/travis/api/app/endpoint/requests.rb",
|
||||
"lib/travis/api/app/endpoint/setting_endpoint.rb",
|
||||
"lib/travis/api/app/endpoint/uptime.rb",
|
||||
"lib/travis/api/app/endpoint/users.rb",
|
||||
"lib/travis/api/app/extensions.rb",
|
||||
|
@ -104,24 +109,60 @@ Gem::Specification.new do |s|
|
|||
"lib/travis/api/app/middleware/scope_check.rb",
|
||||
"lib/travis/api/app/responders.rb",
|
||||
"lib/travis/api/app/responders/atom.rb",
|
||||
"lib/travis/api/app/responders/badge.rb",
|
||||
"lib/travis/api/app/responders/base.rb",
|
||||
"lib/travis/api/app/responders/image.rb",
|
||||
"lib/travis/api/app/responders/json.rb",
|
||||
"lib/travis/api/app/responders/plain.rb",
|
||||
"lib/travis/api/app/responders/service.rb",
|
||||
"lib/travis/api/app/responders/xml.rb",
|
||||
"lib/travis/api/app/skylight/dalli_probe.rb",
|
||||
"lib/travis/api/app/skylight/redis_probe.rb",
|
||||
"lib/travis/api/app/skylight/service_probe.rb",
|
||||
"lib/travis/api/serializer.rb",
|
||||
"lib/travis/api/v2.rb",
|
||||
"lib/travis/api/v2/http.rb",
|
||||
"lib/travis/api/v2/http/accounts.rb",
|
||||
"lib/travis/api/v2/http/annotations.rb",
|
||||
"lib/travis/api/v2/http/branch.rb",
|
||||
"lib/travis/api/v2/http/branches.rb",
|
||||
"lib/travis/api/v2/http/broadcasts.rb",
|
||||
"lib/travis/api/v2/http/build.rb",
|
||||
"lib/travis/api/v2/http/builds.rb",
|
||||
"lib/travis/api/v2/http/caches.rb",
|
||||
"lib/travis/api/v2/http/error.rb",
|
||||
"lib/travis/api/v2/http/hooks.rb",
|
||||
"lib/travis/api/v2/http/job.rb",
|
||||
"lib/travis/api/v2/http/jobs.rb",
|
||||
"lib/travis/api/v2/http/log.rb",
|
||||
"lib/travis/api/v2/http/permissions.rb",
|
||||
"lib/travis/api/v2/http/repositories.rb",
|
||||
"lib/travis/api/v2/http/repository.rb",
|
||||
"lib/travis/api/v2/http/request.rb",
|
||||
"lib/travis/api/v2/http/requests.rb",
|
||||
"lib/travis/api/v2/http/ssh_key.rb",
|
||||
"lib/travis/api/v2/http/ssh_keys.rb",
|
||||
"lib/travis/api/v2/http/ssl_key.rb",
|
||||
"lib/travis/api/v2/http/user.rb",
|
||||
"lib/travis/api/v2/http/validation_error.rb",
|
||||
"public/favicon.ico",
|
||||
"public/images/result/error.png",
|
||||
"public/images/result/error.svg",
|
||||
"public/images/result/failing.png",
|
||||
"public/images/result/failing.svg",
|
||||
"public/images/result/passing.png",
|
||||
"public/images/result/passing.svg",
|
||||
"public/images/result/pending.png",
|
||||
"public/images/result/pending.svg",
|
||||
"public/images/result/unknown.png",
|
||||
"public/images/result/unknown.svg",
|
||||
"script/console",
|
||||
"script/server",
|
||||
"spec/integration/formats_handling_spec.rb",
|
||||
"spec/integration/responders_spec.rb",
|
||||
"spec/integration/routes.backup.rb",
|
||||
"spec/integration/scopes_spec.rb",
|
||||
"spec/integration/settings_endpoint_spec.rb",
|
||||
"spec/integration/uptime_spec.rb",
|
||||
"spec/integration/v1/branches_spec.rb",
|
||||
"spec/integration/v1/builds_spec.rb",
|
||||
|
@ -134,12 +175,33 @@ Gem::Specification.new do |s|
|
|||
"spec/integration/v2/hooks_spec.rb",
|
||||
"spec/integration/v2/jobs_spec.rb",
|
||||
"spec/integration/v2/repositories_spec.rb",
|
||||
"spec/integration/v2/requests_spec.rb",
|
||||
"spec/integration/v2/users_spec.rb",
|
||||
"spec/integration/v2_spec.backup.rb",
|
||||
"spec/integration/version_spec.rb",
|
||||
"spec/spec_helper.rb",
|
||||
"spec/support/formats.rb",
|
||||
"spec/support/matchers.rb",
|
||||
"spec/unit/access_token_spec.rb",
|
||||
"spec/unit/api/v2/http/accounts_spec.rb",
|
||||
"spec/unit/api/v2/http/annotations_spec.rb",
|
||||
"spec/unit/api/v2/http/branch_spec.rb",
|
||||
"spec/unit/api/v2/http/branches_spec.rb",
|
||||
"spec/unit/api/v2/http/broadcasts_spec.rb",
|
||||
"spec/unit/api/v2/http/build_spec.rb",
|
||||
"spec/unit/api/v2/http/builds_spec.rb",
|
||||
"spec/unit/api/v2/http/caches_spec.rb",
|
||||
"spec/unit/api/v2/http/hooks_spec.rb",
|
||||
"spec/unit/api/v2/http/job_spec.rb",
|
||||
"spec/unit/api/v2/http/jobs_spec.rb",
|
||||
"spec/unit/api/v2/http/log_spec.rb",
|
||||
"spec/unit/api/v2/http/permissions_spec.rb",
|
||||
"spec/unit/api/v2/http/repositories_spec.rb",
|
||||
"spec/unit/api/v2/http/repository_spec.rb",
|
||||
"spec/unit/api/v2/http/request_spec.rb",
|
||||
"spec/unit/api/v2/http/requests_spec.rb",
|
||||
"spec/unit/api/v2/http/ssl_key_spec.rb",
|
||||
"spec/unit/api/v2/http/user_spec.rb",
|
||||
"spec/unit/app_spec.rb",
|
||||
"spec/unit/cors_spec.rb",
|
||||
"spec/unit/default_spec.rb",
|
||||
|
@ -148,7 +210,6 @@ Gem::Specification.new do |s|
|
|||
"spec/unit/endpoint/authorization_spec.rb",
|
||||
"spec/unit/endpoint/branches_spec.rb",
|
||||
"spec/unit/endpoint/builds_spec.rb",
|
||||
"spec/unit/endpoint/documentation_spec.rb",
|
||||
"spec/unit/endpoint/endpoints_spec.rb",
|
||||
"spec/unit/endpoint/hooks_spec.rb",
|
||||
"spec/unit/endpoint/jobs_spec.rb",
|
||||
|
@ -165,6 +226,7 @@ Gem::Specification.new do |s|
|
|||
"spec/unit/middleware/scope_check_spec.rb",
|
||||
"spec/unit/responders/json_spec.rb",
|
||||
"spec/unit/responders/service_spec.rb",
|
||||
"tmp/.gitkeep",
|
||||
"travis-api.gemspec"
|
||||
]
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user