Skip to content

Commit

Permalink
Replace Travis CI with GitHub Actions (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
pkuczynski authored Jan 8, 2020
1 parent 0ce94f0 commit baaae44
Show file tree
Hide file tree
Showing 9 changed files with 96 additions and 60 deletions.
7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
63 changes: 63 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: tests

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
test:
name: ${{ matrix.ruby }}
runs-on: ubuntu-latest
env:
COVERAGE_RUBY_VERSION: 2.6
BUNDLER_PATH: vendor/bundle
strategy:
matrix:
ruby:
- 2.4
- 2.5
- 2.6
- 2.7
- truffleruby
steps:
- name: Checkout
uses: actions/checkout@master

- name: Setup ruby ${{ matrix.ruby }}
uses: eregon/use-ruby-action@master
with:
ruby-version: ${{ matrix.ruby }}

- name: Restore cache
uses: actions/cache@v1
with:
path: ${{ env.BUNDLER_PATH }}
key: ruby-${{ matrix.ruby }}-bundler-${{ hashFiles('*.gemspec') }}-${{ hashFiles('**/gemfiles/**') }}

- name: Prepare environment
run: |
sudo apt-get -y install libsqlite3-dev libxslt1-dev
gem uninstall bundler -v '>= 2' -ax --force || true
gem install bundler -v '~>1.0' -N || true
echo "::set-env name=BUNDLER_VERSION::$(bundle -v | grep -o -P '\d+\.\d+.\d+')"
- name: Install
run: |
bundle config path ${{ env.BUNDLER_PATH }}
bundle install
bundle exec appraisal install
- name: Test
run: bundle exec appraisal rspec

- name: Publish code coverage
if: startsWith(env.RUBY_VERSION, env.COVERAGE_RUBY_VERSION)
uses: paambaati/[email protected]
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
coverageCommand: bundle exec appraisal rspec
39 changes: 0 additions & 39 deletions .travis.yml

This file was deleted.

17 changes: 11 additions & 6 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
appraise 'rails-4.2' do
gem 'rails', '4.2.11.1'
gem 'rspec-rails', '~> 3.7'
gem 'sprockets', '~> 3.7'
gem 'sqlite3', '< 1.4.0'
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]
# Bundler >= 2.x do not work with Rails 4.2
if (ENV['BUNDLER_VERSION'] || `bundler -v`[/\d+\.\d+\.\d+/]).start_with?('1.17')
appraise 'rails-4.2' do
gem 'rails', '4.2.11.1'
gem 'rspec-rails', '~> 3.7'
gem 'sprockets', '~> 3.7'
gem 'sqlite3', '< 1.4.0'
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]
end
else
puts 'Skipping rails-4.2 for Bundler >= 2.x'
end

appraise 'rails-5.0' do
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* Cleanup example Rails application used for testing ([#263](https://github.com/railsconfig/config/pull/263))
* Upgrade markdown linter and fix errors ([#265](https://github.com/railsconfig/config/pull/265))
* Upgrade development dependencies and test matrix with latest Ruby and Rails versions ([#264](https://github.com/railsconfig/config/pull/264))
* Replace Travis CI with GitHub Actions ([#266](https://github.com/railsconfig/config/pull/266))

## 2.1.0

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Config

[![Build Status](https://api.travis-ci.org/railsconfig/config.svg?branch=master)](http://travis-ci.org/railsconfig/config)
[![Gem Version](https://badge.fury.io/rb/config.svg)](http://badge.fury.io/rb/config)
[![Tests](https://github.com/railsconfig/config/workflows/tests/badge.svg)](https://github.com/railsconfig/config/actions?query=branch%3Amaster)
[![Maintainability](https://api.codeclimate.com/v1/badges/85c206c13dce7de090af/maintainability)](https://codeclimate.com/github/railsconfig/config/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/85c206c13dce7de090af/test_coverage)](https://codeclimate.com/github/railsconfig/config/test_coverage)
[![Financial Contributors on Open Collective](https://opencollective.com/rubyconfig/all/badge.svg?label=financial+contributors)](https://opencollective.com/rubyconfig)
[![Financial Contributors on Open Collective](https://opencollective.com/rubyconfig/all/badge.svg?label=backers)](https://opencollective.com/rubyconfig)

## Summary

Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec)

# Test for multiple Rails scenarios
if !ENV["APPRAISAL_INITIALIZED"] && !ENV["TRAVIS"]
if !ENV['APPRAISAL_INITIALIZED'] && !ENV['GITHUB_ACTIONS']
require "appraisal"

task :default => :appraisal
Expand Down
14 changes: 7 additions & 7 deletions config.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ Please consider donating to our open collective to help us maintain this project
end
end

# Static code analysis
s.add_development_dependency 'mdl', '~> 0.8', '>= 0.8.0'
s.add_development_dependency 'rubocop', '~> 0.78.0'

if ENV['TRAVIS'] && ENV['TRAVIS_RUBY_VERSION'] != 'truffleruby'
s.add_development_dependency 'codeclimate-test-reporter', '~> 1.0.9'
s.add_development_dependency 'simplecov', '~> 0.13'
if ENV['GITHUB_ACTIONS']
# Code coverage is needed only in CI
s.add_development_dependency 'simplecov', '~> 0.17.1' if RUBY_ENGINE == 'ruby'
else
# Static code analysis to be used locally
s.add_development_dependency 'mdl', '~> 0.8', '>= 0.8.0'
s.add_development_dependency 'rubocop', '~> 0.78.0'
end
end
9 changes: 4 additions & 5 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
ENV['RAILS_ENV'] ||= 'test'

puts "TRAVIS_COMPILER #{ENV['TRAVIS_COMPILER']}"
puts "TRAVIS_RUBY_VERSION #{ENV['TRAVIS_RUBY_VERSION']}"
puts ENV
puts "RUBY_ENGINE: #{RUBY_ENGINE}"
puts "RUBY_VERSION: #{RUBY_VERSION}\n\n"

##
# Code Climate
#
if ENV['TRAVIS'] && ENV['TRAVIS_RUBY_VERSION'] != 'truffleruby'
if ENV['GITHUB_ACTIONS'] && RUBY_ENGINE == 'ruby' && RUBY_VERSION.start_with?(ENV['COVERAGE_RUBY_VERSION'] || 'x')
require 'simplecov'
SimpleCov.start
end
Expand All @@ -20,7 +19,7 @@
##
# Detect Rails/Sinatra dummy application based on gemfile name substituted by Appraisal
#
if ENV['APPRAISAL_INITIALIZED'] || ENV['TRAVIS']
if ENV['GITHUB_ACTIONS']
app_name = Pathname.new(ENV['BUNDLE_GEMFILE']).basename.sub('.gemfile', '')
else
/.*?(?<app_name>rails.*?)\.gemfile/ =~ Dir["gemfiles/rails*.gemfile"].sort.last
Expand Down

0 comments on commit baaae44

Please sign in to comment.