2012-08-29 05:43:31 +04:00
|
|
|
#-------------------------------------------------------------------------
|
2013-11-26 04:38:44 +04:00
|
|
|
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
2012-08-29 05:43:31 +04:00
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
#--------------------------------------------------------------------------
|
2017-11-20 21:42:26 +03:00
|
|
|
|
|
|
|
#
|
|
|
|
# This rakefile consists of several tasks. This section will provide an overview of the
|
|
|
|
# tasks and their dependencies.
|
|
|
|
#
|
|
|
|
# -------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
# | No | Task | Description |
|
|
|
|
# |----|---------------------------------|--------------------------------------------------------------------------------------------------|
|
|
|
|
# | 1 | regen | Regenerates all the SDK versions for all the services and all the profiles for all the services. |
|
|
|
|
# | | | This task has regen_sdk_versions and regen_all_profiles as prereqs. |
|
|
|
|
# |----|---------------------------------|--------------------------------------------------------------------------------------------------|
|
|
|
|
# | 2 | regen_sdk_versions | Regenerates all the SDK versions for all the services. At the end, this task calls |
|
|
|
|
# | | | regen_individual_require_files as an enhancement. This task has clean_generated as prereq. This |
|
|
|
|
# |. |. | task is focused on code generation using autorest and will generate api versions as indicated in |
|
|
|
|
# | | |.in the config.json file. |
|
|
|
|
# |----|---------------------------------|--------------------------------------------------------------------------------------------------|
|
|
|
|
# | 3 | regen_all_profiles | Regenerates all the profiles for all the services. This task has regen_rollup_profile and |
|
|
|
|
# | | | regen_individual_profiles as prereqs. This task uses the profile_generator to generate the |
|
|
|
|
# | | | with inputs from profiles.json and dir_metadata.json. |
|
|
|
|
# |----|---------------------------------|--------------------------------------------------------------------------------------------------|
|
|
|
|
# | 4 | clean_generated | Cleans all the generated folders in multiple SDK versions. |
|
|
|
|
# |----|---------------------------------|--------------------------------------------------------------------------------------------------|
|
|
|
|
# | 5 | regen_rollup_profile | Regenerates all profiles within the rollup gem. At the end, this task calls |
|
|
|
|
# | | | regen_rollup_require_files as an enhancement. This task has clean_rollup_profiles as prereq. This|
|
|
|
|
#.|. | | task requires correct definition of rollup profiles in profiles.json file. |
|
|
|
|
# |----|---------------------------------|--------------------------------------------------------------------------------------------------|
|
|
|
|
# | 6 | regen_individual_profiles | Regenerates all profiles with all the services. At the end, this task calls |
|
|
|
|
# | | | regen_individual_require_files as an enhancement. This task calls clean_individual_profiles |
|
|
|
|
# | | | as prereq. This task requires correct definition of individual profiles in profiles.json file. |
|
|
|
|
# |----|---------------------------------|--------------------------------------------------------------------------------------------------|
|
|
|
|
# | 7 | clean_all_profiles | Cleans all profiles inside the rollup gem and individual gems.This task has clean_rollup_profiles|
|
|
|
|
# | | | and clean_individual_profiles as prereqs. |
|
|
|
|
# |----|---------------------------------|--------------------------------------------------------------------------------------------------|
|
|
|
|
# | 8 | clean_rollup_profiles | Cleans all profiles inside the rollup gem. |
|
|
|
|
# |----|---------------------------------|--------------------------------------------------------------------------------------------------|
|
|
|
|
# | 9 | clean_individual_profiles | Cleans all profiles inside individual gems. |
|
|
|
|
# |----|---------------------------------|--------------------------------------------------------------------------------------------------|
|
|
|
|
# | 10 | regen_all_require_files | Regenerates the require files for the rollup gem and individual gems. This task has |
|
|
|
|
# | | | regen_rollup_require_files and regen_individual_require_files as prereqs. A require file is the |
|
|
|
|
# | | | base file for a gem which includes other file. A sample could be found here: |
|
|
|
|
# |. | | https://github.com/Azure/azure-sdk-for-ruby/blob/master/azure_sdk/lib/azure_sdk.rb |
|
|
|
|
# |----|---------------------------------|--------------------------------------------------------------------------------------------------|
|
|
|
|
# | 11 | regen_rollup_require_files | Regenerates the require files for the rollup gem |
|
|
|
|
# |----|---------------------------------|--------------------------------------------------------------------------------------------------|
|
|
|
|
# | 12 | regen_individual_require_files | Regenerates the require files for the individual gems |
|
|
|
|
# |----|---------------------------------|--------------------------------------------------------------------------------------------------|
|
|
|
|
# | 13 | release | Release gems. This task has build as a prereq. The gems to be released must be indicated in the |
|
|
|
|
# |. | | GEMS_TO_RELEASE file. |
|
|
|
|
# |----|---------------------------------|--------------------------------------------------------------------------------------------------|
|
|
|
|
# | 14 | build | Builds all gems. This task has clean as a prereq. |
|
|
|
|
# |----|---------------------------------|--------------------------------------------------------------------------------------------------|
|
|
|
|
# | 15 | clean | Cleans the pks folder inside all the gems. |
|
|
|
|
# |----|---------------------------------|--------------------------------------------------------------------------------------------------|
|
|
|
|
# | 16 | bundle:update | Performs bundle update for all gems. |
|
|
|
|
# |----|---------------------------------|--------------------------------------------------------------------------------------------------|
|
|
|
|
# | 17 | spec | Executes tests for all gems. |
|
|
|
|
# -------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# regen
|
|
|
|
# |
|
|
|
|
# -----------------------------------------------------------------------------------------------------
|
|
|
|
# | |
|
|
|
|
# regen_sdk_versions -->enhancement--> regen_individual_require_files |
|
|
|
|
# | regen_all_profiles
|
|
|
|
# | |
|
|
|
|
# clean_generated ------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
# | |
|
|
|
|
# | |
|
|
|
|
# | |
|
|
|
|
# | |
|
|
|
|
# | regen_all_require_files |
|
|
|
|
# | | |
|
|
|
|
# | ----------------------------------------- |
|
|
|
|
# | | | |
|
|
|
|
# | | | |
|
|
|
|
# | | | |
|
|
|
|
# regen_rollup_profile -->enhancement--> regen_rollup_require_files | |
|
|
|
|
# | | |
|
|
|
|
# | | |
|
|
|
|
# | | |
|
|
|
|
# | | |
|
|
|
|
# | | |
|
|
|
|
# | | |
|
|
|
|
# | regen_individual_require_files<--enhancement<--regen_individual_profiles
|
|
|
|
# | |
|
|
|
|
# | clean_all_profiles |
|
|
|
|
# | | |
|
|
|
|
# | --------------------------------------------------------------------------------------------------------------- |
|
|
|
|
# | | | |
|
|
|
|
# | | | |
|
|
|
|
# clean_rollup_profiles clean_individual_profiles
|
|
|
|
#
|
|
|
|
# release
|
|
|
|
# |
|
|
|
|
# build
|
|
|
|
# |
|
|
|
|
# clean
|
|
|
|
#
|
|
|
|
# bundle:update
|
|
|
|
#
|
|
|
|
# spec
|
|
|
|
#
|
|
|
|
|
2015-04-22 00:26:45 +03:00
|
|
|
require 'dotenv/tasks'
|
2016-08-06 02:55:55 +03:00
|
|
|
require 'rspec/core/rake_task'
|
|
|
|
require 'open3'
|
|
|
|
require 'os'
|
2017-08-31 02:37:29 +03:00
|
|
|
require 'json'
|
2017-10-11 00:52:43 +03:00
|
|
|
require 'fileutils'
|
2012-06-15 01:45:06 +04:00
|
|
|
|
2018-05-08 22:38:56 +03:00
|
|
|
def get_config_files_folder
|
|
|
|
"#{__dir__}/config"
|
|
|
|
end
|
|
|
|
|
|
|
|
gem_versions = JSON.parse(File.read(File.expand_path("#{get_config_files_folder}/GEM_VERSIONS", __FILE__)).strip)
|
|
|
|
gems_to_release = JSON.parse(File.read(File.expand_path("#{get_config_files_folder}/GEMS_TO_RELEASE", __FILE__)).strip)
|
2018-07-28 00:54:37 +03:00
|
|
|
GEMS_TO_IGNORE = %w{azure_mgmt_graph, azure_mgmt_mobile_engagement, azure_mgmt_server_management}
|
2017-11-07 07:58:18 +03:00
|
|
|
REGEN_EXCLUDES = ['azure_sdk']
|
2012-06-15 01:45:06 +04:00
|
|
|
|
2016-08-06 02:55:55 +03:00
|
|
|
desc 'Azure Resource Manager related tasks which often traverse each of the arm gems'
|
|
|
|
namespace :arm do
|
|
|
|
desc 'Delete ./pkg for each of the Azure Resource Manager projects'
|
2018-01-10 23:43:39 +03:00
|
|
|
task :clean, [:gem_name] do |_, args|
|
|
|
|
each_gem do |dir|
|
|
|
|
if !should_i_continue(args[:gem_name], dir)
|
|
|
|
next
|
|
|
|
end
|
|
|
|
|
2017-11-07 07:58:18 +03:00
|
|
|
FileUtils.rm_rf('pkg')
|
2016-08-06 02:55:55 +03:00
|
|
|
end
|
2012-07-07 02:59:00 +04:00
|
|
|
end
|
|
|
|
|
2017-10-11 01:49:45 +03:00
|
|
|
desc 'Delete multiple version folders for each sdk'
|
2018-01-10 23:43:39 +03:00
|
|
|
task :clean_generated, [:gem_name] do |_, args|
|
|
|
|
clean_generated('management', args[:gem_name])
|
|
|
|
clean_generated('data', args[:gem_name])
|
2017-10-11 01:49:45 +03:00
|
|
|
Dir.chdir(File.expand_path('..', __FILE__))
|
2012-06-15 01:45:06 +04:00
|
|
|
end
|
2013-10-11 14:09:19 +04:00
|
|
|
|
2016-08-06 02:55:55 +03:00
|
|
|
desc 'Build gems for each of the Azure Resource Manager projects'
|
2018-01-10 23:43:39 +03:00
|
|
|
task :build, [:gem_name] => :clean do |_, args|
|
|
|
|
each_gem do |dir|
|
|
|
|
if !should_i_continue(args[:gem_name], dir)
|
|
|
|
next
|
|
|
|
end
|
|
|
|
|
2016-08-06 02:55:55 +03:00
|
|
|
execute_and_stream('rake build')
|
2012-10-04 13:01:22 +04:00
|
|
|
end
|
|
|
|
end
|
2012-06-15 01:45:06 +04:00
|
|
|
|
2017-11-07 07:58:18 +03:00
|
|
|
desc 'Push gem for each of the Azure projects'
|
2016-08-06 02:55:55 +03:00
|
|
|
task :release, [:key] => :build do |_, args|
|
2017-11-07 07:58:18 +03:00
|
|
|
gems_to_release.each do |key, gems|
|
|
|
|
gems.each do |gem|
|
|
|
|
if(key == 'rollup')
|
|
|
|
Dir.chdir("#{__dir__}/azure_sdk")
|
|
|
|
version = gem_versions['rollup'][gem]
|
|
|
|
elsif(key == 'management')
|
|
|
|
Dir.chdir("#{__dir__}/management/#{gem}")
|
|
|
|
version = gem_versions['management'][gem]
|
2017-12-21 23:10:57 +03:00
|
|
|
elsif(key == 'data')
|
|
|
|
Dir.chdir("#{__dir__}/data/#{gem}")
|
|
|
|
version = gem_versions['data'][gem]
|
2017-11-07 07:58:18 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
# Delay for 10 seconds before publishing gem
|
|
|
|
puts "Going to sleep for 10 seconds before publishing #{gem} ..."
|
|
|
|
sleep(10)
|
2017-10-12 02:10:30 +03:00
|
|
|
|
2017-11-07 07:58:18 +03:00
|
|
|
execute("gem push ./pkg/#{gem}-#{version}.gem" + (args[:key].nil? ? '' : " -k #{args[:key]}"))
|
|
|
|
end
|
2015-06-09 09:26:01 +03:00
|
|
|
end
|
2012-06-15 01:45:06 +04:00
|
|
|
end
|
|
|
|
|
2017-08-31 02:37:29 +03:00
|
|
|
desc 'Regen code for each sdk with all its api versions'
|
2018-01-10 23:43:39 +03:00
|
|
|
task :regen_sdk_versions, [:gem_name] => :clean_generated do |_, args|
|
2017-08-31 02:37:29 +03:00
|
|
|
json = get_config_file
|
2017-12-21 23:10:57 +03:00
|
|
|
each_gem do |dir| # dir corresponds to each azure_* folder
|
2018-11-07 01:00:10 +03:00
|
|
|
if REGEN_EXCLUDES.include?(dir.to_s)
|
|
|
|
update_gem_version('lib/azure_sdk/version.rb', gem_versions['rollup'][dir])
|
2018-01-10 23:43:39 +03:00
|
|
|
next
|
|
|
|
end
|
|
|
|
|
2018-11-07 01:00:10 +03:00
|
|
|
if !should_i_continue(args[:gem_name], dir)
|
2017-11-07 07:58:18 +03:00
|
|
|
next
|
|
|
|
end
|
2017-12-21 23:10:57 +03:00
|
|
|
|
|
|
|
mode = get_mode(dir)
|
2017-11-07 07:58:18 +03:00
|
|
|
|
|
|
|
puts "\nGenerating #{dir}\n"
|
|
|
|
ar_base_command = "#{ENV.fetch('AUTOREST_LOC', 'autorest')}"
|
|
|
|
ar_base_command = "#{ar_base_command} --use=#{ENV.fetch('AUTOREST_RUBY_LOC')}" unless ENV.fetch('AUTOREST_RUBY_LOC', nil).nil?
|
|
|
|
puts "ar_base_command #{ar_base_command}"
|
|
|
|
md = json[dir] # there should be an entry in the metadata for each of the api versions to generate
|
|
|
|
package_name = dir
|
|
|
|
md.each do |api_version_pkg, api_version_value|
|
|
|
|
ar_arguments = ''
|
|
|
|
output_folder = ''
|
|
|
|
api_version_value.each do |argument_name, argument_value|
|
|
|
|
if argument_name.casecmp("output-folder") == 0
|
|
|
|
output_folder = argument_value
|
|
|
|
else
|
|
|
|
if argument_name.casecmp("package-name") == 0
|
|
|
|
package_name = argument_value
|
|
|
|
else
|
|
|
|
if argument_name.casecmp("markdown") == 0
|
|
|
|
ar_arguments = ar_arguments + " #{argument_value}"
|
|
|
|
else
|
|
|
|
if argument_name.casecmp("input-file") == 0
|
|
|
|
input_files = argument_value.map {|file| "--input-file=#{file}"}
|
|
|
|
ar_arguments = ar_arguments + input_files.join(" ")
|
|
|
|
else
|
|
|
|
ar_arguments = ar_arguments + " --#{argument_name}=#{argument_value}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-08-31 02:37:29 +03:00
|
|
|
end
|
2017-12-21 23:10:57 +03:00
|
|
|
command = "#{ar_base_command} --package-name=#{package_name} #{ar_arguments} --package-version=#{gem_versions[mode][dir]} --output-folder=#{File.join(Dir.pwd, 'lib', output_folder)} --ruby --azure-arm"
|
2017-11-07 07:58:18 +03:00
|
|
|
execute_and_stream(command)
|
2016-09-12 21:02:17 +03:00
|
|
|
end
|
2017-12-21 23:10:57 +03:00
|
|
|
update_gem_version('lib/version.rb', gem_versions[mode][dir])
|
2012-06-15 01:45:06 +04:00
|
|
|
end
|
2016-08-06 02:55:55 +03:00
|
|
|
end
|
2012-06-15 01:45:06 +04:00
|
|
|
|
2016-08-06 02:55:55 +03:00
|
|
|
desc 'Bundler related helper'
|
|
|
|
namespace :bundle do
|
|
|
|
desc 'bundle update for each of the Azure Resource Manager projects'
|
2018-01-10 23:43:39 +03:00
|
|
|
task :update, [:gem_name] do |_, args|
|
2016-08-06 02:55:55 +03:00
|
|
|
each_gem do
|
2018-01-10 23:43:39 +03:00
|
|
|
if !should_i_continue(args[:gem_name], dir)
|
|
|
|
next
|
|
|
|
end
|
|
|
|
|
2016-08-06 02:55:55 +03:00
|
|
|
execute_and_stream('bundle update')
|
|
|
|
end
|
|
|
|
end
|
2012-06-15 01:45:06 +04:00
|
|
|
end
|
|
|
|
|
2016-08-06 02:55:55 +03:00
|
|
|
desc 'run specs for each of the Azure Resource Manager projects'
|
2018-01-10 23:43:39 +03:00
|
|
|
task :spec, [:gem_name] => :dotenv do |_, args|
|
2017-01-13 00:49:00 +03:00
|
|
|
each_gem do |gem_dir|
|
2018-01-10 23:43:39 +03:00
|
|
|
if !should_i_continue(args[:gem_name], gem_dir)
|
|
|
|
next
|
|
|
|
end
|
|
|
|
|
2017-01-13 00:49:00 +03:00
|
|
|
puts "Executing spec on #{gem_dir}"
|
2016-08-06 02:55:55 +03:00
|
|
|
execute_and_stream('bundle install')
|
|
|
|
execute_and_stream('bundle exec rspec')
|
2016-04-02 02:45:32 +03:00
|
|
|
end
|
|
|
|
end
|
2017-10-11 00:52:43 +03:00
|
|
|
|
|
|
|
desc 'Clean Rollup Profiles'
|
|
|
|
task :clean_rollup_profiles do
|
|
|
|
Dir.chdir(File.expand_path('../azure_sdk/lib', __FILE__))
|
|
|
|
subdir_list = Dir['*'].reject{|o| not File.directory?(o)}
|
|
|
|
subdir_list.each do |subdir|
|
2017-11-08 23:34:16 +03:00
|
|
|
if subdir != 'azure_sdk'
|
2017-10-11 00:52:43 +03:00
|
|
|
folder_to_be_cleaned = File.expand_path("../azure_sdk/lib/#{subdir}", __FILE__)
|
|
|
|
puts "Cleaning folder - #{folder_to_be_cleaned}"
|
|
|
|
FileUtils.rm_rf(folder_to_be_cleaned)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
desc 'Clean Individual Profiles'
|
2018-01-10 23:43:39 +03:00
|
|
|
task :clean_individual_profiles, [:gem_name] do |_, args|
|
2017-11-07 07:58:18 +03:00
|
|
|
each_gem_dir do |gem|
|
2018-01-10 23:43:39 +03:00
|
|
|
if !should_i_continue(args[:gem_name], gem)
|
|
|
|
next
|
|
|
|
end
|
|
|
|
|
2017-11-07 07:58:18 +03:00
|
|
|
if REGEN_EXCLUDES.include?gem
|
|
|
|
next
|
|
|
|
end
|
2018-01-10 23:43:39 +03:00
|
|
|
|
2017-12-21 23:10:57 +03:00
|
|
|
mode = get_mode(gem)
|
|
|
|
Dir.chdir("#{__dir__}/#{mode}/#{gem}/lib/profiles")
|
2017-11-07 07:58:18 +03:00
|
|
|
|
2017-10-11 00:52:43 +03:00
|
|
|
subdir_list = Dir['*'].reject{|o| not File.directory?(o)}
|
|
|
|
subdir_list.each do |subdir|
|
2017-12-21 23:10:57 +03:00
|
|
|
folder_to_be_cleaned = "#{__dir__}/#{mode}/#{gem}/lib/profiles/#{subdir}"
|
2017-11-08 23:34:16 +03:00
|
|
|
puts "Cleaning folder - #{folder_to_be_cleaned}"
|
|
|
|
FileUtils.rm_rf(folder_to_be_cleaned)
|
2017-10-11 00:52:43 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
desc 'Clean All profiles'
|
2018-01-10 23:43:39 +03:00
|
|
|
task :clean_all_profiles, [:gem_name] => [:clean_rollup_profiles, :clean_individual_profiles] do
|
2017-10-11 00:52:43 +03:00
|
|
|
puts 'Cleaned all profiles'
|
|
|
|
end
|
|
|
|
|
|
|
|
desc 'Regen rollup profiles'
|
|
|
|
task :regen_rollup_profile => :clean_rollup_profiles do
|
2017-11-07 07:58:18 +03:00
|
|
|
Dir.chdir(__dir__)
|
2017-10-11 00:52:43 +03:00
|
|
|
# Sample Command
|
2017-11-07 07:58:18 +03:00
|
|
|
# bundle exec ruby profile_generator_client.rb --dir_metadata=dir_metadata.json --profile=profiles.json --mode=rollup --key=azure_sdk
|
2018-05-08 22:38:56 +03:00
|
|
|
command = "#{get_base_profile_generation_cmd} --dir_metadata=#{get_config_files_folder}/dir_metadata.json --profile=#{get_config_files_folder}/profiles.json --mode=rollup --key=azure_sdk --sdk_path=#{__dir__}"
|
2017-10-11 00:52:43 +03:00
|
|
|
execute_and_stream(command)
|
|
|
|
end
|
|
|
|
|
|
|
|
desc 'Regen individual profiles'
|
2018-01-10 23:43:39 +03:00
|
|
|
task :regen_individual_profiles, [:gem_name] => :clean_individual_profiles do |_, args|
|
2017-11-07 07:58:18 +03:00
|
|
|
each_gem_dir do |gem|
|
2018-01-10 23:43:39 +03:00
|
|
|
if !should_i_continue(args[:gem_name], gem)
|
|
|
|
next
|
|
|
|
end
|
|
|
|
|
2017-11-07 07:58:18 +03:00
|
|
|
if REGEN_EXCLUDES.include?gem
|
|
|
|
next
|
2017-10-11 00:52:43 +03:00
|
|
|
end
|
2017-12-21 23:10:57 +03:00
|
|
|
mode = get_mode(gem)
|
2017-11-07 07:58:18 +03:00
|
|
|
|
|
|
|
# Sample Command
|
|
|
|
# bundle exec ruby profile_generator_client.rb --dir_metadata=dir_metadata.json --profile=authorization_profiles.json --mode=management --key=azure_mgmt_authorization
|
2018-05-08 22:38:56 +03:00
|
|
|
command = "#{get_base_profile_generation_cmd} --dir_metadata=#{get_config_files_folder}/dir_metadata.json --profile=#{get_config_files_folder}/profiles.json --mode=#{mode} --key=#{gem} --sdk_path=#{__dir__}"
|
2017-11-07 07:58:18 +03:00
|
|
|
execute_and_stream(command)
|
2017-10-11 00:52:43 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
desc 'Generate individual require files'
|
2018-01-10 23:43:39 +03:00
|
|
|
task :regen_individual_require_files, [:gem_name] do |_, args|
|
|
|
|
key = args[:gem_name].nil? ? '*' : args[:gem_name]
|
|
|
|
command = "bundle exec ruby #{__dir__}/generators/requirefilegen/src/require_file_generator.rb --mode=individual --sdk_path=#{__dir__} --gem_name=#{key}"
|
2017-10-11 00:52:43 +03:00
|
|
|
execute_and_stream(command)
|
|
|
|
end
|
|
|
|
|
|
|
|
desc 'Generate rollup require files'
|
|
|
|
task :regen_rollup_require_files do
|
2018-01-10 23:43:39 +03:00
|
|
|
command = "bundle exec ruby #{__dir__}/generators/requirefilegen/src/require_file_generator.rb --mode=rollup --sdk_path=#{__dir__} --gem_name=azure_sdk"
|
2017-10-11 00:52:43 +03:00
|
|
|
execute_and_stream(command)
|
|
|
|
end
|
|
|
|
|
2018-11-03 00:10:10 +03:00
|
|
|
task :regen_folder_structure_if_required, [:gem_name] do |_, args|
|
|
|
|
plane = 'data'
|
|
|
|
if(args[:gem_name].include?'_mgmt_')
|
|
|
|
plane = 'management'
|
|
|
|
end
|
|
|
|
command = "bundle exec ruby #{__dir__}/generators/metadatagen/src/metadatagen.rb --plane=#{plane} --gem_name=#{args[:gem_name]} --sdk_path=#{__dir__}"
|
|
|
|
execute_and_stream(command)
|
|
|
|
end
|
|
|
|
|
2017-10-11 00:52:43 +03:00
|
|
|
desc 'Generate all require files'
|
2018-01-10 23:43:39 +03:00
|
|
|
task :regen_all_require_files, [:gem_name] => [:regen_individual_require_files, :regen_rollup_require_files] do
|
2017-10-11 00:52:43 +03:00
|
|
|
puts 'Generated all require files'
|
|
|
|
end
|
|
|
|
|
|
|
|
desc 'Regen all profiles'
|
2018-01-10 23:43:39 +03:00
|
|
|
task :regen_all_profiles, [:gem_name] => [:regen_rollup_profile, :regen_individual_profiles] do
|
2017-10-11 00:52:43 +03:00
|
|
|
puts 'Regenerated all profiles'
|
|
|
|
end
|
2017-11-07 07:58:18 +03:00
|
|
|
|
|
|
|
desc 'Regen all versions of sdk and profiles'
|
2018-01-10 23:43:39 +03:00
|
|
|
task :regen, [:gem_name] => [:regen_sdk_versions, :regen_all_profiles] do
|
2017-11-07 07:58:18 +03:00
|
|
|
puts 'Regenerated all versions of sdk and profiles'
|
|
|
|
end
|
2017-10-11 00:52:43 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
Rake::Task['arm:regen_rollup_profile'].enhance do
|
|
|
|
Rake::Task['arm:regen_rollup_require_files'].invoke
|
2018-06-07 00:06:08 +03:00
|
|
|
Rake::Task['arm:regen_rollup_require_files'].reenable
|
2017-10-11 00:52:43 +03:00
|
|
|
end
|
|
|
|
|
2018-01-10 23:43:39 +03:00
|
|
|
Rake::Task['arm:regen_individual_profiles'].enhance do |_, args|
|
|
|
|
Rake::Task['arm:regen_individual_require_files'].invoke(args[:gem_name])
|
2018-06-07 00:06:08 +03:00
|
|
|
Rake::Task['arm:regen_individual_require_files'].reenable
|
2016-08-06 02:55:55 +03:00
|
|
|
end
|
2016-04-02 02:45:32 +03:00
|
|
|
|
2018-01-10 23:43:39 +03:00
|
|
|
Rake::Task['arm:regen_sdk_versions'].enhance do |_, args|
|
|
|
|
Rake::Task['arm:regen_individual_require_files'].invoke(args[:gem_name])
|
2018-06-07 00:06:08 +03:00
|
|
|
Rake::Task['arm:regen_individual_require_files'].reenable
|
2017-11-07 07:58:18 +03:00
|
|
|
end
|
|
|
|
|
2016-08-06 02:55:55 +03:00
|
|
|
task :default => :spec
|
|
|
|
|
2018-01-10 23:43:39 +03:00
|
|
|
def should_i_continue(key, dir)
|
|
|
|
return (key.nil? || key == dir)
|
|
|
|
end
|
|
|
|
|
2017-12-21 23:10:57 +03:00
|
|
|
def get_mode(dir)
|
|
|
|
mode = ''
|
|
|
|
if (dir.include? '_mgmt_')
|
|
|
|
mode = 'management'
|
|
|
|
else
|
|
|
|
mode = 'data'
|
|
|
|
end
|
|
|
|
mode
|
|
|
|
end
|
|
|
|
|
2018-01-10 23:43:39 +03:00
|
|
|
def clean_generated(parent_dir, key)
|
2017-12-21 23:10:57 +03:00
|
|
|
Dir.chdir(File.expand_path("../#{parent_dir}", __FILE__))
|
|
|
|
gem_folders = Dir['*'].reject{|o| not File.directory?(o)}
|
|
|
|
gem_folders.each do |gem|
|
2018-01-10 23:43:39 +03:00
|
|
|
if !should_i_continue(key, gem)
|
|
|
|
next
|
|
|
|
end
|
|
|
|
|
2017-12-21 23:10:57 +03:00
|
|
|
if GEMS_TO_IGNORE.include?gem
|
|
|
|
next
|
|
|
|
end
|
|
|
|
|
|
|
|
Dir.chdir(File.expand_path("../#{parent_dir}/#{gem}/lib", __FILE__))
|
|
|
|
subdir_list = Dir['*'].reject{|o| not File.directory?(o)}
|
|
|
|
subdir_list.each do |subdir|
|
|
|
|
if subdir.to_s == 'profiles'
|
|
|
|
next
|
|
|
|
end
|
|
|
|
|
|
|
|
folder_to_be_cleaned = File.expand_path("../#{parent_dir}/#{gem}/lib/#{subdir}", __FILE__)
|
|
|
|
puts "Cleaning folder - #{folder_to_be_cleaned}"
|
|
|
|
FileUtils.rm_rf(folder_to_be_cleaned)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-10-11 00:52:43 +03:00
|
|
|
def get_base_profile_generation_cmd
|
2017-11-07 07:58:18 +03:00
|
|
|
"bundle exec ruby #{__dir__}/generators/profilegen/src/profile_generator_client.rb"
|
2017-10-11 00:52:43 +03:00
|
|
|
end
|
|
|
|
|
2016-08-06 02:55:55 +03:00
|
|
|
def execute_and_stream(cmd)
|
|
|
|
puts "running: #{cmd}"
|
|
|
|
execute(cmd)
|
|
|
|
end
|
|
|
|
|
|
|
|
def execute(cmd)
|
|
|
|
Open3.popen2e(cmd) do |_, stdout_err, wait_thr|
|
|
|
|
while line = stdout_err.gets
|
|
|
|
puts line
|
2016-04-02 02:45:32 +03:00
|
|
|
end
|
|
|
|
|
2016-08-06 02:55:55 +03:00
|
|
|
exit_status = wait_thr.value
|
|
|
|
unless exit_status.success?
|
|
|
|
abort "FAILED !!!"
|
|
|
|
end
|
2016-04-02 02:45:32 +03:00
|
|
|
end
|
2016-08-06 02:55:55 +03:00
|
|
|
end
|
2016-04-02 02:45:32 +03:00
|
|
|
|
2017-08-31 02:37:29 +03:00
|
|
|
def get_config_file
|
2018-05-08 22:38:56 +03:00
|
|
|
config_file = File.read(File.expand_path("#{get_config_files_folder}/config.json", __FILE__))
|
2017-09-15 00:36:39 +03:00
|
|
|
JSON.parse(config_file)
|
2017-08-31 02:37:29 +03:00
|
|
|
end
|
|
|
|
|
2017-12-21 23:10:57 +03:00
|
|
|
def each_child
|
|
|
|
each_child_mode_specific('management') {|dir| yield dir }
|
|
|
|
each_child_mode_specific('data') {|dir| yield dir }
|
2017-11-07 07:58:18 +03:00
|
|
|
|
2017-12-21 23:10:57 +03:00
|
|
|
Dir.chdir(File.expand_path('../azure_sdk', __FILE__))
|
|
|
|
yield('azure_sdk')
|
2017-11-07 07:58:18 +03:00
|
|
|
end
|
|
|
|
|
2017-12-21 23:10:57 +03:00
|
|
|
def each_child_mode_specific(parent_dir, change_dir = true)
|
|
|
|
Dir.chdir(File.expand_path("../#{parent_dir}", __FILE__))
|
|
|
|
sub_dirs = Dir['*'].reject{|o| not File.directory?(o)}
|
|
|
|
sub_dirs.each do |dir|
|
2017-11-07 07:58:18 +03:00
|
|
|
if GEMS_TO_IGNORE.include?dir
|
|
|
|
next
|
|
|
|
end
|
2017-12-21 23:10:57 +03:00
|
|
|
|
|
|
|
if (change_dir)
|
|
|
|
Dir.chdir(dir) do
|
|
|
|
yield(dir)
|
|
|
|
end
|
|
|
|
else
|
|
|
|
yield dir
|
2012-06-15 01:45:06 +04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-08-06 02:55:55 +03:00
|
|
|
def each_gem
|
|
|
|
each_child do |dir|
|
2017-08-31 02:37:29 +03:00
|
|
|
gem_dir = dir.split('/').last
|
2017-11-07 07:58:18 +03:00
|
|
|
yield gem_dir
|
2016-08-06 02:55:55 +03:00
|
|
|
end
|
|
|
|
end
|
2012-06-15 01:45:06 +04:00
|
|
|
|
2017-12-21 23:10:57 +03:00
|
|
|
def each_gem_dir
|
|
|
|
each_child_mode_specific('management', false) {|dir| yield dir }
|
|
|
|
each_child_mode_specific('data', false) {|dir| yield dir }
|
|
|
|
end
|
|
|
|
|
2017-11-07 07:58:18 +03:00
|
|
|
def update_gem_version(version_file, new_version)
|
|
|
|
existing_contents = File.read(version_file)
|
|
|
|
content_to_replace = existing_contents.gsub(/VERSION = '.*'/, "VERSION = '#{new_version}'")
|
|
|
|
File.open(version_file, 'w') { |file| file.puts content_to_replace }
|
|
|
|
end
|