Skip to content

Commit

Permalink
Add rubocop
Browse files Browse the repository at this point in the history
Adds rubocop with a basic ruleset that can be run in the following ways:

* `rubocop` - will run checks against codebase
* `rubocop -a` - will run checks and fix what it can
* `rake` - will run autocorrect (`rubocop -a`) and specs

CI now runs rubocop and specs as two separate (and parallel) tasks, so we can see discrete passes and failures on PRs.

Also fixes existing rubocop failures.
  • Loading branch information
hartsick authored Feb 16, 2019
1 parent 5a9c76d commit 62cceea
Show file tree
Hide file tree
Showing 34 changed files with 1,084 additions and 351 deletions.
106 changes: 71 additions & 35 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,75 @@
---
# Ruby CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
#

defaults: &defaults
working_directory: ~/repo
docker:
- image: circleci/ruby:2.5.3-node-browsers

version: 2
jobs:
build:
parallelism: 3
working_directory: ~/repo
install_dependencies:
<<: *defaults
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "Gemfile.lock" }}
- v1-dependencies-
- run: bundle install --jobs=4 --retry=3 --path vendor/bundle
- save_cache:
paths:
- ./vendor/bundle
key: v1-dependencies-{{ checksum "Gemfile.lock" }}

run_checks:
<<: *defaults
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "Gemfile.lock" }}
- v1-dependencies-
- run: bundle --path vendor/bundle
- run: bundle exec rubocop

run_tests:
<<: *defaults
docker:
- image: circleci/ruby:2.5.1-node-browsers
- image: circleci/ruby:2.5.3-node-browsers
steps:
- checkout
# Restore Cached Dependencies
- restore_cache:
name: Restore bundle cache
key: v1-cfa_styleguide-{{ checksum "Gemfile.lock" }}
# Bundle install dependencies
- run: bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3 --full-index
# Cache Dependencies
- save_cache:
name: Store bundle cache
key: v1-cfa_styleguide-{{ checksum "Gemfile.lock" }}
paths:
- vendor/bundle
# Create place to store test results
- run: mkdir /tmp/test-results
# Run the tests
- type: shell
command: |
gem install rspec && \
bundle exec rspec --profile 10 \
--require ./spec/support/pre_documentation_formatter.rb \
--format RspecJunitFormatter \
--out /tmp/test-results/rspec.xml \
--format PreDocumentationFormatter \
$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
- store_test_results:
path: /tmp/test-results
- store_artifacts:
path: spec/test_app/tmp/screenshots
destination: screenshots
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "Gemfile.lock" }}
- v1-dependencies-
- run: bundle --path vendor/bundle
- run: mkdir /tmp/test-results
- type: shell
command: |
bundle exec rspec --profile 10 \
--require ./spec/support/pre_documentation_formatter.rb \
--format RspecJunitFormatter \
--out /tmp/test-results/rspec.xml \
--format PreDocumentationFormatter \
$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
# collect reports
- store_test_results:
path: /tmp/test-results
- store_artifacts:
path: spec/test_app/tmp/screenshots
destination: screenshots

workflows:
version: 2
build:
jobs:
- install_dependencies
- run_checks:
requires:
- install_dependencies
- run_tests:
requires:
- install_dependencies
Loading

0 comments on commit 62cceea

Please sign in to comment.