Skip to content

Commit

Permalink
Add code coverage (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
baldarn authored Sep 14, 2024
1 parent 24cbc12 commit fb778d6
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 29 deletions.
29 changes: 1 addition & 28 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,34 +32,7 @@ jobs:
- name: Set up database schema
run: bin/rails db:schema:load
- name: Run tests
run: bin/rails test

system-tests:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16.4-alpine
ports:
- "5432:5432"
env:
POSTGRES_DB: opengas_test
POSTGRES_USER: opengas
POSTGRES_PASSWORD: opengas
env:
RAILS_ENV: test
DATABASE_URL: "postgres://opengas:opengas@localhost:5432/opengas_test"
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Ruby and gems
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3.5
bundler-cache: true
- name: Set up database schema
run: bin/rails db:schema:load
- name: Run tests
run: bin/rails test:system
run: bin/rails test:all

lint:
runs-on: ubuntu-latest
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,9 @@
/app/assets/builds/*
!/app/assets/builds/.keep

# coverage
/coverage/*
!/coverage
!/coverage/.keep

.DS_Store
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,5 @@ end
group :test do
gem 'capybara'
gem 'selenium-webdriver'
gem 'simplecov', require: false
end
8 changes: 8 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ GEM
warden (~> 1.2.3)
devise-i18n (1.12.1)
devise (>= 4.9.0)
docile (1.4.1)
dotenv (2.8.1)
dotenv-rails (2.8.1)
dotenv (= 2.8.1)
Expand Down Expand Up @@ -419,6 +420,12 @@ GEM
simple_form (5.3.1)
actionpack (>= 5.2)
activemodel (>= 5.2)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.13.1)
simplecov_json_formatter (0.1.4)
solid_queue (0.5.0)
activejob (>= 7.1)
activerecord (>= 7.1)
Expand Down Expand Up @@ -539,6 +546,7 @@ DEPENDENCIES
selenium-webdriver
simple_calendar
simple_form (~> 5.3)
simplecov
solid_queue (~> 0.5.0)
sprockets-rails
sqlite3 (~> 1.4)
Expand Down
2 changes: 1 addition & 1 deletion config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# this is usually not necessary, and can slow down your test suite. However, it's
# recommended that you enable it in continuous integration systems to ensure eager
# loading is working properly before deploying your code.
config.eager_load = ENV['CI'].present?
config.eager_load = true

# Configure public file server for tests with Cache-Control for performance.
config.public_file_server.headers = { 'Cache-Control' => "public, max-age=#{1.hour.to_i}" }
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# frozen_string_literal: true

require 'simplecov'
SimpleCov.start

ENV['RAILS_ENV'] ||= 'test'
require_relative '../config/environment'
require 'rails/test_help'
Expand Down

0 comments on commit fb778d6

Please sign in to comment.