現在のブランチとマスターの間で変更されたファイルに対して Rubocop スタイル チェッカーを実行するspec/lint/rubocop_spec.rbを作成しました。これは、ローカルでテストする場合は機能しますが、ビルド サーバー Circle.ci でテストを実行する場合は機能しません。問題のブランチのみがダウンロードされているためと思われるため、マスター間の違いは見つかりません。よりも良い方法はありgit co master && git pull origin master
ますか?変更されたファイルを一覧表示するために Github API にクエリを実行できますか?
require 'spec_helper'
describe 'Check that the files we have changed have correct syntax' do
before do
current_sha = `git rev-parse --verify HEAD`.strip!
files = `git diff master #{current_sha} --name-only | grep .rb`
files.tr!("\n", ' ')
@report = 'nada'
if files.present?
puts "Changed files: #{files}"
@report = `rubocop #{files}`
puts "Report: #{@report}"
end
end
it { @report.match('Offenses').should_not be true }
end