forked from googleapis/google-cloud-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
116 lines (97 loc) · 3.31 KB
/
Rakefile
File metadata and controls
116 lines (97 loc) · 3.31 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
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
require "bundler/setup"
require "bundler/gem_tasks"
require "rubocop/rake_task"
RuboCop::RakeTask.new
task :test do
$LOAD_PATH.unshift "lib", "test"
Dir.glob("test/**/*_test.rb").each { |file| require_relative file }
end
namespace :test do
desc "Runs tests with coverage."
task :coverage do
require "simplecov"
SimpleCov.start do
command_name "google-cloud-bigquery"
track_files "lib/**/*.rb"
add_filter "test/"
end
Rake::Task["test"].invoke
end
end
# Acceptance tests
desc "Runs the bigquery acceptance tests."
task :acceptance, :project, :keyfile do |t, args|
project = args[:project]
project ||= ENV["GCLOUD_TEST_PROJECT"] || ENV["BIGQUERY_TEST_PROJECT"]
keyfile = args[:keyfile]
keyfile ||= ENV["GCLOUD_TEST_KEYFILE"] || ENV["BIGQUERY_TEST_KEYFILE"]
if project.nil? || keyfile.nil?
fail "You must provide a project and keyfile. e.g. rake acceptance[test123, /path/to/keyfile.json] or PUBSUB_TEST_PROJECT=test123 PUBSUB_TEST_KEYFILE=/path/to/keyfile.json rake acceptance"
end
# always overwrite when running tests
ENV["BIGQUERY_PROJECT"] = project
ENV["BIGQUERY_KEYFILE"] = keyfile
$LOAD_PATH.unshift "lib", "acceptance"
Dir.glob("acceptance/bigquery/**/*_test.rb").each { |file| require_relative file }
end
namespace :acceptance do
desc "Runs acceptance tests with coverage."
task :coverage, :project, :keyfile do |t, args|
require "simplecov"
SimpleCov.start do
command_name "google-cloud-bigquery"
track_files "lib/**/*.rb"
add_filter "acceptance/"
end
Rake::Task["acceptance"].invoke
end
desc "Removes *ALL* BigQuery datasets and tables. Use with caution."
task :cleanup, :project, :keyfile do |t, args|
project = args[:project]
project ||= ENV["GCLOUD_TEST_PROJECT"] || ENV["BIGQUERY_TEST_PROJECT"]
keyfile = args[:keyfile]
keyfile ||= ENV["GCLOUD_TEST_KEYFILE"] || ENV["BIGQUERY_TEST_KEYFILE"]
if project.nil? || keyfile.nil?
fail "You must provide a project and keyfile. e.g. rake acceptance:cleanup[test123, /path/to/keyfile.json] or PUBSUB_TEST_PROJECT=test123 PUBSUB_TEST_KEYFILE=/path/to/keyfile.json rake acceptance:cleanup"
end
# always overwrite when running tests
ENV["BIGQUERY_PROJECT"] = project
ENV["BIGQUERY_KEYFILE"] = keyfile
$LOAD_PATH.unshift "lib"
require "google/cloud/bigquery"
puts "Cleaning up BigQuery datasets and tables"
Google::Cloud.bigquery.datasets.all do |ds|
begin
ds.tables.all &:delete
ds.delete
rescue Google::Cloud::Bigquery::ApiError => e
puts e.message
end
end
end
end
desc "Start an interactive shell."
task :console do
require "irb"
require "irb/completion"
require "pp"
$LOAD_PATH.unshift "lib"
require "google-cloud-bigquery"
def gcloud; @gcloud ||= Google::Cloud.new; end
ARGV.clear
IRB.start
end
require "yard"
require "yard/rake/yardoc_task"
YARD::Rake::YardocTask.new
desc "Generates JSON output from google-cloud-ruby .yardoc"
task :jsondoc => :yard do
require "rubygems"
spec = Gem::Specification::load("gcloud.gemspec")
require "gcloud/jsondoc"
registry = YARD::Registry.load! ".yardoc"
generator = Gcloud::Jsondoc::Generator.new registry
generator.write_to "jsondoc"
cp ["docs/authentication.md", "docs/toc.json"], "jsondoc", verbose: true
end
task :default => :test