Skip to content

Commit

Permalink
Merge pull request #3 from customink/coding-bunny/cleanup
Browse files Browse the repository at this point in the history
[DevOps] Rubygems Standards
  • Loading branch information
Arne De Herdt authored Dec 2, 2020
2 parents 3f4a69f + 0d0628f commit ab412bc
Show file tree
Hide file tree
Showing 13 changed files with 137 additions and 18 deletions.
69 changes: 69 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
# ---------------------------------------------------------------------------------------------------------------------
# CircleCI Snippets
#
# Reusable snippets are defined below this section. These are yaml fragments that can injected into the standard
# CircleCI configuration, reducing the complexity of the entire block.
# ---------------------------------------------------------------------------------------------------------------------
docker_image: &docker_image
image: 916869144969.dkr.ecr.us-east-1.amazonaws.com/customink/base-ruby:2.7-v4.0
aws_auth:
aws_access_key_id: ${PRODUCTION_AWS_ACCESS_KEY_ID}
aws_secret_access_key: ${PRODUCTION_AWS_SECRET_ACCESS_KEY}

# ---------------------------------------------------------------------------------------------------------------------
# CircleCI Commands Configuration
#
# Commands are re-usable steps that can be shared across jobs. For example the installation of gems using bundler or
# waiting on a database connection. By defining them inside the commands section, they can be invoked as any standard
# command on the system, but will already be preconfigured. This allows us to keep the jobs definition small and clean
# ---------------------------------------------------------------------------------------------------------------------
version: 2.1
commands:
bundle_install:
description: "Performs the bundler installation, relying on the CircleCI cache for performance"
steps:
- restore_cache:
keys:
- bundler-cache-{{ checksum "is_it_up.gemspec" }}
- run:
name: "Bundle Install"
command: bundle install --path=.bundle
- save_cache:
key: bundler-cache-{{ checksum "is_it_up.gemspec" }}
paths:
- .bundle
minitest:
description: "Runs Minitest with the correct configuration so it runs in parallel and is configured for CircleCI"
steps:
- run:
name: "Minitest Test Suite"
command: bundle exec rake
# ---------------------------------------------------------------------------------------------------------------------
# CircleCI Job Configuration
#
# This section defines all the available jobs that can be executed inside a Workflow.
# Think of a Job as a batch of tasks that need to be performed to setup the environment and perform a specific task
# such as running RSpec, uploading the test results to CodeClimate etc.
# ---------------------------------------------------------------------------------------------------------------------
jobs:
tests:
working_directory: ~/is_it_up
docker:
- <<: *docker_image
environment:
RAILS_ENV: test
steps:
- checkout
- bundle_install
- minitest
- store_test_results:
path: test/reports
- store_artifacts:
path: coverage
workflows:
version: 2.1
build-and-test:
jobs:
- tests:
context: customink
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ doc/
lib/bundler/man
pkg
rdoc
spec/reports
test/tmp
test/version_tmp
test/reports
tmp
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# IsItUp Changelog

## 0.0.3
- Added `bin/console` for local testing
- Added `bin/setup` for easier installation
- Decoupled the gemspec from bundler and git
- Applied Rubygem standards
- Removed minitest deprecation warnings
- Used `autoload` for configuring the gem
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ source 'https://rubygems.org'

# Specify your gem's dependencies in is_it_up.gemspec
gemspec

group :test do
gem 'minitest-ci', require: false
gem 'simplecov', require: false
end
14 changes: 14 additions & 0 deletions bin/console
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env ruby

require 'bundler/setup'
require 'is_it_up'

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.

# (If you use this, don't forget to add pry to your Gemfile!)
# require "pry"
# Pry.start

require 'irb'
::IRB.start(__FILE__)
8 changes: 8 additions & 0 deletions bin/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
set -vx

bundle install

# Do any other automated setup that you need to do here
6 changes: 6 additions & 0 deletions bin/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env sh
set -e

echo "== Running tests =="

bundle exec rake test
12 changes: 6 additions & 6 deletions is_it_up.gemspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'is_it_up/version'
require_relative 'lib/is_it_up/version'

Gem::Specification.new do |spec|
spec.name = "is_it_up"
Expand All @@ -13,14 +10,17 @@ Gem::Specification.new do |spec|
spec.homepage = "https://github.com/customink/is_it_up"
spec.license = "MIT"

spec.files = `git ls-files -z`.split("\x0")
spec.files = ::Dir.glob(::Pathname.new(__dir__).join("lib/**/**")).reject do |file|
file.match(%r{^(test|spec|features)/}) || ::File.directory?(file)
end
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]

spec.add_dependency "rack"

spec.add_development_dependency "rake"
spec.add_development_dependency "json"
spec.add_development_dependency "bundler", "~> 1.5"
spec.add_development_dependency "bundler"
spec.add_development_dependency "minitest", "~> 5.0"
end
6 changes: 3 additions & 3 deletions lib/is_it_up.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "rack"
require "is_it_up/version"
require "is_it_up/middleware"
require 'is_it_up/railtie' if defined?(Rails::Railtie)

module IsItUp
autoload :VERSION, "is_it_up/version"
autoload :Middleware, "is_it_up/middleware"
autoload :railtie, "is_it_up/railtie" if defined?(Rails::Railtie)
end
2 changes: 1 addition & 1 deletion lib/is_it_up/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module IsItUp
VERSION = "0.0.2"
VERSION = "0.0.3"
end
2 changes: 1 addition & 1 deletion test/cases/is_it_up_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module IsItUp
class IsItUpTest < TestCase
it "must define the version" do
VERSION.wont_be_nil
refute_nil VERSION
end
end
end
10 changes: 5 additions & 5 deletions test/cases/middleware_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ class MiddlewareTest < TestCase
end

it "must respond with a JSON content type'" do
@response.content_type.must_equal "application/json"
assert_equal "application/json", @response.content_type
end

it "must render a JSON response indicating success'" do
json = JSON.parse(@response.body)
json["status"].must_equal("ok")
json["code"].must_equal(200)
assert_equal "ok", json["status"]
assert_equal 200, json["code"]
end
end

Expand All @@ -39,11 +39,11 @@ class MiddlewareTest < TestCase
end

it "must not render the JSON content type" do
@response.content_type.must_equal "text/html"
assert_equal "text/html", @response.content_type
end

it "must not render the JSON response for /is_it_up" do
@response.body.must_equal "A normal response"
assert_equal "A normal response", @response.body
end
end
end
Expand Down
10 changes: 9 additions & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
require "bundler" ; Bundler.require :development, :test
if ENV['CI']
require 'simplecov'
SimpleCov.start
end

require "bundler"
Bundler.require :development, :test

require "is_it_up"
require "minitest/autorun"
require "minitest/pride"
require "minitest/ci" if ENV["CI"]

module IsItUp
class TestCase < Minitest::Spec
Expand Down

0 comments on commit ab412bc

Please sign in to comment.