Skip to content

Commit

Permalink
Use RSpec and GitHub Actions
Browse files Browse the repository at this point in the history
Fix Purple-Devs#138

As of 2024, [using Travis CI to build OSS requires contacting them to request a monthly allocation of credits](https://docs.travis-ci.com/user/billing-faq/#what-if-i-am-building-open-source), making the process more cumbersome. To simplify this, I migrated from Travis CI to GitHub Actions.

I converted the [test coverage previously created with shell scripts](https://github.com/Purple-Devs/health_check/blob/53ae042bf0cc69b1d8d7b1b47e2296303b0a591c/test/test_with_railsapp) to RSpec's Request Spec. Health checks for services like s3 and sidekiq were not included in the original tests, so they are not part of this commit. Additionally, redundant development gems and configuration for the test application that seemed unnecessary were removed to avoid noise.

I created a test matrix covering Ruby versions 2.4 to 3.3 and Rails versions 5.1 to 7.2, ensuring all tests pass.

You can also run the tests locally as follows:
  • Loading branch information
willnet committed Nov 8, 2024
1 parent 53ae042 commit d00b366
Show file tree
Hide file tree
Showing 49 changed files with 579 additions and 2,120 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: CI
on:
push:
pull_request:

jobs:
test:
runs-on: ubuntu-20.04

strategy:
matrix:
include:
- { ruby: '2.2', gemfile: './gemfiles/rails_5.0.gemfile', middleware: 'true' }
- { ruby: '2.2', gemfile: './gemfiles/rails_5.0.gemfile', middleware: 'false' }
- { ruby: '2.3', gemfile: './gemfiles/rails_5.0.gemfile', middleware: 'true' }
- { ruby: '2.3', gemfile: './gemfiles/rails_5.0.gemfile', middleware: 'false' }
- { ruby: '2.2', gemfile: './gemfiles/rails_5.1.gemfile', middleware: 'true' }
- { ruby: '2.2', gemfile: './gemfiles/rails_5.1.gemfile', middleware: 'false' }
- { ruby: '2.3', gemfile: './gemfiles/rails_5.1.gemfile', middleware: 'true' }
- { ruby: '2.3', gemfile: './gemfiles/rails_5.1.gemfile', middleware: 'false' }
- { ruby: '2.4', gemfile: './gemfiles/rails_5.1.gemfile', middleware: 'true' }
- { ruby: '2.4', gemfile: './gemfiles/rails_5.1.gemfile', middleware: 'false' }
- { ruby: '2.5', gemfile: './gemfiles/rails_6.0.gemfile', middleware: 'true' }
- { ruby: '2.5', gemfile: './gemfiles/rails_6.0.gemfile', middleware: 'false' }
- { ruby: '2.6', gemfile: './gemfiles/rails_6.0.gemfile', middleware: 'true' }
- { ruby: '2.6', gemfile: './gemfiles/rails_6.0.gemfile', middleware: 'false' }
- { ruby: '2.5', gemfile: './gemfiles/rails_6.1.gemfile', middleware: 'true' }
- { ruby: '2.5', gemfile: './gemfiles/rails_6.1.gemfile', middleware: 'false' }
- { ruby: '2.6', gemfile: './gemfiles/rails_6.1.gemfile', middleware: 'true' }
- { ruby: '2.6', gemfile: './gemfiles/rails_6.1.gemfile', middleware: 'false' }
- { ruby: '2.7', gemfile: './gemfiles/rails_6.1.gemfile', middleware: 'true' }
- { ruby: '2.7', gemfile: './gemfiles/rails_6.1.gemfile', middleware: 'false' }
- { ruby: '3.0', gemfile: './gemfiles/rails_6.1.gemfile', middleware: 'true' }
- { ruby: '3.0', gemfile: './gemfiles/rails_6.1.gemfile', middleware: 'false' }
- { ruby: '2.7', gemfile: './gemfiles/rails_7.0.gemfile', middleware: 'true' }
- { ruby: '2.7', gemfile: './gemfiles/rails_7.0.gemfile', middleware: 'false' }
- { ruby: '3.0', gemfile: './gemfiles/rails_7.0.gemfile', middleware: 'true' }
- { ruby: '3.0', gemfile: './gemfiles/rails_7.0.gemfile', middleware: 'false' }
- { ruby: '3.1', gemfile: './gemfiles/rails_7.0.gemfile', middleware: 'true' }
- { ruby: '3.1', gemfile: './gemfiles/rails_7.0.gemfile', middleware: 'false' }
- { ruby: '2.7', gemfile: './gemfiles/rails_7.1.gemfile', middleware: 'true' }
- { ruby: '2.7', gemfile: './gemfiles/rails_7.1.gemfile', middleware: 'false' }
- { ruby: '3.0', gemfile: './gemfiles/rails_7.1.gemfile', middleware: 'true' }
- { ruby: '3.0', gemfile: './gemfiles/rails_7.1.gemfile', middleware: 'false' }
- { ruby: '3.1', gemfile: './gemfiles/rails_7.1.gemfile', middleware: 'true' }
- { ruby: '3.1', gemfile: './gemfiles/rails_7.1.gemfile', middleware: 'false' }
- { ruby: '3.2', gemfile: './gemfiles/rails_7.1.gemfile', middleware: 'true' }
- { ruby: '3.2', gemfile: './gemfiles/rails_7.1.gemfile', middleware: 'false' }
- { ruby: '3.3', gemfile: './gemfiles/rails_7.1.gemfile', middleware: 'true' }
- { ruby: '3.3', gemfile: './gemfiles/rails_7.1.gemfile', middleware: 'false' }
- { ruby: '3.1', gemfile: './gemfiles/rails_7.2.gemfile', middleware: 'true' }
- { ruby: '3.1', gemfile: './gemfiles/rails_7.2.gemfile', middleware: 'false' }
- { ruby: '3.2', gemfile: './gemfiles/rails_7.2.gemfile', middleware: 'true' }
- { ruby: '3.2', gemfile: './gemfiles/rails_7.2.gemfile', middleware: 'false' }
- { ruby: '3.3', gemfile: './gemfiles/rails_7.2.gemfile', middleware: 'true' }
- { ruby: '3.3', gemfile: './gemfiles/rails_7.2.gemfile', middleware: 'false' }
env:
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
MIDDLEWARE: ${{ matrix.middleware }}
steps:
- uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- name: Run tests
run: bundle exec rake
14 changes: 8 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,21 @@ lib/bundler/man
pkg
rdoc
spec/reports
test/tmp
test/version_tmp
tmp
spec/dummy/db/*.sqlite3*
spec/dummy/log/*
.ruby-version

## PROJECT::SPECIFIC
bin/
test/bin/
railsapps/
test/*.gemfile.lock
gemfiles/*.gemfile.lock
,*
.vagrant
ubuntu*console.log

tmp
# See: https://gist.github.com/ianheggie/9327010
# for Global git ignore for OS/IDE/temp/backup files

spec/dummy/tmp/*
!spec/dummy/tmp/.keep
spec/dummy/db/*.sqlite3
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--require spec_helper
218 changes: 0 additions & 218 deletions .travis.yml

This file was deleted.

15 changes: 0 additions & 15 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,3 @@ source 'https://rubygems.org'
# Specify your gem's dependencies in health_check.gemspec

gemspec

group :development, :test do
if defined?(JRUBY_VERSION)
gem 'jruby-openssl'
gem 'activerecord-jdbcsqlite3-adapter'
else
gem 'sqlite3', '~> 1.3.7'
end
# run travis-lint to check .travis.yml
gem 'travis-lint'
# mime-types 2.0 requires Ruby version >= 1.9.2
# mime-types 3.0 requires Ruby version >= 2.0
gem 'mime-types', defined?(JRUBY_VERSION) || RUBY_VERSION < '2.0' ? '< 3' : '>= 3.0'

end
5 changes: 2 additions & 3 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,11 @@ To change the configuration of health_check, create a file `config/initializers/
config.on_failure do |checks, msg|
# log msg somewhere
end

config.on_success do |checks|
# flag that everything is well
end


end

Expand Down Expand Up @@ -292,7 +292,6 @@ Last-modified is set to the current time (rounded down to a multiple of max_age
=== Automated testing and other checks

* {<img src="https://badge.fury.io/rb/health_check.svg" alt="Gem Version" />}[http://badge.fury.io/rb/health_check] - Latest Gem
* {<img src="https://travis-ci.org/ianheggie/health_check.svg">}[https://travis-ci.org/ianheggie/health_check] - Travis CI
* {<img src="https://codeclimate.com/github/ianheggie/health_check.svg" />}[https://codeclimate.com/github/ianheggie/health_check] - Code quality
* {<img src="https://gemnasium.com/ianheggie/health_check.svg">}[https://gemnasium.com/ianheggie/health_check] - Gem dependencies

Expand Down
9 changes: 4 additions & 5 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ require "bundler/gem_tasks"
#require 'rubygems'
require 'rake'

#tests as gem
task :test do
exec '/bin/bash', './test/test_with_railsapp'
end
require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new(:spec)

task default: :test
task :default => :spec

begin
gem 'rdoc'
Expand Down
Loading

0 comments on commit d00b366

Please sign in to comment.