diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 192c66eb..3c9e696c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,8 +17,8 @@ jobs: - name: Setup Node uses: actions/setup-node@v3 with: - cache: 'yarn' - node-version-file: '.node-version' + cache: "yarn" + node-version-file: ".node-version" - name: Install Yarn packages run: yarn install --check-files --pure-lockfile @@ -52,7 +52,7 @@ jobs: services: postgres: image: postgres:14.2 - ports: ['5432:5432'] + ports: ["5432:5432"] env: POSTGRES_DB: app_test POSTGRES_USER: postgres @@ -70,18 +70,34 @@ jobs: - name: Install postgres client run: sudo apt-get install libpq-dev + - name: Install Ruby dependencies + run: bundle install + - name: Setup Node uses: actions/setup-node@v3 with: - cache: 'yarn' - node-version-file: '.node-version' + cache: "yarn" + node-version-file: ".node-version" - name: Install Yarn packages run: yarn install --check-files --pure-lockfile + - name: Clean up coverage cache + run: rm -rf coverage/ + + - name: Ensure coverage directory exists + run: mkdir -p coverage + - name: Create database structure run: RAILS_ENV=test bin/rails db:create db:migrate + - name: Wait for PostgreSQL to be ready + run: | + until pg_isready -h localhost -p 5432; do + echo "Waiting for PostgreSQL..." + sleep 2 + done + - name: Configure sysctl limits run: | sudo swapoff -a @@ -89,6 +105,5 @@ jobs: sudo sysctl -w fs.file-max=262144 sudo sysctl -w vm.max_map_count=262144 - - name: Run tests + - name: Run tests and check coverage run: bundle exec rspec - # run: bundle exec bin/rspec spec --format progress -P ./*/**/*_spec.rb diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 524c7586..2b15725a 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -7,7 +7,7 @@ # Prevent database truncation if the environment is production abort("The Rails environment is running in production mode!") if Rails.env.production? require "rspec/rails" - +Rails.application.eager_load! require "pundit/matchers" # Add additional requires below this line. Rails is not loaded until this point! diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 677d7436..ae230f88 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true - +require_relative "support/simplecov.rb" require "sidekiq" # This file was generated by the `rails generate rspec:install` command. Conventionally, all diff --git a/spec/support/simplecov.rb b/spec/support/simplecov.rb index c0f8dc1c..030f9f2b 100644 --- a/spec/support/simplecov.rb +++ b/spec/support/simplecov.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - require "simplecov" SimpleCov.start do @@ -12,6 +10,9 @@ add_filter "config" add_filter %r{^/spec/} add_filter "app/channels" + add_filter "app/dashboards" + + minimum_coverage 100 end SimpleCov.at_exit do