Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rspec-github integration #353

Merged
merged 1 commit into from
Oct 24, 2022
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
4 changes: 4 additions & 0 deletions lib/puppetlabs_spec_helper/module_spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ def verify_contents(subject, title, expected_lines)
end

RSpec.configure do |c|
if ENV['GITHUB_ACTIONS'] == 'true'
c.formatter = 'RSpec::Github::Formatter'
end

c.environmentpath = spec_path if Puppet.version.to_f >= 4.0
c.module_path = module_path
c.manifest_dir = File.join(fixture_path, 'manifests')
Expand Down
1 change: 1 addition & 0 deletions puppetlabs_spec_helper.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency 'pathspec', '~> 1.0'
spec.add_runtime_dependency 'puppet-lint', '~> 3.0'
spec.add_runtime_dependency 'puppet-syntax', '~> 3.0'
spec.add_runtime_dependency 'rspec-github', '~> 2.0'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As an alternative to making it a hard dependency, it can also be made a soft dependency:

RSpec.configure do |c|
  if ENV['GITHUB_ACTIONS'] == 'true'
    begin
      c.formatter = 'RSpec::Github::Formatter'
    rescue LoadError
      # rspec-github not present
    end
  end

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it really matter if it is a hard dep? As long as there is a flag to turn it off for other CI systems, I don't see the gem being pulled as much of a problem.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it isn't a hard dep, that would mean that rspec-github would have to be manually added to (literally) 100s of repos.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it really matter if it is a hard dep? As long as there is a flag to turn it off for other CI systems, I don't see the gem being pulled as much of a problem.

Every additional gem is a potential problem. Just wanted to highlight it.

If it isn't a hard dep, that would mean that rspec-github would have to be manually added to (literally) 100s of repos.

That was also my consideration. This looked easier for the average case.

spec.add_runtime_dependency 'rspec-puppet', '~> 2.0'
end