diff --git a/qa/Rakefile b/qa/Rakefile index 6af05e9a667..479d49effec 100644 --- a/qa/Rakefile +++ b/qa/Rakefile @@ -20,9 +20,6 @@ require "rspec/core/runner" require "rspec/core/rake_task" require "stud/try" -task :spec => 'spec:all' -task :default => :spec - namespace :qa do namespace :acceptance do desc "Run all acceptance tests" diff --git a/rakelib/docs.rake b/rakelib/docs.rake deleted file mode 100644 index 8971f30c2ca..00000000000 --- a/rakelib/docs.rake +++ /dev/null @@ -1,41 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you 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. - -require "fileutils" - -DEFAULT_DOC_DIRECTORY = ::File.join(::File.dirname(__FILE__), "..", "build", "docs") - -namespace "docs" do - desc "Generate documentation for all plugins" - task "generate" do - Rake::Task['docs:generate-plugins'].invoke - end - - desc "Generate the doc for all the currently installed plugins" - task "generate-plugins", [:output] do |t, args| - args.with_defaults(:output => DEFAULT_DOC_DIRECTORY) - - require "bootstrap/environment" - require "logstash-core/logstash-core" - LogStash::Bundler.setup!({:without => [:build]}) - - require "logstash/docgen/logstash_generator" - - FileUtils.mkdir_p(args[:output]) - exit(LogStash::Docgen::LogStashGenerator.new(args[:output]).generate_plugins_docs) - end -end diff --git a/rakelib/plugin.rake b/rakelib/plugin.rake index 3742b59b8d5..34f76e8bb86 100644 --- a/rakelib/plugin.rake +++ b/rakelib/plugin.rake @@ -18,9 +18,21 @@ require_relative "default_plugins" require 'rubygems' require 'shellwords' +require 'yaml' require 'bootstrap/environment' +VERSION_FILE = "versions.yml" + +def get_versions + yaml_versions = YAML.safe_load(IO.read(VERSION_FILE)) + { + "logstash" => yaml_versions["logstash"], + "logstash-core" => yaml_versions["logstash-core"], + "logstash-core-plugin-api" => yaml_versions["logstash-core-plugin-api"], + } +end + namespace "plugin" do def install_plugins(*args) require_relative "../lib/pluginmanager/main" diff --git a/rakelib/test.rake b/rakelib/test.rake index 26459d7471c..6d7c6e12b7e 100644 --- a/rakelib/test.rake +++ b/rakelib/test.rake @@ -15,60 +15,6 @@ # specific language governing permissions and limitations # under the License. -# we need to call exit explicitly in order to set the proper exit code, otherwise -# most common CI systems can not know whats up with this tests. - -require 'pathname' - namespace "test" do - desc "run the ruby unit tests" - task "core-ruby" => "compliance" do - exit 1 unless system(*default_spec_command) - end - - desc 'run the ruby compliance tests' - task 'compliance' do - exit 1 unless system('bin/rspec', '-fd', '--patern', 'spec/compliance/**/*_spec.rb') - end - - def default_spec_command - ["bin/rspec", "-fd", "--pattern", "spec/unit/**/*_spec.rb,logstash-core/spec/**/*_spec.rb"] - end - - desc "run core specs excluding slower tests like stress tests" - task "core-fast" do - exit 1 unless system(*(default_spec_command.concat(["--tag", "~stress_test"]))) - end - - desc "run all installed plugins specs" - task "plugins" => "bootstrap" do - plugins_to_exclude = ENV.fetch("EXCLUDE_PLUGIN", "").split(",") - # the module LogStash::PluginManager requires the file `lib/pluginmanager/plugin_aliases.yml`, - # that file is created during the bootstrap task - require "pluginmanager/util" - - # grab all spec files using the live plugins gem specs. this allows correctly also running the specs - # of a local plugin dir added using the Gemfile :path option. before this, any local plugin spec would - # not be run because they were not under the vendor/bundle/jruby/2.0/gems path - test_files = LogStash::PluginManager.find_plugins_gem_specs.map do |spec| - if plugins_to_exclude.size > 0 - if !plugins_to_exclude.include?(Pathname.new(spec.gem_dir).basename.to_s) - Rake::FileList[File.join(spec.gem_dir, "spec/{input,filter,codec,output}s/*_spec.rb")] - end - else - Rake::FileList[File.join(spec.gem_dir, "spec/{input,filter,codec,output}s/*_spec.rb")] - end - end.flatten.compact - - # "--format=documentation" - exit 1 unless system(*(["bin/rspec", "-fd", "--order", "rand"].concat(test_files))) - end - - desc "install dev dependencies" task "install-core" => ["bootstrap", "plugin:install-development-dependencies"] - - desc "install default plugins and dev dependencies" - task "install-default" => ["bootstrap", "plugin:install-default", "plugin:install-development-dependencies"] end - -task "test" => ["test:core-ruby"] diff --git a/rakelib/vendor.rake b/rakelib/vendor.rake index 80d0b67c340..4c0898ccfea 100644 --- a/rakelib/vendor.rake +++ b/rakelib/vendor.rake @@ -16,10 +16,6 @@ # under the License. namespace "vendor" do - namespace "force" do - task "gems" => ["vendor:gems"] - end - task "gems", [:bundle] do |task, args| require "bootstrap/environment" @@ -33,9 +29,4 @@ namespace "vendor" do end end # task gems task "all" => "gems" - - desc "Clean the vendored files" - task :clean do - rm_rf('vendor') - end end diff --git a/rakelib/version.rake b/rakelib/version.rake deleted file mode 100644 index 72de1af05f2..00000000000 --- a/rakelib/version.rake +++ /dev/null @@ -1,124 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you 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. - -require 'yaml' - -VERSION_FILE = "versions.yml" -README_FILE = "README.md" -INDEX_SHARED1_FILE = "docs/index.asciidoc" - -def get_versions - yaml_versions = YAML.safe_load(IO.read(VERSION_FILE)) - { - "logstash" => yaml_versions["logstash"], - "logstash-core" => yaml_versions["logstash-core"], - "logstash-core-plugin-api" => yaml_versions["logstash-core-plugin-api"], - } -end - -# Update the version file, keeping the comments in tact -def update_version_file(old_version, new_version) - versions_as_text = IO.read(VERSION_FILE) - %w(logstash logstash-core logstash-core-plugin-api).each do |field| - versions_as_text.gsub!(/(?<=#{field}: )#{old_version[field]}/, "#{new_version[field]}") - end - IO.write(VERSION_FILE, versions_as_text) -end - -def update_lock_release_file(old_version, new_version) - lock_file = Dir.glob('Gemfile*.lock.release').first - unless lock_file - warn "Gemfile*.lock.release missing - skipping version update" - return - end - old_version = old_version['logstash-core'] - new_version = new_version['logstash-core'] - versions_as_text = IO.read(lock_file) - # logstash-core (= 7.16.0) - versions_as_text.sub!(/logstash-core \(=\s?(#{old_version})\)/) { |m| m.sub(old_version, new_version) } - # logstash-core (7.16.0-java) - versions_as_text.sub!(/logstash-core \((#{old_version})-java\)/) { |m| m.sub(old_version, new_version) } - IO.write(lock_file, versions_as_text) -end - -def update_index_shared1(new_version) - index_shared1 = IO.read(INDEX_SHARED1_FILE) - old_version = index_shared1.match(':logstash_version:\s+(?\d[.]\d[.]\d.*)')[:logstash_version] - %w(logstash elasticsearch kibana).each do |field| - index_shared1.gsub!(/(:#{field}_version:\s+)#{old_version}/) { "#{$1}#{new_version}" } - end - IO.write(INDEX_SHARED1_FILE, index_shared1) -end - -def update_readme(old_version, new_version) - readme = IO.read(README_FILE) - readme.gsub!(/(logstash\-(oss\-)?)#{old_version['logstash']}/) { "#{$1}#{new_version['logstash']}" } - IO.write(README_FILE, readme) -end - -namespace :version do - desc "show version of core components" - task :show do - get_versions.each do |component, version| - puts "#{component}: #{version}" - end - end - - desc "set version of logstash, logstash-core" - task :set, [:version] => [:validate] do |t, args| - new_version = {} - get_versions.each do |component, version| - # we just assume that, usually, all components except - # "logstash-core-plugin-api" will be versioned together - # so let's skip this one and have a separate task for it - if component == "logstash-core-plugin-api" - new_version[component] = version - else - new_version[component] = args[:version] - end - end - old_version = YAML.safe_load(File.read(VERSION_FILE)) - update_readme(old_version, new_version) - update_version_file(old_version, new_version) - update_lock_release_file(old_version, new_version) - end - - desc "set stack version referenced in docs" - task :set_doc_version, [:version] => [:validate] do |t, args| - update_index_shared1(args[:version]) - end - - desc "set version of logstash-core-plugin-api" - task :set_plugin_api, [:version] => [:validate] do |t, args| - new_version = {} - get_versions.each do |component, version| - if component == "logstash-core-plugin-api" - new_version[component] = args[:version] - else - new_version[component] = version - end - end - old_version = YAML.safe_load(File.read(VERSION_FILE)) - update_version_file(old_version, new_version) - end - - task :validate, :version do |t, args| - unless Regexp.new('^\d+\.\d+\.\d+(?:-\w+\d+)?$').match(args[:version]) - abort("Invalid version argument: \"#{args[:version]}\". Aborting...") - end - end -end