API for CI Lint
This commit is contained in:
parent
1d54886996
commit
fb1c7254d5
4 changed files with 55 additions and 0 deletions
|
@ -24,6 +24,7 @@ module Ci
|
||||||
mount ::Ci::API::Builds
|
mount ::Ci::API::Builds
|
||||||
mount ::Ci::API::Runners
|
mount ::Ci::API::Runners
|
||||||
mount ::Ci::API::Triggers
|
mount ::Ci::API::Triggers
|
||||||
|
mount ::Ci::API::Lint
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -59,6 +59,13 @@ module Ci
|
||||||
expose :id, :variables
|
expose :id, :variables
|
||||||
expose :pipeline, using: Commit, as: :commit
|
expose :pipeline, using: Commit, as: :commit
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Lint < Grape::Entity
|
||||||
|
expose :content
|
||||||
|
expose :status
|
||||||
|
expose :builds
|
||||||
|
expose :stages
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
24
lib/ci/api/lint.rb
Normal file
24
lib/ci/api/lint.rb
Normal 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
|
23
spec/requests/ci/api/lint_spec.rb
Normal file
23
spec/requests/ci/api/lint_spec.rb
Normal 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
|
Loading…
Reference in a new issue