Skip to content

Commit

Permalink
Switch to GitHub Actions for Continuous Integration (globalize#742)
Browse files Browse the repository at this point in the history
This covers all the same stuff as before, but inside GitHub,
which allows us to see build status much more quickly.
  • Loading branch information
parndt authored Dec 10, 2019
1 parent 22c298d commit ca17b20
Show file tree
Hide file tree
Showing 12 changed files with 105 additions and 61 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: CI

on: [ push ]
jobs:
test:
strategy:
matrix:
architecture: [ x64 ]
database: [ mysql, postgresql, sqlite3 ]
gemfile: [ '5.2.1', '5.1.6', '4.2.10' ]
ruby: [ '2.6.x', '2.5.x', '2.4.x' ]
fail-fast: false
max-parallel: 20
runs-on: ubuntu-latest
name: ${{ matrix.ruby }} ${{ matrix.database }} rails-${{ matrix.gemfile }}
steps:
- uses: actions/[email protected]
with:
architecture: ${{ matrix.architecture }}
ruby-version: ${{ matrix.ruby }}
version: ${{ matrix.ruby }}
- uses: actions/checkout@v1
- run: sudo apt-get update
- run: sudo apt-get install libpq-dev postgresql-client -y
if: matrix.database == 'postgresql'
- run: sudo apt-get install libmysqlclient-dev -y
if: matrix.database == 'mysql'
- run: sudo apt-get install libsqlite3-dev -y
if: matrix.database == 'sqlite3'
- id: cache-bundler
uses: actions/cache@v1
with:
path: gemfiles/vendor/bundle
key: ${{ matrix.ruby }}-gem-${{ hashFiles(format('gemfiles/Gemfile.rails-{0}.rb', matrix.gemfile)) }}
- run: gem install bundler
- run: bundle install --path vendor/bundle
- run: bundle exec rake db:create db:migrate
- run: bundle exec rake test

env:
BUNDLE_GEMFILE: gemfiles/Gemfile.rails-${{ matrix.gemfile }}.rb
BUNDLE_JOBS: 4
BUNDLE_PATH: vendor/bundle
CI: true
COVERALLS: true
DB: ${{ matrix.database }}
MYSQL_PASSWORD: root
PGHOST: localhost
PGPORT: 5432
PGUSER: postgres
RAILS_ENV: test

services:
postgres:
image: postgres:11.5
ports: ["5432:5432"]
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

32 changes: 0 additions & 32 deletions .travis.yml

This file was deleted.

6 changes: 3 additions & 3 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ RAILS_VERSIONS.each do |version|
end

platforms :jruby do
if !ENV['TRAVIS'] || ENV['DB'] == 'sqlite3'
if !ENV['CI'] || ENV['DB'] == 'sqlite3'
gem 'activerecord-jdbcsqlite3-adapter', '~> 1'
end

if !ENV['TRAVIS'] || ENV['DB'] == 'mysql'
if !ENV['CI'] || ENV['DB'] == 'mysql'
gem 'activerecord-jdbcmysql-adapter', '~> 1'
end

if !ENV['TRAVIS'] || %w(postgres postgresql).include?(ENV['DB'])
if !ENV['CI'] || %w(postgres postgresql).include?(ENV['DB'])
gem 'activerecord-jdbcpostgresql-adapter', '~> 1'
end
end
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Have a bug fix, code improvement or proposed feature? Do the following:

For pull requests to Rails/ActiveRecord 4 version of Globalize (v3.x), post to the `master` branch. For pull requests to the Rails/ActiveRecord 3.x version of Globalize (3.x), post to the `3-0-stable` branch.

When you submit the pull request, Travis CI will run the [test suite](https://travis-ci.org/globalize/globalize) against your branch and will highlight any failures. Unless there is a good reason for it, we do not generally accept pull requests that take Globalize from green to red.
When you submit the pull request, GitHub Actions will run the [test suite](https://github.com/globalize/globalize/actions) against your branch and will highlight any failures. Unless there is a good reason for it, we do not generally accept pull requests that take Globalize from green to red.

## Testing

Expand Down
17 changes: 17 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
source 'https://rubygems.org'

gemspec

# Database Configuration
if !ENV['CI'] || ENV['DB'] == 'sqlite3'
gem 'sqlite3', platforms: [:ruby, :rbx]
end

if !ENV['CI'] || ENV['DB'] == 'mysql'
group :mysql do
gem 'mysql2', platforms: [:ruby, :rbx]
end
end

if !ENV['CI'] || %w(postgres postgresql).include?(ENV['DB'])
group :postgres, :postgresql do
gem 'pg', '< 1.0', platforms: [:ruby, :rbx]
end
end
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![Globalize](http://globalize.github.io/globalize/images/globalize.png)

[![Build Status](https://travis-ci.org/globalize/globalize.svg?branch=master)](https://travis-ci.org/globalize/globalize) [![Code Climate](https://codeclimate.com/github/globalize/globalize.svg)](https://codeclimate.com/github/globalize/globalize)
[![Build Status](https://github.com/norman/friendly_id/workflows/CI/badge.svg)](https://github.com/globalize/globalize/actions) [![Code Climate](https://codeclimate.com/github/globalize/globalize.svg)](https://codeclimate.com/github/globalize/globalize)
[![Open Source Helpers](https://www.codetriage.com/globalize/globalize/badges/users.svg)](https://www.codetriage.com/globalize/globalize)

You can chat with us using Gitter:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
gem "activerecord", "4.2.10"

# Database Configuration
if !ENV['TRAVIS'] || ENV['DB'] == 'sqlite3'
if !ENV['CI'] || ENV['DB'] == 'sqlite3'
gem 'sqlite3', '~> 1.3.6', platforms: [:ruby, :rbx]
end

if !ENV['TRAVIS'] || ENV['DB'] == 'mysql'
if !ENV['CI'] || ENV['DB'] == 'mysql'
group :mysql do
gem 'mysql2', '0.4.10', platforms: [:ruby, :rbx]
end
end

if !ENV['TRAVIS'] || %w(postgres postgresql).include?(ENV['DB'])
if !ENV['CI'] || %w(postgres postgresql).include?(ENV['DB'])
group :postgres, :postgresql do
gem 'pg', '< 1.0', platforms: [:ruby, :rbx]
end
Expand All @@ -28,15 +28,15 @@
end

platforms :jruby do
if !ENV['TRAVIS'] || ENV['DB'] == 'sqlite3'
if !ENV['CI'] || ENV['DB'] == 'sqlite3'
gem 'activerecord-jdbcsqlite3-adapter', '~> 1'
end

if !ENV['TRAVIS'] || ENV['DB'] == 'mysql'
if !ENV['CI'] || ENV['DB'] == 'mysql'
gem 'activerecord-jdbcmysql-adapter', '~> 1'
end

if !ENV['TRAVIS'] || %w(postgres postgresql).include?(ENV['DB'])
if !ENV['CI'] || %w(postgres postgresql).include?(ENV['DB'])
gem 'activerecord-jdbcpostgresql-adapter', '~> 1'
end
end
Expand Down
12 changes: 6 additions & 6 deletions gemfiles/rails_5.1.6.gemfile → gemfiles/Gemfile.rails-5.1.6.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
gem "activerecord", "5.1.6"

# Database Configuration
if !ENV['TRAVIS'] || ENV['DB'] == 'sqlite3'
if !ENV['CI'] || ENV['DB'] == 'sqlite3'
gem 'sqlite3', '~> 1.3.6', platforms: [:ruby, :rbx]
end

if !ENV['TRAVIS'] || ENV['DB'] == 'mysql'
if !ENV['CI'] || ENV['DB'] == 'mysql'
group :mysql do
gem 'mysql2', platforms: [:ruby, :rbx]
end
end

if !ENV['TRAVIS'] || %w(postgres postgresql).include?(ENV['DB'])
if !ENV['CI'] || %w(postgres postgresql).include?(ENV['DB'])
group :postgres, :postgresql do
gem 'pg', '< 1.0', platforms: [:ruby, :rbx]
end
Expand All @@ -28,15 +28,15 @@
end

platforms :jruby do
if !ENV['TRAVIS'] || ENV['DB'] == 'sqlite3'
if !ENV['CI'] || ENV['DB'] == 'sqlite3'
gem 'activerecord-jdbcsqlite3-adapter', '~> 1'
end

if !ENV['TRAVIS'] || ENV['DB'] == 'mysql'
if !ENV['CI'] || ENV['DB'] == 'mysql'
gem 'activerecord-jdbcmysql-adapter', '~> 1'
end

if !ENV['TRAVIS'] || %w(postgres postgresql).include?(ENV['DB'])
if !ENV['CI'] || %w(postgres postgresql).include?(ENV['DB'])
gem 'activerecord-jdbcpostgresql-adapter', '~> 1'
end
end
Expand Down
12 changes: 6 additions & 6 deletions gemfiles/rails_5.2.1.gemfile → gemfiles/Gemfile.rails-5.2.1.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
gem "activerecord", "5.2.1"

# Database Configuration
if !ENV['TRAVIS'] || ENV['DB'] == 'sqlite3'
if !ENV['CI'] || ENV['DB'] == 'sqlite3'
gem 'sqlite3', '~> 1.3.6', platforms: [:ruby, :rbx]
end

if !ENV['TRAVIS'] || ENV['DB'] == 'mysql'
if !ENV['CI'] || ENV['DB'] == 'mysql'
group :mysql do
gem 'mysql2', platforms: [:ruby, :rbx]
end
end

if !ENV['TRAVIS'] || %w(postgres postgresql).include?(ENV['DB'])
if !ENV['CI'] || %w(postgres postgresql).include?(ENV['DB'])
group :postgres, :postgresql do
gem 'pg', '< 1.0', platforms: [:ruby, :rbx]
end
Expand All @@ -28,15 +28,15 @@
end

platforms :jruby do
if !ENV['TRAVIS'] || ENV['DB'] == 'sqlite3'
if !ENV['CI'] || ENV['DB'] == 'sqlite3'
gem 'activerecord-jdbcsqlite3-adapter', '~> 1'
end

if !ENV['TRAVIS'] || ENV['DB'] == 'mysql'
if !ENV['CI'] || ENV['DB'] == 'mysql'
gem 'activerecord-jdbcmysql-adapter', '~> 1'
end

if !ENV['TRAVIS'] || %w(postgres postgresql).include?(ENV['DB'])
if !ENV['CI'] || %w(postgres postgresql).include?(ENV['DB'])
gem 'activerecord-jdbcpostgresql-adapter', '~> 1'
end
end
Expand Down
1 change: 0 additions & 1 deletion globalize.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,4 @@ Gem::Specification.new do |s|
s.add_development_dependency 'pry'
s.add_development_dependency 'rake'
s.add_development_dependency 'rdoc'
s.add_development_dependency 'sqlite3'
end
9 changes: 5 additions & 4 deletions test/support/database.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'active_record'
require 'erb'
require 'fileutils'
require 'logger'
require 'yaml'
Expand Down Expand Up @@ -40,7 +41,7 @@ def connect
end

def config
@config ||= YAML::load(File.open(DATABASE_PATH))
@config ||= YAML::load(ERB.new(File.read(DATABASE_PATH)).result)
end

def driver
Expand All @@ -55,7 +56,7 @@ def create!
db_config = config[driver]
command = case driver
when "mysql"
"mysql -u #{db_config['username']} --protocol tcp -e 'create database #{db_config['database']} character set utf8 collate utf8_general_ci;' >/dev/null"
"mysql -u #{db_config['username']} --password=#{db_config['password']} --protocol tcp -e 'create database #{db_config['database']} character set utf8 collate utf8_general_ci;' >/dev/null"
when "postgres", "postgresql"
"psql -c 'create database #{db_config['database']};' -U #{db_config['username']} -h localhost >/dev/null"
end
Expand All @@ -69,7 +70,7 @@ def drop!
db_config = config[driver]
command = case driver
when "mysql"
"mysql -u #{db_config['username']} --protocol tcp -e 'drop database #{db_config["database"]};' >/dev/null"
"mysql -u #{db_config['username']} --password=#{db_config['password']} --protocol tcp -e 'drop database #{db_config["database"]};' >/dev/null"
when "postgres", "postgresql"
"psql -c 'drop database #{db_config['database']};' -U #{db_config['username']} -h localhost >/dev/null"
end
Expand All @@ -92,7 +93,7 @@ def mysql?
end

def postgres?
driver == 'postgres'
driver == 'postgresql'
end

def sqlite?
Expand Down
3 changes: 2 additions & 1 deletion test/support/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ mysql:
port: 3306
database: globalize_test
username: root
password: <%= ENV['MYSQL_PASSWORD'] %>
encoding: utf8

postgres:
postgresql:
adapter: postgresql
host: localhost
port: 5432
Expand Down

0 comments on commit ca17b20

Please sign in to comment.