Skip to content

Commit

Permalink
Refractor CI, Add Rails 7.1 to CI
Browse files Browse the repository at this point in the history
  • Loading branch information
westonganger committed Oct 17, 2023
1 parent 01c4c64 commit 74bfc7c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 41 deletions.
57 changes: 25 additions & 32 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,43 @@
name: Tests

on:
push:
branches:
- master
branches: ['master']
pull_request:
branches:
- '*'

jobs:
test_sqlite:
runs-on: ubuntu-20.04
test:
runs-on: ubuntu-latest

env:
RAILS_ENV: test

strategy:
fail-fast: false
matrix:
include:
### TEST ALL RUBY VERSIONS, USE DEFAULT GEMFILE
- ruby: 2.5
- ruby: 2.6
- ruby: 2.7
- ruby: "3.0" ### must be quoted otherwise will be treated as "3" which will resolve to latest 3.x version
- ruby: 3.1
- ruby: 3.2

### RAILS VERSION TESTING
- ruby: 2.6
env:
RAILS_VERSION: "5.0"
- ruby: 2.6
env:
RAILS_VERSION: "5.1"
- ruby: 2.6
### TEST RUBY VERSIONS
- ruby: "2.5"
- ruby: "2.6"
- ruby: "2.7"
- ruby: "3.0"
- ruby: "3.1"
- ruby: "3.2"
### TEST RAILS VERSIONS
- ruby: "2.6"
env:
RAILS_VERSION: "5.2"
- ruby: 2.6
- ruby: "2.6"
env:
RAILS_VERSION: "6.0"
- ruby: 2.6
- ruby: "2.6"
env:
RAILS_VERSION: "6.1"
- ruby: "3.1"
- ruby: "3.2"
env:
RAILS_VERSION: "7.0"

env:
BUNDLE_GEMFILE: "${{ matrix.gemfile }}"
DB_GEM: "sqlite3"
- ruby: "3.2"
env:
RAILS_VERSION: "7.1"

steps:
- uses: actions/checkout@v3
Expand All @@ -54,10 +46,11 @@ jobs:
uses: ruby/setup-ruby@v1
with:
ruby-version: "${{ matrix.ruby }}"
bundler-cache: true
bundler-cache: false ### not compatible with ENV-style Gemfile

- name: Run tests
- name: Run test
run: |
bundle install
bundle exec rake db:create
bundle exec rake db:migrate
bundle exec rake test
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
log/*.log
pkg/
spec/dummy/db/*.sqlite3
spec/dummy/db/*.sqlite3-journal
spec/dummy/db/*.sqlite3*
spec/dummy/log/*.log
spec/dummy/storage/
spec/dummy/tmp/
Expand Down
8 changes: 5 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ gemspec
# Git. Remember to move these dependencies to your gemspec before releasing
# your gem to rubygems.org.

ENV['DB_GEM'] ||= 'sqlite3'
def get_env(name)
(ENV[name] && !ENV[name].empty?) ? ENV[name] : nil
end

gem 'rails', ENV["RAILS_VERSION"]
gem ENV['DB_GEM']
gem "rails", get_env("RAILS_VERSION")
gem "sqlite3"

group :development, :test do
gem "sprockets-rails" ### just for dummy app
Expand Down
10 changes: 5 additions & 5 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ load 'rails/tasks/statistics.rake'

require 'bundler/gem_tasks'

task :test do
system("rspec", out: STDOUT)
exit $?.exitstatus
end
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)

task test: [:spec]

task default: :test
task default: [:spec]

0 comments on commit 74bfc7c

Please sign in to comment.