kennel 1.161.0 → 1.163.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 856d925b4aeee8af7171cb092b746c70c8e21cfa06a1987910a25ef193e79a50
4
- data.tar.gz: c174845463912362beba00a86f63d11316ec54f0a57459e4c6cd32e0d1d358d4
3
+ metadata.gz: 0b07d4f21ef18f6f89875f4bdb1f4ba86144d4291180ffeff34ef6c8c8b6ad01
4
+ data.tar.gz: e90f0c27577b343baf745b342b6eea95053b029a788bdaf740c9a1e717da0303
5
5
  SHA512:
6
- metadata.gz: 328b385c98c37473d65799e1721da32f9a8ff4d4d238be42a37196aea6e880d5ce1ae76dfb5ec8ffd4e6f60c70c99af070566b09c3fa4c34032d431b4e2a6189
7
- data.tar.gz: f74557a8ff3fe9ee436034774ed1fe5c5176e9919114e48241f08f3ffbc3950b2a32d25574d9d99c1a3c6470d3381d2880b356a7a54cc2795c2f13b4843980af
6
+ metadata.gz: 4aa14e50c3b4c17690de793c84889e0a92fa48c6d59b491226cc487de75922ec98300cdaded30781ac22f1845c14a834aa9fec0bffe2b31d72fc4726a7948d95
7
+ data.tar.gz: 95b2a1d28f5f98703c7ba448cf865009e9d53989bb7aec3492adddde172f032ebdae447688615e29a1d47055f785a50ee8ea9fe7278ab7c88436b5e418529c7e
data/lib/kennel/filter.rb CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  module Kennel
4
4
  class Filter
5
+ attr_reader :project_filter
6
+
5
7
  def initialize
6
8
  # read early so we fail fast on invalid user input
7
9
  @tracking_id_filter = read_tracking_id_filter_from_env
@@ -39,7 +41,7 @@ module Kennel
39
41
 
40
42
  private
41
43
 
42
- attr_reader :project_filter, :tracking_id_filter
44
+ attr_reader :tracking_id_filter
43
45
 
44
46
  # needs to be called after read_tracking_id_filter_from_env
45
47
  def read_project_filter_from_env
@@ -1,6 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
  module Kennel
3
3
  class ProjectsProvider
4
+ class AutoloadFailed < StandardError
5
+ end
6
+
7
+ def initialize(filter:)
8
+ @filter = filter
9
+ end
10
+
11
+ # @return [Array<Models::Project>]
12
+ # All projects in the system. This is a slow operation.
13
+ # Use `projects` to get all projects in the system.
14
+ def all_projects
15
+ load_all
16
+ Models::Project.recursive_subclasses.map(&:new)
17
+ end
18
+
19
+ # @return [Array<Models::Project>]
20
+ # All projects in the system. This is a slow operation.
21
+
4
22
  def projects
5
23
  load_all
6
24
  Models::Project.recursive_subclasses.map(&:new)
@@ -21,37 +39,38 @@ module Kennel
21
39
  Dir.exist?("teams") && loader.push_dir("teams", namespace: Teams)
22
40
  Dir.exist?("parts") && loader.push_dir("parts")
23
41
 
24
- # TODO: verify this works by running generate and also running generate for each possible PROJECT
25
- # in isolation, then remove AUTOLOAD_PROJECTS
26
- if ENV["AUTOLOAD_PROJECTS"]
42
+ if (autoload = ENV["AUTOLOAD_PROJECTS"]) && autoload != "false"
27
43
  loader.push_dir("projects")
28
44
  loader.setup
29
45
 
30
- if (project = ENV["PROJECT"]) # TODO: use project filter instead and also support TRACKING_ID
31
- # we support PROJECT being used for nested folders, to allow teams to easily group their projects
32
- # so when loading a project we need to find anything that could be a project source
33
- # sorting by name and nesting level to avoid confusion
34
- segments = project.split("_")
35
- search = /#{segments[0...-1].map { |p| "#{p}[_/]" }.join}#{segments[-1]}(\.rb|\/project\.rb)/
36
-
46
+ if (projects = @filter.project_filter)
37
47
  projects_path = "#{File.expand_path("projects")}/"
38
- known_paths = loader.all_expected_cpaths.keys
39
- project_path = known_paths.select do |path|
40
- path.start_with?(projects_path) && path.match?(search)
41
- end.sort.min_by { |p| p.count("/") }
42
- if project_path
43
- require project_path
44
- else
45
- Kennel.err.puts(
46
- "No projects/ file matching #{search} found" \
47
- ", falling back to slow loading of all projects instead"
48
- )
49
- loader.eager_load
48
+ known_paths = loader.all_expected_cpaths.keys.select! { |path| path.start_with?(projects_path) }
49
+
50
+ # - we support PROJECT being used for nested folders, to allow teams to easily group their projects
51
+ # - when loading a project we need to find anything that could be a project source
52
+ # sorting by name and nesting level to avoid confusion
53
+ projects.each do |project|
54
+ segments = project.tr("-", "_").split("_")
55
+ search = /#{segments[0...-1].map { |part| "#{part}[_/]" }.join}#{segments[-1]}(\.rb|\/project\.rb|\/base\.rb)/
56
+
57
+ if (project_path = known_paths.grep(search).sort.min_by { |path| path.count("/") })
58
+ require project_path
59
+ elsif autoload != "abort"
60
+ Kennel.err.puts(
61
+ "No projects/ file matching #{search} found" \
62
+ ", falling back to slow loading of all projects instead"
63
+ )
64
+ loader.eager_load
65
+ break
66
+ else
67
+ raise AutoloadFailed, "No projects/ file matching #{search} found"
68
+ end
50
69
  end
51
- else
70
+ else # all projects needed
52
71
  loader.eager_load
53
72
  end
54
- else
73
+ else # old style without autoload to be removed eventually
55
74
  loader.setup
56
75
  loader.eager_load # TODO: this should not be needed but we see hanging CI processes when it's not added
57
76
  # TODO: also auto-load projects and update expected path too
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Kennel
3
- VERSION = "1.161.0"
3
+ VERSION = "1.163.0"
4
4
  end
data/lib/kennel.rb CHANGED
@@ -107,7 +107,7 @@ module Kennel
107
107
  def generated(**kwargs)
108
108
  @generated ||= begin
109
109
  projects = Progress.progress "Loading projects", **kwargs do
110
- projects = ProjectsProvider.new.projects
110
+ projects = ProjectsProvider.new(filter: filter).projects
111
111
  filter.filter_projects projects
112
112
  end
113
113
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kennel
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.161.0
4
+ version: 1.163.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-04-26 00:00:00.000000000 Z
11
+ date: 2025-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: diff-lcs