diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..1802bee --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,172 @@ +version: 2.1 + +defaults: &defaults + working_directory: ~/couponable-build + docker: + - image: circleci/ruby:2.4-node-browsers + environment: + BUNDLER_VERSION: 2.0.1 + BUNDLE_JOBS: 3 + BUNDLE_RETRY: 3 + BUNDLE_PATH: vendor/bundle + PGHOST: 127.0.0.1 + PGUSER: ubuntu + RAILS_ENV: test + - image: circleci/postgres:9.6-alpine + environment: + POSTGRES_USER: ubuntu + POSTGRES_DB: barkbox_test + +aliases: + # Shallow Git Clone + # https://discuss.circleci.com/t/shallow-clone-for-circleci-2-0-builds/20200 + - &checkout-shallow + name: Checkout + command: | + #!/bin/sh + set -e + + # Workaround old docker images with incorrect $HOME + # check https://github.com/docker/docker/issues/2968 for details + if [ "${HOME}" = "/" ] + then + export HOME=$(getent passwd $(id -un) | cut -d: -f6) + fi + + mkdir -p ~/.ssh + + echo 'github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ== + bitbucket.org ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAubiN81eDcafrgMeLzaFPsw2kNvEcqTKl/VqLat/MaB33pZy0y3rJZtnqwR2qOOvbwKZYKiEO1O6VqNEBxKvJJelCq0dTXWT5pbO2gDXC6h6QDXCaHo6pOHGPUy+YBaGQRGuSusMEASYiWunYN0vCAI8QaXnWMXNMdFP3jHAJH0eDsoiGnLPBlBp4TNm6rYI74nMzgz3B9IikW4WVK+dc8KZJZWYjAuORU3jc1c/NPskD2ASinf8v3xnfXeukU0sJ5N6m5E8VLjObPEO+mN2t/FZTMZLiFqPWc/ALSqnMnnhwrNi2rbfg/rd/IpL8Le3pSBne8+seeFVBoGqzHM9yXw== + ' >> ~/.ssh/known_hosts + + (umask 077; touch ~/.ssh/id_rsa) + chmod 0600 ~/.ssh/id_rsa + (cat \< ~/.ssh/id_rsa + $CHECKOUT_KEY + EOF + ) + + # use git+ssh instead of https + git config --global url."ssh://git@github.com".insteadOf "https://github.com" || true + + if [ -e ~/couponable-build/.git ] + then + cd ~/couponable-build + git remote set-url origin "$CIRCLE_REPOSITORY_URL" || true + else + mkdir -p ~/couponable-build + cd ~/couponable-build + git clone --depth=1 "$CIRCLE_REPOSITORY_URL" . + fi + + if [ -n "$CIRCLE_TAG" ] + then + git fetch --depth=10 --force origin "refs/tags/${CIRCLE_TAG}" + elif [[ "$CIRCLE_BRANCH" =~ ^pull\/* ]] + then + # For PR from Fork + git fetch --depth=10 --force origin "$CIRCLE_BRANCH/head:remotes/origin/$CIRCLE_BRANCH" + else + git fetch --depth=10 --force origin "$CIRCLE_BRANCH:remotes/origin/$CIRCLE_BRANCH" + fi + + if [ -n "$CIRCLE_TAG" ] + then + git reset --hard "$CIRCLE_SHA1" + git checkout -q "$CIRCLE_TAG" + elif [ -n "$CIRCLE_BRANCH" ] + then + git reset --hard "$CIRCLE_SHA1" + git checkout -q -B "$CIRCLE_BRANCH" + fi + + git reset --hard "$CIRCLE_SHA1" + +jobs: + checkout_code: + <<: *defaults + steps: + - run: *checkout-shallow + - add_ssh_keys + - attach_workspace: + at: ~/couponable-build + - run: + name: Install Bundler + command: | + echo 'export BUNDLER_VERSION=$(cat Gemfile.lock | tail -1 | tr -d " ")' >> $BASH_ENV + source $BASH_ENV + gem install bundler + - run: + name: Which bundler? + command: bundle -v + - restore_cache: + keys: + - v1-couponable-v2.4.4-{{ checksum "Gemfile.lock" }} + - v1-couponable-v2.4.4- + - run: + name: Bundle Install + command: bundle check --path vendor/bundle || bundle install --path vendor/bundle + - save_cache: + key: v1-couponable-v2.4.4-{{ checksum "Gemfile.lock" }} + paths: + - vendor/bundle + - persist_to_workspace: + root: ~/couponable-build + paths: + - . + + test: + <<: *defaults + parallelism: 1 +# total parallelism should be 10 for rspec_test and flaky_rspec_test, if one is taking signifigantly longer than the other these should be adjusted + steps: + - attach_workspace: + at: ~/couponable-build + - run: + name: Install Bundler + command: | + echo 'export BUNDLER_VERSION=$(cat Gemfile.lock | tail -1 | tr -d " ")' >> $BASH_ENV + source $BASH_ENV + gem install bundler + - run: bundle --path vendor/bundle + - run: + name: Install psql + command: | + wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - + sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main" >> /etc/apt/sources.list.d/postgresql.list' + sudo apt update -y + sudo apt-get install postgresql-client-9.5 -y + - run: + name: Swap Database Config + command: cp test/dummy/config/database.yml.ci test/dummy/config/database.yml + - run: + name: Wait for DB + command: dockerize -wait tcp://localhost:5432 -timeout 1m + - run: + name: Database Setup + command: | + bundle exec rails db:create db:migrate RAILS_ENV=test + - run: | + mkdir -p ~/couponable-build/tmp + mkdir -p ~/couponable-build/test_results + bundle exec ruby -Itest $(circleci tests glob "test/**/*_test.rb" | circleci tests split --split-by=timings)\ + --junit \ + --junit-filename=test_results/test.xml + + - store_test_results: + path: test_results + +experimental: + notify: + branches: + only: + - master + +workflows: + version: 2 + build-and-test: + jobs: + - checkout_code + - test: + requires: + - checkout_code diff --git a/Gemfile.lock b/Gemfile.lock index 6695f5b..20780ca 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,112 +7,114 @@ PATH GEM remote: http://rubygems.org/ specs: - actioncable (5.0.0.beta3) - actionpack (= 5.0.0.beta3) - nio4r (~> 1.2) + actioncable (5.0.7.2) + actionpack (= 5.0.7.2) + nio4r (>= 1.2, < 3.0) websocket-driver (~> 0.6.1) - actionmailer (5.0.0.beta3) - actionpack (= 5.0.0.beta3) - actionview (= 5.0.0.beta3) - activejob (= 5.0.0.beta3) + actionmailer (5.0.7.2) + actionpack (= 5.0.7.2) + actionview (= 5.0.7.2) + activejob (= 5.0.7.2) mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (5.0.0.beta3) - actionview (= 5.0.0.beta3) - activesupport (= 5.0.0.beta3) - rack (~> 2.x) + rails-dom-testing (~> 2.0) + actionpack (5.0.7.2) + actionview (= 5.0.7.2) + activesupport (= 5.0.7.2) + rack (~> 2.0) rack-test (~> 0.6.3) - rails-dom-testing (~> 1.0, >= 1.0.5) + rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.0.0.beta3) - activesupport (= 5.0.0.beta3) + actionview (5.0.7.2) + activesupport (= 5.0.7.2) builder (~> 3.1) erubis (~> 2.7.0) - rails-dom-testing (~> 1.0, >= 1.0.5) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - activejob (5.0.0.beta3) - activesupport (= 5.0.0.beta3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.0.7.2) + activesupport (= 5.0.7.2) globalid (>= 0.3.6) - activemodel (5.0.0.beta3) - activesupport (= 5.0.0.beta3) - activerecord (5.0.0.beta3) - activemodel (= 5.0.0.beta3) - activesupport (= 5.0.0.beta3) + activemodel (5.0.7.2) + activesupport (= 5.0.7.2) + activerecord (5.0.7.2) + activemodel (= 5.0.7.2) + activesupport (= 5.0.7.2) arel (~> 7.0) - activesupport (5.0.0.beta3) - concurrent-ruby (~> 1.0) - i18n (~> 0.7) + activesupport (5.0.7.2) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) - arel (7.0.0) - builder (3.2.2) - concurrent-ruby (1.0.1) + arel (7.1.4) + builder (3.2.3) + concurrent-ruby (1.1.5) + crass (1.0.4) erubis (2.7.0) - globalid (0.3.6) - activesupport (>= 4.1.0) - i18n (0.7.0) - jquery-rails (4.1.1) + globalid (0.4.2) + activesupport (>= 4.2.0) + i18n (1.6.0) + concurrent-ruby (~> 1.0) + jquery-rails (4.3.3) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - json (1.8.3) - loofah (2.0.3) + loofah (2.2.3) + crass (~> 1.0.2) nokogiri (>= 1.5.9) - mail (2.6.3) - mime-types (>= 1.16, < 3) - method_source (0.8.2) - mime-types (2.99.1) - mini_portile2 (2.0.0) - minitest (5.8.4) - nio4r (1.2.1) - nokogiri (1.6.7.2) - mini_portile2 (~> 2.0.0.rc2) - rack (2.0.0.alpha) - json + mail (2.7.1) + mini_mime (>= 0.1.1) + method_source (0.9.2) + mini_mime (1.0.1) + mini_portile2 (2.4.0) + minitest (5.11.3) + minitest-junit (0.2.0) + builder (~> 3.2) + minitest (~> 5.0) + nio4r (2.3.1) + nokogiri (1.10.2) + mini_portile2 (~> 2.4.0) + pg (1.1.4) + rack (2.0.6) rack-test (0.6.3) rack (>= 1.0) - rails (5.0.0.beta3) - actioncable (= 5.0.0.beta3) - actionmailer (= 5.0.0.beta3) - actionpack (= 5.0.0.beta3) - actionview (= 5.0.0.beta3) - activejob (= 5.0.0.beta3) - activemodel (= 5.0.0.beta3) - activerecord (= 5.0.0.beta3) - activesupport (= 5.0.0.beta3) - bundler (>= 1.3.0, < 2.0) - railties (= 5.0.0.beta3) + rails (5.0.7.2) + actioncable (= 5.0.7.2) + actionmailer (= 5.0.7.2) + actionpack (= 5.0.7.2) + actionview (= 5.0.7.2) + activejob (= 5.0.7.2) + activemodel (= 5.0.7.2) + activerecord (= 5.0.7.2) + activesupport (= 5.0.7.2) + bundler (>= 1.3.0) + railties (= 5.0.7.2) sprockets-rails (>= 2.0.0) - rails-deprecated_sanitizer (1.0.3) - activesupport (>= 4.2.0.alpha) - rails-dom-testing (1.0.7) - activesupport (>= 4.2.0.beta, < 5.0) - nokogiri (~> 1.6.0) - rails-deprecated_sanitizer (>= 1.0.1) - rails-html-sanitizer (1.0.3) - loofah (~> 2.0) - railties (5.0.0.beta3) - actionpack (= 5.0.0.beta3) - activesupport (= 5.0.0.beta3) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.0.4) + loofah (~> 2.2, >= 2.2.2) + railties (5.0.7.2) + actionpack (= 5.0.7.2) + activesupport (= 5.0.7.2) method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rake (11.1.1) - sprockets (3.5.2) + rake (12.3.2) + sprockets (3.7.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (3.0.4) + sprockets-rails (3.2.1) actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - sqlite3 (1.3.11) - thor (0.19.1) - thread_safe (0.3.5) - tzinfo (1.2.2) + sqlite3 (1.4.0) + thor (0.20.3) + thread_safe (0.3.6) + tzinfo (1.2.5) thread_safe (~> 0.1) - websocket-driver (0.6.3) + websocket-driver (0.6.5) websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.2) + websocket-extensions (0.1.3) PLATFORMS ruby @@ -120,7 +122,9 @@ PLATFORMS DEPENDENCIES couponable! jquery-rails + minitest-junit + pg sqlite3 BUNDLED WITH - 1.11.2 + 2.0.1 diff --git a/Rakefile b/Rakefile index 83db91e..d3ee201 100644 --- a/Rakefile +++ b/Rakefile @@ -22,8 +22,6 @@ end APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__) load 'rails/tasks/engine.rake' - - Bundler::GemHelper.install_tasks require 'rake/testtask' diff --git a/couponable.gemspec b/couponable.gemspec index 45bb843..84965c9 100644 --- a/couponable.gemspec +++ b/couponable.gemspec @@ -16,7 +16,9 @@ Gem::Specification.new do |s| s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.md"] s.test_files = Dir["test/**/*"] - s.add_dependency "rails", '>= 5.0.0.beta3', '< 5.1' + s.add_dependency "rails", '>= 5.0.0.beta3' s.add_development_dependency "sqlite3" + s.add_development_dependency "minitest-junit" + s.add_development_dependency "pg" end diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb index 9d34409..9f5b074 100644 --- a/test/dummy/config/application.rb +++ b/test/dummy/config/application.rb @@ -43,12 +43,6 @@ class Application < Rails::Application # like if you have constraints or database-specific column types # config.active_record.schema_format = :sql - # Enforce whitelist mode for mass assignment. - # This will create an empty whitelist of attributes available for mass-assignment for all models - # in your app. As such, your models will need to explicitly whitelist or blacklist accessible - # parameters by using an attr_accessible or attr_protected declaration. - config.active_record.whitelist_attributes = true - # Enable the asset pipeline config.assets.enabled = true diff --git a/test/dummy/config/database.yml.ci b/test/dummy/config/database.yml.ci new file mode 100644 index 0000000..ef67477 --- /dev/null +++ b/test/dummy/config/database.yml.ci @@ -0,0 +1,6 @@ +test: + adapter: postgresql + database: couponable_test + username: ubuntu + encoding: unicode + pool: 5 diff --git a/test/dummy/config/environments/development.rb b/test/dummy/config/environments/development.rb index 82c74d1..4db6d36 100644 --- a/test/dummy/config/environments/development.rb +++ b/test/dummy/config/environments/development.rb @@ -22,9 +22,6 @@ # Only use best-standards-support built into browsers config.action_dispatch.best_standards_support = :builtin - # Raise exception on mass assignment protection for Active Record models - config.active_record.mass_assignment_sanitizer = :strict - # Log the query plan for queries taking more than this (works # with SQLite, MySQL, and PostgreSQL) config.active_record.auto_explain_threshold_in_seconds = 0.5 diff --git a/test/dummy/config/environments/test.rb b/test/dummy/config/environments/test.rb index f1a4814..2a0783b 100644 --- a/test/dummy/config/environments/test.rb +++ b/test/dummy/config/environments/test.rb @@ -29,9 +29,6 @@ # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test - # Raise exception on mass assignment protection for Active Record models - config.active_record.mass_assignment_sanitizer = :strict - # Print deprecation notices to the stderr config.active_support.deprecation = :stderr end