diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..83e36ca --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,65 @@ +version: 2.1 + +orbs: + ruby: circleci/ruby@1.8.0 + +executors: + ruby: + docker: + - image: cimg/ruby:3.0.0 + environment: + RAILS_ENV: test + ruby_and_postgres: + docker: + - image: cimg/ruby:3.0.0 + environment: + RAILS_ENV: test + DATABASE_HOST: localhost + - image: cimg/postgres:14.4 + environment: + POSTGRES_USER: postgres + POSTGRES_HOST_AUTH_METHOD: trust + +jobs: + build: + executor: ruby + steps: + - checkout + - ruby/install-deps: + key: gems-{{ checksum "Gemfile.lock" }} + - persist_to_workspace: + root: . + paths: . + tests: + parallelism: 4 + executor: ruby_and_postgres + steps: + - attach_workspace: + at: . + - run: bundle exec rails db:setup + - ruby/rspec-test + # does not check coverage because of parallelism + static_analysis: + parallelism: 4 + executor: ruby + steps: + - attach_workspace: + at: . + - ruby/rubocop-check: + parallel: true + - run: bundle exec brakeman -z + - run: gem install bundle-audit + - run: bundle-audit update + - run: bundle-audit + +workflows: + version: 2 + ci_workflow: + jobs: + - build + - tests: + requires: + - build + - static_analysis: + requires: + - build diff --git a/Gemfile b/Gemfile index c3c4d15..c2a99be 100644 --- a/Gemfile +++ b/Gemfile @@ -47,6 +47,7 @@ group :development do end group :test do + gem 'rspec_junit_formatter' gem 'rspec-sidekiq' gem 'simplecov', require: false gem 'timecop' diff --git a/Gemfile.lock b/Gemfile.lock index 192554d..954cb15 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -191,6 +191,8 @@ GEM rspec-core (~> 3.0, >= 3.0.0) sidekiq (>= 2.4.0) rspec-support (3.10.2) + rspec_junit_formatter (0.5.1) + rspec-core (>= 2, < 4, != 2.12.0) rubocop (1.31.2) json (~> 2.3) parallel (~> 1.10) @@ -266,6 +268,7 @@ DEPENDENCIES rails (~> 6.1.4, >= 6.1.4.1) rspec-rails rspec-sidekiq + rspec_junit_formatter rubocop rubocop-rails rubocop-rspec diff --git a/README.md b/README.md index ab88790..a3c39b6 100644 --- a/README.md +++ b/README.md @@ -53,10 +53,9 @@ After cloning secret_key_base: ``` -- Example of command for db since pgsql is a badly made as rvm: +- Example of command for db: - `sudo -u postgres psql` - `create user the_simple_api with password 'password';` - - `alter role the_simple_api superuser createrole createdb replication;` - `create database the_simple_api_production owner the_simple_api;` @@ -69,7 +68,7 @@ After cloning to place both in `/etc/nginx/sites-available/`. Templates are available in `external_files` folders. - Passenger is [installed](https://www.phusionpassenger.com/docs/advanced_guides/install_and_upgrade/nginx/install/oss/focal.html) -- Redis is [installed](https://redis.io/docs/getting-started/installation/install-redis-on-linux/) +- Redis is [installed](https://redis.io/docs/getting-started/installation/install-redis-on-linux/) + `sudo systemctl enable redis-server` + `sudo systemctl start redis-server` ## Make it work - `export production_server_ip="120.120.120.120"`