From 146c765e044353d00ceb3564d8ba8e947014c5af Mon Sep 17 00:00:00 2001 From: Daniel Azuma Date: Thu, 31 Dec 2020 17:13:48 -0800 Subject: [PATCH] chore: Cleanup of separate library generation (#2138) --- google-api-client/bin/generate-api | 15 +++++++- google-api-client/google-api-client.gemspec | 2 +- .../generator/templates/dot-yardopts.tmpl | 1 - .../apis/generator/templates/gemfile.tmpl | 37 ++++--------------- .../apis/generator/templates/gemspec.tmpl | 2 +- .../apis/generator/templates/rakefile.tmpl | 6 ++- google-apis-core/Rakefile | 15 +++----- 7 files changed, 31 insertions(+), 47 deletions(-) diff --git a/google-api-client/bin/generate-api b/google-api-client/bin/generate-api index c25b5fb65..0a76ae4a8 100755 --- a/google-api-client/bin/generate-api +++ b/google-api-client/bin/generate-api @@ -155,8 +155,19 @@ module Google def run_spot_check(gem_name) Dir.chdir(File.join(destination_root, gem_name)) do - system("bundle install") or error_and_exit("Failed to install bundle for newly generated library") - system("bundle exec rake ci") or error_and_exit("Failed to run spot check for newly generated library") + check_proc = Proc.new do + system("bundle install") or error_and_exit("Failed to install bundle for newly generated library") + system("bundle exec rake ci") or error_and_exit("Failed to run spot check for newly generated library") + end + if defined?(Bundler) + if Bundler.respond_to?(:with_unbundled_env) + Bundler.with_unbundled_env(&check_proc) + else + Bundler.with_clean_env(&check_proc) + end + else + check_proc.call + end end end diff --git a/google-api-client/google-api-client.gemspec b/google-api-client/google-api-client.gemspec index 169a18a24..6978a03cc 100644 --- a/google-api-client/google-api-client.gemspec +++ b/google-api-client/google-api-client.gemspec @@ -25,7 +25,7 @@ Gem::Specification.new do |gem| gem.required_ruby_version = '>= 2.4' - gem.add_runtime_dependency 'google-apis-core', '~> 0.0' + gem.add_runtime_dependency 'google-apis-core', '~> 0.1' gem.add_development_dependency 'thor', '~> 0.19' gem.add_development_dependency 'activesupport', '>= 4.2', '< 5.1' end diff --git a/google-api-client/lib/google/apis/generator/templates/dot-yardopts.tmpl b/google-api-client/lib/google/apis/generator/templates/dot-yardopts.tmpl index c344917d5..82ad0c619 100644 --- a/google-api-client/lib/google/apis/generator/templates/dot-yardopts.tmpl +++ b/google-api-client/lib/google/apis/generator/templates/dot-yardopts.tmpl @@ -4,7 +4,6 @@ --markup-provider=redcarpet --markup=markdown --main OVERVIEW.md - lib/<%= api.base_path %>/*.rb lib/<%= api.base_path %>.rb - diff --git a/google-api-client/lib/google/apis/generator/templates/gemfile.tmpl b/google-api-client/lib/google/apis/generator/templates/gemfile.tmpl index 2e139b768..6fa8bb627 100644 --- a/google-api-client/lib/google/apis/generator/templates/gemfile.tmpl +++ b/google-api-client/lib/google/apis/generator/templates/gemfile.tmpl @@ -2,45 +2,22 @@ source 'https://rubygems.org' gemspec -gem "google-apis-core", path: "../../google-apis-core" - group :development do - gem 'bundler', '>= 1.7' - gem 'rake', '~> 11.2' - gem 'rspec', '~> 3.1' - gem 'json_spec', '~> 1.1' - gem 'webmock', '~> 2.1' - gem 'simplecov', '~> 0.12' - gem 'coveralls', '~> 0.8' - gem 'rubocop', '~> 0.49.0' - gem 'launchy', '~> 2.4' - gem 'dotenv', '~> 2.0' - gem 'fakefs', '~> 0.6', require: "fakefs/safe" - gem 'google-id-token', '~> 1.3' - gem 'os', '~> 0.9' - gem 'rmail', '~> 1.1' - gem 'redis', '~> 3.2' - gem 'logging', '~> 2.2' - gem 'opencensus', '~> 0.4' - gem 'httparty' + gem "bundler", ">= 1.17" + gem "rake", ">= 12.0" + gem "rspec", "~> 3.9" + gem "opencensus", "~> 0.5" end platforms :jruby do group :development do - gem 'jruby-openssl' + gem "jruby-openssl" end end platforms :ruby do group :development do - gem 'yard', '~> 0.9', '>= 0.9.11' - gem 'redcarpet', '~> 3.2' - gem 'github-markup', '~> 1.3' - gem 'pry-doc', '~> 0.8' - gem 'pry-byebug', '~> 3.2' + gem "yard", "~> 0.9", ">= 0.9.25" + gem "redcarpet", "~> 3.5" end end - -if ENV['RAILS_VERSION'] - gem 'rails', ENV['RAILS_VERSION'] -end diff --git a/google-api-client/lib/google/apis/generator/templates/gemspec.tmpl b/google-api-client/lib/google/apis/generator/templates/gemspec.tmpl index 83192dda8..1a64749ba 100644 --- a/google-api-client/lib/google/apis/generator/templates/gemspec.tmpl +++ b/google-api-client/lib/google/apis/generator/templates/gemspec.tmpl @@ -28,5 +28,5 @@ Gem::Specification.new do |gem| gem.require_paths = ["lib"] gem.required_ruby_version = '>= 2.4' - gem.add_runtime_dependency "google-apis-core", "~> 0.0" + gem.add_runtime_dependency "google-apis-core", "~> 0.1" end diff --git a/google-api-client/lib/google/apis/generator/templates/rakefile.tmpl b/google-api-client/lib/google/apis/generator/templates/rakefile.tmpl index 7ef3c3fa6..defbde597 100644 --- a/google-api-client/lib/google/apis/generator/templates/rakefile.tmpl +++ b/google-api-client/lib/google/apis/generator/templates/rakefile.tmpl @@ -1,7 +1,10 @@ require "bundler/gem_tasks" +task :release_gem do + Rake::Task["build"].invoke + Rake::Task["release:rubygem_push"].invoke +end require 'rake/clean' - CLOBBER.include('coverage', 'doc') CLEAN.include('.yardoc') @@ -11,7 +14,6 @@ RSpec::Core::RakeTask.new(:spec) begin require 'yard' require 'yard/rake/yardoc_task' - YARD::Rake::YardocTask.new do |t| t.files = ['lib/**/*.rb', 'generated/**/*.rb'] t.options = ['--verbose', '--markup', 'markdown'] diff --git a/google-apis-core/Rakefile b/google-apis-core/Rakefile index cba7298ef..704ba4c7d 100644 --- a/google-apis-core/Rakefile +++ b/google-apis-core/Rakefile @@ -1,7 +1,10 @@ require "bundler/gem_tasks" +task :release_gem do + Rake::Task["build"].invoke + Rake::Task["release:rubygem_push"].invoke +end require 'rubocop/rake_task' - desc 'Run RuboCop on the lib directory' RuboCop::RakeTask.new(:rubocop) do |task| task.patterns = ['lib/**/*.rb'] @@ -12,23 +15,15 @@ RuboCop::RakeTask.new(:rubocop) do |task| end require 'rake/clean' - CLOBBER.include('coverage', 'doc') CLEAN.include('.yardoc') require 'rspec/core/rake_task' - -namespace :spec do - RSpec::Core::RakeTask.new(:all) -end - -desc 'Alias to spec:all' -task 'spec' => 'spec:all' +RSpec::Core::RakeTask.new(:spec) begin require 'yard' require 'yard/rake/yardoc_task' - YARD::Rake::YardocTask.new do |t| t.files = ['lib/**/*.rb', 'generated/**/*.rb'] t.options = ['--verbose', '--markup', 'markdown']