gitlab-fluent-plugin-redis-slowlog 0.0.0 → 0.0.1.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +11 -4
- data/README.md +0 -37
- data/Rakefile +7 -12
- data/gitlab-fluent-plugin-redis-slowlog.gemspec +1 -1
- data/test/helper.rb +8 -0
- data/test/plugin/test_in_redis_slowlog.rb +18 -0
- metadata +7 -11
- data/.gitlab-ci.yml +0 -21
- data/.rubocop.yml +0 -17
- data/spec/fluent/plugin/redis_slowlog_input_spec.rb +0 -119
- data/spec/spec_helper.rb +0 -15
- data/tools/deploy-rubygem.sh +0 -31
- data/tools/update-changelog.rb +0 -106
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8104bc9262ab90f07e653d801a21ed7384f8d53a3bbc7644d3f568c9cd2a0be
|
4
|
+
data.tar.gz: cb9da92f38150d81e5927b0ffb9710de9eb9dfff1b9a5b9233fa42dc40e508c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae18b72578831c8ba6d58a6c82df91c75a9c9dca51ed5c6546765afba1193090dc4583999fa30be0d508611e414cc1f5cffa1ebe3e6cc927434dede4ba06ec95
|
7
|
+
data.tar.gz: c33ebe9e818ea120eac6f900c62c1bc61c91fe5d9dde5a367b84f65f45895bc19c673337b184ffe3ca9f8f62c56d63dec9c227a2f6e7bc0e19d01dfabd8e9c9e
|
data/Gemfile.lock
CHANGED
@@ -1,13 +1,16 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
gitlab-fluent-plugin-redis-slowlog (0.0.
|
4
|
+
gitlab-fluent-plugin-redis-slowlog (0.0.1.pre)
|
5
5
|
fluentd (>= 0.14.10, < 2)
|
6
6
|
redis (>= 4.1.3, < 5)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
+
activesupport (3.2.22.5)
|
12
|
+
i18n (~> 0.6, >= 0.6.4)
|
13
|
+
multi_json (~> 1.0)
|
11
14
|
ast (2.4.0)
|
12
15
|
coderay (1.1.2)
|
13
16
|
concurrent-ruby (1.1.6)
|
@@ -30,11 +33,14 @@ GEM
|
|
30
33
|
rubocop-rails (~> 2.0)
|
31
34
|
rubocop-rspec (~> 1.36)
|
32
35
|
http_parser.rb (0.6.0)
|
36
|
+
i18n (0.9.5)
|
37
|
+
concurrent-ruby (~> 1.0)
|
33
38
|
jaro_winkler (1.5.4)
|
34
39
|
method_source (0.9.2)
|
35
40
|
msgpack (1.3.3)
|
41
|
+
multi_json (1.14.1)
|
36
42
|
parallel (1.19.1)
|
37
|
-
parser (2.7.1.
|
43
|
+
parser (2.7.1.3)
|
38
44
|
ast (~> 2.4.0)
|
39
45
|
power_assert (1.1.3)
|
40
46
|
pry (0.12.2)
|
@@ -68,10 +74,11 @@ GEM
|
|
68
74
|
rubocop (>= 0.51)
|
69
75
|
rubocop-performance (1.4.1)
|
70
76
|
rubocop (>= 0.71.0)
|
71
|
-
rubocop-rails (2.
|
77
|
+
rubocop-rails (2.5.2)
|
78
|
+
activesupport
|
72
79
|
rack (>= 1.1)
|
73
80
|
rubocop (>= 0.72.0)
|
74
|
-
rubocop-rspec (1.
|
81
|
+
rubocop-rspec (1.39.0)
|
75
82
|
rubocop (>= 0.68.1)
|
76
83
|
ruby-progressbar (1.10.1)
|
77
84
|
serverengine (2.2.1)
|
data/README.md
CHANGED
@@ -94,40 +94,3 @@ Default value: `128`.
|
|
94
94
|
The time in seconds to wait between `SLOWLOG` commands.
|
95
95
|
|
96
96
|
Default value: `10`.
|
97
|
-
|
98
|
-
## Development
|
99
|
-
|
100
|
-
After checking out the repository, run `bundle install` to install all
|
101
|
-
dependencies.
|
102
|
-
|
103
|
-
After that, you can run `bundle exec rake` to run all lints and
|
104
|
-
specs.
|
105
|
-
|
106
|
-
Other rake tasks:
|
107
|
-
|
108
|
-
```
|
109
|
-
rake build # Build gitlab-fluent-plugin-redis-slowlog-0.gem into the pkg directory
|
110
|
-
rake clean # Remove any temporary products
|
111
|
-
rake clobber # Remove any generated files
|
112
|
-
rake console # Start an interactive console with the gem loaded
|
113
|
-
rake install # Build and install gitlab-fluent-plugin-redis-slowlog-0.gem into system gems
|
114
|
-
rake install:local # Build and install gitlab-fluent-plugin-redis-slowlog-0.gem into system gems without network access
|
115
|
-
rake release[remote] # Create tag v0 and build and push gitlab-fluent-plugin-redis-slowlog-0.gem to rubygems.org
|
116
|
-
rake spec # Run RSpec code examples
|
117
|
-
rake verify # Run RuboCop
|
118
|
-
rake verify:auto_correct # Auto-correct RuboCop offenses
|
119
|
-
```
|
120
|
-
|
121
|
-
|
122
|
-
### Releasing a new version
|
123
|
-
|
124
|
-
Releasing a new version can be done by pushing a new tag, or creating
|
125
|
-
it from the
|
126
|
-
[interface](https://gitlab.com/gitlab-org/fluent-plugin-redis-slowlog/-/tags).
|
127
|
-
|
128
|
-
A new changelog will automatically be added to the release on Gitlab.
|
129
|
-
|
130
|
-
The new version will automatically be published to
|
131
|
-
[rubygems](https://rubygems.org/gems/gitlab-labkit) when the pipeline
|
132
|
-
for the tag completes. It might take a few minutes before the update
|
133
|
-
is available.
|
data/Rakefile
CHANGED
@@ -1,17 +1,12 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
-
require "rspec/core/rake_task"
|
3
|
-
require "rubocop/rake_task"
|
4
2
|
|
5
|
-
|
6
|
-
RuboCop::RakeTask.new(:verify)
|
3
|
+
require "rake/testtask"
|
7
4
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
Pry.start
|
5
|
+
Rake::TestTask.new(:test) do |t|
|
6
|
+
t.libs.push("lib", "test")
|
7
|
+
t.test_files = FileList["test/**/test_*.rb"]
|
8
|
+
t.verbose = true
|
9
|
+
t.warning = true
|
15
10
|
end
|
16
11
|
|
17
|
-
task default: [:
|
12
|
+
task default: [:test]
|
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |spec|
|
5
5
|
spec.name = "gitlab-fluent-plugin-redis-slowlog"
|
6
|
-
spec.version = "0.0.
|
6
|
+
spec.version = "0.0.1.pre" # `git describe --tags`.chomp.gsub(/^v/, "")
|
7
7
|
spec.metadata = { "source_code_uri" => "https://gitlab.com/gitlab-org/fluent-plugin-redis-slowlog" }
|
8
8
|
spec.authors = ["Bob Van Landuyt"]
|
9
9
|
spec.email = ["bob@gitlab.com"]
|
data/test/helper.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.expand_path("../../", __FILE__))
|
2
|
+
require "test-unit"
|
3
|
+
require "fluent/test"
|
4
|
+
require "fluent/test/driver/input"
|
5
|
+
require "fluent/test/helpers"
|
6
|
+
|
7
|
+
Test::Unit::TestCase.include(Fluent::Test::Helpers)
|
8
|
+
Test::Unit::TestCase.extend(Fluent::Test::Helpers)
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "helper"
|
2
|
+
require "fluent/plugin/in_redis_slowlog.rb"
|
3
|
+
|
4
|
+
class RedisSlowlogInputTest < Test::Unit::TestCase
|
5
|
+
setup do
|
6
|
+
Fluent::Test.setup
|
7
|
+
end
|
8
|
+
|
9
|
+
test "failure" do
|
10
|
+
flunk
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def create_driver(conf)
|
16
|
+
Fluent::Test::Driver::Input.new(Fluent::Plugin::RedisSlowlogInput).configure(conf)
|
17
|
+
end
|
18
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab-fluent-plugin-redis-slowlog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Van Landuyt
|
@@ -142,8 +142,6 @@ extensions: []
|
|
142
142
|
extra_rdoc_files: []
|
143
143
|
files:
|
144
144
|
- ".gitignore"
|
145
|
-
- ".gitlab-ci.yml"
|
146
|
-
- ".rubocop.yml"
|
147
145
|
- Gemfile
|
148
146
|
- Gemfile.lock
|
149
147
|
- LICENSE
|
@@ -151,10 +149,8 @@ files:
|
|
151
149
|
- Rakefile
|
152
150
|
- gitlab-fluent-plugin-redis-slowlog.gemspec
|
153
151
|
- lib/fluent/plugin/in_redis_slowlog.rb
|
154
|
-
-
|
155
|
-
-
|
156
|
-
- tools/deploy-rubygem.sh
|
157
|
-
- tools/update-changelog.rb
|
152
|
+
- test/helper.rb
|
153
|
+
- test/plugin/test_in_redis_slowlog.rb
|
158
154
|
homepage: http://gitlab.com/gitlab-org/gitlab-fluent-plugin-redis-slowlog
|
159
155
|
licenses:
|
160
156
|
- MIT
|
@@ -171,14 +167,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
171
167
|
version: '2.6'
|
172
168
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
173
169
|
requirements:
|
174
|
-
- - "
|
170
|
+
- - ">"
|
175
171
|
- !ruby/object:Gem::Version
|
176
|
-
version:
|
172
|
+
version: 1.3.1
|
177
173
|
requirements: []
|
178
174
|
rubygems_version: 3.0.3
|
179
175
|
signing_key:
|
180
176
|
specification_version: 4
|
181
177
|
summary: Emit redis slowlog entries into fluentd
|
182
178
|
test_files:
|
183
|
-
-
|
184
|
-
-
|
179
|
+
- test/helper.rb
|
180
|
+
- test/plugin/test_in_redis_slowlog.rb
|
data/.gitlab-ci.yml
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
test:
|
2
|
-
image: ruby:2.6
|
3
|
-
stage: test
|
4
|
-
script:
|
5
|
-
- gem install bundler
|
6
|
-
- bundle install
|
7
|
-
- bundle exec rake
|
8
|
-
|
9
|
-
deploy:
|
10
|
-
stage: deploy
|
11
|
-
script:
|
12
|
-
- tools/deploy-rubygem.sh
|
13
|
-
only:
|
14
|
-
- tags
|
15
|
-
|
16
|
-
release:
|
17
|
-
stage: deploy
|
18
|
-
script:
|
19
|
-
- tools/update-changelog.rb "${CI_COMMIT_TAG}"
|
20
|
-
only:
|
21
|
-
- tags
|
data/.rubocop.yml
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
inherit_gem:
|
2
|
-
gitlab-styles:
|
3
|
-
- rubocop-default.yml
|
4
|
-
|
5
|
-
AllCops:
|
6
|
-
TargetRubyVersion: 2.6
|
7
|
-
|
8
|
-
# Let's just pick something from the beginning
|
9
|
-
Style/StringLiterals:
|
10
|
-
Enabled: true
|
11
|
-
EnforcedStyle: double_quotes
|
12
|
-
|
13
|
-
# This isn't Rails, so diable these
|
14
|
-
Rails/RakeEnvironment:
|
15
|
-
Enabled: false
|
16
|
-
CodeReuse/ActiveRecord:
|
17
|
-
Enabled: false
|
@@ -1,119 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Fluent::Plugin::RedisSlowlogInput do
|
4
|
-
let(:config) do
|
5
|
-
{ tag: "redis.slowlog" }
|
6
|
-
end
|
7
|
-
|
8
|
-
let(:plugin) { driver.instance }
|
9
|
-
let(:slowlog) { [] }
|
10
|
-
let(:fake_redis) { instance_double(Redis, ping: "PONG", quit: "OK", slowlog: slowlog) }
|
11
|
-
|
12
|
-
subject(:driver) do
|
13
|
-
config_string = config.map { |key, value| "#{key} #{value}" }.join("\n")
|
14
|
-
Fluent::Test::Driver::Input.new(described_class).configure(config_string)
|
15
|
-
end
|
16
|
-
|
17
|
-
before do
|
18
|
-
Fluent::Test.setup
|
19
|
-
end
|
20
|
-
|
21
|
-
context "when redis can't be reached" do
|
22
|
-
it "raises an error" do
|
23
|
-
expect { driver.run }.to raise_error(Redis::CannotConnectError)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
context "when specifying redis connection attributes" do
|
28
|
-
let(:config) do
|
29
|
-
{ tag: "redis.slowlog",
|
30
|
-
url: "redis://:p4ssw0rd@10.0.1.1:6380/15",
|
31
|
-
path: "/path/to/redis.sock",
|
32
|
-
host: "localhost",
|
33
|
-
port: 1234,
|
34
|
-
password: "5iveL!fe" }
|
35
|
-
end
|
36
|
-
|
37
|
-
it "delegates all of them to redis-rb" do
|
38
|
-
redis_params = [:url, :path, :host, :port, :password]
|
39
|
-
|
40
|
-
expect(Redis).to receive(:new).with(config.slice(*redis_params)).and_return(fake_redis)
|
41
|
-
|
42
|
-
driver.run
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
context "when redis is available" do
|
47
|
-
let(:config) do
|
48
|
-
{
|
49
|
-
tag: "redis.slowlog",
|
50
|
-
interval: 0,
|
51
|
-
logsize: 10
|
52
|
-
}
|
53
|
-
end
|
54
|
-
|
55
|
-
before do
|
56
|
-
allow(plugin).to receive(:redis).and_return(fake_redis)
|
57
|
-
end
|
58
|
-
|
59
|
-
after do
|
60
|
-
# Wait for the thread polling redis to finish
|
61
|
-
plugin.__send__(:watcher).join
|
62
|
-
end
|
63
|
-
|
64
|
-
it "does not raise errors" do
|
65
|
-
expect { driver.run }.not_to raise_error
|
66
|
-
end
|
67
|
-
|
68
|
-
it "polls the slowlog at with the configured interval and size" do
|
69
|
-
expect(plugin).to receive(:sleep).with(0).ordered
|
70
|
-
expect(fake_redis).to receive(:slowlog).with("get", 10).ordered
|
71
|
-
expect(plugin).to receive(:sleep).with(0).ordered
|
72
|
-
expect(fake_redis).to receive(:slowlog).with("get", 10).ordered
|
73
|
-
|
74
|
-
# Limit to 2 cycles
|
75
|
-
allow(plugin).to receive(:watching).thrice.and_return(true, true, false)
|
76
|
-
|
77
|
-
driver.run
|
78
|
-
end
|
79
|
-
|
80
|
-
context "when the slowlog returns entries" do
|
81
|
-
let(:slowlog) do
|
82
|
-
[
|
83
|
-
[25640, 1590522258, 1, %w[ping]],
|
84
|
-
[25639, 1590522249, 1, %w[ping]],
|
85
|
-
[25638, 1590522208, 5, %w[SCAN 0]]
|
86
|
-
]
|
87
|
-
end
|
88
|
-
|
89
|
-
let(:expected_entries) do
|
90
|
-
slowlog.map(&method(:log_entry)).sort_by { |event| event["id"] }
|
91
|
-
end
|
92
|
-
|
93
|
-
let(:emitted_entries) { driver.events.map(&:last) }
|
94
|
-
|
95
|
-
it "emits an event for each slowlog in reverse order" do
|
96
|
-
driver.run(expect_emits: 3)
|
97
|
-
|
98
|
-
expect(driver.events.size).to eq(3)
|
99
|
-
expect(emitted_entries).to eq(expected_entries)
|
100
|
-
end
|
101
|
-
|
102
|
-
it "does not log the same event twice" do
|
103
|
-
expect(fake_redis).to receive(:slowlog).and_return(slowlog.last(1), slowlog)
|
104
|
-
|
105
|
-
driver.run(expect_emits: 3)
|
106
|
-
|
107
|
-
expect(driver.events.size).to eq(3)
|
108
|
-
expect(emitted_entries).to eq(expected_entries)
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
def log_entry(slowlog_entry)
|
114
|
-
{ "id" => slowlog_entry.first,
|
115
|
-
"timestamp" => Time.at(slowlog_entry[1]),
|
116
|
-
"exec_time" => slowlog_entry[2],
|
117
|
-
"command" => slowlog_entry.last }
|
118
|
-
end
|
119
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require "rspec"
|
2
|
-
require "fluent/test"
|
3
|
-
require "fluent/test/driver/input"
|
4
|
-
require "fluent/test/helpers"
|
5
|
-
require "pry"
|
6
|
-
|
7
|
-
Dir.glob(File.expand_path("../lib/**/*.rb", __dir__)).each(&method(:require))
|
8
|
-
|
9
|
-
# Test::Unit is required for fluent/test, but we don't want it to autorun when
|
10
|
-
# required
|
11
|
-
Test::Unit::AutoRunner.need_auto_run = false
|
12
|
-
|
13
|
-
RSpec.configure do |config|
|
14
|
-
config.include Fluent::Test::Helpers
|
15
|
-
end
|
data/tools/deploy-rubygem.sh
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
|
3
|
-
set -euo pipefail
|
4
|
-
IFS=$'\n\t'
|
5
|
-
|
6
|
-
mkdir -p ~/.gem/
|
7
|
-
temp_file=$(mktemp)
|
8
|
-
|
9
|
-
# Revert change the credentials file
|
10
|
-
function revert_gem_cred_switch {
|
11
|
-
mv "$temp_file" ~/.gem/credentials
|
12
|
-
}
|
13
|
-
|
14
|
-
if [[ -f ~/.gem/credentials ]]; then
|
15
|
-
echo "Temporarily moving existing credentials to $temp_file"
|
16
|
-
mv ~/.gem/credentials "$temp_file"
|
17
|
-
trap revert_gem_cred_switch EXIT
|
18
|
-
fi
|
19
|
-
|
20
|
-
cat <<EOD > ~/.gem/credentials
|
21
|
-
---
|
22
|
-
:rubygems_api_key: $RUBYGEMS_API_KEY
|
23
|
-
EOD
|
24
|
-
chmod 600 ~/.gem/credentials
|
25
|
-
|
26
|
-
set -x
|
27
|
-
rm -rf pkg/
|
28
|
-
mkdir -p pkg/
|
29
|
-
bundle install
|
30
|
-
bundle exec rake verify build
|
31
|
-
gem push pkg/*.gem
|
data/tools/update-changelog.rb
DELETED
@@ -1,106 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "uri"
|
4
|
-
require "net/http"
|
5
|
-
require "openssl"
|
6
|
-
require "json"
|
7
|
-
require "optparse"
|
8
|
-
|
9
|
-
GitlabError = Class.new(StandardError)
|
10
|
-
GitlabClientError = Class.new(GitlabError)
|
11
|
-
|
12
|
-
def gitlab_client(path, method, body = nil)
|
13
|
-
url = URI("https://gitlab.com#{path}")
|
14
|
-
|
15
|
-
http = Net::HTTP.new(url.host, url.port)
|
16
|
-
http.use_ssl = true
|
17
|
-
|
18
|
-
request = case method
|
19
|
-
when :get
|
20
|
-
Net::HTTP::Get.new(url)
|
21
|
-
when :post
|
22
|
-
Net::HTTP::Post.new(url)
|
23
|
-
when :put
|
24
|
-
Net::HTTP::Put.new(url)
|
25
|
-
else
|
26
|
-
raise "Unknown method: #{method}"
|
27
|
-
end
|
28
|
-
|
29
|
-
request["content-type"] = "application/json"
|
30
|
-
request["PRIVATE-TOKEN"] = ENV["GITLAB_TOKEN"]
|
31
|
-
request.body = JSON.dump(body) if body
|
32
|
-
|
33
|
-
response = http.request(request)
|
34
|
-
|
35
|
-
case response
|
36
|
-
when Net::HTTPSuccess
|
37
|
-
JSON.parse(response.read_body)
|
38
|
-
when Net::HTTPClientError
|
39
|
-
raise GitlabClientError, "HTTP #{response.code} for #{method} #{url}: #{response.read_body}"
|
40
|
-
else
|
41
|
-
raise GitLabError, "HTTP #{response.code} for #{method} #{url}: #{response.read_body}"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def list_commits_for_tag(tag)
|
46
|
-
commits = `git rev-list --no-merges $(git describe --tags --abbrev=0 #{tag}^)..#{tag}`.lines
|
47
|
-
commits.map(&:chomp)
|
48
|
-
end
|
49
|
-
|
50
|
-
def get_mrs_for_commit(commit_id)
|
51
|
-
gitlab_client("/api/v4/projects/gitlab-org%2ffluent-plugin-redis-slowlog/repository/commits/#{commit_id}/merge_requests", :get)
|
52
|
-
end
|
53
|
-
|
54
|
-
def create_release_for_tag(tag, description)
|
55
|
-
req_body = { tag_name: tag, description: description }
|
56
|
-
gitlab_client("/api/v4/projects/gitlab-org%2ffluent-plugin-redis-slowlog/releases", :post, req_body)
|
57
|
-
end
|
58
|
-
|
59
|
-
def update_release_for_tag(tag, description)
|
60
|
-
req_body = { description: description }
|
61
|
-
gitlab_client("/api/v4/projects/gitlab-org%2ffluent-plugin-redis-slowlog/releases/#{tag}", :put, req_body)
|
62
|
-
end
|
63
|
-
|
64
|
-
def get_unique_mrs_for_tag(tag)
|
65
|
-
commit_ids = list_commits_for_tag(tag)
|
66
|
-
dup_mrs = commit_ids.map { |commit_id| get_mrs_for_commit(commit_id) }.flatten
|
67
|
-
uniq_mrs = dup_mrs.uniq { |mr| mr["iid"] }
|
68
|
-
|
69
|
-
uniq_mrs.sort { |mr| mr["iid"] }.reverse
|
70
|
-
end
|
71
|
-
|
72
|
-
options = {}
|
73
|
-
OptionParser.new do |opts|
|
74
|
-
opts.banner = "Usage: update-changelog.rb [options] tag"
|
75
|
-
|
76
|
-
opts.on("-d", "--[no-]dry-run", "Display only. Do not update release notes.") do |d|
|
77
|
-
options[:dry_run] = d
|
78
|
-
end
|
79
|
-
end.parse!
|
80
|
-
|
81
|
-
# Check required conditions
|
82
|
-
unless ARGV.length == 1
|
83
|
-
puts optparse
|
84
|
-
exit(-1)
|
85
|
-
end
|
86
|
-
|
87
|
-
tag = ARGV.first
|
88
|
-
|
89
|
-
changelog = get_unique_mrs_for_tag(tag).map { |mr| "* #{mr['web_url']}: #{mr['title']}" }.join("\n")
|
90
|
-
|
91
|
-
raise "No new changes found" if changelog.empty?
|
92
|
-
|
93
|
-
changelog = "## Changes in #{tag}\n\n" + changelog
|
94
|
-
|
95
|
-
if options[:dry_run]
|
96
|
-
puts changelog
|
97
|
-
exit
|
98
|
-
end
|
99
|
-
|
100
|
-
begin
|
101
|
-
create_release_for_tag(tag, changelog)
|
102
|
-
puts "Created release: https://gitlab.com/gitlab-org/fluent-plugin-redis-slowlog/-/releases##{tag}"
|
103
|
-
rescue GitlabClientError
|
104
|
-
update_release_for_tag(tag, changelog)
|
105
|
-
puts "Updated release: https://gitlab.com/gitlab-org/fluent-plugin-redis-slowlog/-/releases##{tag}"
|
106
|
-
end
|