embulk-input-buildkite 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c5dfd55ed609222978610c93683b3a5a7efc4dcd4eebba14e764b54d425b5d50
4
+ data.tar.gz: 0acf8586a04c97b305d140f467885bd277c20e05432c93e927cb87ab5b35676e
5
+ SHA512:
6
+ metadata.gz: e47572bfed8427c8af0bed642bb424054b853f430d9a228026dc77f34b720f4ca4bfca868dbcb8ae7146c33dd8da891dcc899a182f5b4b09b500934b5948726c
7
+ data.tar.gz: 416c503194e2b7ea9ef009c89f307f658084832af26b2575b400f72fd82432ee82dad613ee3ecc5fa06bc083c81af2157d0647c027ff18c832cb8b467aa44b0f
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ *~
2
+ /pkg/
3
+ /tmp/
4
+ /.bundle/
5
+ /Gemfile.lock
6
+
7
+ *.env
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
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org/'
2
+ gemspec
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,51 @@
1
+ # Buildkite input plugin for Embulk
2
+
3
+ Fetch Buildkite build results
4
+
5
+ ## Overview
6
+
7
+ - **Plugin type**: input
8
+ - **Resume supported**: ?
9
+ - **Cleanup supported**: ?
10
+ - **Guess supported**: no
11
+
12
+ ## Configuration
13
+
14
+ - **org_slug**: Target repository name like `rails` (string, required)
15
+ - **pipeline_slug**: Target pipeline name like `rails` (string, required)
16
+ - **build_nums**: Build numbers (Array of integer, required)
17
+ - **token**: Buildkite API token which can be found on https://buildkite.com/user/api-access-tokens (string, required)
18
+
19
+ ## Example
20
+
21
+ ```liquid
22
+ in:
23
+ type: buildkite
24
+ org_slug: rails
25
+ pipeline_slug: rails
26
+ build_nums: [60894]
27
+ token: {{ env.BUILDKITE_ACCESS_TOKEN }}
28
+ ```
29
+
30
+ ## Build
31
+
32
+ ```
33
+ $ rake
34
+ ```
35
+
36
+ ## Test
37
+
38
+ ```
39
+ $ embulk run config.yml.liquid -b $BUNDLE_PATH -L .
40
+ ```
41
+
42
+ ## Example
43
+
44
+ ```yaml
45
+ in:
46
+ type: travis
47
+ repo: rails/rails
48
+ build_num_from: 59100
49
+ step: 15
50
+ token: xxxxxxxxxxxxxxxxxxxxxx
51
+ ```
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ task default: :build
data/config.yml.liquid ADDED
@@ -0,0 +1,8 @@
1
+ in:
2
+ type: buildkite
3
+ org_slug: rails
4
+ pipeline_slug: rails
5
+ build_nums: [60894]
6
+ token: {{ env.BUILDKITE_ACCESS_TOKEN }}
7
+ out:
8
+ type: stdout
@@ -0,0 +1,17 @@
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
+ env_file: app.env
15
+ volumes:
16
+ home:
17
+ vendor:
@@ -0,0 +1,20 @@
1
+
2
+ Gem::Specification.new do |spec|
3
+ spec.name = "embulk-input-buildkite"
4
+ spec.version = "0.1.0"
5
+ spec.authors = ["Fumiaki MATSUSHIMA"]
6
+ spec.summary = "Buildkite input plugin for Embulk"
7
+ spec.description = "Loads records from Buildkite."
8
+ spec.email = ["mtsmfm@gmail.com"]
9
+ spec.licenses = ["MIT"]
10
+ # TODO set this: spec.homepage = "https://github.com/mtsmfm/embulk-input-buildkite"
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 'unofficial_buildkite_client', ['0.2.0']
17
+ spec.add_development_dependency 'bundler', ['>= 1.10.6']
18
+ spec.add_development_dependency 'rake', ['>= 10.0']
19
+ spec.add_development_dependency 'pry'
20
+ end
@@ -0,0 +1,101 @@
1
+ require "unofficial_buildkite_client"
2
+
3
+ module Embulk
4
+ module Input
5
+
6
+ class Buildkite < InputPlugin
7
+ class Logger
8
+ def initialize(embulk_logger)
9
+ @embulk_logger = embulk_logger
10
+ end
11
+
12
+ def info(message)
13
+ @embulk_logger.info("embulk-input-buildkite: #{message}")
14
+ end
15
+ end
16
+
17
+ Plugin.register_input("buildkite", self)
18
+
19
+ def self.transaction(config, &control)
20
+ # configuration code:
21
+ task = {
22
+ "org_slug" => config.param("org_slug", :string),
23
+ "pipeline_slug" => config.param("pipeline_slug", :string),
24
+ "build_nums" => config.param("build_nums", :array),
25
+ "token" => config.param("token", :string, nil),
26
+ }
27
+
28
+ columns = [
29
+ Column.new(0, "id", :long),
30
+ Column.new(1, "data", :string),
31
+ Column.new(2, "log", :string),
32
+ Column.new(3, "started_at", :timestamp),
33
+ Column.new(4, "build_number", :long),
34
+ Column.new(5, "build_data", :string),
35
+ ]
36
+
37
+ resume(task, columns, 1, &control)
38
+ end
39
+
40
+ def self.resume(task, columns, count, &control)
41
+ task_reports = yield(task, columns, count)
42
+
43
+ next_config_diff = {}
44
+ return next_config_diff
45
+ end
46
+
47
+ # TODO
48
+ # def self.guess(config)
49
+ # sample_records = [
50
+ # {"example"=>"a", "column"=>1, "value"=>0.1},
51
+ # {"example"=>"a", "column"=>2, "value"=>0.2},
52
+ # ]
53
+ # columns = Guess::SchemaGuess.from_hash_records(sample_records)
54
+ # return {"columns" => columns}
55
+ # end
56
+
57
+ def init
58
+ # initialization code:
59
+ end
60
+
61
+ def run
62
+ task['build_nums'].each do |build_num|
63
+ logger.info("Start build_num:[#{build_num}]")
64
+
65
+ build = client.fetch_build(number: build_num)
66
+ build[:jobs].each do |job|
67
+ logger.info("Start Start job_id:[#{job[:id]}]")
68
+ log = client.fetch_log(build_number: job[:build_number], job_id: job[:id])[:output]
69
+
70
+ page_builder.add([
71
+ job[:id],
72
+ job.to_json,
73
+ log,
74
+ job[:started_at],
75
+ job[:build_number],
76
+ build.to_json,
77
+ ])
78
+
79
+ page_builder.flush
80
+ end
81
+ end
82
+
83
+ page_builder.finish
84
+
85
+ task_report = {}
86
+ return task_report
87
+ end
88
+
89
+ private
90
+
91
+ def client
92
+ @client ||= UnofficialBuildkiteClient.new(access_token: task["token"], org_slug: task["org_slug"], pipeline_slug: task["pipeline_slug"], logger: logger)
93
+ end
94
+
95
+ def logger
96
+ @logger ||= Logger.new(Embulk.logger)
97
+ end
98
+ end
99
+
100
+ end
101
+ end
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: embulk-input-buildkite
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Fumiaki MATSUSHIMA
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-05-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: unofficial_buildkite_client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.2.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.2.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 Buildkite.
70
+ email:
71
+ - mtsmfm@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - Dockerfile
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - config.yml.liquid
83
+ - docker-compose.yml
84
+ - embulk-input-buildkite.gemspec
85
+ - lib/embulk/input/buildkite.rb
86
+ homepage:
87
+ licenses:
88
+ - MIT
89
+ metadata: {}
90
+ post_install_message:
91
+ rdoc_options: []
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ requirements: []
105
+ rubygems_version: 3.0.1
106
+ signing_key:
107
+ specification_version: 4
108
+ summary: Buildkite input plugin for Embulk
109
+ test_files: []