.circleci/config.yml
version: 2.1
executors:
ruby:
docker:
- image: cimg/ruby:3.1.2-browsers
environment:
PGHOST: 127.0.0.1
PGUSER: postgres
PGPASS: postgres
RAILS_ENV: test
CC_TEST_REPORTER_ID: 06b784c7df61a8978ec796c2acbbf9c686eb701e336fba3900b997427b06076b
- image: cimg/postgres:12.12
environment:
POSTGRES_DB: pg_rails_test
# POSTGRES_USER: pg_rails
# POSTGRES_PASSWORD: grafitis
- image: cimg/redis:7.0
commands:
bundle_install:
description: Install Ruby dependencies with Bundler
steps:
- restore_cache:
keys:
- bundle-v1-{{ arch }}-{{ checksum ".ruby-version" }}-{{ checksum "Gemfile.lock" }}
- bundle-v1-{{ arch }}-{{ checksum ".ruby-version" }}-
- run: sudo apt-get --allow-releaseinfo-change update && sudo apt-get install -y libmagic-dev # libmagic (requerido por carrierwave-magic)
- run: sudo apt-get install -y poppler-utils # requerido por PdfPreviewGenerator, para el binario pdftoppm
# TODO: ver qué onda, si se puede evitar, pesa 250mbbbb
# - run: sudo apt-get install -y ruby-vips # requerido por image_processing
- run:
name: Install Ruby Dependencies
command: |
gem install bundler -v 2.4.22 --conservative --no-document
gem install slim_lint ruby-lint
bundle config --local deployment true
bundle config --local path vendor/bundle
bundle config --local without production
bundle check || (bundle install --jobs=4 --retry=3 && bundle clean)
- save_cache:
paths:
- ./vendor/bundle
key: bundle-v1-{{ arch }}-{{ checksum ".ruby-version" }}-{{ checksum "Gemfile.lock" }}
set_up_database:
steps:
- run:
name: Set Up Database
command: |
bundle exec rails db:schema:load
orbs:
browser-tools: circleci/browser-tools@1.4
node: circleci/node@5.2.0
jobs:
static_analysis:
executor: ruby
steps:
- node/install:
install-yarn: true
node-version: '20.11.0'
- checkout
- bundle_install
- run: yarn install
- run:
name: Run Overcommit
command: |
gem install overcommit
git config --local user.name "Circle CI"
git config --local user.email ci@example.com
overcommit --sign
overcommit --run
- run:
name: Run Security Audits
command: |
bundle exec brakeman -q --no-summary --skip-files node_modules/ --force
# interactive: bundle exec brakeman -q --no-summary --skip-files node_modules/ -I --force
# bundle exec bundle-audit check --update -v
test:
executor: ruby
steps:
- node/install:
install-yarn: true
node-version: '20.11.0'
- browser-tools/install-browser-tools
- checkout
- bundle_install
- set_up_database
- run:
command: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
- run:
name: Run tests
command: |
./cc-test-reporter before-build
bundle exec rake test_prepare
./cc-test-reporter after-build --coverage-input-type simplecov --exit-code $?
workflows:
build-test:
jobs:
- static_analysis
- test:
requires:
- static_analysis