-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathRakefile
More file actions
68 lines (57 loc) · 1.79 KB
/
Copy pathRakefile
File metadata and controls
68 lines (57 loc) · 1.79 KB
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
# frozen_string_literal: true
require 'rake'
require 'rake/testtask'
require 'http'
require 'graphql'
require 'json'
Rake::TestTask.new do |t|
t.warning = false
t.libs << 'test'
t.test_files = FileList['test/*_test.rb']
end
desc 'Typecheck with Sorbet'
task :typecheck do
sh 'bundle exec srb tc'
end
desc 'Run the tests under SimpleCov; report in coverage/index.html'
task :coverage do
# Read by test/test_helper.rb. Rake::TestTask shells out, so it is inherited.
ENV['COVERAGE'] = '1'
Rake::Task['test'].invoke
end
desc 'Lint with RuboCop'
task :lint do
sh 'bundle exec rubocop'
end
desc 'Regenerate the typed Ledger Entry payload RBI and read the diff'
task :snapshot do
# The snapshot is the reviewable record of the surface a caller touches; see
# test/snapshot_test.rb for why regenerating it is a decision, not a chore.
ENV['RECORD_SNAPSHOTS'] = '1'
ruby '-Itest test/snapshot_test.rb'
sh 'git diff --stat -- sorbet/snapshots'
end
namespace :sorbet do
desc 'Regenerate gem RBIs, annotations, and the unresolved-constant list'
task :update do
sh 'bundle exec tapioca gem --all'
sh 'bundle exec tapioca annotations'
sh 'bundle exec bin/tapioca todo'
end
end
task default: %i[test typecheck]
namespace :graphql do
desc 'Download and convert GraphQL schema to JSON'
task :update_schema do
schema_url = 'https://api.us-west-2.fragment.dev/schema.graphql'
schema_path = 'lib/fragment.schema.json'
response = HTTP.get(schema_url)
schema = GraphQL::Schema.from_definition(response.to_s)
introspection_result = GraphQL::Introspection::INTROSPECTION_QUERY
query_result = schema.execute(introspection_result)
json_schema = JSON.pretty_generate(query_result)
File.open(schema_path, 'w') do |file|
file.write(json_schema)
end
end
end