From 2f66c1df25405869e3e93a85ea3c3477cab660ab Mon Sep 17 00:00:00 2001 From: Zmago Devetak Date: Thu, 23 Nov 2017 09:55:57 +0100 Subject: [PATCH] adds travis config file (#873) * adds travis config file * add dist to travis * adds script section * test env * remove globals * adds hashed variables * add matrix * removed matrix * test env * testing * test * update Gemfile * test travis * test * test * test travis * test * build with docker * test * test * ads * add devise secre * test travis * test * test * test * adds travis db configurations * make travis happy * test * test * test * test * test * test * testing devise * test * test * teset * test * test * test * test * test * test * test * test * test * test * edit env * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * final commit * test * cleanup * cleanup --- .rspec | 1 + .travis.yml | 8 ++++++++ Gemfile | 2 +- Makefile | 12 ++++++++++-- config/initializers/devise.rb | 2 +- config/secrets.yml | 4 ++-- 6 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 .travis.yml diff --git a/.rspec b/.rspec index 5be63fcb0..7a2cc1a6e 100644 --- a/.rspec +++ b/.rspec @@ -1,2 +1,3 @@ --require spec_helper --format documentation +--color diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..9541c172c --- /dev/null +++ b/.travis.yml @@ -0,0 +1,8 @@ +sudo: required +install: true +services: + - docker +before_script: + - make docker +script: + - make tests-ci diff --git a/Gemfile b/Gemfile index 77f3dd90b..998e4b62e 100644 --- a/Gemfile +++ b/Gemfile @@ -106,7 +106,7 @@ end group :test do gem 'shoulda-matchers' - gem 'cucumber-rails', '~> 1.5' + gem 'cucumber-rails', '~> 1.5', require: false gem 'database_cleaner' gem 'capybara' gem 'capybara-email' diff --git a/Makefile b/Makefile index 06628aaff..8603db94d 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ APP_HOME="/usr/src/app" DB_IP=$(shell docker inspect scinote_db_development | grep "\"IPAddress\": " | awk '{ match($$0, /"IPAddress": "([0-9\.]*)",/, a); print a[1] }') +PAPERCLIP_HASH_SECRET=$(shell openssl rand -base64 128 | tr -d '\n') define PRODUCTION_CONFIG_BODY SECRET_KEY_BASE=$(shell openssl rand -hex 64) @@ -14,6 +15,7 @@ DEFACE_ENABLED=false endef export PRODUCTION_CONFIG_BODY + all: docker database heroku: @@ -74,8 +76,14 @@ cli: cli-production: @$(MAKE) rails-production cmd="/bin/bash" -tests: - @$(MAKE) rails cmd="rake test" +unit-tests: + @$(MAKE) rails cmd="bundle exec rspec" + +integration-tests: + @$(MAKE) rails cmd="bundle exec cucumber" + +tests-ci: + @docker-compose run -e PAPERCLIP_HASH_SECRET=PAPERCLIP_HASH_SECRET -e PAPERCLIP_STORAGE=filesystem -e ENABLE_TUTORIAL=false -e ENABLE_RECAPTCHA=false -e ENABLE_USER_CONFIRMATION=false -e ENABLE_USER_REGISTRATION=true --rm web bash -c "bundle install && rake db:create db:migrate && rake db:migrate RAILS_ENV=test && yarn install && bundle exec rspec && bundle exec cucumber" console: @$(MAKE) rails cmd="rails console" diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 28e701cf6..af1646826 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -6,7 +6,7 @@ Devise.setup do |config| # confirmation, reset password and unlock tokens in the database. # Devise will use the `secret_key_base` on Rails 4+ applications as its `secret_key` # by default. You can change it below and use your own secret key. - # config.secret_key = '541693b548daa586c6f7d4d4ac38de22e7d46b64ff85492ca05bb176b3b18249d6dbcf74b419a7d680146c6f6173b9c780d77e10580d98b0dc7f8f0c18efae9a' + # config.secret_key = '8d3a7b1acfb05057553abeb1ee4709f9f2d7e2fa1e5e60e7f45ab2e9244c301adcf0d146ae7cf74ba03c39c5bf895f08606a9f98051478ac4c6a695cafb4007a' # ==> Mailer Configuration # Configure the e-mail address which will be shown in Devise::Mailer, diff --git a/config/secrets.yml b/config/secrets.yml index 78ebbff25..974d6b9e9 100644 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -57,11 +57,11 @@ common: &common # ====================================================================== development: - secret_key_base: <%= ENV["DEVELOPMENT_KEY_BASE"] %> + secret_key_base: 22f2adf8f5cb73351da28f2292daa840cc2a414ae00ae605b175a8d5c73932f7e5b8ff8ef8f1554a7f1064f9869b15347f7709f0daa6ccb24c50f3cace304f64 <<: *common test: - secret_key_base: <%= ENV["TEST_KEY_BASE"] %> + secret_key_base: f3719934e04fa8871cf5d33d5c60f05e1b8995e0315265aef9f8b878da49bd2d386eb25ce35545b469a94ccf22f91e0052b93a15194b4f57b0c8d6ce8b150e1e <<: *common production: