Skip to content

Instantly share code, notes, and snippets.

@codesword
codesword / spec_helper.rb
Created June 19, 2016 12:29
Building An MVC Framework - Part 2
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require "todolist/config/application.rb"
require 'rspec'
require 'rack/test'
ENV['RACK_ENV'] = 'test'
@codesword
codesword / application.rb
Created June 19, 2016 12:28
Building An MVC Framework - Part 2
require "zucy"
$LOAD_PATH << File.join(File.dirname(__FILE__), "..", "app", "controllers")
module Todolist
class Application < Zucy::Application
end
end
@codesword
codesword / zucy.rb
Created June 19, 2016 12:25
Building An MVC Framework - Part 2
require "zucy/version"
module Zucy
class Application
def call(env)
@req = Rack::Request.new(env)
path = @req.path_info
request_method = @req.request_method.downcase
return [500, {}, []] if path == "/favicon.ico"
controller, action = get_controller_and_action_for(path, request_method)
@codesword
codesword / config.ru
Created June 19, 2016 12:12
Building An MVC Framework - Part 2
require "./config/application.rb"
TodoApplication = Todolist::Application.new
run TodoApplication
@codesword
codesword / todolist_controller.rb
Last active June 19, 2016 12:32
Building An MVC Framework - Part 2
class TodolistController
def get
"['Write a book', 'Build a house', 'Get married', 'Buy a car']"
end
def get_first
"Write a book"
end
@codesword
codesword / ci_cd_andela_systems.md
Last active June 14, 2016 21:45
Continuous Integration and Delivery for Andela Microservices

CI pipeline(CircleCI)

Each commit to the remote github repository will trigger the CI pipeline which is handled by circleCI. Each microservice comes with it's own set of unit/component tests. So we will like to know if the build is passing at every point in time and the current test coverage. Before a PR is merged, the build must be running and the test coverage must be high(over 90%). The CI pipeline via circleCI is already up and running.

CD pipeline(ConcourseCI)

The CD pipeline will be built using concourse-ci. ConcourseCI will be installed on a VM running on google cloud(1CPU, 3.75GB RAM, 50GB Storage, ssh_keys: CONCOURSECI_SSH_KEYS). Once a PR is merged into develop, the CD pipeline kicks off by pulling develop branch of all microservices and running their unit tests. We currently have about 5 microservices, 1 api-gateway and 1 acceptance test repo:

Repo Name DEPLOY KEY DOCKER BASE IMAGE TEST COMMAND
use ActionDispatch::Static
use Rack::Lock
use Rack::Runtime
use ActionDispatch::RequestId
use Rails::Rack::Logger
use ActionDispatch::ShowExceptions
use ActionDispatch::DebugExceptions
use ActionDispatch::RemoteIp
use ActionDispatch::Reloader
use ActionDispatch::Callbacks
app = AnotherRackApp.new
Rack::Handler::Puma.run app, Port: 9292
app = Rack::Builder.new do
use MethodOverrideMiddleware
run AnotherRackApp.new
end
Rack::Handler::WEBrick.run app, Port: 9292
require "rack"
class MethodOverrideMiddleware
def initialize(app)
@app = app
end
def call(env)
request = Rack::Request.new(env)
if request.params["method"]