API for CI Lint

This commit is contained in:
Katarzyna Kobierska 2016-08-18 08:50:01 +02:00
parent 1d54886996
commit fb1c7254d5
4 changed files with 55 additions and 0 deletions

View File

@ -24,6 +24,7 @@ module Ci
mount ::Ci::API::Builds
mount ::Ci::API::Runners
mount ::Ci::API::Triggers
mount ::Ci::API::Lint
end
end
end

View File

@ -59,6 +59,13 @@ module Ci
expose :id, :variables
expose :pipeline, using: Commit, as: :commit
end
class Lint < Grape::Entity
expose :content
expose :status
expose :builds
expose :stages
end
end
end
end

24
lib/ci/api/lint.rb Normal file
View File

@ -0,0 +1,24 @@
module Ci
module API
class Lint < Grape::API
before { authenticate! }
resources :lint do
post do
content = params[:content]
if content
config_processor = Ci::GitlabCiYamlProcessor.new(content)
stages = config_processor.stages
builds = config_processor.builds
status = true
response = { status: status, stages: stages, builds: builds }
end
response
end
end
end
end
end

View File

@ -0,0 +1,23 @@
require 'spec_helper'
describe Ci::API::API do
include ApiHelpers
let(:content) do
File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))
end
describe "Builds API for Lint" do
describe 'POST /ci/lint' do
before { content }
context "with valid .gitlab-ci.yaml file" do
it "has success status" do
# binding.pry
expect(response).to have_content(true)
end
end
end
end
end