From b13cfc0ed4beb9e51b0bed8f6f68aa6a2cb7c6e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Nie=C5=82acny?= Date: Tue, 28 Dec 2021 16:07:48 +0100 Subject: [PATCH] Migrate to GitHub actions (#160) --- .github/workflows/test.yml | 122 ++++++++++++++++++++++++++++++++++ .travis.yml | 54 --------------- Appraisals | 7 ++ Gemfile | 2 +- Gemfile.lock | 29 ++++---- README.md | 3 +- gemfiles/rails_3.2.gemfile | 2 +- gemfiles/rails_4.2.gemfile | 2 +- gemfiles/rails_5.2.gemfile | 2 +- gemfiles/rails_6.0.gemfile | 2 +- gemfiles/rails_7.0.gemfile | 23 +++++++ gemfiles/rails_master.gemfile | 4 +- spec/spec_helper.rb | 17 +++-- 13 files changed, 186 insertions(+), 83 deletions(-) create mode 100644 .github/workflows/test.yml delete mode 100644 .travis.yml create mode 100644 gemfiles/rails_7.0.gemfile diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..fdfbaf14c --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,122 @@ +name: Test + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + schedule: + - cron: '02 4 * * *' + +jobs: + static: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.7 + bundler-cache: true + - run : bundle exec rake rubocop + test: + runs-on: ubuntu-latest + services: + postgres: + image: postgres + env: + POSTGRES_PASSWORD: password + 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 + env: + BUNDLE_GEMFILE: ${{ github.workspace }}/${{ matrix.gemfile }} + RUN_GENERATORS: ${{ matrix.run_generators }} + PGPASSWORD: password + DATABASE_ADAPTER: ${{ matrix.database_adapter }} + DATABASE_NAME: ${{ matrix.database_name }} + DATABASE_PASSWORD: ${{ matrix.database_password }} + COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} + strategy: + matrix: + rvm: ["2.7"] + gemfile: ["Gemfile"] + run_generators: ["false"] + database_adapter: ['sqlite3'] + database_name: [":memory:"] + database_password: ["password"] + include: + - rvm: ruby-head + gemfile: gemfiles/rails_master.gemfile + run_generators: "false" + database_adapter: 'sqlite3' + database_name: ":memory:" + - rvm: 2.3.8 + gemfile: gemfiles/rails_3.2.gemfile + run_generators: "false" + database_adapter: 'sqlite3' + database_name: ":memory:" + - rvm: 2.3.8 + gemfile: gemfiles/rails_4.2.gemfile + run_generators: "false" + database_adapter: 'sqlite3' + database_name: ":memory:" + - rvm: 2.7 + gemfile: gemfiles/rails_5.2.gemfile + run_generators: "false" + database_adapter: 'sqlite3' + database_name: ":memory:" + - rvm: 2.7 + gemfile: gemfiles/rails_6.0.gemfile + run_generators: "false" + database_adapter: 'sqlite3' + database_name: ":memory:" + - rvm: 2.7 + gemfile: gemfiles/rails_5.2.gemfile + run_generators: "false" + database_adapter: 'sqlite3' + database_name: ":memory:" + - rvm: 2.7 + gemfile: gemfiles/rails_6.0.gemfile + run_generators: "true" + database_adapter: 'sqlite3' + database_name: ":memory:" + - rvm: 2.7 + gemfile: gemfiles/rails_6.0.gemfile + database_adapter: 'postgresql' + database_name: 'ci_test' + database_password: "password" + run_generators: "false" + - rvm: 2.7 + gemfile: gemfiles/rails_7.0.gemfile + run_generators: "true" + database_adapter: 'sqlite3' + database_name: ":memory:" + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.rvm }} + bundler-cache: true + - run: psql -c 'create database ci_test;' -U postgres -h localhost + - run: bundle exec rake + documentation: + runs-on: ubuntu-latest + needs: ['test', 'static'] + if: github.ref == 'refs/heads/master' + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.7 + bundler-cache: true + - run: 'bundle exec yard doc --private' + - uses: JamesIves/github-pages-deploy-action@4.1.7 + with: + branch: gh-pages + folder: doc + diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index bdfbc7847..000000000 --- a/.travis.yml +++ /dev/null @@ -1,54 +0,0 @@ -stages: - - "Static analysis" - - "Test" - - "Documentation" -matrix: - allow_failures: - - rvm: ruby-head - include: - - rvm: 2.3.8 - gemfile: gemfiles/rails_3.2.gemfile - - rvm: 2.3.8 - gemfile: gemfiles/rails_4.2.gemfile - - rvm: 2.7 - gemfile: gemfiles/rails_5.2.gemfile - - rvm: 2.7 - gemfile: gemfiles/rails_6.0.gemfile - - rvm: 2.7 - gemfile: gemfiles/rails_5.2.gemfile - - rvm: 2.7 - env: RUN_GENERATORS=true - gemfile: gemfiles/rails_6.0.gemfile - - rvm: 2.7 - name: "PostgreSQL" - services: - - postgresql - before_script: - - psql -c 'create database ci_test;' -U postgres - env: - - DATABASE_ADAPTER=postgresql - - DATABASE_NAME=ci_test - - rvm: 2.7 - gemfile: gemfiles/rails_master.gemfile - - rvm: ruby-head - gemfile: gemfiles/rails_master.gemfile - - rvm: 2.7 - stage: "Static analysis" - name: "Rubocop" - script: bundle exec rake rubocop - - rvm: 2.7 - stage: "Documentation" - name: "Documentation" - before_deploy: 'bundle exec yard doc --private' - deploy: - provider: pages - skip_cleanup: true - github_token: $GITHUB_TOKEN - local_dir: doc - on: - branch: master -before_install: - - gem update --system - - gem install bundler -cache: bundler - diff --git a/Appraisals b/Appraisals index 1c9a9ff11..b5595659c 100644 --- a/Appraisals +++ b/Appraisals @@ -41,6 +41,12 @@ appraise 'rails-6.0' do end end +appraise 'rails-7.0' do + gem 'activerecord', '~> 7' + gem 'activesupport', '~> 7' + gem 'railties', '~> 7' +end + appraise 'rails-master' do gem 'activerecord', git: 'https://github.com/rails/rails.git' gem 'activesupport', git: 'https://github.com/rails/rails.git' @@ -48,5 +54,6 @@ appraise 'rails-master' do group :development do gem 'sqlite3' + gem 'pg', git: 'https://github.com/ged/ruby-pg.git' end end diff --git a/Gemfile b/Gemfile index e49705630..6e4144f6d 100644 --- a/Gemfile +++ b/Gemfile @@ -9,7 +9,7 @@ gem 'railties' group :development do gem 'appraisal' - gem 'coveralls', require: false + gem 'coveralls_reborn', require: false gem 'jeweler' gem 'pg' gem 'pry' diff --git a/Gemfile.lock b/Gemfile.lock index b48dac442..b20e5d845 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -36,17 +36,16 @@ GEM builder (3.2.4) coderay (1.1.3) concurrent-ruby (1.1.9) - coveralls (0.8.23) - json (>= 1.8, < 3) - simplecov (~> 0.16.1) - term-ansicolor (~> 1.3) - thor (>= 0.19.4, < 2.0) - tins (~> 1.6) + coveralls_reborn (0.23.1) + simplecov (>= 0.18.1, < 0.22.0) + term-ansicolor (~> 1.6) + thor (>= 0.20.3, < 2.0) + tins (~> 1.16) crass (1.0.6) descendants_tracker (0.0.4) thread_safe (~> 0.3, >= 0.3.1) diff-lcs (1.4.4) - docile (1.3.2) + docile (1.4.0) erubi (1.10.0) faraday (0.9.2) multipart-post (>= 1.2, < 3) @@ -74,7 +73,6 @@ GEM rake rdoc semver2 - json (2.3.0) jwt (2.2.1) loofah (2.12.0) crass (~> 1.0.2) @@ -150,11 +148,12 @@ GEM parser (>= 3.0.1.1) ruby-progressbar (1.11.0) semver2 (3.4.2) - simplecov (0.16.1) + simplecov (0.21.2) docile (~> 1.1) - json (>= 1.8, < 3) - simplecov-html (~> 0.10.0) - simplecov-html (0.10.2) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.12.3) + simplecov_json_formatter (0.1.3) sqlite3 (1.4.2) sync (0.5.0) term-ansicolor (1.7.1) @@ -162,7 +161,7 @@ GEM thor (1.1.0) thread_safe (0.3.6) timecop (0.9.4) - tins (1.24.1) + tins (1.30.0) sync tzinfo (2.0.4) concurrent-ruby (~> 1.0) @@ -178,7 +177,7 @@ DEPENDENCIES activesupport ancestry appraisal - coveralls + coveralls_reborn jeweler pg pry @@ -190,4 +189,4 @@ DEPENDENCIES yard BUNDLED WITH - 2.1.4 + 2.2.30 diff --git a/README.md b/README.md index ebcb11c7a..ddbccd568 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,7 @@ ActsAsMessageable ================= The Acts As Messageable allows communication between the models. - -[![Build Status](https://secure.travis-ci.org/LTe/acts-as-messageable.png)](http://travis-ci.org/LTe/acts-as-messageable) +[![Build Status](https://github.com/LTe/acts-as-messageable/actions/workflows/test.yml/badge.svg)](https://github.com/LTe/acts-as-messageable/actions/workflows/test.yml) [![Code Climate](https://codeclimate.com/github/LTe/acts-as-messageable.png)](https://codeclimate.com/github/LTe/acts-as-messageable) [![Coverage Status](https://coveralls.io/repos/LTe/acts-as-messageable/badge.png?branch=master)](https://coveralls.io/r/LTe/acts-as-messageable?branch=master) [![Gem Version](https://badge.fury.io/rb/acts-as-messageable.png)](http://badge.fury.io/rb/acts-as-messageable) diff --git a/gemfiles/rails_3.2.gemfile b/gemfiles/rails_3.2.gemfile index 90b6f53d3..b975a653f 100644 --- a/gemfiles/rails_3.2.gemfile +++ b/gemfiles/rails_3.2.gemfile @@ -11,7 +11,7 @@ gem 'railties', '~> 3.2.22' group :development do gem 'appraisal' - gem 'coveralls', require: false + gem 'coveralls_reborn', require: false gem 'jeweler' gem 'pg' gem 'pry' diff --git a/gemfiles/rails_4.2.gemfile b/gemfiles/rails_4.2.gemfile index 3fc786ed8..4b10d3634 100644 --- a/gemfiles/rails_4.2.gemfile +++ b/gemfiles/rails_4.2.gemfile @@ -12,7 +12,7 @@ gem 'rdoc', '6.2.0' group :development do gem 'appraisal' - gem 'coveralls', require: false + gem 'coveralls_reborn', require: false gem 'jeweler' gem 'pg' gem 'pry' diff --git a/gemfiles/rails_5.2.gemfile b/gemfiles/rails_5.2.gemfile index 22a44aa47..32a997270 100644 --- a/gemfiles/rails_5.2.gemfile +++ b/gemfiles/rails_5.2.gemfile @@ -11,7 +11,7 @@ gem 'railties', '~> 5.2.0' group :development do gem 'appraisal' - gem 'coveralls', require: false + gem 'coveralls_reborn', require: false gem 'jeweler' gem 'pg' gem 'pry' diff --git a/gemfiles/rails_6.0.gemfile b/gemfiles/rails_6.0.gemfile index f7a23a1d2..81dea4d04 100644 --- a/gemfiles/rails_6.0.gemfile +++ b/gemfiles/rails_6.0.gemfile @@ -11,7 +11,7 @@ gem 'railties', '~> 6' group :development do gem 'appraisal' - gem 'coveralls', require: false + gem 'coveralls_reborn', require: false gem 'jeweler' gem 'pg' gem 'pry' diff --git a/gemfiles/rails_7.0.gemfile b/gemfiles/rails_7.0.gemfile new file mode 100644 index 000000000..12e34a535 --- /dev/null +++ b/gemfiles/rails_7.0.gemfile @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +# This file was generated by Appraisal + +source 'http://rubygems.org' + +gem 'activerecord', '~> 7' +gem 'activesupport', '~> 7' +gem 'ancestry' +gem 'railties', '~> 7' + +group :development do + gem 'appraisal' + gem 'coveralls_reborn', require: false + gem 'jeweler' + gem 'pg' + gem 'pry' + gem 'rspec' + gem 'rubocop', require: false + gem 'sqlite3' + gem 'timecop' + gem 'yard' +end diff --git a/gemfiles/rails_master.gemfile b/gemfiles/rails_master.gemfile index 7b7355fee..f290bbe26 100644 --- a/gemfiles/rails_master.gemfile +++ b/gemfiles/rails_master.gemfile @@ -11,9 +11,9 @@ gem 'railties', git: 'https://github.com/rails/rails.git' group :development do gem 'appraisal' - gem 'coveralls', require: false + gem 'coveralls_reborn', require: false gem 'jeweler' - gem 'pg' + gem 'pg', git: 'https://github.com/ged/ruby-pg.git' gem 'pry' gem 'rspec' gem 'rubocop', require: false diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 882329ca6..48a8c26ab 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -24,10 +24,7 @@ RSpec.configure do |config| config.before(:all) do - ActiveRecord::Base.establish_connection( - adapter: ENV.fetch('DATABASE_ADAPTER', 'sqlite3'), - database: ENV.fetch('DATABASE_NAME', ':memory:') - ) + establish_connection create_database @alice = User.create email: 'alice@example.com' @@ -47,12 +44,22 @@ end config.around(:each) do |example| - supported_rails = Array.wrap(example.metadata[:rails]).presence || [3, 4, 5, 6] + supported_rails = Array.wrap(example.metadata[:rails]).presence || [3, 4, 5, 6, 7] example.run if supported_rails.include?(Rails::VERSION::MAJOR) end end +def establish_connection + ActiveRecord::Base.establish_connection( + adapter: ENV.fetch('DATABASE_ADAPTER', 'sqlite3'), + database: ENV.fetch('DATABASE_NAME', ':memory:'), + password: ENV.fetch('DATABASE_PASSWORD', 'password'), + host: 'localhost', + user: 'postgres' + ) +end + def create_database ActiveRecord::Schema.define(version: 1) do enable_extension 'pgcrypto' if ENV.fetch('DATABASE_ADAPTER', '') == 'postgresql' && !extension_enabled?('pgcrypto')