代码拉取完成,页面将自动刷新
同步操作将从 compass-ci/lkp-tests 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
require 'rubygems'
require 'bundler/setup'
require 'rspec/core/rake_task'
require 'fileutils'
require 'rubocop/rake_task'
require 'English'
desc 'Show help'
task :help do
puts <<~EOF
== SPEC ==
usage: rake spec [spec=result_path]
example:
rake spec # check all unit tests status
rake spec spec=job" # check spec/job_spec.rb status
== RUBOCOP ==
usage: rake rubocop [file=pattern]
example:
rake rubocop file="lib/**/*.rb" # check all lib files
EOF
end
RSpec::Core::RakeTask.new do |t|
ENV['LKP_SRC'] ||= File.expand_path File.dirname(__FILE__).to_s
puts "PWD = #{Dir.pwd}"
puts "ENV['LKP_SRC'] = #{ENV['LKP_SRC']}"
spec = ENV['spec'] || '*'
t.pattern = "spec/**{,/*/**}/#{spec}_spec.rb"
end
if ENV['GENERATE_REPORTS'] == 'true'
require 'ci/reporter/rake/rspec'
task spec: 'ci:setup:rspec'
end
begin
RuboCop::RakeTask.new(:rubocop) do |t|
t.options = ['-D', '-c.rubocop.yml']
t.patterns = [ENV['file']] if ENV['file']
puts "PWD = #{Dir.pwd}"
puts "rubocop.patterns = #{t.patterns}"
puts "rubocop.options = #{t.options}"
end
rescue StandardError => e
puts e.to_s
end
def bash(cmd)
output = `bash -c #{Shellwords.escape(cmd)}`
puts output unless output.empty?
raise "bash exitstatus: #{$CHILD_STATUS.exitstatus}" unless $CHILD_STATUS.success?
end
desc 'Run syntax check'
task :syntax do
executables = `find -type f -executable ! -path "./.git*" ! -path "./vendor*" ! -size +100k`.split("\n").join(' ')
bash "grep -s -l '^#!/.*ruby$' #{executables} | xargs -n1 ruby -c >/dev/null"
bash "grep -s -l '^#!/.*bash$' #{executables} | xargs -n1 bash -n"
bash "grep -s -l '^#!/bin/sh$' #{executables} | xargs -n1 dash -n"
puts 'syntax OK'
end
desc 'Run shellcheck'
task :shellcheck do
executables = `find -type f -executable ! -path "./.git*" ! -path "./vendor*" ! -size +100k | xargs grep -s -l -e '^#!/.*bash$' -e '^#!/bin/sh$'`.split("\n").join(' ')
format = ENV['format'] || 'tty'
base_cmd = "shellcheck -S warning -f #{format}"
base_cmd += " -i #{ENV['code']}" if ENV['code']
bash "#{base_cmd} #{executables}"
puts 'shellcheck OK'
end
desc 'Run code check'
task code: %i[syntax shellcheck rubocop spec]
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。