Skip to content

Commit

Permalink
Add system specs to CirceCI config
Browse files Browse the repository at this point in the history
Also refactors .circleci/config.yml:
- rename some commands, steps, jobs, workflows for consistency and to
  reduce ambiguity between the different types of elements
- consolidatees all tmp files under /tmp
  • Loading branch information
solebared committed May 8, 2021
1 parent fb8f576 commit a86e007
Showing 1 changed file with 81 additions and 40 deletions.
121 changes: 81 additions & 40 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,49 @@
docker_image: &docker_image
image: circleci/ruby:2.7.2-node

version: 2.1

commands:
bundle_install:
description: 'Performs the bundler installation, relying on the CircleCI cache for performance'
description: 'Perform bundler installation, relying on CircleCI cache for performance'
steps:
- restore_cache:
keys:
- bundler-cache-{{ checksum ".ruby-version" }}-{{ checksum "Gemfile.lock" }}
- run:
name: 'Bundle Install'
name: 'Bundle install'
command: |
set -euxo pipefail
bundle config set frozen 'true'
bin/bundle install --path=.bundle
bundle install --path=.bundle
- save_cache:
key: bundler-cache-{{ checksum ".ruby-version" }}-{{ checksum "Gemfile.lock" }}
paths:
- .bundle
yarn_install:
description: 'Performs node module installation, relying on the CircleCI cache for performance'
description: 'Perform node module installation, relying on CircleCI cache for performance'
steps:
- restore_cache:
keys:
- node-cache-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
- run:
name: 'Yarn Modules Install'
name: 'Yarn install'
command: bin/yarn install
- save_cache:
key: node-cache-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
paths:
- node_modules
rubocop:
description: 'Runs Rubocop'
run_rubocop:
description: 'Run rubocop'
steps:
- restore_cache:
keys:
- bundler-cache-{{ checksum ".ruby-version" }}-{{ checksum "Gemfile.lock" }}
- run:
name: Rubocop
name: 'Run rubocop'
command: |
set -euxo pipefail
bundle config path .bundle
bundle config path .bundle
bundle exec rubocop
rspec_tests:
description: 'Run the RSpec test suite'
rspec_backend:
description: 'Run rspec backend specs'
steps:
- restore_cache:
keys:
Expand All @@ -54,83 +52,126 @@ commands:
keys:
- node-cache-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
- run:
name: 'Run the RSpec Test Suite'
name: 'Run rspec backend specs'
command: |
set -euxo pipefail
bundle config path .bundle
bundle exec rails db:create
bundle exec rspec --format progress --format RspecJunitFormatter -o ~/rspec/rspec.xml
yarn_tests:
description: 'Run the Mocha test suite'
bundle exec rspec --format progress --format RspecJunitFormatter -o /tmp/rspec_backend/rspec.xml
mocha_specs:
description: 'Run mocha specs'
steps:
- restore_cache:
keys:
- node-cache-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
- run:
name: 'Run the Mocha Test Suite'
name: 'Run mocha specs'
command: yarn test --reporter mocha-junit-reporter
environment:
MOCHA_FILE: test/test-results.xml
MOCHA_FILE: /tmp/frontend/test-results.xml
rspec_system:
description: 'Run rspec system specs'
steps:
- restore_cache:
keys:
- bundler-cache-{{ checksum ".ruby-version" }}-{{ checksum "Gemfile.lock" }}
- restore_cache:
keys:
- node-cache-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
- run:
name: 'Run rspec system specs'
command: |
set -euxo pipefail
bundle config path .bundle
bundle exec rails db:create
bundle exec rails webpacker:compile
bundle exec rspec --format progress --format RspecJunitFormatter -o /tmp/rspec_system/rspec.xml spec/system
app_image: &app_image
image: circleci/ruby:2.7.2-node-browsers
db_image: &db_image
image: circleci/postgres:latest

jobs:
bundle:
docker:
- <<: *docker_image
- <<: *app_image
steps:
- checkout
- bundle_install
node_modules:
yarn:
docker:
- <<: *docker_image
- <<: *app_image
steps:
- checkout
- yarn_install
rubocop:
docker:
- <<: *docker_image
- <<: *app_image
steps:
- checkout
- rubocop
ruby_tests:
- run_rubocop
backend_specs:
docker:
- <<: *docker_image
- <<: *app_image
environment:
RAILS_ENV: test
POSTGRES_HOST: 127.0.0.1
- image: circleci/postgres:latest
- <<: *db_image
environment:
POSTGRES_USER: circleci
POSTGRES_DB: mutualaid_test
POSTGRES_HOST_AUTH_METHOD: trust
steps:
- checkout
- rspec_tests
- rspec_backend
- store_test_results:
path: ~/rspec
js_tests:
path: /tmp/rspec_backend
frontend_specs:
docker:
- <<: *docker_image
- <<: *app_image
steps:
- checkout
- yarn_tests
- mocha_specs
- store_test_results:
path: test
path: /tmp/frontend
- store_artifacts:
path: test
path: /tmp/frontend
system_specs:
docker:
- <<: *app_image
environment:
RAILS_ENV: test
POSTGRES_HOST: 127.0.0.1
HEADLESS_CHROME: true
- <<: *db_image
environment:
POSTGRES_USER: circleci
POSTGRES_DB: mutualaid_test
POSTGRES_HOST_AUTH_METHOD: trust
steps:
- checkout
- rspec_system
- store_test_results:
path: /tmp/rspec_system

workflows:
version: 2.1
mutual_aid:
jobs:
- bundle
- node_modules
- yarn
- rubocop:
requires:
- bundle
- ruby_tests:
- backend_specs:
requires:
- bundle
- node_modules
- js_tests:
- yarn
- frontend_specs:
requires:
- node_modules
- yarn
- system_specs:
requires:
- bundle
- yarn

0 comments on commit a86e007

Please sign in to comment.