Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug flaky database in CI #5159

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,16 @@ Rake::TestTask.new do |t|
t.libs << "spec" << "lib" << "graphql-c_parser/lib"

exclude_integrations = []
['Mongoid', 'Rails'].each do |integration|
['mongoid', 'rails'].each do |integration|
begin
Object.const_get(integration)
rescue NameError
exclude_integrations << integration.downcase
require integration
rescue LoadError
exclude_integrations << integration
end
end

t.test_files = Dir['spec/**/*_spec.rb'].reject do |f|
next unless f.start_with?("spec/integration/")
excluded = exclude_integrations.any? do |integration|
f.start_with?("spec/integration/#{integration}/")
end
puts "+ #{f}" unless excluded
excluded
t.test_files = FileList.new("spec/**/*_spec.rb") do |fl|
fl.exclude(*exclude_integrations.map { |int| "spec/integration/#{int}/**/*" })
end

# After 2.7, there were not warnings for uninitialized ivars anymore
Expand Down
1 change: 1 addition & 0 deletions spec/integration/mongoid/star_trek/data.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true
require 'ostruct'
require 'support/mongoid_setup'

module StarTrek
names = [
Expand Down
1 change: 1 addition & 0 deletions spec/integration/rails/data.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true
require 'ostruct'
require "support/active_record_setup"

module StarWars
names = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class GraphQLGeneratorsInputGeneratorTest < BaseGeneratorTest
tests Graphql::Generators::InputGenerator

ActiveRecord::Schema.define do
self.verbose = !!ENV["GITHUB_ACTIONS"]
create_table :input_test_users, force: true do |t|
t.datetime :created_at
t.date :birthday
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class GraphQLGeneratorsObjectGeneratorTest < BaseGeneratorTest
tests Graphql::Generators::ObjectGenerator

ActiveRecord::Schema.define do
self.verbose = !!ENV["GITHUB_ACTIONS"]
create_table :test_users, force: true do |t|
t.datetime :created_at
t.date :birthday
Expand Down
25 changes: 8 additions & 17 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,27 +109,18 @@ def testing_mongoid?
defined?(::Mongoid)
end

# Load support files
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each do |f|
require f
end

if testing_rails?
require "integration/rails/spec_helper"
end

# Load dependencies
['Mongoid', 'Rails'].each do |integration|
integration_loaded = begin
Object.const_get(integration)
rescue NameError
nil
end
if ENV["TEST"].nil? && integration_loaded
Dir["spec/integration/#{integration.downcase}/**/*.rb"].each do |f|
require f.sub("spec/", "")
end
end
if testing_mongoid?
require "integration/mongoid/star_trek/data"
require "integration/mongoid/star_trek/schema"
end

# Load support files
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each do |f|
require f
end

def star_trek_query(string, variables={}, context: {})
Expand Down
2 changes: 1 addition & 1 deletion spec/support/active_record_setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

ActiveRecord::Base.establish_connection(:starwars)
ActiveRecord::Schema.define do
self.verbose = false
self.verbose = !!ENV["GITHUB_ACTIONS"]
create_table :bases, force: true do |t|
t.column :name, :string
t.column :planet, :string
Expand Down
Loading