Skip to content

Commit

Permalink
Refactor tests. (#1953)
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Aug 26, 2022
1 parent 293b8e7 commit 1a37044
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 97 deletions.
8 changes: 0 additions & 8 deletions .ci.gemfile

This file was deleted.

62 changes: 0 additions & 62 deletions .github/workflows/development.yml

This file was deleted.

34 changes: 34 additions & 0 deletions .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
37 changes: 37 additions & 0 deletions .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
5 changes: 5 additions & 0 deletions Gemfile
Expand Up @@ -14,3 +14,8 @@ end
group :doc do
gem 'rdoc'
end

group :test do
gem 'minitest'
gem 'bake-test-external'
end
27 changes: 0 additions & 27 deletions Rakefile
Expand Up @@ -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
3 changes: 3 additions & 0 deletions config/external.yaml
@@ -0,0 +1,3 @@
protocol-rack:
url: https://github.com/socketry/protocol-rack
command: bundle exec bake test

0 comments on commit 1a37044

Please sign in to comment.