From 0e8bf2efe885c59aa586f44634789052244554bb Mon Sep 17 00:00:00 2001 From: Geremia Taglialatela Date: Tue, 29 Jun 2021 12:23:48 +0200 Subject: [PATCH] Move to GitHub Actions --- .github/workflows/ruby.yml | 75 +++++++++++++++++++ .travis.yml | 73 ------------------ README.md | 4 +- gemfiles/rails_5.0.gemfile | 5 ++ gemfiles/rails_5.1.gemfile | 5 ++ gemfiles/rails_5.2.gemfile | 5 ++ ...ase_with_default_username_and_password.yml | 1 + ...database_without_username_and_password.yml | 1 + spec/{config.travis.yml => config.github.yml} | 2 +- 9 files changed, 95 insertions(+), 76 deletions(-) create mode 100644 .github/workflows/ruby.yml delete mode 100644 .travis.yml rename spec/{config.travis.yml => config.github.yml} (75%) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml new file mode 100644 index 00000000..42821cc1 --- /dev/null +++ b/.github/workflows/ruby.yml @@ -0,0 +1,75 @@ +name: Ruby specs + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + test: + name: Ruby specs + runs-on: ubuntu-latest + + services: + db: + image: postgres:12 + ports: ['5432:5432'] + env: + POSTGRES_HOST_AUTH_METHOD: trust + + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + strategy: + matrix: + ruby-version: ['2.3', '2.4', '2.5', '2.6', '2.7', '3.0'] + gemfile: [ rails_5.0, rails_5.1, rails_5.2, rails_6.0 ] + + exclude: + - ruby-version: '2.3' + gemfile: rails_6.0 + - ruby-version: '2.4' + gemfile: rails_6.0 + - ruby-version: '2.6' + gemfile: rails_5.0 + - ruby-version: '2.6' + gemfile: rails_5.1 + - ruby-version: '2.7' + gemfile: rails_5.0 + - ruby-version: '2.7' + gemfile: rails_5.1 + - ruby-version: '2.7' + gemfile: rails_5.2 + - ruby-version: '3.0' + gemfile: rails_5.0 + - ruby-version: '3.0' + gemfile: rails_5.1 + - ruby-version: '3.0' + gemfile: rails_5.2 + + env: + BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile + TEST_CONFIG: ./spec/config.github.yml + + steps: + - uses: actions/checkout@v2 + - name: Set up Database + run: | + psql -c "CREATE ROLE runner SUPERUSER LOGIN CREATEDB;" -U postgres -h localhost + psql -c "CREATE DATABASE chronomodel;" -U postgres -h localhost + psql -c "CREATE DATABASE chronomodel_railsapp;" -U postgres -h localhost + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true + - name: Run specs and publish code coverage + uses: paambaati/codeclimate-action@v3.0.0 + env: + CC_TEST_REPORTER_ID: dedfb7472ee410eec459bff3681d9a8fd8dd237e9bd7e8675a7c8eb7e253bba9 + with: + coverageCommand: bundle exec rake diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 4a5334e9..00000000 --- a/.travis.yml +++ /dev/null @@ -1,73 +0,0 @@ -language: ruby -os: linux -dist: xenial -cache: bundler - -rvm: - - 2.3 - - 2.4 - - 2.5 - - 2.6 - - 2.7 - - 3.0 - -gemfile: - - gemfiles/rails_5.0.gemfile - - gemfiles/rails_5.1.gemfile - - gemfiles/rails_5.2.gemfile - - gemfiles/rails_6.0.gemfile - -jobs: - exclude: - - rvm: 2.3 - gemfile: gemfiles/rails_6.0.gemfile - - rvm: 2.4 - gemfile: gemfiles/rails_6.0.gemfile - - rvm: 2.6 - gemfile: gemfiles/rails_5.0.gemfile - - rvm: 2.6 - gemfile: gemfiles/rails_5.1.gemfile - - rvm: 2.7 - gemfile: gemfiles/rails_5.0.gemfile - - rvm: 2.7 - gemfile: gemfiles/rails_5.1.gemfile - - rvm: 2.7 - gemfile: gemfiles/rails_5.2.gemfile - - rvm: 3.0 - gemfile: gemfiles/rails_5.0.gemfile - - rvm: 3.0 - gemfile: gemfiles/rails_5.1.gemfile - - rvm: 3.0 - gemfile: gemfiles/rails_5.2.gemfile - -addons: - postgresql: "12" - apt: - packages: - - postgresql-12 - - postgresql-client-12 - -before_install: - - sudo sed -i -e '/local.*peer/s/postgres/all/' -e 's/peer\|md5/trust/g' /etc/postgresql/*/main/pg_hba.conf - - sudo sed -i -e "s/^port =.*/port = $PGPORT/" /etc/postgresql/*/main/postgresql.conf - - sudo /etc/init.d/postgresql restart - - sleep 2 - - psql -c "CREATE DATABASE chronomodel;" -U postgres - - psql -c "CREATE DATABASE chronomodel_railsapp;" -U postgres - - gem install simplecov -v '0.17.1' - -env: - global: - - CC_TEST_REPORTER_ID=dedfb7472ee410eec459bff3681d9a8fd8dd237e9bd7e8675a7c8eb7e253bba9 - - PGPORT=5433 - -before_script: - - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter - - chmod +x ./cc-test-reporter - - ./cc-test-reporter before-build - -script: - - bundle exec rake TEST_CONFIG=./spec/config.travis.yml - -after_script: - - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT diff --git a/README.md b/README.md index 1c91d844..4c040eaf 100644 --- a/README.md +++ b/README.md @@ -383,8 +383,8 @@ while using it in many important projects. This software is Made in Italy :it: :smile:. -[build-status]: https://travis-ci.org/ifad/chronomodel -[build-status-badge]: https://travis-ci.org/ifad/chronomodel.svg +[build-status]: https://github.com/ifad/chronomodel/actions +[build-status-badge]: https://github.com/ifad/chronomodel/actions/workflows/ruby.yml/badge.svg [code-analysis]: https://codeclimate.com/github/ifad/chronomodel [code-analysis-badge]: https://codeclimate.com/github/ifad/chronomodel.svg [docs-analysis]: http://inch-ci.org/github/ifad/chronomodel diff --git a/gemfiles/rails_5.0.gemfile b/gemfiles/rails_5.0.gemfile index db8e9aba..13678245 100644 --- a/gemfiles/rails_5.0.gemfile +++ b/gemfiles/rails_5.0.gemfile @@ -3,4 +3,9 @@ source "https://rubygems.org" gem "activerecord", "~> 5.0.0" gem "rails", "~> 5.0.0" +# Fix code coverage on old Ruby versions +if RUBY_VERSION < '2.5' + gem 'simplecov', '< 0.18.0' +end + gemspec :path => "../" diff --git a/gemfiles/rails_5.1.gemfile b/gemfiles/rails_5.1.gemfile index 189a376b..48b140dd 100644 --- a/gemfiles/rails_5.1.gemfile +++ b/gemfiles/rails_5.1.gemfile @@ -3,4 +3,9 @@ source "https://rubygems.org" gem "activerecord", "~> 5.1.0" gem "rails", "~> 5.1.0" +# Fix code coverage on old Ruby versions +if RUBY_VERSION < '2.5' + gem 'simplecov', '< 0.18.0' +end + gemspec :path => "../" diff --git a/gemfiles/rails_5.2.gemfile b/gemfiles/rails_5.2.gemfile index 18937f06..470a9434 100644 --- a/gemfiles/rails_5.2.gemfile +++ b/gemfiles/rails_5.2.gemfile @@ -3,4 +3,9 @@ source "https://rubygems.org" gem "activerecord", "~> 5.2.0" gem "rails", "~> 5.2.0" +# Fix code coverage on old Ruby versions +if RUBY_VERSION < '2.5' + gem 'simplecov', '< 0.18.0' +end + gemspec :path => "../" diff --git a/spec/aruba/fixtures/database_with_default_username_and_password.yml b/spec/aruba/fixtures/database_with_default_username_and_password.yml index f3cc94b4..b1ffd6fb 100644 --- a/spec/aruba/fixtures/database_with_default_username_and_password.yml +++ b/spec/aruba/fixtures/database_with_default_username_and_password.yml @@ -5,6 +5,7 @@ default: &default encoding: unicode pool: 20 database: chronomodel_railsapp + host: <%= ENV['CI'] ? 'localhost' : '' %> development: <<: *default diff --git a/spec/aruba/fixtures/database_without_username_and_password.yml b/spec/aruba/fixtures/database_without_username_and_password.yml index 81d2ada3..a24b83c4 100644 --- a/spec/aruba/fixtures/database_without_username_and_password.yml +++ b/spec/aruba/fixtures/database_without_username_and_password.yml @@ -3,6 +3,7 @@ default: &default encoding: unicode pool: 20 database: chronomodel_railsapp + host: <%= ENV['CI'] ? 'localhost' : '' %> development: <<: *default diff --git a/spec/config.travis.yml b/spec/config.github.yml similarity index 75% rename from spec/config.travis.yml rename to spec/config.github.yml index 56056b75..ce27bc19 100644 --- a/spec/config.travis.yml +++ b/spec/config.github.yml @@ -1,4 +1,4 @@ -hostname: localhost +host: localhost username: postgres password: "" database: chronomodel