From f7450cdb6b195e5220b6568f2fbf07db88171dd0 Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Wed, 6 Nov 2013 01:40:42 +0100 Subject: [PATCH 1/3] removed the branches endpoint we already have branch info accessible via the repos endpoints, having this at the root level doesn't make sense. --- lib/travis/api/app/endpoint/branches.rb | 16 ---------------- spec/integration/v1/branches_spec.rb | 11 ----------- spec/integration/v2/branches_spec.rb | 11 ----------- spec/unit/endpoint/branches_spec.rb | 5 ----- 4 files changed, 43 deletions(-) delete mode 100644 lib/travis/api/app/endpoint/branches.rb delete mode 100644 spec/integration/v1/branches_spec.rb delete mode 100644 spec/integration/v2/branches_spec.rb delete mode 100644 spec/unit/endpoint/branches_spec.rb diff --git a/lib/travis/api/app/endpoint/branches.rb b/lib/travis/api/app/endpoint/branches.rb deleted file mode 100644 index 5f071bd6..00000000 --- a/lib/travis/api/app/endpoint/branches.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'travis/api/app' - -class Travis::Api::App - class Endpoint - class Branches < Endpoint - get '/' do - respond_with service(:find_branches, params), type: :branches - end - - # get '/:owner_name/:name/branches' do # v1 - # get '/repos/:owner_name/:name/branches' do # v2 - # respond_with service(:branches, :find_all, params), type: :branches - # end - end - end -end diff --git a/spec/integration/v1/branches_spec.rb b/spec/integration/v1/branches_spec.rb deleted file mode 100644 index 6e5c8735..00000000 --- a/spec/integration/v1/branches_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'spec_helper' - -describe 'Branches' do - let(:repo) { Repository.by_slug('svenfuchs/minimal').first } - let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.1+json' } } - - it 'GET /branches?repository_id=:repository_id' do - response = get '/branches', { repository_id: repo.id }, headers - response.should deliver_json_for(repo.last_finished_builds_by_branches, version: 'v1', type: 'branches') - end -end diff --git a/spec/integration/v2/branches_spec.rb b/spec/integration/v2/branches_spec.rb deleted file mode 100644 index 3e54ecc8..00000000 --- a/spec/integration/v2/branches_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'spec_helper' - -describe 'Branches' do - let(:repo) { Repository.by_slug('svenfuchs/minimal').first } - let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.2+json' } } - - it 'GET /branches?repository_id=:repository_id' do - response = get '/branches', { repository_id: repo.id }, headers - response.should deliver_json_for(repo.last_finished_builds_by_branches, version: 'v2', type: 'branches') - end -end diff --git a/spec/unit/endpoint/branches_spec.rb b/spec/unit/endpoint/branches_spec.rb deleted file mode 100644 index 03923cfd..00000000 --- a/spec/unit/endpoint/branches_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe Travis::Api::App::Endpoint::Branches do - it 'has to be tested' -end From 27f091d3f37323168b757197b9f004a85576b4b1 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Tue, 17 Jun 2014 11:42:35 +0200 Subject: [PATCH 2/3] regenerate gemspec --- Gemfile.lock | 2 +- travis-api.gemspec | 94 ++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 79 insertions(+), 17 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 69a7646e..ddb365e2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) diff --git a/travis-api.gemspec b/travis-api.gemspec index 43570731..9e735082 100644 --- a/travis-api.gemspec +++ b/travis-api.gemspec @@ -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" ] From 10fe7e1c39c173ff39747eed43b386cb084d25ae Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Tue, 17 Jun 2014 12:14:10 +0200 Subject: [PATCH 3/3] add endpoint for linting --- Gemfile | 1 + Gemfile.lock | 7 +++++++ lib/travis/api/app/endpoint/lint.rb | 19 +++++++++++++++++++ spec/unit/endpoint/lint_spec.rb | 18 ++++++++++++++++++ 4 files changed, 45 insertions(+) create mode 100644 lib/travis/api/app/endpoint/lint.rb create mode 100644 spec/unit/endpoint/lint_spec.rb diff --git a/Gemfile b/Gemfile index f8051f9c..89cee7dd 100644 --- a/Gemfile +++ b/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 diff --git a/Gemfile.lock b/Gemfile.lock index ddb365e2..4ae4edb4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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! diff --git a/lib/travis/api/app/endpoint/lint.rb b/lib/travis/api/app/endpoint/lint.rb new file mode 100644 index 00000000..30437e51 --- /dev/null +++ b/lib/travis/api/app/endpoint/lint.rb @@ -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 diff --git a/spec/unit/endpoint/lint_spec.rb b/spec/unit/endpoint/lint_spec.rb new file mode 100644 index 00000000..025130de --- /dev/null +++ b/spec/unit/endpoint/lint_spec.rb @@ -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