-
-
Notifications
You must be signed in to change notification settings - Fork 530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for CircleCI 2.0 #934
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
module Suspenders | ||
module Adapters | ||
class CircleCI | ||
def initialize(app_builder) | ||
@app_builder = app_builder | ||
end | ||
|
||
def configure_circleci | ||
app_builder.empty_directory(".circleci") | ||
app_builder.template "circleci.yml.erb", ".circleci/config.yml" | ||
end | ||
|
||
def configure_circleci_deployment | ||
deploy_command = <<-YML.strip_heredoc | ||
deploy: | ||
docker: | ||
- image: buildpack-deps:trusty | ||
steps: | ||
- checkout | ||
- run: | ||
name: Deploy to staging | ||
command: bin/deploy staging | ||
|
||
workflows: | ||
version: 2 | ||
build-deploy: | ||
jobs: | ||
- build | ||
- deploy: | ||
requires: | ||
- build | ||
filters: | ||
branches: | ||
only: master | ||
|
||
YML | ||
|
||
app_builder.append_file ".circleci/config.yml", deploy_command | ||
end | ||
|
||
private | ||
|
||
attr_reader :app_builder | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,7 @@ def suspenders_customization | |
invoke :setup_bundler_audit | ||
invoke :setup_spring | ||
invoke :generate_default | ||
invoke :configure_circleci | ||
invoke :setup_default_directories | ||
invoke :create_local_heroku_setup | ||
invoke :create_heroku_apps | ||
|
@@ -177,12 +178,16 @@ def remove_routes_comment_lines | |
build :remove_routes_comment_lines | ||
end | ||
|
||
def configure_circleci | ||
say "Configuring CircleCI" | ||
build :configure_circleci | ||
end | ||
|
||
def generate_default | ||
run("spring stop") | ||
generate("suspenders:static") | ||
generate("suspenders:stylesheet_base") | ||
generate("suspenders:testing") | ||
generate("suspenders:ci") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'll need to keep this in the generator, so people can remove CI support if they don't want it (or, for people who just add the gem to their Gemfile, so people can add CI support if they want it). |
||
generate("suspenders:js_driver") | ||
unless options[:api] | ||
generate("suspenders:forms") | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
require "spec_helper" | ||
|
||
RSpec.describe "CircleCI" do | ||
before(:all) do | ||
drop_dummy_database | ||
remove_project_directory | ||
run_suspenders | ||
setup_app_dependencies | ||
end | ||
|
||
it "creates CircleCI config file" do | ||
expect(File).to exist("#{project_path}/.circleci/config.yml") | ||
end | ||
|
||
it "uses the app name in the config file" do | ||
circleci_config = IO.read("#{project_path}/.circleci/config.yml") | ||
|
||
expect(circleci_config).to match(/working_directory: ~\/#{app_name}/) | ||
end | ||
|
||
def app_name | ||
SuspendersTestHelpers::APP_NAME | ||
end | ||
end |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
version: 2 | ||
jobs: | ||
build: | ||
working_directory: ~/<%= app_name %> | ||
docker: | ||
- image: circleci/ruby:<%= Suspenders::RUBY_VERSION %>-node | ||
environment: | ||
RAILS_ENV: test | ||
PGHOST: localhost | ||
PGUSER: <%= app_name %> | ||
- image: postgres:10.5 | ||
environment: | ||
POSTGRES_USER: <%= app_name %> | ||
POSTGRES_DB: <%= app_name %>_test | ||
POSTGRES_PASSWORD: "" | ||
steps: | ||
- checkout | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Give that you have have not spaced out the rest of this file, what are your thoughts on removing this whitespace? |
||
- run: | ||
name: Which Bundler? | ||
command: bundle -v | ||
|
||
- restore_cache: | ||
keys: | ||
- <%= app_name %>-{{ .Branch }}-{{ checksum "Gemfile.lock" }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this need to be branch specific? I kind of like the idea that this would restore the cache for any ol' branch so long as the gems are the same. |
||
- <%= app_name %>- | ||
|
||
- run: | ||
name: Bundle Install | ||
command: | | ||
bundle install --deployment \ | ||
--retry=3 \ | ||
--jobs=3 | ||
|
||
- save_cache: | ||
key: <%= app_name %>-{{ .Branch }}-{{ checksum "Gemfile.lock" }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above |
||
paths: | ||
- vendor/bundle | ||
|
||
- run: | ||
name: Wait for database | ||
command: dockerize -wait tcp://localhost:5432 -timeout 1m | ||
|
||
- run: | ||
name: Database setup | ||
command: RAILS_ENV=development bin/setup | ||
|
||
- run: | ||
name: Run tests | ||
command: COVERAGE=true bundle exec rake | ||
|
||
- store_artifacts: | ||
path: coverage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason why this isn't in the the
circleci.yml.erb
file?