build-labels 0.0.56 → 0.0.58

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 61e09a2b53199061c138de8b452d78860107b7037ed5284aeeb8e6b68a966045
4
- data.tar.gz: 54cd7756c9c2c8a24e6ca5fe42bd3589e49f27f880f88d772df32960e52870db
3
+ metadata.gz: 7973e798f3fbfa85ef2d3bb84e6110779ac279e0671f4cf3e000ad0f41105ade
4
+ data.tar.gz: e2d553de020f7b92a65fbae6f94b37e21a1ee4c251552d8aa5d801bea15a11cf
5
5
  SHA512:
6
- metadata.gz: e97c613ad8936018139783235bc53fcf8b033670b308db16bf6b01e20d465f4b7d6ba002856e833037345d206863ea32c0b19ce69f7e7937f1bbf7acc2223dff
7
- data.tar.gz: 90be90e2f86b228d1e9053e8d3c46530add74768d3bbd9e7a605e7f29b0790830efe696e9451badcfa49eb550c368ad8a7c91b578eb7e9d58966b3f3cd3f3274
6
+ metadata.gz: b0ff6cabbd9b18af1e97dadb598f647e3a43fa8a66d8072ae9254124ebd304d53e0b4a22cfef899e63d73a0a9782c23fc998a7d3f80e6dea078d5792bff1f9e7
7
+ data.tar.gz: 356aa7f3d31672441e6af9b6cd79d856db435c9554d6458c4ded05b17b77f2aa177fddfe8f59cbaf692f538171bf4093a31e87f53bc4a2bf1e9bd3453e6d26e6
data/bin/build-labels CHANGED
@@ -12,6 +12,7 @@ require 'build-labels/command_github'
12
12
  require 'build-labels/command_cache'
13
13
  require 'build-labels/command_print'
14
14
  require 'build-labels/command_set_version'
15
+ require 'build-labels/command_changed'
15
16
 
16
17
  include BuildLabels
17
18
 
@@ -0,0 +1,49 @@
1
+ require_relative 'command_line'
2
+
3
+ BuildLabels::CommandLine::COMMANDS[:changed] = Class.new do
4
+ def options(parser)
5
+ parser.on('', '--changes-compose FOLDER', 'docker-compose path ... ')
6
+ end
7
+
8
+ def run(builder, params, compose)
9
+ dc_folder = params[:'changes-compose'] || __dir__
10
+ ch_folder = params[:'changes-git'] || __dir__
11
+ $stderr.puts "Changes Compose: #{ch_folder}, Changes Git: #{ch_folder}, CI_COMMIT_BEFORE_SHA: #{ENV['CI_COMMIT_BEFORE_SHA']}, CI_COMMIT_SHA: #{ENV['CI_COMMIT_SHA']}"
12
+
13
+ compose['services'].each do |service_name, service|
14
+ next unless service['build']
15
+ $stderr.puts "Checking #{service_name} for changes ..."
16
+
17
+ ad = service.dig('build','additional_contexts') || []
18
+ ad = ad.class == Hash ? ad.values : ad.map{_1[/=(.*)/,1]}
19
+ contexts = [service.dig('build','context')] + ad
20
+ contexts = contexts.flatten.compact.map{File::absolute_path(dc_folder + '/' + _1) + '/' }
21
+ contexts << File::absolute_path(service.dig('build','dockerfile'))
22
+
23
+
24
+ should_build = contexts.any? do |path|
25
+ $stderr.puts "Checking #{path} for changes..."
26
+ Dir.chdir path do
27
+ files = `git diff --name-only $CI_COMMIT_BEFORE_SHA $CI_COMMIT_SHA`.split("\n").map(&:strip).delete_if(:empty?)
28
+
29
+ if files.any?
30
+ $stderr.puts "changes found:"
31
+ files[0..3].each{ $stderr.puts "\t#{_1}" }
32
+ next true
33
+ else
34
+ false
35
+ end
36
+ end
37
+ end
38
+
39
+ $stderr.puts "should_build: #{should_build}"
40
+
41
+ service.delete 'build' unless should_build
42
+ end
43
+
44
+ end
45
+
46
+ def help = 'Detect git changes and filter compose service list'
47
+ end.new
48
+
49
+
data/lib/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module BuildLabels
2
2
  class Builder
3
- VERSION = '0.0.56'
3
+ VERSION = '0.0.58'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: build-labels
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.56
4
+ version: 0.0.58
5
5
  platform: ruby
6
6
  authors:
7
7
  - Artyom B
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-04-01 00:00:00.000000000 Z
11
+ date: 2025-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -110,6 +110,7 @@ files:
110
110
  - lib/build-labels.rb
111
111
  - lib/build-labels/builder.rb
112
112
  - lib/build-labels/command_cache.rb
113
+ - lib/build-labels/command_changed.rb
113
114
  - lib/build-labels/command_github.rb
114
115
  - lib/build-labels/command_gitlab.rb
115
116
  - lib/build-labels/command_line.rb