Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ on:

jobs:
call-workflow-from-shared-config:
permissions:
contents: write
uses: rubyatscale/shared-config/.github/workflows/cd.yml@main
secrets: inherit

3 changes: 3 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ on:
- cron: '0 0 * * *'
jobs:
call-workflow-from-shared-config:
permissions:
issues: write
pull-requests: write
uses: rubyatscale/shared-config/.github/workflows/stale.yml@main
2 changes: 2 additions & 0 deletions .github/workflows/triage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ on:
- opened
jobs:
call-workflow-from-shared-config:
permissions:
issues: write
uses: rubyatscale/shared-config/.github/workflows/triage.yml@main
12 changes: 6 additions & 6 deletions lib/packs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,27 @@ def self.start_interactive_mode!
sig { returns(T::Boolean) }
def self.update
if Packs.config.use_pks
Private.system_with('bin/pks update')
Private.system_with(['bin/pks', 'update'])
else
Private.system_with('bin/packwerk update-todo')
Private.system_with(['bin/packwerk', 'update-todo'])
end
end

sig { returns(T::Boolean) }
def self.validate
if Packs.config.use_pks
Private.system_with('bin/pks validate')
Private.system_with(['bin/pks', 'validate'])
else
Private.system_with('bin/packwerk validate')
Private.system_with(['bin/packwerk', 'validate'])
end
end

sig { params(files: T::Array[String]).returns(T::Boolean) }
def self.check(files)
if Packs.config.use_pks
Private.system_with("bin/pks check #{files.join(' ')}")
Private.system_with(['bin/pks', 'check', *files])
else
Private.system_with("bin/packwerk check #{files.join(' ')}")
Private.system_with(['bin/packwerk', 'check', *files])
end
end

Expand Down
10 changes: 6 additions & 4 deletions lib/packs/private.rb
Original file line number Diff line number Diff line change
Expand Up @@ -783,10 +783,12 @@ def self.exit_with(code)
exit code
end

# This function exists to give us something to stub in test
sig { params(command: String).returns(T::Boolean) }
def self.system_with(command)
T.cast(system(command), T::Boolean)
# This function exists to give us something to stub in test.
# Each argv entry is passed to `system` as a separate argument, so the
# command is executed directly and never interpreted by a shell.
sig { params(argv: T::Array[String]).returns(T::Boolean) }
def self.system_with(argv)
T.cast(T.unsafe(Kernel).system(*argv), T::Boolean)
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/packs/private/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def expect_failure
it 'exits successfully' do
expect_success
expect(Packs.const_get(:Private)).to receive(:system_with).with(
'bin/packwerk validate'
['bin/packwerk', 'validate']
).and_return(true)
described_class.start(['validate'])
end
Expand All @@ -102,7 +102,7 @@ def expect_failure
it 'exits unsuccessfully' do
expect_failure
expect(Packs.const_get(:Private)).to receive(:system_with).with(
'bin/packwerk validate'
['bin/packwerk', 'validate']
).and_return(false)
described_class.start(['validate'])
end
Expand Down