Last active
July 5, 2016 23:35
-
-
Save ajsharma/5165123e964162fa278e7a23e59e0af1 to your computer and use it in GitHub Desktop.
Simple rake script to run failed specs from CircleCi on your computer
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
group :development do | |
gem 'circleci', require: false | |
end |
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
namespace :spec do | |
desc <<-DESC | |
Run specs that failed for a CircleCi build | |
Uses bin/rspec as driver | |
Can be run as `bin/rake spec:circle_ci[build_id]` | |
DESC | |
task :circle_ci, [ :circle_ci_build_id ] do |task, task_args| | |
require 'circleci' # Cuz we dont wanna pollute the rest of the stack | |
CircleCi.configure do |config| | |
config.token = ENV['CIRCLE_CI_API_TOKEN'] | |
end | |
# The CircleCi gem add webmock into env.development, which blocks | |
# remote calls when in development | |
# So...don't run this as part of a test suite | |
WebMock.disable! | |
response = CircleCi::Build.tests( | |
'my_github_organization', | |
'my_github_repo', | |
task_args[ :circle_ci_build_id ] | |
) | |
tests = response.body[ "tests" ] | |
files = tests.select{ |test| test["result"] == "failure" } | |
.map{ |test| test[ "file" ] } | |
sh "bin/rspec #{ files.to_a.join ' ' }" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So simple, thanks to the https://github.com/mtchavez/circleci gem