line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Ukigumo::Client::Notify::GitHubStatuses; |
2
|
2
|
|
|
2
|
|
930
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
63
|
|
3
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
46
|
|
4
|
2
|
|
|
2
|
|
9
|
use utf8; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
11
|
|
5
|
2
|
|
|
2
|
|
34
|
use Mouse; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
13
|
|
6
|
2
|
|
|
2
|
|
624
|
use JSON qw/encode_json/; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
19
|
|
7
|
2
|
|
|
2
|
|
262
|
use Ukigumo::Constants; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
232
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has 'api_endpoint' => ( |
10
|
|
|
|
|
|
|
is => 'ro', |
11
|
|
|
|
|
|
|
isa => 'Str', |
12
|
|
|
|
|
|
|
required => 1, |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has 'access_token' => ( |
16
|
|
|
|
|
|
|
is => 'ro', |
17
|
|
|
|
|
|
|
isa => 'Str', |
18
|
|
|
|
|
|
|
required => 1, |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
2
|
|
10
|
no Mouse; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
11
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub send { |
24
|
0
|
|
|
0
|
0
|
|
my ($self, $c, $status, $last_status, $report_url, $current_revision, $repository_owner, $repository_name) = @_; |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
my $ua = $c->user_agent; |
27
|
0
|
|
|
|
|
|
my $access_token = $self->access_token; |
28
|
0
|
|
|
|
|
|
$ua->default_header('Authorization' => "token $access_token"); |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
my ($state, $description) = _determine_status_and_description($status); |
31
|
0
|
0
|
0
|
|
|
|
if (!$state || !$description) { |
32
|
|
|
|
|
|
|
# Nothing to do |
33
|
0
|
|
|
|
|
|
return; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
my $payload = encode_json({ |
37
|
|
|
|
|
|
|
state => $state, |
38
|
|
|
|
|
|
|
target_url => $report_url, |
39
|
|
|
|
|
|
|
description => $description, |
40
|
|
|
|
|
|
|
}); |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
my $destination = sprintf("%s/repos/%s/%s/statuses/%s", $self->api_endpoint, $repository_owner, $repository_name, $current_revision); |
43
|
0
|
|
|
|
|
|
my $res = $ua->post($destination, Content => $payload); |
44
|
|
|
|
|
|
|
|
45
|
0
|
0
|
|
|
|
|
if ( $res->is_success ) { |
46
|
0
|
|
|
|
|
|
$c->logger->infof("Set commit status to $current_revision"); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
else { |
49
|
0
|
|
|
|
|
|
warn "Cannot set commit status to GitHub (NOTE: please check your OAuth permission)"; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub _determine_status_and_description { |
54
|
0
|
|
|
0
|
|
|
my ($status) = @_; |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
my ($state, $description); |
57
|
|
|
|
|
|
|
|
58
|
0
|
0
|
0
|
|
|
|
if ($status eq STATUS_SUCCESS) { |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
$state = 'success'; |
60
|
0
|
|
|
|
|
|
$description = 'The Ukigumo builds passed'; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
elsif ($status eq STATUS_FAIL || $status eq STATUS_TIMEOUT) { |
63
|
0
|
|
|
|
|
|
$state = 'failure'; |
64
|
0
|
|
|
|
|
|
$description = 'The Ukigumo builds failed'; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
elsif ($status eq STATUS_NA || $status eq STATUS_SKIP) { |
67
|
|
|
|
|
|
|
# Nothing to do |
68
|
0
|
|
|
|
|
|
return; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
elsif ($status eq STATUS_PENDING) { |
71
|
0
|
|
|
|
|
|
$state = 'pending'; |
72
|
0
|
|
|
|
|
|
$description = 'The Ukigumo is running!'; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
else { |
75
|
0
|
|
|
|
|
|
$state = 'error'; |
76
|
0
|
|
|
|
|
|
$description = 'The Ukigumo builds with errores'; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
return ($state, $description); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
__END__ |