From 1a37044281bffb91f06cd890727638b904a8c122 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Fri, 26 Aug 2022 19:32:03 +1200 Subject: Refactor tests. (#1953) --- .ci.gemfile | 8 ----- .github/workflows/development.yml | 62 ------------------------------------ .github/workflows/test-external.yaml | 34 ++++++++++++++++++++ .github/workflows/test.yaml | 37 +++++++++++++++++++++ Gemfile | 5 +++ Rakefile | 27 ---------------- config/external.yaml | 3 ++ 7 files changed, 79 insertions(+), 97 deletions(-) delete mode 100644 .ci.gemfile delete mode 100644 .github/workflows/development.yml create mode 100644 .github/workflows/test-external.yaml create mode 100644 .github/workflows/test.yaml create mode 100644 config/external.yaml diff --git a/.ci.gemfile b/.ci.gemfile deleted file mode 100644 index 9a62f512..00000000 --- a/.ci.gemfile +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true - -source 'https://rubygems.org' - -gem "webrick" -gem "minitest", "~> 5.0" -gem "minitest-global_expectations" -gem "rake" diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml deleted file mode 100644 index 53ee8676..00000000 --- a/.github/workflows/development.yml +++ /dev/null @@ -1,62 +0,0 @@ -name: Development - -on: [push, pull_request] - -permissions: - contents: read - -jobs: - test: - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, macos-latest] - ruby: [2.4, 2.5, 2.6, 2.7, '3.0', 3.1, jruby, truffleruby-head] - runs-on: ${{matrix.os}} - env: - BUNDLE_GEMFILE: .ci.gemfile - steps: - - uses: actions/checkout@v3 - - - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{matrix.ruby}} - bundler-cache: true - - - name: Installing packages (ubuntu) - if: matrix.os == 'ubuntu-latest' - run: sudo apt-get install libfcgi-dev libmemcached-dev - - - name: Installing packages (macos) - if: matrix.os == 'macos-latest' - run: brew install fcgi libmemcached - - - run: bundle exec rake - - external: - needs: test - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, macos-latest] - ruby: [2.6, 2.7] - runs-on: ${{matrix.os}} - env: - BUNDLE_GEMFILE: .ci.gemfile - steps: - - uses: actions/checkout@v3 - - - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{matrix.ruby}} - bundler-cache: true - - - name: Installing packages (ubuntu) - if: matrix.os == 'ubuntu-latest' - run: sudo apt-get install libmemcached-dev - - - name: Installing packages (macos) - if: matrix.os == 'macos-latest' - run: brew install libmemcached - - - run: bundle exec rake external diff --git a/.github/workflows/test-external.yaml b/.github/workflows/test-external.yaml new file mode 100644 index 00000000..59c25ef4 --- /dev/null +++ b/.github/workflows/test-external.yaml @@ -0,0 +1,34 @@ +name: Test External + +on: [push, pull_request] + +permissions: + contents: read + +jobs: + test: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + ruby: ['2.7', '3.0', '3.1'] + + runs-on: ${{matrix.os}} + + steps: + - uses: actions/checkout@v3 + + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{matrix.ruby}} + bundler-cache: true + + - name: Installing packages (ubuntu) + if: matrix.os == 'ubuntu-latest' + run: sudo apt-get install libfcgi-dev libmemcached-dev + + - name: Installing packages (macos) + if: matrix.os == 'macos-latest' + run: brew install fcgi libmemcached + + - run: bundle exec bake test:external diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 00000000..a224f677 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,37 @@ +name: Test + +on: [push, pull_request] + +permissions: + contents: read + +jobs: + test: + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + ruby: + - '2.4' + - '2.5' + - '2.6' + - '2.7' + - '3.0' + - '3.1' + - jruby + - truffleruby-head + include: + - os: macos-latest + ruby: '3.1' + runs-on: ${{matrix.os}} + + 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/Gemfile b/Gemfile index c17dadb5..526aa496 100644 --- a/Gemfile +++ b/Gemfile @@ -14,3 +14,8 @@ end group :doc do gem 'rdoc' end + +group :test do + gem 'minitest' + gem 'bake-test-external' +end diff --git a/Rakefile b/Rakefile index 9691af82..7df2fa82 100644 --- a/Rakefile +++ b/Rakefile @@ -134,30 +134,3 @@ task rdoc: %w[changelog spec] do `git ls-files lib/\*\*/\*.rb`.strip.split) cp "contrib/rdoc.css", "doc/rdoc.css" end - -def clone_and_test(url, name, command) - path = "external/#{name}" - FileUtils.rm_rf path - FileUtils.mkdir_p path - - sh("git clone #{url} #{path}") - - # I tried using `bundle config --local local.async ../` but it simply doesn't work. - File.open("#{path}/Gemfile", "a") do |file| - file.puts("gem 'rack', path: '../../'") - file.puts("gem 'rack-session', github: 'rack/rack-session'") if name == 'rack-attack' - end - - sh("cd #{path} && bundle install && #{command}") -end - -task :external do - # In order not to interfere with external tests: rename our config file - FileUtils.mv ".rubocop.yml", ".rack.rubocop.yml.disabled" - - Bundler.with_clean_env do - clone_and_test("https://github.com/rack/rack-attack", "rack-attack", "bundle exec rake test") - clone_and_test("https://github.com/rack/rack-cache", "rack-cache", "bundle exec rake") - clone_and_test("https://github.com/socketry/falcon", "falcon", "bundle exec rspec") - end -end diff --git a/config/external.yaml b/config/external.yaml new file mode 100644 index 00000000..92e64509 --- /dev/null +++ b/config/external.yaml @@ -0,0 +1,3 @@ +protocol-rack: + url: https://github.com/socketry/protocol-rack + command: bundle exec bake test -- cgit v1.2.3-24-ge0c7