embulk-input-travis 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ac9b30ab3e49a4c3a66404cca85fc2c52a280d02e195940d2ddd687100d9244d
4
- data.tar.gz: e870fb44cf66833c3dd2e7b3dab5547655269215c3544b28b35ea4f9e1891241
3
+ metadata.gz: 505e7ec4a05361418365c85e289819a047e0850641dd4b7d22e55db658afbdd7
4
+ data.tar.gz: 9a19650beb11ee32ab9ab8b60481b7578a1b8569c80fdf88a18b70f48dfa5949
5
5
  SHA512:
6
- metadata.gz: 5e3083c635119273bcb82570c7e4c40b7686b1476d6aa6191d6cb0b3bb766ec6d6b01d249c5960bc63c8fbd746338e3f1136d41d208f44c39b55a81063206e10
7
- data.tar.gz: 291f60296f2743a6e3e33c0664ef364b95186aca72770f1dbc8515ade9801e25d3038dc827b60ac2cb09495eaaf201f3338696bccb8ed347bb015582ed6a46d7
6
+ metadata.gz: c63620f847cab224d667a3b681e176e1eebda8dea87a1d4816134ef710a48250d91a1e4f4ea1c8f7f65b44a33583218823c3550549c3c390d257e6b170c4464a
7
+ data.tar.gz: a4a157dfcf9a7a09b855fb6062a64c62a3c8e800d328db01ff5619eb765322dabca0c9dedcdd9d80da044078bd5de7bc9ec79408b5918f55ff841f0ae88fc5aa
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # 0.2.0
2
+
3
+ - Implement retry
4
+
5
+ # 0.1.0
6
+
7
+ - First release
@@ -1,7 +1,7 @@
1
1
 
2
2
  Gem::Specification.new do |spec|
3
3
  spec.name = "embulk-input-travis"
4
- spec.version = "0.1.0"
4
+ spec.version = "0.2.0"
5
5
  spec.authors = [""]
6
6
  spec.summary = "Travis input plugin for Embulk"
7
7
  spec.description = "Loads records from Travis."
@@ -67,7 +67,7 @@ module Embulk
67
67
 
68
68
  repo.session.clear_cache!
69
69
 
70
- build = repo.build(build_num)
70
+ build = with_retry { repo.build(build_num) }
71
71
  unless build&.finished?
72
72
  Embulk.logger.info { "embulk-input-travis: Skip build_num:[#{build_num}]" }
73
73
 
@@ -75,6 +75,22 @@ module Embulk
75
75
  next
76
76
  end
77
77
 
78
+ build.job_ids.each do |job_id|
79
+ with_retry do
80
+ job = client.session.find_one(::Travis::Client::Job, job_id)
81
+
82
+ Embulk.logger.info { "embulk-input-travis: Start job_id:[#{job.id}]" }
83
+
84
+ page_builder.add([
85
+ job.id,
86
+ job.to_h.to_json,
87
+ job.log.body,
88
+ build.number.to_i,
89
+ build.to_h.to_json
90
+ ])
91
+ end
92
+ end
93
+
78
94
  build.jobs.each do |job|
79
95
  Embulk.logger.info { "embulk-input-travis: Start job_id:[#{job.id}]" }
80
96
 
@@ -115,6 +131,26 @@ module Embulk
115
131
  def client
116
132
  @client ||= ::Travis::Client.new(access_token: task["token"])
117
133
  end
134
+
135
+ MAX_RETRY = 5
136
+
137
+ def with_retry(&block)
138
+ retries = 0
139
+ begin
140
+ yield
141
+ rescue => e
142
+ sleep retries
143
+
144
+ if retries < MAX_RETRY
145
+ retries += 1
146
+ Embulk.logger.warn { "embulk-input-travis: retry ##{retries}, #{e.message}" }
147
+ retry
148
+ else
149
+ Embulk.logger.error { "embulk-input-travis: retry exhausted ##{retries}, #{e.message}" }
150
+ raise e
151
+ end
152
+ end
153
+ end
118
154
  end
119
155
 
120
156
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-input-travis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-28 00:00:00.000000000 Z
11
+ date: 2019-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: travis
@@ -75,6 +75,7 @@ extra_rdoc_files: []
75
75
  files:
76
76
  - ".gitignore"
77
77
  - ".ruby-version"
78
+ - CHANGELOG.md
78
79
  - Dockerfile
79
80
  - Gemfile
80
81
  - LICENSE.txt