forked from rmosolgo/graphql-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
131 lines (108 loc) · 3.21 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# frozen_string_literal: true
require "bundler/setup"
Bundler::GemHelper.install_tasks
require "rake/testtask"
require_relative "guides/_tasks/site"
require_relative "lib/graphql/rake_task/validate"
Rake::TestTask.new do |t|
t.libs << "spec" << "lib"
if ENV["WITHOUT_RAILS"] == "yes"
t.test_files = Dir['spec/**/*_spec.rb'].reject do |f|
f.end_with?('_generator_spec.rb') ||
f.end_with?('input_object_type_spec.rb') ||
f.end_with?('variables_spec.rb') ||
f.end_with?('relation_connection_spec.rb') ||
f.end_with?('node_spec.rb') ||
f.end_with?('connection_instrumentation_spec.rb') ||
f.end_with?('graphql/schema_spec.rb') ||
f.end_with?('graphql/tracing/active_support_notifications_tracing_spec.rb') ||
f.start_with?('spec/graphql/relay/')
end
else
t.pattern = "spec/**/*_spec.rb"
end
t.warning = false
end
require 'rubocop/rake_task'
RuboCop::RakeTask.new
default_tasks = [:test, :rubocop, "js:all"]
if ENV["SYSTEM_TESTS"]
task(default: ["test:system"] + default_tasks)
else
task(default: default_tasks)
end
desc "Use Racc & Ragel to regenerate parser.rb & lexer.rb from configuration files"
task :build_parser do
def assert_dependency_version(dep_name, required_version, check_script)
version = `#{check_script}`
if !version.include?(required_version)
raise <<-ERR
build_parser requires #{dep_name} version "#{required_version}", but found:
$ #{check_script}
> #{version}
To fix this issue:
- Update #{dep_name} to the required version
- Update the assertion in `Rakefile` to match the current version
ERR
end
end
assert_dependency_version("Ragel", "7.0.0.9", "ragel -v")
assert_dependency_version("Racc", "1.4.14", %|ruby -e "require 'racc'; puts Racc::VERSION"|)
`rm -f lib/graphql/language/parser.rb lib/graphql/language/lexer.rb `
`racc lib/graphql/language/parser.y -o lib/graphql/language/parser.rb`
`ragel -R -F1 lib/graphql/language/lexer.rl`
end
namespace :bench do
def prepare_benchmark
$LOAD_PATH << "./lib" << "./spec/support"
require_relative("./benchmark/run.rb")
end
desc "Benchmark the introspection query"
task :query do
prepare_benchmark
GraphQLBenchmark.run("query")
end
desc "Benchmark validation of several queries"
task :validate do
prepare_benchmark
GraphQLBenchmark.run("validate")
end
desc "Generate a profile of the introspection query"
task :profile do
prepare_benchmark
GraphQLBenchmark.profile
end
end
namespace :test do
desc "Run system tests for ActionCable subscriptions"
task :system do
success = Dir.chdir("spec/dummy") do
system("bin/rails test:system")
end
success || exit(0)
end
task js: "js:test"
end
namespace :js do
client_dir = "./javascript_client"
desc "Run the tests for javascript_client"
task :test do
success = Dir.chdir(client_dir) do
system("yarn run test")
end
success || exit(0)
end
desc "Install JS dependencies"
task :install do
Dir.chdir(client_dir) do
system("yarn install")
end
end
desc "Publish the package to NPM"
task :publish do
Dir.chdir(client_dir) do
system("npm publish")
end
end
task all: [:install, :test]
end