embulk-input-travis 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +7 -0
- data/.ruby-version +1 -0
- data/Dockerfile +12 -0
- data/Gemfile +2 -0
- data/LICENSE.txt +21 -0
- data/README.md +35 -0
- data/Rakefile +3 -0
- data/bin/console +9 -0
- data/docker-compose.yml +16 -0
- data/embulk-input-travis.gemspec +21 -0
- data/lib/embulk/input/travis.rb +121 -0
- data/lib/embulk/input/travis/travis_patch.rb +15 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ac9b30ab3e49a4c3a66404cca85fc2c52a280d02e195940d2ddd687100d9244d
|
4
|
+
data.tar.gz: e870fb44cf66833c3dd2e7b3dab5547655269215c3544b28b35ea4f9e1891241
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5e3083c635119273bcb82570c7e4c40b7686b1476d6aa6191d6cb0b3bb766ec6d6b01d249c5960bc63c8fbd746338e3f1136d41d208f44c39b55a81063206e10
|
7
|
+
data.tar.gz: 291f60296f2743a6e3e33c0664ef364b95186aca72770f1dbc8515ade9801e25d3038dc827b60ac2cb09495eaaf201f3338696bccb8ed347bb015582ed6a46d7
|
data/.gitignore
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
jruby-9.1.15.0
|
data/Dockerfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
FROM ruby:2.6
|
2
|
+
|
3
|
+
RUN apt-get update && apt-get install -y git default-jdk
|
4
|
+
|
5
|
+
RUN curl --create-dirs -o /usr/local/bin/embulk -L "https://dl.embulk.org/embulk-latest.jar"
|
6
|
+
RUN chmod +x /usr/local/bin/embulk
|
7
|
+
|
8
|
+
RUN useradd --create-home --user-group --uid 1000 app && mkdir /app /vendor && chown app:app /app /vendor
|
9
|
+
|
10
|
+
USER app
|
11
|
+
|
12
|
+
WORKDIR /app
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
MIT License
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
a copy of this software and associated documentation files (the
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Travis input plugin for Embulk
|
2
|
+
|
3
|
+
Fetch Travis build results
|
4
|
+
|
5
|
+
## Overview
|
6
|
+
|
7
|
+
- **Plugin type**: input
|
8
|
+
- **Resume supported**: ?
|
9
|
+
- **Cleanup supported**: ?
|
10
|
+
- **Guess supported**: ?
|
11
|
+
|
12
|
+
## Configuration
|
13
|
+
|
14
|
+
- **repo**: Target repository name like `rails/rails` (string, required)
|
15
|
+
- **build_num_from**: Build number from (integer, required)
|
16
|
+
- **build_num_to**: Build number to (integer, optional)
|
17
|
+
- **step**: Amount of builds (string, default: `10`)
|
18
|
+
- **token**: Travis API token which can be found on https://travis-ci.org/account/preferences (string, default: `null`)
|
19
|
+
|
20
|
+
## Example
|
21
|
+
|
22
|
+
```yaml
|
23
|
+
in:
|
24
|
+
type: travis
|
25
|
+
repo: rails/rails
|
26
|
+
build_num_from: 59100
|
27
|
+
step: 15
|
28
|
+
token: xxxxxxxxxxxxxxxxxxxxxx
|
29
|
+
```
|
30
|
+
|
31
|
+
## Build
|
32
|
+
|
33
|
+
```
|
34
|
+
$ rake
|
35
|
+
```
|
data/Rakefile
ADDED
data/bin/console
ADDED
data/docker-compose.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
version: "3.7"
|
2
|
+
services:
|
3
|
+
embulk:
|
4
|
+
build: .
|
5
|
+
volumes:
|
6
|
+
- .:/app:cached
|
7
|
+
- home:/home/app
|
8
|
+
- vendor:/vendor
|
9
|
+
- $HOME/.gitconfig:/home/app/.gitconfig:ro
|
10
|
+
- $HOME/.ssh:/home/app/.ssh:ro
|
11
|
+
- $HOME/.gem:/home/app/.gem
|
12
|
+
environment:
|
13
|
+
BUNDLE_PATH: /vendor/bundle
|
14
|
+
volumes:
|
15
|
+
home:
|
16
|
+
vendor:
|
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
Gem::Specification.new do |spec|
|
3
|
+
spec.name = "embulk-input-travis"
|
4
|
+
spec.version = "0.1.0"
|
5
|
+
spec.authors = [""]
|
6
|
+
spec.summary = "Travis input plugin for Embulk"
|
7
|
+
spec.description = "Loads records from Travis."
|
8
|
+
spec.email = [""]
|
9
|
+
spec.licenses = ["MIT"]
|
10
|
+
# TODO set this: spec.homepage = "https://github.com//embulk-input-travis"
|
11
|
+
|
12
|
+
spec.files = `git ls-files`.split("\n") + Dir["classpath/*.jar"]
|
13
|
+
spec.test_files = spec.files.grep(%r{^(test|spec)/})
|
14
|
+
spec.require_paths = ["lib"]
|
15
|
+
|
16
|
+
spec.add_dependency 'travis'
|
17
|
+
|
18
|
+
spec.add_development_dependency 'bundler', ['>= 1.10.6']
|
19
|
+
spec.add_development_dependency 'rake', ['>= 10.0']
|
20
|
+
spec.add_development_dependency 'pry'
|
21
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
require 'travis'
|
2
|
+
require 'embulk/input/travis/travis_patch'
|
3
|
+
|
4
|
+
module Embulk
|
5
|
+
module Input
|
6
|
+
|
7
|
+
class Travis < InputPlugin
|
8
|
+
Plugin.register_input("travis", self)
|
9
|
+
|
10
|
+
def self.transaction(config, &control)
|
11
|
+
# configuration code:
|
12
|
+
task = {
|
13
|
+
"repo" => config.param("repo", :string),
|
14
|
+
"build_num_from" => config.param("build_num_from", :integer),
|
15
|
+
"build_num_to" => config.param("build_num_to", :integer, nil),
|
16
|
+
"token" => config.param("token", :string, nil),
|
17
|
+
"step" => config.param("step", :integer, 10),
|
18
|
+
}
|
19
|
+
|
20
|
+
columns = [
|
21
|
+
Column.new(0, "id", :long),
|
22
|
+
Column.new(1, "data", :string),
|
23
|
+
Column.new(2, "log", :string),
|
24
|
+
Column.new(3, "build_number", :long),
|
25
|
+
Column.new(4, "build_data", :string)
|
26
|
+
]
|
27
|
+
|
28
|
+
resume(task, columns, 1, &control)
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.resume(task, columns, count, &control)
|
32
|
+
task_reports = yield(task, columns, count)
|
33
|
+
report = task_reports.first
|
34
|
+
|
35
|
+
next_from = report["not_finished_build_nums"].min || report["build_num_to"] + 1
|
36
|
+
|
37
|
+
next_config_diff = {
|
38
|
+
"build_num_from" => next_from,
|
39
|
+
"build_num_to" => next_from + task["step"]
|
40
|
+
}
|
41
|
+
return next_config_diff
|
42
|
+
end
|
43
|
+
|
44
|
+
# TODO
|
45
|
+
# def self.guess(config)
|
46
|
+
# sample_records = [
|
47
|
+
# {"example"=>"a", "column"=>1, "value"=>0.1},
|
48
|
+
# {"example"=>"a", "column"=>2, "value"=>0.2},
|
49
|
+
# ]
|
50
|
+
# columns = Guess::SchemaGuess.from_hash_records(sample_records)
|
51
|
+
# return {"columns" => columns}
|
52
|
+
# end
|
53
|
+
|
54
|
+
def init
|
55
|
+
if client.access_token
|
56
|
+
Embulk.logger.info { "embulk-input-travis: Logged in as @#{client.user.login}" }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def run
|
61
|
+
not_finished_build_nums = []
|
62
|
+
|
63
|
+
Embulk.logger.info { "embulk-input-travis: Start from build_num:[#{build_num_from}] to build_num:[#{build_num_to}]" }
|
64
|
+
|
65
|
+
(build_num_from..build_num_to).each do |build_num|
|
66
|
+
Embulk.logger.info { "embulk-input-travis: Start build_num:[#{build_num}]" }
|
67
|
+
|
68
|
+
repo.session.clear_cache!
|
69
|
+
|
70
|
+
build = repo.build(build_num)
|
71
|
+
unless build&.finished?
|
72
|
+
Embulk.logger.info { "embulk-input-travis: Skip build_num:[#{build_num}]" }
|
73
|
+
|
74
|
+
not_finished_build_nums << build_num
|
75
|
+
next
|
76
|
+
end
|
77
|
+
|
78
|
+
build.jobs.each do |job|
|
79
|
+
Embulk.logger.info { "embulk-input-travis: Start job_id:[#{job.id}]" }
|
80
|
+
|
81
|
+
page_builder.add([
|
82
|
+
job.id,
|
83
|
+
job.to_h.to_json,
|
84
|
+
job.log.body,
|
85
|
+
build.number.to_i,
|
86
|
+
build.to_h.to_json
|
87
|
+
])
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
page_builder.finish
|
92
|
+
|
93
|
+
task_report = {
|
94
|
+
"build_num_from" => build_num_from,
|
95
|
+
"build_num_to" => build_num_to,
|
96
|
+
"not_finished_build_nums" => not_finished_build_nums
|
97
|
+
}
|
98
|
+
return task_report
|
99
|
+
end
|
100
|
+
|
101
|
+
private
|
102
|
+
|
103
|
+
def repo
|
104
|
+
@repo ||= client.repo(task["repo"])
|
105
|
+
end
|
106
|
+
|
107
|
+
def build_num_from
|
108
|
+
@build_num_from ||= task["build_num_from"]
|
109
|
+
end
|
110
|
+
|
111
|
+
def build_num_to
|
112
|
+
@build_num_to ||= (task["build_num_to"] || build_num_from + task["step"])
|
113
|
+
end
|
114
|
+
|
115
|
+
def client
|
116
|
+
@client ||= ::Travis::Client.new(access_token: task["token"])
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'travis'
|
2
|
+
# https://github.com/travis-ci/travis.rb/pull/644/files
|
3
|
+
Travis::Client::Session.prepend(Module.new do
|
4
|
+
private
|
5
|
+
|
6
|
+
def fetch_one(entity, id = nil)
|
7
|
+
path = "/#{entity.base_path}/#{id}"
|
8
|
+
|
9
|
+
if entity == Travis::Client::Artifact
|
10
|
+
load({'log' => {'id' => id, 'body' => get_raw(path)}})[entity.one]
|
11
|
+
else
|
12
|
+
get(path)[entity.one]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end)
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: embulk-input-travis
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ''
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-02-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: travis
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.10.6
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.10.6
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Loads records from Travis.
|
70
|
+
email:
|
71
|
+
- ''
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".ruby-version"
|
78
|
+
- Dockerfile
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/console
|
84
|
+
- docker-compose.yml
|
85
|
+
- embulk-input-travis.gemspec
|
86
|
+
- lib/embulk/input/travis.rb
|
87
|
+
- lib/embulk/input/travis/travis_patch.rb
|
88
|
+
homepage:
|
89
|
+
licenses:
|
90
|
+
- MIT
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubygems_version: 3.0.1
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: Travis input plugin for Embulk
|
111
|
+
test_files: []
|