Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display last GitHub status message if cloning fails #929

Merged
merged 7 commits into from
Jan 23, 2017
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions lib/travis/build/git/clone.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'shellwords'
require 'uri'

module Travis
module Build
Expand All @@ -18,6 +19,13 @@ def apply
def clone_or_fetch
sh.if "! -d #{dir}/.git" do
sh.cmd "git clone #{clone_args} #{data.source_url} #{dir}", assert: true, retry: true
if github?
sh.if "$? -ne 0" do
sh.echo "Failed to clone from GitHub.", ansi: :red
sh.echo "Checking GitHub status (https://status.github.com/api/last-message.json):"
sh.raw "curl -sL https://status.github.com/api/last-message.json | jq -r .[]"
end
end
end
sh.else do
sh.cmd "git -C #{dir} fetch origin", assert: true, retry: true
Expand Down Expand Up @@ -63,6 +71,16 @@ def dir
def config
data.config
end

def github?
if md = /[^@]+@(.*):/.match(data.source_url)

This comment was marked as spam.

# we will assume that the URL looks like one for git+ssh; e.g., git@github.com:travis-ci/travis-build.git
host = md[1]

This comment was marked as spam.

else
host = URI.parse(data.source_url).host.downcase
end
host == 'github.com' || host.end_with?('.gh.neting.cc')
end
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/build/script/node_js_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
end

context 'when nvm install fails' do
let(:sexp_if) { sexp_filter(subject, [:if, '$? -ne 0'], [:then]) }
let(:sexp_if) { sexp_filter(subject, [:if, '$? -ne 0'])[1] }

it 'tries to use locally available version' do
expect(sexp_if).to include_sexp [:cmd, 'nvm use 0.9', echo: true]
Expand Down