version: 2.1 orbs: browser-tools: circleci/browser-tools@1.2.5 node: circleci/node@5.0.2 commands: install_dependencies: steps: - run: gem install bundler -v '2.3.18' - restore_cache: keys: - pul_rails_template-{{ checksum "Gemfile.lock" }} - run: bundle install --path ./vendor/bundle - save_cache: key: pul_rails_template-{{ checksum "Gemfile.lock" }} paths: - ./vendor/bundle - restore_cache: name: Restore Yarn Package Cache key: pul_rails_template-yarn-{{ checksum "yarn.lock" }} - run: name: Install NPM Dependencies via Yarn command: yarn install --frozen-lockfile - save_cache: name: Save Yarn Package Cache key: pul_rails_template-yarn-{{ checksum "yarn.lock" }} paths: - ~/.cache/yarn jobs: build: working_directory: ~/pul_rails_template docker: - image: cimg/ruby:3.1.0-browsers environment: RAILS_ENV: test steps: - browser-tools/install-browser-tools - run: name: remove errant LICENSE file command: rm LICENSE.chromedriver - checkout - node/install: install-yarn: true node-version: '16.15.0' - run: sudo apt update && sudo apt install postgresql-client - install_dependencies - persist_to_workspace: root: '~/pul_rails_template' paths: '*' rubocop: working_directory: ~/pul_rails_template docker: - image: cimg/ruby:3.1.0-browsers environment: RAILS_ENV: test steps: - attach_workspace: at: '~/pul_rails_template' - install_dependencies - run: name: Run rubocop command: bundle exec rubocop test: working_directory: ~/pul_rails_template docker: - image: cimg/ruby:3.1.0-browsers environment: RAILS_ENV: test - image: postgres:10.6-alpine environment: POSTGRES_USER: pul_rails_template_user POSTGRES_DB: test_db POSTGRES_HOST_AUTH_METHOD: trust steps: - browser-tools/install-browser-tools - attach_workspace: at: '~/pul_rails_template' - install_dependencies - run: name: Wait for PostgreSQL command: dockerize -wait tcp://localhost:5432 -timeout 1m - run: bundle exec rake db:create - run: bundle exec rake db:migrate - run: bundle exec rake db:migrate RAILS_ENV=test - run: name: Run Rspec command: bundle exec rspec - store_artifacts: path: coverage workflows: version: 2 build_accept_deploy: jobs: - build - test: requires: - build - rubocop: requires: - build