diffend 0.2.16 → 0.2.24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.github/workflows/ci.yml +12 -2
- data/CHANGELOG.md +59 -0
- data/Gemfile +2 -1
- data/Gemfile.lock +12 -1
- data/{LICENSE → LICENSE.md} +0 -0
- data/lib/diffend.rb +71 -20
- data/lib/diffend/build_bundler_definition.rb +26 -0
- data/lib/diffend/config/fetcher.rb +92 -9
- data/lib/diffend/config/validator.rb +25 -0
- data/lib/diffend/errors.rb +14 -4
- data/lib/diffend/handle_errors/build_exception_payload.rb +30 -0
- data/lib/diffend/handle_errors/display_to_stdout.rb +17 -0
- data/lib/diffend/handle_errors/messages.rb +29 -0
- data/lib/diffend/handle_errors/report.rb +59 -0
- data/lib/diffend/request.rb +165 -0
- data/lib/diffend/voting.rb +37 -8
- data/lib/diffend/voting/versions/local.rb +156 -52
- data/lib/diffend/voting/versions/remote.rb +46 -16
- data/scripts/generate_payload_for_file.rb +1 -1
- metadata +11 -4
- metadata.gz.sig +0 -0
- data/lib/diffend/voting/request.rb +0 -191
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bc33803e8086ca502424fae528475182c196daf3b5971200a7988fca0936822
|
4
|
+
data.tar.gz: 138b0750cff7e555d62f82ca8716b4d21dbd32fd5c6de898fd7c7653d7c56501
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf6b14a1ca18e978b709905159b17caacb5cc5a2812ecb1b655961041e44134eed33d840ac3679b451aa49b33f2dcf7f96ffa6e5535a102f7799cf927fb8e9af
|
7
|
+
data.tar.gz: 39e1f326632af4f2f658d027ebb8277fd1b24262a9e1fd90a10747c8d85e1bf7ead72c65c44716af7a4d4f06a746d0be008b1a76fb82ba88034c1b1c6cdcf04f
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/.github/workflows/ci.yml
CHANGED
@@ -3,16 +3,27 @@ name: ci
|
|
3
3
|
jobs:
|
4
4
|
specs:
|
5
5
|
runs-on: ubuntu-latest
|
6
|
+
|
6
7
|
strategy:
|
7
8
|
fail-fast: false
|
8
9
|
matrix:
|
9
10
|
ruby:
|
10
11
|
- '2.7'
|
12
|
+
- '2.6'
|
13
|
+
- '2.5'
|
14
|
+
- 'jruby'
|
11
15
|
include:
|
12
16
|
- ruby: '2.7'
|
13
17
|
coverage: 'true'
|
18
|
+
|
14
19
|
steps:
|
15
20
|
- uses: actions/checkout@v2
|
21
|
+
- uses: actions/cache@v2
|
22
|
+
with:
|
23
|
+
path: vendor/bundle
|
24
|
+
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
|
25
|
+
restore-keys: |
|
26
|
+
${{ runner.os }}-gems-
|
16
27
|
- name: Install package dependencies
|
17
28
|
run: "[ -e $APT_DEPS ] || sudo apt-get install -y --no-install-recommends $APT_DEPS"
|
18
29
|
- name: Set up Ruby
|
@@ -22,10 +33,9 @@ jobs:
|
|
22
33
|
- name: Install latest bundler
|
23
34
|
run: |
|
24
35
|
gem install bundler --no-document
|
25
|
-
bundle config set without 'tools benchmarks docs'
|
26
36
|
- name: Bundle install
|
27
37
|
run: |
|
28
|
-
bundle config
|
38
|
+
bundle config path vendor/bundle
|
29
39
|
bundle install --jobs 4 --retry 3
|
30
40
|
- name: Run all tests
|
31
41
|
env:
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## [Unreleased][master]
|
4
|
+
|
5
|
+
## [0.2.24] (2020-09-08)
|
6
|
+
- better error handling of response ([#28](https://github.com/diffend-io/diffend-ruby/pull/28))
|
7
|
+
- fix jruby specs ([#29](https://github.com/diffend-io/diffend-ruby/pull/29))
|
8
|
+
- handle request server errors ([#30](https://github.com/diffend-io/diffend-ruby/pull/30))
|
9
|
+
- better detection of gem source ([#31](https://github.com/diffend-io/diffend-ruby/pull/31))
|
10
|
+
- detect if we are running outdated version of the plugin ([#32](https://github.com/diffend-io/diffend-ruby/pull/32))
|
11
|
+
|
12
|
+
## [0.2.23] (2020-09-06)
|
13
|
+
- fix how we build gem platform ([#26](https://github.com/diffend-io/diffend-ruby/pull/26))
|
14
|
+
- test against jruby, ruby-2.5 and ruby-2.6 ([#25](https://github.com/diffend-io/diffend-ruby/pull/25))
|
15
|
+
|
16
|
+
## [0.2.22] (2020-09-03)
|
17
|
+
- fix how we build host command
|
18
|
+
|
19
|
+
## [0.2.21] (2020-09-03)
|
20
|
+
- bring back support for ruby 2.5.x
|
21
|
+
|
22
|
+
## [0.2.20] (2020-09-03)
|
23
|
+
- expose host command ([#21](https://github.com/diffend-io/diffend-ruby/pull/21))
|
24
|
+
- expose host pid ([#20](https://github.com/diffend-io/diffend-ruby/pull/20))
|
25
|
+
- use `Bundler.feature_flag.default_cli_command` which is used as the default task if no command provided, instead of `Diffend::Commands::INSTALL` ([#19](https://github.com/diffend-io/diffend-ruby/pull/19))
|
26
|
+
- better error handling ([#18](https://github.com/diffend-io/diffend-ruby/pull/18))
|
27
|
+
- better detection of gem versions ([#17](https://github.com/diffend-io/diffend-ruby/pull/17))
|
28
|
+
- introduce `Diffend::BuildBundlerDefinition` ([#16](https://github.com/diffend-io/diffend-ruby/pull/16))
|
29
|
+
|
30
|
+
## [0.2.19] (2020-08-18)
|
31
|
+
|
32
|
+
- better detection of gem sources ([#13](https://github.com/diffend-io/diffend-ruby/pull/13))
|
33
|
+
|
34
|
+
## [0.2.18] (2020-08-05)
|
35
|
+
|
36
|
+
- use `Etc.getpwuid` instead of `Etc.getlogin` for fetching host user ([#11](https://github.com/diffend-io/diffend-ruby/pull/11))
|
37
|
+
|
38
|
+
## [0.2.17] (2020-08-05)
|
39
|
+
|
40
|
+
- introduce config validation ([#9](https://github.com/diffend-io/diffend-ruby/pull/9))
|
41
|
+
|
42
|
+
## [0.2.16] (2020-07-28)
|
43
|
+
|
44
|
+
- report unexpected errors ([#8](https://github.com/diffend-io/diffend-ruby/pull/8))
|
45
|
+
|
46
|
+
## 0.2.15 (2020-06-07)
|
47
|
+
|
48
|
+
- initial release
|
49
|
+
|
50
|
+
[master]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.24...HEAD
|
51
|
+
[0.2.24]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.23...v0.2.24
|
52
|
+
[0.2.23]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.22...v0.2.23
|
53
|
+
[0.2.22]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.21...v0.2.22
|
54
|
+
[0.2.21]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.20...v0.2.21
|
55
|
+
[0.2.20]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.19...v0.2.20
|
56
|
+
[0.2.19]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.18...v0.2.19
|
57
|
+
[0.2.18]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.17...v0.2.18
|
58
|
+
[0.2.17]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.16...v0.2.17
|
59
|
+
[0.2.16]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.15...v0.2.16
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,13 +1,20 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
diffend (0.2.
|
4
|
+
diffend (0.2.24)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
9
|
byebug (11.1.3)
|
10
|
+
coderay (1.1.3)
|
10
11
|
diff-lcs (1.4.4)
|
12
|
+
ffi (1.13.1-java)
|
13
|
+
method_source (1.0.0)
|
14
|
+
pry (0.13.1-java)
|
15
|
+
coderay (~> 1.1)
|
16
|
+
method_source (~> 1.0)
|
17
|
+
spoon (~> 0.0)
|
11
18
|
rake (13.0.1)
|
12
19
|
rspec (3.9.0)
|
13
20
|
rspec-core (~> 3.9.0)
|
@@ -22,14 +29,18 @@ GEM
|
|
22
29
|
diff-lcs (>= 1.2.0, < 2.0)
|
23
30
|
rspec-support (~> 3.9.0)
|
24
31
|
rspec-support (3.9.3)
|
32
|
+
spoon (0.0.6)
|
33
|
+
ffi
|
25
34
|
|
26
35
|
PLATFORMS
|
36
|
+
java
|
27
37
|
ruby
|
28
38
|
|
29
39
|
DEPENDENCIES
|
30
40
|
bundler
|
31
41
|
byebug
|
32
42
|
diffend!
|
43
|
+
pry
|
33
44
|
rake
|
34
45
|
rspec
|
35
46
|
|
data/{LICENSE → LICENSE.md}
RENAMED
File without changes
|
data/lib/diffend.rb
CHANGED
@@ -5,15 +5,21 @@
|
|
5
5
|
].each(&method(:require))
|
6
6
|
|
7
7
|
%w[
|
8
|
+
build_bundler_definition
|
9
|
+
errors
|
8
10
|
config/fetcher
|
9
11
|
config/file_finder
|
12
|
+
config/validator
|
10
13
|
commands
|
11
|
-
|
14
|
+
handle_errors/messages
|
15
|
+
handle_errors/build_exception_payload
|
16
|
+
handle_errors/display_to_stdout
|
17
|
+
handle_errors/report
|
18
|
+
request
|
12
19
|
voting
|
13
20
|
].each { |file| require "diffend/#{file}" }
|
14
21
|
|
15
22
|
%w[
|
16
|
-
request
|
17
23
|
versions/local
|
18
24
|
versions/remote
|
19
25
|
].each { |file| require "diffend/voting/#{file}" }
|
@@ -21,7 +27,7 @@
|
|
21
27
|
# Diffend main namespace
|
22
28
|
module Diffend
|
23
29
|
# Current plugin version
|
24
|
-
VERSION = '0.2.
|
30
|
+
VERSION = '0.2.24'
|
25
31
|
# Diffend homepage
|
26
32
|
HOMEPAGE = 'https://diffend.io'
|
27
33
|
|
@@ -29,35 +35,80 @@ module Diffend
|
|
29
35
|
# Registers the plugin and add before install all hook
|
30
36
|
def register
|
31
37
|
Bundler::Plugin.add_hook('before-install-all') do |_|
|
32
|
-
|
33
|
-
command,
|
34
|
-
build_definition(command)
|
35
|
-
)
|
38
|
+
execute
|
36
39
|
end
|
37
40
|
end
|
38
41
|
|
39
|
-
#
|
40
|
-
|
41
|
-
|
42
|
-
#
|
43
|
-
# @return [Bundler::Definition]
|
44
|
-
def build_definition(command)
|
45
|
-
unlock = command == 'update' ? true : nil
|
42
|
+
# Execute diffend plugin
|
43
|
+
def execute
|
44
|
+
detect_installed_version
|
46
45
|
|
47
|
-
|
46
|
+
config = fetch_config
|
48
47
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
48
|
+
Diffend::Voting.call(
|
49
|
+
command,
|
50
|
+
config,
|
51
|
+
Diffend::BuildBundlerDefinition.call(
|
52
|
+
command,
|
53
|
+
Bundler.default_gemfile,
|
54
|
+
Bundler.default_lockfile
|
55
|
+
)
|
53
56
|
)
|
57
|
+
rescue StandardError => e
|
58
|
+
Diffend::HandleErrors::Report.call(
|
59
|
+
exception: e,
|
60
|
+
config: config,
|
61
|
+
message: :unhandled_exception,
|
62
|
+
report: true
|
63
|
+
)
|
64
|
+
end
|
65
|
+
|
66
|
+
def detect_installed_version
|
67
|
+
return if installed_version == VERSION
|
68
|
+
|
69
|
+
build_outdated_version_message(installed_version)
|
70
|
+
.tap(&Bundler.ui.method(:error))
|
71
|
+
|
72
|
+
exit 1
|
73
|
+
end
|
74
|
+
|
75
|
+
# @param version [Hash] installed version
|
76
|
+
#
|
77
|
+
# @return [String]
|
78
|
+
def build_outdated_version_message(version)
|
79
|
+
<<~MSG
|
80
|
+
\nYou are running an outdated version (#{version}) of the plugin, which will lead to issues.
|
81
|
+
\nPlease upgrade to the latest one (#{VERSION}) by executing "rm -rf .bundle/plugin".\n
|
82
|
+
MSG
|
83
|
+
end
|
84
|
+
|
85
|
+
# @return [String] installed plugin version
|
86
|
+
def installed_version
|
87
|
+
Bundler::Plugin
|
88
|
+
.index
|
89
|
+
.plugin_path('diffend')
|
90
|
+
.basename
|
91
|
+
.to_s
|
92
|
+
.split('-')
|
93
|
+
.last
|
54
94
|
end
|
55
95
|
|
56
96
|
# Command that was run with bundle
|
57
97
|
#
|
58
98
|
# @return [String]
|
59
99
|
def command
|
60
|
-
ARGV.first ||
|
100
|
+
ARGV.first || Bundler.feature_flag.default_cli_command.to_s
|
101
|
+
end
|
102
|
+
|
103
|
+
# Fetch diffend config file
|
104
|
+
#
|
105
|
+
# @return [OpenStruct, nil] configuration object
|
106
|
+
#
|
107
|
+
# @raise [Errors::MissingConfigurationFile] when no config file
|
108
|
+
def fetch_config
|
109
|
+
Config::Fetcher.call(
|
110
|
+
File.expand_path('..', Bundler.bin_path)
|
111
|
+
)
|
61
112
|
end
|
62
113
|
end
|
63
114
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Diffend
|
4
|
+
# Builds bundler definition used within the plugin
|
5
|
+
module BuildBundlerDefinition
|
6
|
+
class << self
|
7
|
+
# Build clean instance of bundler definition, as we don't want to pollute the main one
|
8
|
+
#
|
9
|
+
# @param command [String] bundler command that we are executing
|
10
|
+
# @param gemfile [String] path to Gemfile
|
11
|
+
# @param lockfile [String] path to Gemfile.lock
|
12
|
+
#
|
13
|
+
# @return [Bundler::Definition]
|
14
|
+
def call(command, gemfile, lockfile)
|
15
|
+
unlock = command == 'update' ? true : nil
|
16
|
+
|
17
|
+
Bundler.configure
|
18
|
+
Bundler::Fetcher.disable_endpoint = nil
|
19
|
+
|
20
|
+
Bundler::Definition
|
21
|
+
.build(gemfile, lockfile, unlock)
|
22
|
+
.tap(&:validate_runtime!)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -7,22 +7,105 @@ module Diffend
|
|
7
7
|
module Config
|
8
8
|
# Class responsible for fetching the config from .diffend.yml
|
9
9
|
module Fetcher
|
10
|
+
# All the errors for missing keys in the configuration file
|
11
|
+
MISSING_KEY_ERRORS = [
|
12
|
+
Errors::ProjectIdMissingInConfigurationFile,
|
13
|
+
Errors::ShareableIdMissingInConfigurationFile,
|
14
|
+
Errors::ShareableKeyMissingInConfigurationFile,
|
15
|
+
Errors::BuildPathMissingInConfigurationFile
|
16
|
+
].freeze
|
17
|
+
|
10
18
|
class << self
|
11
19
|
# @param build_path [String] path of the current build
|
20
|
+
#
|
12
21
|
# @return [OpenStruct] open struct with config details
|
22
|
+
#
|
13
23
|
# @example
|
14
24
|
# details = Fetcher.new.call('./')
|
15
25
|
# details.build_path #=> './'
|
16
26
|
def call(build_path)
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
)
|
27
|
+
build(build_path)
|
28
|
+
rescue Errors::MissingConfigurationFile
|
29
|
+
Bundler.ui.error(build_missing_error_message(build_path))
|
30
|
+
exit 1
|
31
|
+
rescue Errors::EmptyConfigurationFile
|
32
|
+
Bundler.ui.error(build_empty_error_message(build_path))
|
33
|
+
exit 1
|
34
|
+
rescue Errors::MalformedConfigurationFile
|
35
|
+
Bundler.ui.error(build_malformed_error_message(build_path))
|
36
|
+
exit 1
|
37
|
+
rescue *MISSING_KEY_ERRORS => e
|
38
|
+
Bundler.ui.error(build_missing_key_error_message(e))
|
39
|
+
exit 1
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
# @param build_path [String] path of the current build
|
45
|
+
#
|
46
|
+
# @return [OpenStruct] open struct with config details
|
47
|
+
def build(build_path)
|
48
|
+
content = ERB.new(
|
49
|
+
File.read(
|
50
|
+
FileFinder.call(build_path)
|
51
|
+
)
|
52
|
+
).result
|
53
|
+
|
54
|
+
raise Errors::EmptyConfigurationFile if content.empty?
|
55
|
+
|
56
|
+
OpenStruct.new(parse_file(content).merge(build_path: build_path))
|
57
|
+
.tap(&Validator.method(:call))
|
58
|
+
end
|
59
|
+
|
60
|
+
def parse_file(content)
|
61
|
+
YAML.safe_load(content)
|
62
|
+
rescue Psych::SyntaxError
|
63
|
+
raise Errors::MalformedConfigurationFile
|
64
|
+
end
|
65
|
+
|
66
|
+
# @param build_path [String] path of the current build
|
67
|
+
#
|
68
|
+
# @return [String] missing configuration file message
|
69
|
+
def build_missing_error_message(build_path)
|
70
|
+
<<~MSG
|
71
|
+
\nWe were unable to locate Diffend configuration file.\n
|
72
|
+
Please make sure that .diffend.yml is present in #{build_path} folder.\n
|
73
|
+
MSG
|
74
|
+
end
|
75
|
+
|
76
|
+
# @return [String] empty configuration file message
|
77
|
+
def build_empty_error_message
|
78
|
+
<<~MSG
|
79
|
+
\nYour Diffend configuration file is empty.\n
|
80
|
+
Please re-setup.\n
|
81
|
+
MSG
|
82
|
+
end
|
83
|
+
|
84
|
+
# @return [String] malformed configuration file message
|
85
|
+
def build_malformed_error_message
|
86
|
+
<<~MSG
|
87
|
+
\nYour Diffend configuration file is malformed.\n
|
88
|
+
Please re-setup.\n
|
89
|
+
MSG
|
90
|
+
end
|
91
|
+
|
92
|
+
# @return [String] malformed configuration file message
|
93
|
+
def build_missing_key_error_message(exception)
|
94
|
+
missing_key = missing_key_from_exception(exception)
|
95
|
+
|
96
|
+
<<~MSG
|
97
|
+
\nYour Diffend configuration file is missing #{missing_key} key.\n
|
98
|
+
Please re-setup.\n
|
99
|
+
MSG
|
100
|
+
end
|
101
|
+
|
102
|
+
def missing_key_from_exception(exception)
|
103
|
+
case exception
|
104
|
+
when Errors::ProjectIdMissingInConfigurationFile then 'project_id'
|
105
|
+
when Errors::ShareableIdMissingInConfigurationFile then 'shareable_id'
|
106
|
+
when Errors::ShareableKeyMissingInConfigurationFile then 'shareable_key'
|
107
|
+
when Errors::BuildPathMissingInConfigurationFile then 'build_path'
|
108
|
+
end
|
26
109
|
end
|
27
110
|
end
|
28
111
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Diffend
|
4
|
+
# Module for all the components related to setting up the config
|
5
|
+
module Config
|
6
|
+
# Class responsible for validating the config from .diffend.yml
|
7
|
+
module Validator
|
8
|
+
class << self
|
9
|
+
# @param config [OpenStruct] path of the current build
|
10
|
+
def call(config)
|
11
|
+
raise Errors::ProjectIdMissingInConfigurationFile if missing?(config, 'project_id')
|
12
|
+
raise Errors::ShareableIdMissingInConfigurationFile if missing?(config, 'shareable_id')
|
13
|
+
raise Errors::ShareableKeyMissingInConfigurationFile if missing?(config, 'shareable_key')
|
14
|
+
raise Errors::BuildPathMissingInConfigurationFile if missing?(config, 'build_path')
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def missing?(config, key)
|
20
|
+
config.public_send(key).nil? || config.public_send(key).empty?
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|