Skip to content
This repository was archived by the owner on Jul 30, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#
version: 2
jobs:
build:
docker:
# specify the version you desire here
- image: circleci/ruby:2.3.4-node-browsers
environment:
CC_TEST_REPORTER_ID: 2ad0d3196c872832cf5d6b34c83bf21dbf0a30e2191ba036be003b01e417a6a1
PG_HOST: localhost
PG_USER: postgres
RAILS_ENV: test
RACK_ENV: test
DATABASE_URL: "postgres://postgres:postgres@localhost:5432/micropurchase_test"

# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
- image: postgres:9.6.2
environment:
POSTGRES_USER: postgres
POSTGRES_DB: micropurchase_test
POSTGRES_PASSWORD: postgres

working_directory: ~/micropurchase

steps:
- checkout

# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "Gemfile.lock" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- run:
name: install dependencies
command: |
bundle install --jobs=4 --retry=3 --path vendor/bundle
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter

- save_cache:
paths:
- ./venv
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
# Database setup
- run: bundle exec rake db:create
- run: bundle exec rake db:schema:load

# run tests!
# TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
- run:
name: run tests
command: |
mkdir /tmp/test-results
./cc-test-reporter before-build
bundle exec rspec --format progress \
--format RspecJunitFormatter \
--out /tmp/test-results/rspec.xml \
--format progress
./cc-test-reporter format-coverage --output coverage/codeclimate.rspec.json
bundle exec cucumber --format junit --out /tmp/test-results/cucumber.xml
./cc-test-reporter format-coverage --output coverage/codeclimate.cucumber.json
./cc-test-reporter sum-coverage --parts 2 --output coverage/codeclimate.json coverage/codeclimate.*.json
./cc-test-reporter upload-coverage

# --format CircleCICucumberFormatter::CircleCIJson
# collect reports
- store_test_results:
path: /tmp/test-results
- store_artifacts:
path: /tmp/test-results
destination: test-results
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.3
2.3.4
10 changes: 4 additions & 6 deletions .simplecov
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ SimpleCov.add_filter '/spec'
SimpleCov.add_filter '/features'
SimpleCov.add_filter '/vendor'

if ENV['CI']
ENV['DEFAULT_BRANCH'] = 'develop'
require 'codeclimate_batch'
CodeclimateBatch.start
else
SimpleCov.start
if ENV['CIRCLE_ARTIFACTS']
dir = File.join(ENV['CIRCLE_ARTIFACTS'], "coverage")
SimpleCov.coverage_dir(dir)
end
SimpleCov.start
48 changes: 0 additions & 48 deletions .travis.yml

This file was deleted.

6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source 'https://rubygems.org'

ruby '2.3.3'
ruby '2.3.4'

gem 'rails', '4.2.7.1'
gem 'pg'
Expand Down Expand Up @@ -41,9 +41,8 @@ gem 'uswds-rails', github: '18F/uswds-rails-gem'
gem 'rest-client'

group :test do
gem "codeclimate-test-reporter", require: nil
gem 'codeclimate_batch', require: nil
gem 'dotenv'
gem "simplecov", require: nil
gem 'db-query-matchers'
gem 'json-schema'
gem 'shoulda-matchers'
Expand All @@ -53,6 +52,7 @@ end

group :development, :test do
gem 'rspec-rails'
gem 'rspec_junit_formatter'
gem 'cucumber-rails', require: false
gem 'capybara'
gem 'poltergeist'
Expand Down
14 changes: 6 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,6 @@ GEM
clockwork (2.0.2)
activesupport
tzinfo
codeclimate-test-reporter (1.0.8)
simplecov (<= 0.13)
codeclimate_batch (0.5.0)
json
coderay (1.1.1)
commander (4.4.3)
highline (~> 1.7.2)
Expand Down Expand Up @@ -354,6 +350,8 @@ GEM
rspec-mocks (~> 3.6.0)
rspec-support (~> 3.6.0)
rspec-support (3.6.0)
rspec_junit_formatter (0.3.0)
rspec-core (>= 2, < 4, != 2.12.0)
rubocop (0.48.1)
parser (>= 2.3.3.1, < 3.0)
powerpack (~> 0.1)
Expand Down Expand Up @@ -449,8 +447,6 @@ DEPENDENCIES
cf-app-utils
chronic
clockwork
codeclimate-test-reporter
codeclimate_batch
cucumber-rails
daemons
database_cleaner
Expand Down Expand Up @@ -491,6 +487,7 @@ DEPENDENCIES
redcarpet
rest-client
rspec-rails
rspec_junit_formatter
rubocop
ruby-saml (= 1.4.2)
saml_idp!
Expand All @@ -499,6 +496,7 @@ DEPENDENCIES
selectize-rails
shoulda-matchers
simple_form
simplecov
sinatra
timecop
uglifier
Expand All @@ -508,7 +506,7 @@ DEPENDENCIES
webmock

RUBY VERSION
ruby 2.3.3p222
ruby 2.3.4p301

BUNDLED WITH
1.14.6
1.15.3
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![Code Climate](https://codeclimate.com/github/18F/micropurchase/badges/gpa.svg)](https://codeclimate.com/github/18F/micropurchase) [![Test Coverage](https://codeclimate.com/github/18F/micropurchase/badges/coverage.svg)](https://codeclimate.com/github/18F/micropurchase/coverage) [![Dependency Status](https://gemnasium.com/18F/micropurchase.svg)](https://gemnasium.com/18F/micropurchase) [![security](https://hakiri.io/github/18F/micropurchase/master.svg)](https://hakiri.io/github/18F/micropurchase/master)
[![Accessibility](https://continua11y.18f.gov/18F/micropurchase.svg?branch=develop)](https://continua11y.18f.gov/18F/micropurchase)
[![Accessibility](https://continua11y.18f.gov/18F/micropurchase.svg?branch=develop)](https://continua11y.18f.gov/18F/micropurchase) [![Build Status](https://circleci.com/gh/18F/micropurchase.svg?style=shield&circle-token=:circle-token)](https://circleci.com/gh/18F/micropurchase.svg?style=shield&circle-token=:circle-token)

# Micro-purchase

Expand Down
79 changes: 79 additions & 0 deletions features/support/_circleci_formatter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
require 'time'

if Cucumber::VERSION =~ /^2.*/
require 'cucumber/core/test/timer'
require 'cucumber/formatter/json'
module Cucumber
module Core
module Test
class Timer
def unpatched_time_now
if Time.respond_to?(:now_without_mock_time)
Time.now_without_mock_time
else
Time.now
end
end

def time_in_nanoseconds
t = unpatched_time_now
t.to_i * 10 ** 9 + t.nsec
end
end
end
end
end

module CircleCICucumberFormatter
class CircleCIJson < Cucumber::Formatter::Json #:nodoc:
end
end
end # if

if Cucumber::VERSION =~ /^1.*/
require 'cucumber/formatter/gherkin_formatter_adapter'
require 'cucumber/formatter/io'
require 'gherkin/formatter/argument'
require 'gherkin/formatter/json_formatter'

module CircleCICucumberFormatter
class CircleCIJson < Cucumber::Formatter::GherkinFormatterAdapter #:nodoc:
include Cucumber::Formatter::Io

alias_method :original_before_step, :before_step

def unpatched_time_now
if Time.respond_to?(:now_without_mock_time)
Time.now_without_mock_time
else
Time.now
end
end

def initialize(_runtime, io, options)
@io = ensure_io(io, 'json')
f = Gherkin::Formatter::JSONFormatter.new(@io)
begin
super(f, false, options)
rescue ArgumentError # backwards compatibility with old arity
super(f, false)
end
end

# override @step_time with un-patched Time.now
def before_step(step)
original_before_step(step)
@step_time = unpatched_time_now
end

# used for capturing duration, copied from gherkin_formatter_adapter.rb
# override step_finish with un-patched Time.now
def after_step(_step)
return if @outline && @options && @options[:expand] &&
!@in_instantiated_scenario
step_finish = (unpatched_time_now - @step_time)
@gf.append_duration(step_finish)
end
end
end # module
end # if