Skip to content

Commit

Permalink
Implement GitHub Actions for CI
Browse files Browse the repository at this point in the history
  • Loading branch information
aried3r committed May 7, 2021
1 parent 256d1fb commit e3b6a01
Show file tree
Hide file tree
Showing 9 changed files with 114 additions and 77 deletions.
102 changes: 102 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby

name: RPush Test

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

env:
POSTGRES_USER: postgres
POSTGRES_HOST: localhost
POSTGRES_PORT: 5432
POSTGRES_DB: rpush_test
PGPASSWORD: postgres # https://www.postgresql.org/docs/13/libpq-envars.html

jobs:
test:
runs-on: ubuntu-20.04

services:
postgres:
image: postgres:13
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432

redis:
image: redis
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps port 6379 on service container to the host
- 6379:6379

strategy:
matrix:
gemfile: ['rails_5.2', 'rails_6.0', 'rails_6.1']

ruby: ['2.3', '2.4', '2.5', '2.6', '2.7', '3.0']

client: ['active_record', 'redis']

exclude:
# Rails 5.2 requires Ruby < 3.0
# https://github.com/rails/rails/issues/40938
- ruby: '3.0'
gemfile: 'rails_5.2'
# Rails >= 6 need Ruby >= 2.5
- ruby: '2.3'
gemfile: 'rails_6.0'
- ruby: '2.4'
gemfile: 'rails_6.0'
- ruby: '2.3'
gemfile: 'rails_6.1'
- ruby: '2.4'
gemfile: 'rails_6.1'

env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile

steps:
- uses: actions/checkout@v2

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically

- name: Create PostgreSQL database
run: |
createdb \
--host=$POSTGRES_HOST \
--port=$POSTGRES_PORT \
--username=$POSTGRES_USER \
$POSTGRES_DB
- name: Run tests
run: bundle exec rake
env:
# The hostname used to communicate with the PostgreSQL service container
POSTGRES_HOST: localhost
# The default PostgreSQL port
POSTGRES_PORT: 5432
CLIENT: ${{ matrix.client }}
1 change: 0 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ require: rubocop-performance

AllCops:
Exclude:
- gemfiles/vendor/bundle/**/* # This dir only shows up on Travis
- lib/generators/**/*
- vendor/bundle/**/*
TargetRubyVersion: 2.3
Expand Down
65 changes: 0 additions & 65 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![Gem Version](https://badge.fury.io/rb/rpush.svg)](http://badge.fury.io/rb/rpush)
[![Build Status](https://travis-ci.org/rpush/rpush.svg?branch=master)](https://travis-ci.org/rpush/rpush)
[![RPush Test](https://github.com/rpush/rpush/actions/workflows/test.yml/badge.svg)](https://github.com/rpush/rpush/actions/workflows/test.yml)
[![Test Coverage](https://codeclimate.com/github/rpush/rpush/badges/coverage.svg)](https://codeclimate.com/github/rpush/rpush)
[![Code Climate](https://codeclimate.com/github/rpush/rpush/badges/gpa.svg)](https://codeclimate.com/github/rpush/rpush)
[![Join the chat at https://gitter.im/rpush/rpush](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/rpush/rpush?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
Expand Down
2 changes: 1 addition & 1 deletion spec/functional/retry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@
notification.reload
expect(notification.delivered).to eq(false)
end
end
end if redis?
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ def client
(ENV['CLIENT'] || :active_record).to_sym
end

if !ENV['TRAVIS'] || (ENV['TRAVIS'] && ENV['QUALITY'] == 'true')
if !ENV['CI'] || (ENV['CI'] && ENV['QUALITY'] == 'true')
begin
require './spec/support/simplecov_helper'
include SimpleCovHelper
Expand Down
7 changes: 4 additions & 3 deletions spec/support/active_record_setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
SPEC_ADAPTER = 'jdbc' + SPEC_ADAPTER if jruby

require 'yaml'
db_config = YAML.load_file(File.expand_path("config/database.yml", File.dirname(__FILE__)))
db_config_path = File.expand_path("config/database.yml", File.dirname(__FILE__))
db_config = YAML.load(ERB.new(File.read(db_config_path)).result)

if db_config[SPEC_ADAPTER].nil?
puts "No such adapter '#{SPEC_ADAPTER}'. Valid adapters are #{db_config.keys.join(', ')}."
exit 1
end

if ENV['TRAVIS']
if ENV['CI']
db_config[SPEC_ADAPTER]['username'] = 'postgres'
else
require 'etc'
Expand Down Expand Up @@ -62,7 +63,7 @@
Rpush420Updates
]

unless ENV['TRAVIS']
unless ENV['CI']
migrations.reverse_each do |m|
begin
m.down
Expand Down
8 changes: 4 additions & 4 deletions spec/support/config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

postgresql:
adapter: postgresql
database: rpush_test
host: localhost
username: postgres
password: ""
database: <%= ENV.fetch('POSTGRES_DB', 'rpush_test') %>
host: <%= ENV.fetch('POSTGRES_HOST', 'localhost') %>
username: <%= ENV.fetch('POSTGRES_USER', 'postgres') %>
password: <%= ENV.fetch('PGPASSWORD', '') %>

jdbcpostgresql:
adapter: jdbcpostgresql
Expand Down
2 changes: 1 addition & 1 deletion spec/support/simplecov_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def start_simple_cov(name)

formatters = [SimpleCov::Formatter::QualityFormatter]

if ENV['TRAVIS']
if ENV['CI']
require 'codeclimate-test-reporter'

if CodeClimate::TestReporter.run?
Expand Down

0 comments on commit e3b6a01

Please sign in to comment.