Class: Gitlab::Ci::Lint

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/ci/lint.rb

Defined Under Namespace

Classes: Result

Constant Summary collapse

LOG_MAX_DURATION_THRESHOLD =
2.seconds

Instance Method Summary collapse

Constructor Details

#initialize(project:, current_user:, sha: nil) ⇒ Lint

Returns a new instance of Lint.



28
29
30
31
32
# File 'lib/gitlab/ci/lint.rb', line 28

def initialize(project:, current_user:, sha: nil)
  @project = project
  @current_user = current_user
  @sha = sha || project&.repository&.commit&.sha
end

Instance Method Details

#validate(content, dry_run: false, ref: @project&.default_branch) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/gitlab/ci/lint.rb', line 34

def validate(content, dry_run: false, ref: @project&.default_branch)
  if dry_run
    simulate_pipeline_creation(content, ref)
  else
    static_validation(content)
  end
end