Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
licensed/Rakefile /
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
107 lines (89 sloc)
2.85 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
require "bundler/gem_tasks" | |
require "rake/testtask" | |
require "rubocop/rake_task" | |
require "licensed" | |
desc "Run source setup scripts" | |
task :setup, [:arguments] do |task, args| | |
arguments = args[:arguments].to_s.split | |
force = arguments.include?("-f") ? "-f" : "" | |
Dir["script/source-setup/**/*"].each do |script| | |
next if File.directory?(script) | |
# green | |
puts "\033[32mRunning #{script}.\e[0m" | |
if Bundler.with_clean_env { system(script, force) } | |
# green | |
puts "\033[32mCompleted #{script}.\e[0m" | |
elsif $?.exitstatus == 127 | |
# yellow | |
puts "\033[33mSkipped #{script}.\e[0m" | |
else | |
# red | |
puts "\033[31mEncountered an error running #{script}.\e[0m" | |
end | |
puts | |
end | |
end | |
sources = Licensed::Sources::Source.sources.map { |source| source.full_type } | |
namespace :test do | |
sources.each do |source| | |
# hidden task to set ENV and filter tests to the given source | |
# see `each_source` in test/test_helper.rb | |
namespace source.to_sym do | |
task :env do | |
ENV["SOURCE"] = source | |
end | |
end | |
Rake::TestTask.new(source => "test:#{source}:env") do |t| | |
t.description = "Run #{source} tests" | |
t.libs << "test" | |
t.libs << "lib" | |
t.test_files = FileList["test/commands/*_test.rb", "test/sources/#{source}_test.rb"] | |
end | |
end | |
namespace :core do | |
task :env do | |
ENV["SOURCE"] = "" | |
end | |
end | |
Rake::TestTask.new(core: "test:core:env") do |t| | |
t.description = "Run non-source tests" | |
t.libs << "test" | |
t.libs << "lib" | |
t.test_files = FileList["test/**/*_test.rb"].exclude("test/fixtures/**/*_test.rb") | |
.exclude("test/sources/*_test.rb") | |
.exclude("test/sources/**/*_test.rb") | |
end | |
end | |
Rake::TestTask.new(:test) do |t| | |
t.libs << "test" | |
t.libs << "lib" | |
t.test_files = FileList["test/**/*_test.rb"].exclude("test/fixtures/**/*_test.rb") | |
end | |
packages_search = File.expand_path("script/packages/*", __dir__) | |
platforms = Dir[packages_search].map { |f| File.basename(f, ".*") } | |
.reject { |f| f == "build" } | |
namespace :package do | |
platforms.each do |platform| | |
desc "Package licensed for #{platform}" | |
task platform.to_sym do | |
puts "Packaging licensed for #{platform}" | |
if Bundler.with_original_env { system("script/packages/#{platform}") } | |
# green | |
puts "\033[32mCompleted packaging for #{platform}.\e[0m" | |
else | |
# red | |
puts "\033[31mEncountered an error packaging for #{platform}.\e[0m" | |
end | |
puts | |
end | |
end | |
end | |
desc "Package licensed for all platforms" | |
task package: platforms.map { |platform| "package:#{platform}" } | |
# add rubocop task | |
# -S adds styleguide urls to offense messages | |
RuboCop::RakeTask.new do |t| | |
t.options.push "-S" | |
end | |
task default: :test |