Skip to content

Commit 19a51b3

Browse files
nganclaude
andauthored
Lazy load package.yml and improve inspect output (#25)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 71336be commit 19a51b3

8 files changed

Lines changed: 259 additions & 87 deletions

File tree

.github/workflows/ci.yml

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,48 @@ on:
77
pull_request:
88

99
jobs:
10-
call-workflow-from-shared-config:
11-
uses: rubyatscale/shared-config/.github/workflows/ci.yml@main
12-
secrets: inherit
10+
rspec:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
ruby:
16+
- 3.2
17+
- 3.3
18+
- 3.4
19+
- 4.0
20+
name: "RSpec tests: Ruby ${{ matrix.ruby }}"
21+
steps:
22+
- uses: actions/checkout@v6
23+
- name: Set up Ruby ${{ matrix.ruby }}
24+
uses: ruby/setup-ruby@v1
25+
with:
26+
bundler-cache: true
27+
ruby-version: ${{ matrix.ruby }}
28+
- name: Run tests
29+
run: bundle exec rspec
30+
static_type_check:
31+
name: "Type Check"
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/checkout@v6
35+
- name: Set up Ruby
36+
uses: ruby/setup-ruby@v1
37+
with:
38+
bundler-cache: true
39+
ruby-version: 3.3
40+
- name: Run static type checks
41+
run: bundle exec srb tc
42+
notify_on_failure:
43+
runs-on: ubuntu-latest
44+
needs: [rspec, static_type_check]
45+
if: ${{ failure() && github.ref == 'refs/heads/main' }}
46+
steps:
47+
- uses: slackapi/slack-github-action@v2.1.0
48+
with:
49+
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
50+
webhook-type: incoming-webhook
51+
payload: |
52+
{
53+
"text": "${{ github.repository }}/${{ github.ref }}: FAILED\n${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
54+
}

Gemfile.lock

Lines changed: 101 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,137 @@
11
PATH
22
remote: .
33
specs:
4-
packs-specification (0.0.10)
4+
packs-specification (0.0.11)
55
sorbet-runtime
66

77
GEM
88
remote: https://rubygems.org/
99
specs:
10-
ast (2.4.2)
11-
coderay (1.1.3)
12-
diff-lcs (1.5.0)
13-
json (2.7.2)
14-
language_server-protocol (3.17.0.3)
15-
method_source (1.0.0)
10+
ast (2.4.3)
11+
benchmark (0.5.0)
12+
date (3.5.1)
13+
debug (1.11.1)
14+
irb (~> 1.10)
15+
reline (>= 0.3.8)
16+
diff-lcs (1.6.2)
17+
erb (6.0.1)
18+
erubi (1.13.1)
19+
io-console (0.8.2)
20+
irb (1.16.0)
21+
pp (>= 0.6.0)
22+
rdoc (>= 4.0.0)
23+
reline (>= 0.4.2)
24+
json (2.18.1)
25+
language_server-protocol (3.17.0.5)
26+
lint_roller (1.1.0)
27+
logger (1.7.0)
1628
netrc (0.11.0)
17-
parallel (1.24.0)
18-
parser (3.3.1.0)
29+
parallel (1.27.0)
30+
parser (3.3.10.1)
1931
ast (~> 2.4.1)
2032
racc
21-
pry (0.14.1)
22-
coderay (~> 1.1)
23-
method_source (~> 1.0)
24-
racc (1.7.3)
33+
pp (0.6.3)
34+
prettyprint
35+
prettyprint (0.2.0)
36+
prism (1.9.0)
37+
psych (5.3.1)
38+
date
39+
stringio
40+
racc (1.8.1)
2541
rainbow (3.1.1)
26-
rake (13.0.6)
27-
rbi (0.0.16)
28-
ast
29-
parser (>= 2.6.4.0)
30-
sorbet-runtime (>= 0.5.9204)
31-
unparser
32-
regexp_parser (2.9.1)
33-
rexml (3.2.6)
34-
rspec (3.11.0)
35-
rspec-core (~> 3.11.0)
36-
rspec-expectations (~> 3.11.0)
37-
rspec-mocks (~> 3.11.0)
38-
rspec-core (3.11.0)
39-
rspec-support (~> 3.11.0)
40-
rspec-expectations (3.11.1)
42+
rake (13.3.1)
43+
rbi (0.3.9)
44+
prism (~> 1.0)
45+
rbs (>= 3.4.4)
46+
rbs (4.0.0.dev.5)
47+
logger
48+
prism (>= 1.3.0)
49+
tsort
50+
rdoc (7.1.0)
51+
erb
52+
psych (>= 4.0.0)
53+
tsort
54+
regexp_parser (2.11.3)
55+
reline (0.6.3)
56+
io-console (~> 0.5)
57+
require-hooks (0.2.3)
58+
rexml (3.4.4)
59+
rspec (3.13.2)
60+
rspec-core (~> 3.13.0)
61+
rspec-expectations (~> 3.13.0)
62+
rspec-mocks (~> 3.13.0)
63+
rspec-core (3.13.6)
64+
rspec-support (~> 3.13.0)
65+
rspec-expectations (3.13.5)
4166
diff-lcs (>= 1.2.0, < 2.0)
42-
rspec-support (~> 3.11.0)
43-
rspec-mocks (3.11.1)
67+
rspec-support (~> 3.13.0)
68+
rspec-mocks (3.13.7)
4469
diff-lcs (>= 1.2.0, < 2.0)
45-
rspec-support (~> 3.11.0)
46-
rspec-support (3.11.1)
47-
rubocop (1.63.5)
70+
rspec-support (~> 3.13.0)
71+
rspec-support (3.13.7)
72+
rubocop (1.84.1)
4873
json (~> 2.3)
49-
language_server-protocol (>= 3.17.0)
74+
language_server-protocol (~> 3.17.0.2)
75+
lint_roller (~> 1.1.0)
5076
parallel (~> 1.10)
5177
parser (>= 3.3.0.2)
5278
rainbow (>= 2.2.2, < 4.0)
53-
regexp_parser (>= 1.8, < 3.0)
54-
rexml (>= 3.2.5, < 4.0)
55-
rubocop-ast (>= 1.31.1, < 2.0)
79+
regexp_parser (>= 2.9.3, < 3.0)
80+
rubocop-ast (>= 1.49.0, < 2.0)
5681
ruby-progressbar (~> 1.7)
57-
unicode-display_width (>= 2.4.0, < 3.0)
58-
rubocop-ast (1.31.3)
59-
parser (>= 3.3.1.0)
82+
unicode-display_width (>= 2.4.0, < 4.0)
83+
rubocop-ast (1.49.0)
84+
parser (>= 3.3.7.2)
85+
prism (~> 1.7)
6086
ruby-progressbar (1.13.0)
61-
sorbet (0.5.11370)
62-
sorbet-static (= 0.5.11370)
63-
sorbet-runtime (0.5.11370)
64-
sorbet-static (0.5.11370-universal-darwin)
65-
sorbet-static (0.5.11370-x86_64-linux)
66-
sorbet-static-and-runtime (0.5.11370)
67-
sorbet (= 0.5.11370)
68-
sorbet-runtime (= 0.5.11370)
69-
spoom (1.1.12)
70-
sorbet (>= 0.5.9204)
71-
sorbet-runtime (>= 0.5.9204)
87+
sorbet (0.6.12913)
88+
sorbet-static (= 0.6.12913)
89+
sorbet-runtime (0.6.12913)
90+
sorbet-static (0.6.12913-universal-darwin)
91+
sorbet-static (0.6.12913-x86_64-linux)
92+
sorbet-static-and-runtime (0.6.12913)
93+
sorbet (= 0.6.12913)
94+
sorbet-runtime (= 0.6.12913)
95+
spoom (1.7.11)
96+
erubi (>= 1.10.0)
97+
prism (>= 0.28.0)
98+
rbi (>= 0.3.3)
99+
rbs (>= 4.0.0.dev.4)
100+
rexml (>= 3.2.6)
101+
sorbet-static-and-runtime (>= 0.5.10187)
72102
thor (>= 0.19.2)
73-
tapioca (0.10.2)
74-
bundler (>= 1.17.3)
103+
stringio (3.2.0)
104+
tapioca (0.17.10)
105+
benchmark
106+
bundler (>= 2.2.25)
75107
netrc (>= 0.11.0)
76108
parallel (>= 1.21.0)
77-
pry (>= 0.12.2)
78-
rbi (~> 0.0.0, >= 0.0.14)
79-
sorbet-static-and-runtime (>= 0.5.9204)
80-
spoom (~> 1.1.0, >= 1.1.11)
109+
rbi (>= 0.3.7)
110+
require-hooks (>= 0.2.2)
111+
sorbet-static-and-runtime (>= 0.5.11087)
112+
spoom (>= 1.7.9)
81113
thor (>= 1.2.0)
82114
yard-sorbet
83-
thor (1.2.1)
84-
unicode-display_width (2.5.0)
85-
unparser (0.6.5)
86-
diff-lcs (~> 1.3)
87-
parser (>= 3.1.0)
88-
webrick (1.7.0)
89-
yard (0.9.28)
90-
webrick (~> 1.7.0)
91-
yard-sorbet (0.7.0)
92-
sorbet-runtime (>= 0.5)
93-
yard (>= 0.9)
115+
thor (1.5.0)
116+
tsort (0.2.0)
117+
unicode-display_width (3.2.0)
118+
unicode-emoji (~> 4.1)
119+
unicode-emoji (4.2.0)
120+
yard (0.9.38)
121+
yard-sorbet (0.9.0)
122+
sorbet-runtime
123+
yard
94124

95125
PLATFORMS
96126
universal-darwin
97127
x86_64-linux
98128

99129
DEPENDENCIES
100-
bundler (~> 2.2.16)
130+
bundler
131+
debug
101132
packs-specification!
102133
rake
103-
rspec (~> 3.0)
134+
rspec
104135
rubocop
105136
sorbet
106137
tapioca

bin/console

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
require 'bundler/setup'
5+
require 'packs-specification'
6+
require 'irb'
7+
8+
IRB.start(__FILE__)

lib/packs/pack.rb

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,45 @@
11
# typed: strict
22

33
module Packs
4-
class Pack < T::Struct
4+
class Pack
55
extend T::Sig
66

7-
const :name, String
8-
const :path, Pathname
9-
const :relative_path, Pathname
10-
const :raw_hash, T::Hash[T.untyped, T.untyped]
7+
sig { returns(String) }
8+
attr_reader :name
9+
10+
sig { returns(Pathname) }
11+
attr_reader :path
12+
13+
sig { returns(Pathname) }
14+
attr_reader :relative_path
15+
16+
sig { params(name: String, path: Pathname, relative_path: Pathname).void }
17+
def initialize(name:, path:, relative_path:)
18+
@name = name
19+
@path = path
20+
@relative_path = relative_path
21+
@raw_hash = T.let(nil, T.nilable(T::Hash[T.untyped, T.untyped]))
22+
@is_gem = T.let(nil, T.nilable(T::Boolean))
23+
end
1124

1225
sig { params(package_yml_absolute_path: Pathname).returns(Pack) }
1326
def self.from(package_yml_absolute_path)
14-
package_loaded_yml = YAML.load_file(package_yml_absolute_path)
1527
path = package_yml_absolute_path.dirname
1628
relative_path = path.relative_path_from(Specification.root)
1729
package_name = relative_path.cleanpath.to_s
1830

1931
Pack.new(
2032
name: package_name,
2133
path: path,
22-
relative_path: relative_path,
23-
raw_hash: package_loaded_yml || {}
34+
relative_path: relative_path
2435
)
2536
end
2637

38+
sig { returns(T::Hash[T.untyped, T.untyped]) }
39+
def raw_hash
40+
@raw_hash ||= YAML.load_file(yml(relative: false)) || {}
41+
end
42+
2743
sig { params(relative: T::Boolean).returns(Pathname) }
2844
def yml(relative: true)
2945
path_to_use = relative ? relative_path : path
@@ -37,12 +53,25 @@ def last_name
3753

3854
sig { returns(T::Boolean) }
3955
def is_gem? # rubocop:disable Naming/PredicateName
40-
@is_gem ||= T.let(relative_path.glob('*.gemspec').any?, T.nilable(T::Boolean))
56+
@is_gem ||= relative_path.glob('*.gemspec').any?
4157
end
4258

4359
sig { returns(T::Hash[T.untyped, T.untyped]) }
4460
def metadata
4561
raw_hash['metadata'] || {}
4662
end
63+
64+
sig { returns(T::Array[Symbol]) }
65+
private def instance_variables_to_inspect = [:@name]
66+
67+
if RUBY_VERSION < '4'
68+
sig { returns(String) }
69+
def inspect
70+
ivars = instance_variables_to_inspect.map do |ivar|
71+
"#{ivar}=#{instance_variable_get(ivar).inspect}"
72+
end.join(', ')
73+
"#<#{self.class.name}:0x#{object_id.to_s(16)} #{ivars}>"
74+
end
75+
end
4776
end
4877
end

lib/packs/rspec/support.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require 'fileutils'
2+
require 'tmpdir'
13
require_relative 'fixture_helper'
24

35
RSpec.configure do |config|

packs-specification.gemspec

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Gem::Specification.new do |spec|
22
spec.name = 'packs-specification'
3-
spec.version = '0.0.10'
3+
spec.version = '0.0.11'
44
spec.authors = ['Gusto Engineers']
55
spec.email = ['dev@gusto.com']
66
spec.summary = 'The specification for packs in the `rubyatscale` ecosystem.'
@@ -21,13 +21,14 @@ Gem::Specification.new do |spec|
2121
# Specify which files should be added to the gem when it is released.
2222
spec.files = Dir['README.md', 'lib/**/*']
2323
spec.require_paths = ['lib']
24-
spec.required_ruby_version = '>= 2.6'
24+
spec.required_ruby_version = '>= 3.1'
2525

2626
spec.add_dependency 'sorbet-runtime'
2727

28-
spec.add_development_dependency 'bundler', '~> 2.2.16'
28+
spec.add_development_dependency 'bundler'
29+
spec.add_development_dependency 'debug'
2930
spec.add_development_dependency 'rake'
30-
spec.add_development_dependency 'rspec', '~> 3.0'
31+
spec.add_development_dependency 'rspec'
3132
spec.add_development_dependency 'rubocop'
3233
spec.add_development_dependency 'sorbet'
3334
spec.add_development_dependency 'tapioca'

0 commit comments

Comments
 (0)