Skip to content
29 changes: 22 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -70,25 +70,40 @@ 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
sudo sysctl -w vm.swappiness=1
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
2 changes: 1 addition & 1 deletion spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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!

Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 3 additions & 2 deletions spec/support/simplecov.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

require "simplecov"

SimpleCov.start do
Expand All @@ -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
Expand Down
Loading