2013-01-20 22:43:28 +04:00
|
|
|
|
Feature: hub ci-status
|
|
|
|
|
|
|
|
|
|
Background:
|
2013-05-14 12:00:16 +04:00
|
|
|
|
Given I am in "git://github.com/michiels/pencilbox.git" git repo
|
2013-01-20 22:43:28 +04:00
|
|
|
|
And I am "michiels" on github.com with OAuth token "OTOKEN"
|
|
|
|
|
|
|
|
|
|
Scenario: Fetch commit SHA
|
2013-01-30 01:08:26 +04:00
|
|
|
|
Given there is a commit named "the_sha"
|
|
|
|
|
Given the remote commit state of "michiels/pencilbox" "the_sha" is "success"
|
2013-01-20 22:43:28 +04:00
|
|
|
|
When I run `hub ci-status the_sha`
|
|
|
|
|
Then the output should contain exactly "success\n"
|
|
|
|
|
And the exit status should be 0
|
|
|
|
|
|
2013-10-29 03:56:00 +04:00
|
|
|
|
Scenario: Fetch commit SHA with URL
|
|
|
|
|
Given there is a commit named "the_sha"
|
|
|
|
|
Given the remote commit state of "michiels/pencilbox" "the_sha" is "success"
|
|
|
|
|
When I run `hub ci-status the_sha -v`
|
2015-09-27 02:04:56 +03:00
|
|
|
|
Then the output should contain exactly:
|
|
|
|
|
"""
|
|
|
|
|
✔︎ continuous-integration/travis-ci/push https://travis-ci.org/michiels/pencilbox/builds/1234567\n
|
|
|
|
|
"""
|
2013-10-29 03:56:00 +04:00
|
|
|
|
And the exit status should be 0
|
|
|
|
|
|
2015-09-27 02:04:56 +03:00
|
|
|
|
Scenario: Multiple statuses with verbose output
|
2013-04-26 19:53:31 +04:00
|
|
|
|
Given there is a commit named "the_sha"
|
|
|
|
|
Given the remote commit states of "michiels/pencilbox" "the_sha" are:
|
|
|
|
|
"""
|
2018-07-07 14:23:43 +03:00
|
|
|
|
{ :state => "error",
|
2015-09-27 02:04:56 +03:00
|
|
|
|
:statuses => [
|
|
|
|
|
{ :state => "success",
|
|
|
|
|
:context => "continuous-integration/travis-ci/push",
|
|
|
|
|
:target_url => "https://travis-ci.org/michiels/pencilbox/builds/1234567" },
|
2019-01-29 23:00:51 +03:00
|
|
|
|
{ :state => "success",
|
|
|
|
|
:context => "continuous-integration/travis-ci/ants",
|
|
|
|
|
:target_url => "https://travis-ci.org/michiels/pencilbox/builds/1234568" },
|
2015-09-27 02:04:56 +03:00
|
|
|
|
{ :state => "pending",
|
|
|
|
|
:context => "continuous-integration/travis-ci/merge",
|
2015-09-28 14:25:48 +03:00
|
|
|
|
:target_url => nil },
|
2019-01-29 23:00:51 +03:00
|
|
|
|
{ :state => "error",
|
|
|
|
|
:context => "whatevs!" },
|
2015-09-27 02:04:56 +03:00
|
|
|
|
{ :state => "failure",
|
|
|
|
|
:context => "GitHub CLA",
|
|
|
|
|
:target_url => "https://cla.github.com/michiels/pencilbox/accept/mislav" },
|
|
|
|
|
]
|
|
|
|
|
}
|
2013-04-26 19:53:31 +04:00
|
|
|
|
"""
|
2015-09-27 02:04:56 +03:00
|
|
|
|
When I run `hub ci-status -v the_sha`
|
|
|
|
|
Then the output should contain exactly:
|
|
|
|
|
"""
|
2015-09-28 14:25:48 +03:00
|
|
|
|
✖︎ GitHub CLA https://cla.github.com/michiels/pencilbox/accept/mislav
|
2019-01-29 23:00:51 +03:00
|
|
|
|
✖︎ whatevs!
|
|
|
|
|
● continuous-integration/travis-ci/merge
|
|
|
|
|
✔︎ continuous-integration/travis-ci/ants https://travis-ci.org/michiels/pencilbox/builds/1234568
|
|
|
|
|
✔︎ continuous-integration/travis-ci/push https://travis-ci.org/michiels/pencilbox/builds/1234567\n
|
2015-09-27 02:04:56 +03:00
|
|
|
|
"""
|
2018-07-07 14:23:43 +03:00
|
|
|
|
And the exit status should be 1
|
2013-04-26 19:53:31 +04:00
|
|
|
|
|
2019-01-29 23:54:18 +03:00
|
|
|
|
Scenario: Multiple statuses with format string
|
|
|
|
|
Given there is a commit named "the_sha"
|
|
|
|
|
Given the remote commit states of "michiels/pencilbox" "the_sha" are:
|
|
|
|
|
"""
|
|
|
|
|
{ :state => "error",
|
|
|
|
|
:statuses => [
|
|
|
|
|
{ :state => "success",
|
|
|
|
|
:context => "continuous-integration/travis-ci/push",
|
|
|
|
|
:target_url => "https://travis-ci.org/michiels/pencilbox/builds/1234567" },
|
|
|
|
|
{ :state => "success",
|
|
|
|
|
:context => "continuous-integration/travis-ci/ants",
|
|
|
|
|
:target_url => "https://travis-ci.org/michiels/pencilbox/builds/1234568" },
|
|
|
|
|
{ :state => "pending",
|
|
|
|
|
:context => "continuous-integration/travis-ci/merge",
|
|
|
|
|
:target_url => nil },
|
|
|
|
|
{ :state => "error",
|
|
|
|
|
:context => "whatevs!" },
|
|
|
|
|
{ :state => "failure",
|
|
|
|
|
:context => "GitHub CLA",
|
|
|
|
|
:target_url => "https://cla.github.com/michiels/pencilbox/accept/mislav" },
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
"""
|
|
|
|
|
When I run `hub ci-status the_sha --format '%S: %t (%U)%n'`
|
|
|
|
|
Then the output should contain exactly:
|
|
|
|
|
"""
|
|
|
|
|
failure: GitHub CLA (https://cla.github.com/michiels/pencilbox/accept/mislav)
|
|
|
|
|
error: whatevs! ()
|
|
|
|
|
pending: continuous-integration/travis-ci/merge ()
|
|
|
|
|
success: continuous-integration/travis-ci/ants (https://travis-ci.org/michiels/pencilbox/builds/1234568)
|
|
|
|
|
success: continuous-integration/travis-ci/push (https://travis-ci.org/michiels/pencilbox/builds/1234567)\n
|
|
|
|
|
"""
|
|
|
|
|
And the exit status should be 1
|
|
|
|
|
|
2013-01-20 22:43:28 +04:00
|
|
|
|
Scenario: Exit status 1 for 'error' and 'failure'
|
2013-01-30 01:08:26 +04:00
|
|
|
|
Given the remote commit state of "michiels/pencilbox" "HEAD" is "error"
|
2013-01-20 22:43:28 +04:00
|
|
|
|
When I run `hub ci-status`
|
|
|
|
|
Then the exit status should be 1
|
2013-01-30 01:08:26 +04:00
|
|
|
|
And the output should contain exactly "error\n"
|
2013-01-20 22:43:28 +04:00
|
|
|
|
|
|
|
|
|
Scenario: Use HEAD when no sha given
|
2013-01-30 01:08:26 +04:00
|
|
|
|
Given the remote commit state of "michiels/pencilbox" "HEAD" is "pending"
|
2013-01-20 22:43:28 +04:00
|
|
|
|
When I run `hub ci-status`
|
|
|
|
|
Then the exit status should be 2
|
2013-01-30 01:08:26 +04:00
|
|
|
|
And the output should contain exactly "pending\n"
|
2013-01-20 22:43:28 +04:00
|
|
|
|
|
|
|
|
|
Scenario: Exit status 3 for no statuses available
|
2013-01-30 01:08:26 +04:00
|
|
|
|
Given there is a commit named "the_sha"
|
|
|
|
|
Given the remote commit state of "michiels/pencilbox" "the_sha" is nil
|
2013-01-20 22:43:28 +04:00
|
|
|
|
When I run `hub ci-status the_sha`
|
|
|
|
|
Then the output should contain exactly "no status\n"
|
|
|
|
|
And the exit status should be 3
|
|
|
|
|
|
2013-10-29 03:56:00 +04:00
|
|
|
|
Scenario: Exit status 3 for no statuses available without URL
|
|
|
|
|
Given there is a commit named "the_sha"
|
|
|
|
|
Given the remote commit state of "michiels/pencilbox" "the_sha" is nil
|
|
|
|
|
When I run `hub ci-status -v the_sha`
|
|
|
|
|
Then the output should contain exactly "no status\n"
|
|
|
|
|
And the exit status should be 3
|
|
|
|
|
|
2013-01-30 01:08:26 +04:00
|
|
|
|
Scenario: Abort with message when invalid ref given
|
|
|
|
|
When I run `hub ci-status this-is-an-invalid-ref`
|
|
|
|
|
Then the exit status should be 1
|
|
|
|
|
And the output should contain exactly "Aborted: no revision could be determined from 'this-is-an-invalid-ref'\n"
|
|
|
|
|
|
2013-01-20 22:43:28 +04:00
|
|
|
|
Scenario: Non-GitHub repo
|
|
|
|
|
Given the "origin" remote has url "mygh:Manganeez/repo.git"
|
|
|
|
|
When I run `hub ci-status`
|
2018-12-28 05:48:46 +03:00
|
|
|
|
Then the stderr should contain exactly:
|
|
|
|
|
"""
|
|
|
|
|
Aborted: could not find any git remote pointing to a GitHub repository\n
|
|
|
|
|
"""
|
2013-01-30 01:08:26 +04:00
|
|
|
|
And the exit status should be 1
|
2016-05-03 17:59:19 +03:00
|
|
|
|
|
|
|
|
|
Scenario: Enterprise CI statuses
|
|
|
|
|
Given the "origin" remote has url "git@git.my.org:michiels/pencilbox.git"
|
|
|
|
|
And I am "michiels" on git.my.org with OAuth token "FITOKEN"
|
|
|
|
|
And "git.my.org" is a whitelisted Enterprise host
|
|
|
|
|
Given there is a commit named "the_sha"
|
|
|
|
|
Given the remote commit state of "git.my.org/michiels/pencilbox" "the_sha" is "success"
|
|
|
|
|
When I successfully run `hub ci-status the_sha`
|
|
|
|
|
Then the output should contain exactly "success\n"
|
2016-11-05 09:53:36 +03:00
|
|
|
|
|
|
|
|
|
Scenario: If alias named ci-status exists, it should not be expanded.
|
|
|
|
|
Given there is a commit named "the_sha"
|
|
|
|
|
Given the remote commit state of "michiels/pencilbox" "the_sha" is "success"
|
|
|
|
|
When I successfully run `git config --global alias.ci-status "ci-status -v"`
|
2018-07-07 14:23:43 +03:00
|
|
|
|
And I successfully run `hub ci-status the_sha`
|
2016-11-05 09:53:36 +03:00
|
|
|
|
Then the output should contain exactly "success\n"
|
2018-07-07 14:23:43 +03:00
|
|
|
|
|
|
|
|
|
Scenario: Has Checks
|
|
|
|
|
Given there is a commit named "the_sha"
|
|
|
|
|
And the GitHub API server:
|
|
|
|
|
"""
|
|
|
|
|
get('/repos/michiels/pencilbox/commits/:sha/status') {
|
|
|
|
|
json({ :state => "success",
|
|
|
|
|
:statuses => [
|
|
|
|
|
{ :state => "success",
|
|
|
|
|
:context => "travis-ci",
|
|
|
|
|
:target_url => "the://url"}
|
|
|
|
|
]
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
get('/repos/michiels/pencilbox/commits/:sha/check-runs') {
|
|
|
|
|
json({ :check_runs => [
|
|
|
|
|
{ :status => "completed",
|
|
|
|
|
:conclusion => "action_required",
|
|
|
|
|
:name => "check 1",
|
|
|
|
|
:html_url => "the://url" },
|
|
|
|
|
{ :status => "queued",
|
|
|
|
|
:conclusion => "",
|
|
|
|
|
:name => "check 2",
|
|
|
|
|
:html_url => "the://url" },
|
|
|
|
|
]
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
"""
|
|
|
|
|
When I run `hub ci-status the_sha`
|
|
|
|
|
Then the output should contain exactly "action_required\n"
|
|
|
|
|
And the exit status should be 1
|
2018-08-23 15:50:29 +03:00
|
|
|
|
|
|
|
|
|
Scenario: Older Enterprise version doesn't have Checks
|
|
|
|
|
Given the "origin" remote has url "git@git.my.org:michiels/pencilbox.git"
|
|
|
|
|
And I am "michiels" on git.my.org with OAuth token "FITOKEN"
|
|
|
|
|
And "git.my.org" is a whitelisted Enterprise host
|
|
|
|
|
And there is a commit named "the_sha"
|
|
|
|
|
And the GitHub API server:
|
|
|
|
|
"""
|
|
|
|
|
get('/api/v3/repos/michiels/pencilbox/commits/:sha/status', :host_name => 'git.my.org') {
|
|
|
|
|
json({ :state => "success",
|
|
|
|
|
:statuses => [
|
|
|
|
|
{ :state => "success",
|
|
|
|
|
:context => "travis-ci",
|
|
|
|
|
:target_url => "the://url"}
|
|
|
|
|
]
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
get('/api/v3/repos/michiels/pencilbox/commits/:sha/check-runs', :host_name => 'git.my.org') {
|
|
|
|
|
status 403
|
|
|
|
|
json :message => "Must have admin rights to Repository.",
|
|
|
|
|
:documentation_url => "https://developer.github.com/enterprise/2.13/v3/"
|
|
|
|
|
}
|
|
|
|
|
"""
|
|
|
|
|
When I successfully run `hub ci-status the_sha`
|
|
|
|
|
Then the output should contain exactly "success\n"
|