Created
December 6, 2018 15:53
-
-
Save agirlnamedsophia/37df1b028debef784282483bef862ded to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CoachCli::CI::ConfigGenerators::RubyApp < CoachCli::CI::ConfigGenerator | |
def generate_jobs | |
[ | |
lint_job, | |
] | |
end | |
private | |
def lint_job | |
CoachCli::CI::CircleCiJob.new( | |
name: "#{project.name}--lint", | |
config: lint_job_config, | |
project: project, | |
allow_failures: allow_failures | |
).tap do |job| | |
job.add_steps(checkout_step) | |
job.add_steps(bundle_steps) | |
job.add_steps(yarn_steps) if project.file_exists?('package.json') | |
job.add_steps(gradle_steps) if project.file_exists?('build.gradle') | |
job.add_steps(rubocop_step) | |
job.add_steps(scss_lint_step) if project.file_exists?('.scss-lint.yml') | |
job.add_steps(erb_lint_step) if project.file_exists?('.erb-lint.yml') | |
job.add_steps(brakeman_step) if project.file_exists?('config/brakeman.yml') | |
job.add_steps(store_artifacts_step) | |
end | |
end | |
def lint_job_config | |
from_yaml(<<~YAML) | |
resource_class: #{project.resource_class} | |
docker: | |
- image: #{container_image} | |
environment: | |
GEM_SOURCE: https://rubygems.org | |
RAILS_ENV: test | |
RACK_ENV: test | |
YAML | |
end | |
def container_image | |
"#{CoachCli::CI::EC2ContainerRepository.hostname}/betterment/#{project.runtime}:#{project.runtime_version}" | |
end | |
def store_artifacts_step | |
CoachCli::CI::Steps::StoreArtifacts.new | |
end | |
def bundle_steps | |
CoachCli::CI::Steps::Bundle.new(project: project, gemfile: Gemfile) | |
end | |
def gradle_steps | |
[CoachCli::CI::Steps::GradleInstall.new(project: project), CoachCli::CI::Steps::GradleBuild.new(project: project)] | |
end | |
def rubocop_step | |
CoachCli::CI::Steps::Rubocop.new(project: project) | |
end | |
def scss_lint_step | |
CoachCli::CI::Steps::ScssLint.new(project: project) | |
end | |
def erb_lint_step | |
CoachCli::CI::Steps::ErbLint.new(project: project) | |
end | |
def brakeman_step | |
CoachCli::CI::Steps::Brakeman.new(project: project) | |
end | |
def checkout_step | |
CoachCli::CI::Steps::Checkout.new | |
end | |
def from_yaml(input) | |
YAML.safe_load(input) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
maybe just carve off a part of it for illustrative purposes?