diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..58251c7 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,47 @@ +name: Tests +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] +jobs: + tests: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ ubuntu-latest, macos-latest ] # , windows-latest ] + ruby-version: [ "2.6", "2.7", "3.0", "3.1" ] + + services: + cratedb: + image: crate/crate:nightly + ports: + - 44200:4200 + + name: Ruby ${{ matrix.ruby-version }} on OS ${{ matrix.os }} + steps: + + - name: Acquire sources + uses: actions/checkout@v3 + + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + architecture: x64 + + - name: Caching of Ruby gems + uses: actions/cache@v3 + id: cache-gems + with: + path: vendor/bundle + key: gems-os=${{ matrix.os }}-ruby=${{ matrix.ruby-version }}-${{ hashFiles('**/Gemfile.lock') }} + + - name: Bundle install + run: | + gem install bundler + bundle config path vendor/bundle + bundle install + + - name: Run tests + run: bundle exec rspec diff --git a/.gitignore b/.gitignore index 111a7f6..5225b55 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ _yardoc coverage doc/ lib/bundler/man +parts pkg rdoc spec/reports diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 24937a4..0000000 --- a/.travis.yml +++ /dev/null @@ -1,15 +0,0 @@ -language: ruby -rvm: - - "1.9.3" - - "2.0.0" - - "2.1.5" - - "2.2.0" -# uncomment this line if your project needs to run something other than `rake`: - -before_script: - - wget https://cdn.crate.io/downloads/releases/crate-0.47.3.tar.gz -O /tmp/crate.tar.gz - - tar -xvf /tmp/crate.tar.gz - - bundle exec ruby spec/test_server.rb $PWD/crate-0.47.3/ true - -script: bundle exec rspec spec - diff --git a/DEVELOP.md b/DEVELOP.md index 35e2778..07a45e7 100644 --- a/DEVELOP.md +++ b/DEVELOP.md @@ -1,3 +1,19 @@ +# Run tests + +Run CrateDB on port 44200. +```shell +docker run --rm -it --publish=44200:4200 crate:5.1.1 \ + -Cdiscovery.type=single-node \ + -Ccluster.routing.allocation.disk.threshold_enabled=false +``` + +Install project and invoke test suite. +```shell +bundle install +bundle exec rspec +``` + + # Release Process Business as usual, but in case you forgot, here it is. @@ -6,9 +22,8 @@ Business as usual, but in case you forgot, here it is. * update `history.txt` to reflect the changes of this release * Do the traditional trinity of: -```ruby +```shell gem update --system gem build gem build activerecord-crate-adapter.gemspec gem push activerecord-crate-adapter-.gem ``` - diff --git a/README.md b/README.md index 52b2aa2..7c276c6 100644 --- a/README.md +++ b/README.md @@ -123,13 +123,7 @@ Crate does not support Joins (yet) so joins won't work. ## Tests -Start up the crate server before running the tests - - ruby spec/test_server.rb /path/to/crate - -Then run tests with - - bundle exec rspec spec +See [DEVELOP.md](DEVELOP.md). ## Contributing diff --git a/spec/test_server.rb b/spec/test_server.rb deleted file mode 100755 index f7dbeb1..0000000 --- a/spec/test_server.rb +++ /dev/null @@ -1,82 +0,0 @@ -#!/usr/bin/env ruby -# -*- coding: utf-8; -*- -# -# Licensed to CRATE Technology GmbH ("Crate") under one or more contributor -# license agreements. See the NOTICE file distributed with this work for -# additional information regarding copyright ownership. Crate licenses -# this file to you under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. You may -# obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# However, if you have executed another commercial license agreement -# with Crate these terms will supersede the license and you may use the -# software solely pursuant to the terms of the relevant commercial agreement. - -require 'net/http' - -class TestServer - NAME = "TestCluster" - HOST = "127.0.0.1" - PORT = 44200 - TIMEOUT = 30 - - def initialize(crate_home = '~/crate', run_in_background = false) - @crate_home = crate_home - @run_in_background = run_in_background - end - - def start - cmd = "sh #{File.join(@crate_home, 'bin', 'crate')} #{start_params}" - @pid = spawn(cmd, out: "/tmp/crate_test_server.out", - err: "/tmp/crate_test_server.err") - Process.detach(@pid) - puts 'Starting Crate... (this will take a few seconds)' - time_slept = 0 - interval = 2 - while true - if !alive? and time_slept > TIMEOUT - puts "Crate hasn't started for #{TIMEOUT} seconds. Giving up now..." - exit - end - if alive? and @run_in_background - exit - end - sleep(interval) - time_slept += interval - end - end - - private - - def start_params - "-Des.index.storage.type=memory " + - "-Des.node.name=#{NAME} " + - "-Des.cluster.name=Testing#{PORT} " + - "-Des.http.port=#{PORT}-#{PORT} " + - "-Des.network.host=localhost " + - "-Des.discovery.zen.ping.multicast.enabled=false " + - "-Des.es.api.enabled=true" - end - - def alive? - req = Net::HTTP::Get.new('/') - resp = Net::HTTP.new(HOST, PORT) - begin - response = resp.start { |http| http.request(req) } - response.code == "200" ? true : false - rescue Errno::ECONNREFUSED - false - end - end -end - -server = TestServer.new(*ARGV) -server.start