API for CI Lint
This commit is contained in:
parent
1d54886996
commit
fb1c7254d5
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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
|
Loading…
Reference in New Issue