Skip to content

Commit

Permalink
build: Tests endpoint for builds
Browse files Browse the repository at this point in the history
* Add tests endpoint for build
* Specs against circleci gem repo
* Update README
  • Loading branch information
mtchavez committed Mar 29, 2015
1 parent 2a5dbb6 commit 5100818
Show file tree
Hide file tree
Showing 4 changed files with 301 additions and 36 deletions.
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,40 @@ res.body
]
```

#### CircleCi::Build.tests

Tests endpoint to get the recorded tests for a build. Will return an array of
the tests ran and some details.

```ruby
res = CircleCi::Build.tests 'username', 'repo', 'build #'
res.success?
res.body
```

```json
[
{
"message" => nil,
"file" => "spec/unit/user_spec.rb",
"source" => "rspec",
"run_time" => 0.240912,
"result" => "success",
"name" => "user creation",
"classname"=> "spec.unit.user_spec"
},
{
"message" => "Unable to update user",
"file" => "spec/unit/user_spec.rb",
"source"=>"rspec",
"run_time"=>5.58533,
"result"=>"failure",
"name"=>"user update",
"classname"=>"spec.unit.user_spec"
}
]
```

#### CircleCi.organization

Recent builds for an entire organization
Expand Down
41 changes: 29 additions & 12 deletions lib/circleci/build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,54 +8,71 @@ class Build

##
#
# Get a specific build for a project
# Class for interacting with and managing builds

##
#
# Get artifacts for a specific build of a project
#
# @param username [String] - User or org name who owns project
# @param project [String] - Name of project
# @param build [String] - Build ID
# @return [CircleCi::Response] - Response object

def self.get username, project, build
CircleCi.http.get "/project/#{username}/#{project}/#{build}"
def self.artifacts username, project, build
CircleCi.http.get "/project/#{username}/#{project}/#{build}/artifacts"
end

##
#
# Kick off a retry of a specific build
# Cancel a specific build
#
# @param username [String] - User or org name who owns project
# @param project [String] - Name of project
# @param build [String] - Build ID
# @return [CircleCi::Response] - Response object

def self.retry username, project, build
CircleCi.http.post "/project/#{username}/#{project}/#{build}/retry"
def self.cancel username, project, build
CircleCi.http.post "/project/#{username}/#{project}/#{build}/cancel"
end

##
#
# Cancel a specific build
# Get a specific build for a project
#
# @param username [String] - User or org name who owns project
# @param project [String] - Name of project
# @param build [String] - Build ID
# @return [CircleCi::Response] - Response object

def self.cancel username, project, build
CircleCi.http.post "/project/#{username}/#{project}/#{build}/cancel"
def self.get username, project, build
CircleCi.http.get "/project/#{username}/#{project}/#{build}"
end

##
#
# Get artifacts for a specific build of a project
# Kick off a retry of a specific build
#
# @param username [String] - User or org name who owns project
# @param project [String] - Name of project
# @param build [String] - Build ID
# @return [CircleCi::Response] - Response object

def self.artifacts username, project, build
CircleCi.http.get "/project/#{username}/#{project}/#{build}/artifacts"
def self.retry username, project, build
CircleCi.http.post "/project/#{username}/#{project}/#{build}/retry"
end

##
#
# Get tests for a specific build of a project
#
# @param username [String] - User or org name who owns project
# @param project [String] - Name of project
# @param build [String] - Build ID
# @return [CircleCi::Response] - Response object

def self.tests username, project, build
CircleCi.http.get "/project/#{username}/#{project}/#{build}/tests"
end

end
Expand Down
186 changes: 186 additions & 0 deletions spec/cassettes/build/tests/success.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5100818

Please sign in to comment.