From 2de67783d2b6927436c0072731fe337fc6677b2b Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Tue, 1 Sep 2020 09:04:44 +0100 Subject: [PATCH] [CI] Migrates tests to GitHub actions, removes Travis CI --- .ci/travis_before_script.sh | 15 ----- .github/workflows/{tests.yml => 2.4.yml} | 13 ++--- .github/workflows/2.5.yml | 40 +++++++++++++ .github/workflows/2.6.yml | 40 +++++++++++++ .github/workflows/2.7.yml | 40 +++++++++++++ .github/workflows/jruby.yml | 40 +++++++++++++ .travis.yml | 71 ------------------------ README.md | 7 ++- elasticsearch-model/Rakefile | 6 +- 9 files changed, 175 insertions(+), 97 deletions(-) delete mode 100755 .ci/travis_before_script.sh rename .github/workflows/{tests.yml => 2.4.yml} (82%) create mode 100644 .github/workflows/2.5.yml create mode 100644 .github/workflows/2.6.yml create mode 100644 .github/workflows/2.7.yml create mode 100644 .github/workflows/jruby.yml delete mode 100644 .travis.yml diff --git a/.ci/travis_before_script.sh b/.ci/travis_before_script.sh deleted file mode 100755 index 547a5a040..000000000 --- a/.ci/travis_before_script.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -if [ "$ELASTICSEARCH_VERSION" == "6.7.1" ] -then - url="https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ELASTICSEARCH_VERSION}.tar.gz" -else - url="https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ELASTICSEARCH_VERSION}-linux-x86_64.tar.gz" -fi - -echo "Downloading elasticsearch from $url" -curl $url | tar xz -C /tmp - -echo "Starting elasticsearch on port ${TEST_CLUSTER_PORT}" -/tmp/elasticsearch-${ELASTICSEARCH_VERSION}/bin/elasticsearch-keystore create -/tmp/elasticsearch-${ELASTICSEARCH_VERSION}/bin/elasticsearch -E http.port=${TEST_CLUSTER_PORT} &> /dev/null & diff --git a/.github/workflows/tests.yml b/.github/workflows/2.4.yml similarity index 82% rename from .github/workflows/tests.yml rename to .github/workflows/2.4.yml index a756f8025..cd2c4dae5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/2.4.yml @@ -1,21 +1,18 @@ -name: master +name: Ruby 2.4 on: push: branches: - master - - 6.x pull_request: branches: - master - - 6.x jobs: - test-master: + tests: env: TEST_ES_SERVER: http://localhost:9200 + RAILS_VERSIONS: '5.0' strategy: fail-fast: false - matrix: - ruby: [ 2.5, 2.6, 2.7, jruby ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -27,10 +24,10 @@ jobs: sudo sysctl -w vm.max_map_count=262144 - uses: elastic/elastic-github-actions/elasticsearch@master with: - stack-version: 7.8.0 + stack-version: 7.9.0 - uses: ruby/setup-ruby@v1 with: - ruby-version: ${{ matrix.ruby }} + ruby-version: 2.4 - name: Bundle run: | sudo apt-get install libsqlite3-dev diff --git a/.github/workflows/2.5.yml b/.github/workflows/2.5.yml new file mode 100644 index 000000000..19d432062 --- /dev/null +++ b/.github/workflows/2.5.yml @@ -0,0 +1,40 @@ +name: Ruby 2.5 +on: + push: + branches: + - master + pull_request: + branches: + - master +jobs: + tests: + env: + TEST_ES_SERVER: http://localhost:9200 + RAILS_VERSIONS: '5.0,6.0' + strategy: + fail-fast: false + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Increase system limits + run: | + sudo swapoff -a + sudo sysctl -w vm.swappiness=1 + sudo sysctl -w fs.file-max=262144 + sudo sysctl -w vm.max_map_count=262144 + - uses: elastic/elastic-github-actions/elasticsearch@master + with: + stack-version: 7.9.0 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.5 + - name: Bundle + run: | + sudo apt-get install libsqlite3-dev + gem install bundler + bundle install + bundle exec rake bundle:clean + bundle exec rake bundle:install + - name: Test + run: bundle exec rake test:all + diff --git a/.github/workflows/2.6.yml b/.github/workflows/2.6.yml new file mode 100644 index 000000000..da076441e --- /dev/null +++ b/.github/workflows/2.6.yml @@ -0,0 +1,40 @@ +name: Ruby 2.6 +on: + push: + branches: + - master + pull_request: + branches: + - master +jobs: + tests: + env: + TEST_ES_SERVER: http://localhost:9200 + RAILS_VERSIONS: '5.0,6.0' + strategy: + fail-fast: false + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Increase system limits + run: | + sudo swapoff -a + sudo sysctl -w vm.swappiness=1 + sudo sysctl -w fs.file-max=262144 + sudo sysctl -w vm.max_map_count=262144 + - uses: elastic/elastic-github-actions/elasticsearch@master + with: + stack-version: 7.9.0 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.6 + - name: Bundle + run: | + sudo apt-get install libsqlite3-dev + gem install bundler + bundle install + bundle exec rake bundle:clean + bundle exec rake bundle:install + - name: Test + run: bundle exec rake test:all + diff --git a/.github/workflows/2.7.yml b/.github/workflows/2.7.yml new file mode 100644 index 000000000..1823e8333 --- /dev/null +++ b/.github/workflows/2.7.yml @@ -0,0 +1,40 @@ +name: Ruby 2.7 +on: + push: + branches: + - master + pull_request: + branches: + - master +jobs: + tests: + env: + TEST_ES_SERVER: http://localhost:9200 + RAILS_VERSIONS: '5.0,6.0' + strategy: + fail-fast: false + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Increase system limits + run: | + sudo swapoff -a + sudo sysctl -w vm.swappiness=1 + sudo sysctl -w fs.file-max=262144 + sudo sysctl -w vm.max_map_count=262144 + - uses: elastic/elastic-github-actions/elasticsearch@master + with: + stack-version: 7.9.0 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.7 + - name: Bundle + run: | + sudo apt-get install libsqlite3-dev + gem install bundler + bundle install + bundle exec rake bundle:clean + bundle exec rake bundle:install + - name: Test + run: bundle exec rake test:all + diff --git a/.github/workflows/jruby.yml b/.github/workflows/jruby.yml new file mode 100644 index 000000000..e0dadec1c --- /dev/null +++ b/.github/workflows/jruby.yml @@ -0,0 +1,40 @@ +name: JRuby +on: + push: + branches: + - master + pull_request: + branches: + - master +jobs: + tests: + env: + TEST_ES_SERVER: http://localhost:9200 + RAILS_VERSIONS: '5.0' + strategy: + fail-fast: false + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Increase system limits + run: | + sudo swapoff -a + sudo sysctl -w vm.swappiness=1 + sudo sysctl -w fs.file-max=262144 + sudo sysctl -w vm.max_map_count=262144 + - uses: elastic/elastic-github-actions/elasticsearch@master + with: + stack-version: 7.9.0 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: jruby-9.2 + - name: Bundle + run: | + sudo apt-get install libsqlite3-dev + gem install bundler + bundle install + bundle exec rake bundle:clean + bundle exec rake bundle:install + - name: Test + run: bundle exec rake test:all + diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 7ae3e4370..000000000 --- a/.travis.yml +++ /dev/null @@ -1,71 +0,0 @@ -# ----------------------------------------------------------------------------- -# Configuration file for http://travis-ci.org/elasticsearch/elasticsearch-rails -# ----------------------------------------------------------------------------- - -dist: trusty -sudo: required -language: ruby -services: - - mongodb - -branches: - only: - - master - - 6.x - - 7.x - -matrix: - include: - - rvm: 2.4 - jdk: oraclejdk8 - env: RAILS_VERSIONS=5.0 - - - rvm: 2.5 - jdk: oraclejdk8 - env: RAILS_VERSIONS=5.0,6.0 - - - rvm: 2.6 - jdk: oraclejdk8 - env: RAILS_VERSIONS=5.0,6.0 - - - rvm: 2.7 - jdk: oraclejdk8 - env: RAILS_VERSIONS=5.0,6.0 - - - rvm: ruby-head - jdk: oraclejdk8 - env: RAILS_VERSIONS=5.0,6.0 - - - rvm: jruby-9.2.9.0 - jdk: oraclejdk8 - env: RAILS_VERSIONS=5.0 - - allow_failures: - - rvm: ruby-head - jdk: oraclejdk8 - env: RAILS_VERSIONS=5.0,6.0 - -env: - global: - - ELASTICSEARCH_VERSION=7.8.0 - - TEST_ES_SERVER=http://localhost:9250 - - TEST_CLUSTER_PORT=9250 - - QUIET=true - -before_install: - - source ./.ci/travis_before_script.sh - - gem update --system; - - gem update bundler - - gem --version - - bundle version - -install: - - bundle install - - rake bundle:clean - - rake bundle:install - -script: - - rake test:all - -notifications: - disable: true diff --git a/README.md b/README.md index b0d4da164..220816e6e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,11 @@ # Elasticsearch -[![Build Status](https://travis-ci.org/elastic/elasticsearch-rails.svg?branch=master)](https://travis-ci.org/elastic/elasticsearch-rails) [![Code Climate](https://codeclimate.com/github/elastic/elasticsearch-rails/badges/gpa.svg)](https://codeclimate.com/github/elastic/elasticsearch-rails) +[![Ruby 2.7](https://github.com/elastic/elasticsearch-rails/workflows/Ruby%202.7/badge.svg)](https://github.com/elastic/elasticsearch-rails/actions) +[![Ruby 2.6](https://github.com/elastic/elasticsearch-rails/workflows/Ruby%202.6/badge.svg)](https://github.com/elastic/elasticsearch-rails/actions) +[![Ruby 2.5](https://github.com/elastic/elasticsearch-rails/workflows/Ruby%202.5/badge.svg)](https://github.com/elastic/elasticsearch-rails/actions) +[![Ruby 2.4](https://github.com/elastic/elasticsearch-rails/workflows/Ruby%202.4/badge.svg)](https://github.com/elastic/elasticsearch-rails/actions) +[![JRuby](https://github.com/elastic/elasticsearch-rails/workflows/JRuby/badge.svg)](https://github.com/elastic/elasticsearch-rails/actions) +[![Code Climate](https://codeclimate.com/github/elastic/elasticsearch-rails/badges/gpa.svg)](https://codeclimate.com/github/elastic/elasticsearch-rails) This repository contains various Ruby and Rails integrations for [Elasticsearch](http://elasticsearch.org): diff --git a/elasticsearch-model/Rakefile b/elasticsearch-model/Rakefile index 02ab0beb7..3d1ab402a 100644 --- a/elasticsearch-model/Rakefile +++ b/elasticsearch-model/Rakefile @@ -29,13 +29,14 @@ namespace :bundle do desc 'Install dependencies for all the Gemfiles in /gemfiles. Optionally define env variable RAILS_VERSIONS. E.g. RAILS_VERSIONS=3.0,5.0' task :install do unless defined?(JRUBY_VERSION) - puts '-'*80 + puts '-' * 80 gemfiles = ENV['RAILS_VERSIONS'] ? ENV['RAILS_VERSIONS'].split(',').map { |v| "#{v}.gemfile"} : GEMFILES gemfiles.each do |gemfile| + puts "GEMFILE: #{gemfile}" Bundler.with_clean_env do sh "bundle install --gemfile #{File.expand_path('../gemfiles/'+gemfile, __FILE__)}" end - puts '-'*80 + puts '-' * 80 end end end @@ -50,6 +51,7 @@ namespace :test do gemfiles = ENV['RAILS_VERSIONS'] ? ENV['RAILS_VERSIONS'].split(',').map {|v| "#{v}.gemfile"} : GEMFILES puts '-' * 80 gemfiles.each do |gemfile| + puts "GEMFILE: #{gemfile}" sh "BUNDLE_GEMFILE='#{File.expand_path("../gemfiles/#{gemfile}", __FILE__)}' " + " bundle exec rspec" puts '-' * 80