diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml new file mode 100644 index 0000000..9cc856c --- /dev/null +++ b/.github/workflows/ruby.yml @@ -0,0 +1,66 @@ +name: Ruby + +on: + push: + branches: [ master ] + pull_request: {} + +env: + DATABASE_URL: postgres://postgres:test@127.0.0.1:5432/test + BASE_URL: localhost:3000 + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.3.5 + bundler-cache: true + - name: Run rubocop + run: bundle exec rubocop + + security: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.3.5 + bundler-cache: true + - name: bundler-audit + run: bundle exec bundle audit check --update + - name: Brakeman + run: bundle exec brakeman + + test: + runs-on: ubuntu-latest + services: + postgres: + image: postgres + ports: + - 5432:5432 + env: + POSTGRES_PASSWORD: test + steps: + - name: Check out code + uses: actions/checkout@v4 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.3.5 + bundler-cache: true + - name: Create database + run: bundle exec bin/rails db:create db:migrate RAILS_ENV=test + - name: Run tests + run: bundle exec rails test:prepare && bundle exec rails test && bundle exec rspec + - name: SimpleCov+ Action + uses: joshmfrankel/simplecov-check-action@main + with: + minimum_suite_coverage: 100 + github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/Gemfile b/Gemfile index cf68724..cb3662e 100644 --- a/Gemfile +++ b/Gemfile @@ -65,7 +65,8 @@ group :development, :test do gem 'pry-rails', '~> 0.3.9' gem 'rspec-rails' gem 'rspec_api_documentation', '~> 6.1' - gem 'simplecov', '~> 0.17.1', require: false + gem 'simplecov', require: false + gem 'simplecov-json', require: false gem 'faker', '~> 2.7' end diff --git a/Gemfile.lock b/Gemfile.lock index 1f7bb8f..051daa3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -374,11 +374,15 @@ GEM connection_pool (>= 2.2.5, < 3) rack (~> 2.0) redis (>= 4.5.0, < 5) - simplecov (0.17.1) + simplecov (0.22.0) docile (~> 1.1) - json (>= 1.8, < 3) - simplecov-html (~> 0.10.0) - simplecov-html (0.10.2) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.13.1) + simplecov-json (0.2.3) + json + simplecov + simplecov_json_formatter (0.1.4) sprockets (4.2.1) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) @@ -445,7 +449,8 @@ DEPENDENCIES rubocop-rails rubocop-rspec sidekiq (~> 6.2) - simplecov (~> 0.17.1) + simplecov + simplecov-json sprockets-rails state_machines-activerecord (~> 0.6.0) tzinfo-data diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index abc2739..de1521b 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -1,6 +1,15 @@ # frozen_string_literal: true require 'simplecov' +require 'simplecov-json' + +SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new( + [ + SimpleCov::Formatter::HTMLFormatter, + SimpleCov::Formatter::JSONFormatter + ] +) + SimpleCov.start :rails do add_filter '/channels/' add_filter '/controllers/application_controller.rb'