.circleci/config.yml
version: 2.1
orbs:
ruby: circleci/ruby@2.1.4
jobs:
test-ruby:
# Install gems, run rspec tests
docker:
- image: cimg/ruby:3.3.5-node
- image: cimg/postgres:16.2
environment:
POSTGRES_PASSWORD: password
environment:
RAILS_ENV: test
CC_TEST_REPORTER_ID: d2b52300c4073f6cb8eb32d429322cc92e44c8133e6d43cab6d8d7d001d0ddd0
DATABASE_URL: postgres://postgres:postgres@localhost:5432/cipherswarm_test
CI: true
steps:
- checkout
- ruby/install-deps
# Wait for postgres
- run:
name: Wait for postgres
command: dockerize -wait tcp://localhost:5432 -timeout 1m
- run:
name: Setup Database
command: bundle exec rake db:setup --trace
# Rails setup
- run:
name: Install yarn packages
command: yarn install
- run:
name: Precompile assets
command: bundle exec rake assets:precompile
- run:
name: Run Rails Setup
command: bin/setup
# Rubocop
- ruby/rubocop-check
# Brakeman
- run:
name: Run Brakeman
command: bundle exec brakeman
# Rspec
- run:
name: Setup Code Climate Test Reporter
command: |
mkdir -p tmp/
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./tmp/cc-test-reporter
chmod +x ./tmp/cc-test-reporter
./tmp/cc-test-reporter before-build
- run:
name: Run RSpec
command: |
bundle exec rspec --profile 10 \
--format RspecJunitFormatter \
--out /tmp/test-results/rspec.xml \
--format progress \
$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
when: always
- store_test_results:
path: /tmp/test-results
- store_artifacts:
path: /tmp/test-results
destination: test-results
- run:
name: Upload coverage results to Code Climate
command: |
./tmp/cc-test-reporter format-coverage -t simplecov $CIRCLE_ARTIFACTS/coverage/.resultset.json
./tmp/cc-test-reporter upload-coverage
workflows:
build-and-test:
jobs:
- test-ruby