From 1196a23ebf9f8b64a175ea9b91f52f797ae8fedd Mon Sep 17 00:00:00 2001 From: Peter Goldstein Date: Wed, 5 Oct 2022 09:51:00 -0400 Subject: [PATCH] Migrate CI to GitHub Actions Now that Travis CI.org is no more, this PR migrates the CI to GitHub actions. In addition to setting up the pipeline, this PR: 1. Removes several gems that are either inapplicable or unsupported (wwtd, minitest-rg) 2. Updates the gemspec and Gemfile to use the gemspec for specifying dependencies 3. Eliminates use of an unused loop variable in favor of an explicit power. 4. Adds testing on modern Rubies 5. Removes the Gemfile.lock so that different Rubies can use different minitest/rake versions --- .github/workflows/ci.yml | 35 +++++++++++++++++++++++++++++++++++ .travis.yml | 7 ------- Gemfile | 6 +----- Gemfile.lock | 22 ---------------------- Rakefile | 2 -- lib/rchardet/utf8prober.rb | 4 +--- rchardet.gemspec | 3 +++ test/test_helper.rb | 1 - 8 files changed, 40 insertions(+), 40 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml delete mode 100644 Gemfile.lock diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..ad709a8 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,35 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake +# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby + +name: build + +on: [pull_request, push] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + ruby: + - '3.1' + - '3.0' + - '2.7' + - '2.6' + - '2.5' + - '2.4' + - '2.3' + - '2.2' + - '2.1' + - '2.0' + steps: + - uses: actions/checkout@v3 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + - run: bundle exec rake diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f203f61..0000000 --- a/.travis.yml +++ /dev/null @@ -1,7 +0,0 @@ -language: ruby -bundler_args: "" -rvm: - - 1.9.3 - - 2.0.0 - - 2.1.2 - - 2.2.2 diff --git a/Gemfile b/Gemfile index 907b814..b4e2a20 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,3 @@ source "https://rubygems.org" -gem "rake" -gem "wwtd" -gem "bump" -gem "minitest" -gem "minitest-rg" +gemspec diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index 58269bc..0000000 --- a/Gemfile.lock +++ /dev/null @@ -1,22 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - bump (0.5.0) - minitest (5.14.4) - minitest-rg (5.2.0) - minitest (~> 5.0) - rake (10.3.2) - wwtd (0.5.5) - -PLATFORMS - ruby - -DEPENDENCIES - bump - minitest - minitest-rg - rake - wwtd - -BUNDLED WITH - 2.2.16 diff --git a/Rakefile b/Rakefile index 51218b4..aaffc28 100644 --- a/Rakefile +++ b/Rakefile @@ -1,8 +1,6 @@ require 'bundler/setup' require 'bundler/gem_tasks' require 'rake/testtask' -require 'wwtd/tasks' -require 'bump/tasks' Rake::TestTask.new(:default) do |t| t.test_files = FileList['test/*_test.rb'] diff --git a/lib/rchardet/utf8prober.rb b/lib/rchardet/utf8prober.rb index 71af276..0c63712 100644 --- a/lib/rchardet/utf8prober.rb +++ b/lib/rchardet/utf8prober.rb @@ -75,9 +75,7 @@ def feed(aBuf) def get_confidence unlike = 0.99 if @numOfMBChar < 6 - for i in (0...@numOfMBChar) - unlike = unlike * ONE_CHAR_PROB - end + unlike = unlike * (ONE_CHAR_PROB ** @numOfMBChar) return 1.0 - unlike else return unlike diff --git a/rchardet.gemspec b/rchardet.gemspec index 8b78ddd..0091537 100644 --- a/rchardet.gemspec +++ b/rchardet.gemspec @@ -8,4 +8,7 @@ Gem::Specification.new "rchardet", CharDet::VERSION do |s| s.files = Dir["lib/**/*"] s.license = "LGPL" s.required_ruby_version = ">= 1.9.3" + + s.add_development_dependency "minitest" + s.add_development_dependency "rake" end diff --git a/test/test_helper.rb b/test/test_helper.rb index 368bd69..53b6182 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,6 +1,5 @@ require 'bundler/setup' require 'minitest/autorun' -require 'minitest/rg' $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__) require_relative '../lib/rchardet'