From 5944de6561403c8f5ba1d7aefff59a7a2d01459c Mon Sep 17 00:00:00 2001 From: Zsolt Kozaroczy Date: Fri, 26 Jan 2024 06:02:12 +0100 Subject: [PATCH] Use GitHub actions (#76) * Fix tests for Ruby 2.0 * Add github actions * Drop old test running script to have only Rake for testing --- .github/workflows/test.yml | 55 ++++++++++++++++++++++++++++++++++++++ .travis.yml | 14 ---------- Gemfile | 5 ++++ Rakefile | 12 +++++++++ script/test | 25 ----------------- 5 files changed, 72 insertions(+), 39 deletions(-) create mode 100644 .github/workflows/test.yml delete mode 100644 .travis.yml create mode 100644 Rakefile delete mode 100755 script/test diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..488bde6 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,55 @@ +name: Test +on: + push: + branches: ['*'] + pull_request: + branches: ['*'] + +jobs: + test_ruby_versions: + runs-on: ubuntu-20.04 + + continue-on-error: ${{ matrix.allow_failures == 'allow failures' || false }} + + env: + BUNDLE_GEMFILE: "${{ matrix.gemfile }}" ### allows adding gemfile: to the matrix, bundler will automatically pick this up + + strategy: + fail-fast: false + matrix: + include: + - ruby: "2.0" + - ruby: 2.1 + - ruby: 2.2 + - ruby: 2.3 + - ruby: 2.4 + - ruby: 2.5 + - ruby: 2.6 + - ruby: 2.7 + - ruby: "3.0" ### must be quoted otherwise will be treated as "3" which resolves to latest 3.x version + - ruby: 3.1 + allow_failures: 'allow failures' + - ruby: 3.2 + allow_failures: 'allow failures' + - ruby: 3.3 + allow_failures: 'allow failures' + - ruby: head + allow_failures: 'allow failures' + + - ruby: jruby-9.3 + - ruby: jruby-9.4 + allow_failures: 'allow failures' + - ruby: jruby-head + allow_failures: 'allow failures' + steps: + - uses: actions/checkout@v4 + + - name: Install ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: "${{ matrix.ruby }}" + bundler-cache: true + + - name: Run tests + run: | + bundle exec rake diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 450948d..0000000 --- a/.travis.yml +++ /dev/null @@ -1,14 +0,0 @@ -language: ruby -rvm: - - 1.8 - - 1.9 - - 2.0 - - 2.1 - - 2.2 - - jruby - - rbx -matrix: - allow_failures: - - rvm: 1.8 -script: ./script/test -sudo: false \ No newline at end of file diff --git a/Gemfile b/Gemfile index 9cd1abd..d0f7a86 100644 --- a/Gemfile +++ b/Gemfile @@ -3,3 +3,8 @@ gemspec gem "rake" gem "minitest" + +if RUBY_VERSION < '2.1' + gem 'psych', '> 2.0.0' + gem 'rexml', '< 3.2.5' +end diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..e5238c9 --- /dev/null +++ b/Rakefile @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +require 'rake/testtask' + +Rake::TestTask.new do |t| + t.libs << 'test' + t.test_files = FileList['test/**/*_test.rb'] + t.verbose = false + t.warning = true +end + +task default: :test diff --git a/script/test b/script/test deleted file mode 100755 index c50314e..0000000 --- a/script/test +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -#/ Usage: test [individual test file] -#/ -#/ Bootstrap and run all tests or an individual test. -#/ -#/ Examples: -#/ -#/ # run all tests -#/ test -#/ -#/ # run individual test -#/ test test/controller_instrumentation_test.rb -#/ - -set -e -cd $(dirname "$0")/.. - -[ "$1" = "--help" -o "$1" = "-h" -o "$1" = "help" ] && { - grep '^#/' <"$0"| cut -c4- - exit 0 -} - -script/bootstrap && ruby -I lib -I test -r rubygems \ - -e 'require "bundler/setup"' \ - -e '(ARGV.empty? ? Dir["test/**/*_test.rb"] : ARGV).each { |f| load f }' -- "$@"