-
Notifications
You must be signed in to change notification settings - Fork 294
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
Fixes #37095 - Use shared GitHub workflow to run tests #10780
Conversation
c001702
to
f41459b
Compare
Looks like RuboCop isn't in the dependencies. I assume previously it ran from the Foreman codebase. On the DB side we're missing the EVR extension. |
f41459b
to
cd71d49
Compare
488c9d1
to
69f198e
Compare
katello.gemspec
Outdated
gem.add_dependency "simplecov" | ||
gem.add_dependency "simplecov-rcov" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a terrible hack, and I wonder how to "correctly" fix this.
add_development_dependency
adds things to the development
group of Bundler, but we do not install this group as we only want to run tests. There is no add_test_dependency
.
I see three possible solutions, and not quite sure which one I like most:
- install
development
group (and pull in all those really dev-only deps of foreman, meh) - set
development_group
to something else (like${plugin}_dev
) when including the plugin in our actions, this would install all plugin dev deps as the new group is not excluded - provide a
gemfile.d/test.rb
that clearly defines the test deps in thetest
group.
I think 3 is the cleanest, but will also require the most changes (to every plugin that needs to define test deps)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 is what Jenkins does today, btw:
https://github.com/theforeman/jenkins-jobs/blob/6dd3bfe1fa010ecbb4750d9e909246a148c410fb/theforeman.org/pipelines/lib/foreman.groovy#L7
de136b5
to
74b48d8
Compare
@@ -1,3 +1,7 @@ | |||
source 'https://rubygems.org' | |||
|
|||
gemspec | |||
|
|||
Dir[File.join(__dir__, 'gemfile.d', '*.rb')].each do |bundle| | |||
eval_gemfile(bundle) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a shame dependabot doesn't understand this, where it did understand the previous format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in this very particular case, we could just write eval_gemfile('gemfile.d/test.rb')
and Dependabot would work, but otherwise I agree.
74b48d8
to
a32f1d9
Compare
24f1b2c
to
8c6adec
Compare
@@ -0,0 +1,7 @@ | |||
group :test do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why move these into this group in a Gemfile rather than keep them where they are?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Today, they are defined as development dependencies, but we do not install the "development" group in CI as that would be silly (we don't need pry and friends from https://github.com/theforeman/foreman/blob/develop/bundler.d/development.rb).
By moving them to a bundler.d file, we can define them as a group (you can't do that in the gemspec) and install cleanly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More in my old comment at #10780 (review)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree and disagree. These testing frameworks are, I would argue, part of development. We shouldn't divorce testing from development.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But are we divorcing?
bundle install
still installs them by default, we just can avoid pure dev deps (pry) by using "without development" config if we want to (in CI).
And this follows the same pattern we have in core.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically development dependencies in a gemspe end up in a bundler group called development. This just further split it.
It should be noted you can no longer load them via gemspec in a bundler file. Perhaps that's something that will show up in gems that depend on katello and want to use its tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've opened theforeman/jenkins-jobs#410 to at least fix Jenkins support for this setup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ehelms do the recent change to move all devel-like deps to gemfile.d/test.rb
satisfy your need for "consistency"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I sense snark in the force. And yes it does. Thank you.
db/migrate/20160404132250_remove_katello_from_notification_name.rb
Outdated
Show resolved
Hide resolved
94f345d
to
c37ba65
Compare
When a redmine gets created for this, mind linking this redmine to the new one? https://projects.theforeman.org/issues/36998 |
c37ba65
to
97fc34d
Compare
97fc34d
to
4e80072
Compare
FWIW, #10852, #10853 and #10854 are not explicitly required for the shared action work. They are a path forward to make Katello installable ontop of an existing Foreman, which is e.g. required to test that plugins that require Katello are installable after the fact, but today we just disable this part via |
5dc9513
to
35acc4b
Compare
katello.gemspec
Outdated
@@ -64,18 +64,4 @@ Gem::Specification.new do |gem| | |||
# UI | |||
gem.add_dependency "deface", '>= 1.0.2', '< 2.0.0' | |||
gem.add_dependency "angular-rails-templates", "~> 1.1.0" | |||
gem.add_development_dependency "uglifier" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
822f3e5
to
be5139a
Compare
This is now 🍏 and ready! |
be5139a
to
f18f27b
Compare
katello.gemspec
Outdated
gem.add_development_dependency "factory_bot_rails", "~> 4.5" | ||
gem.add_development_dependency "mocha" | ||
gem.add_development_dependency "vcr", "< 4.0.0" | ||
gem.add_development_dependency "webmock" | ||
gem.add_development_dependency "robottelo_reporter" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've dropped factory_bot_rails
, moch
, webmock
and robottelo_reporter
as they are all in https://github.com/theforeman/foreman/blob/develop/bundler.d/test.rb
Only vcr
is Katello-specific in that list.
uses: theforeman/actions/.github/workflows/foreman_plugin.yml@v0 | ||
with: | ||
plugin: katello | ||
postgresql_container: ghcr.io/theforeman/postgresql-evr | ||
test_existing_database: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing to consider for branching. When Katello gets branched, you'll have to add a foreman_version: X.Y-stable
here, as this is what's driving which Foreman branch is used for testing, and you want them to match ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can that be handled somehow centrally through some mapping or matrix file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no such thing today (which of course doesn't mean we can't invent it…)
Today, this mapping lives in https://github.com/theforeman/jenkins-jobs/blob/master/theforeman.org/pipelines/test/testKatello.groovy#L1 and needs to be edited by whoever does the branching. So it's not a workflow change as such.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wbclark @qcjames53 assuming this merges as-is, we'll need a new branching step to update the foreman_version
in this ruby.yml
file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think to make it more explicit, we could go and set foreman_version: develop
today, so it can become s/develop/3.9-stable/
instead of adding a new line?
f18f27b
to
d4c9455
Compare
Also drop some unused dependencies
d4c9455
to
5cf67ba
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this require a matching Foreman PR to work? I'm hitting issues loading vcr
now when running tests locally:
vagrant@centos8-katello-devel-stable ~/katello $ ktest test/services/katello/pulp3/rpm_test.rb
/home/vagrant/foreman/.vendor/ruby/2.7.0/gems/activerecord-6.1.7.6/lib/active_record/connection_adapters/postgresql_adapter.rb:883: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/home/vagrant/foreman/.vendor/ruby/2.7.0/gems/pg-1.5.4/lib/pg/text_decoder/timestamp.rb:8: warning: The called method `initialize' is defined here
Emptying /home/vagrant/foreman/jenkins/reports/unit
-- execute("SET CONSTRAINTS ALL DEFERRED;")
WARNING: SET CONSTRAINTS can only be used in transaction blocks
-> 0.0003s
Traceback (most recent call last):
19: from -e:1:in `<main>'
18: from -e:1:in `each'
17: from -e:1:in `block in <main>'
16: from -e:1:in `require'
15: from /home/vagrant/katello/test/services/katello/pulp3/rpm_test.rb:1:in `<top (required)>'
14: from /home/vagrant/katello/test/services/katello/pulp3/rpm_test.rb:1:in `require'
13: from /home/vagrant/katello/test/katello_test_helper.rb:12:in `<top (required)>'
12: from /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/activesupport-6.1.7.6/lib/active_support/dependencies.rb:332:in `require'
11: from /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/activesupport-6.1.7.6/lib/active_support/dependencies.rb:299:in `load_dependency'
10: from /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/activesupport-6.1.7.6/lib/active_support/dependencies.rb:332:in `block in require'
9: from /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/zeitwerk-2.6.12/lib/zeitwerk/kernel.rb:38:in `require'
8: from /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
7: from /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
6: from /home/vagrant/katello/test/support/vcr.rb:1:in `<top (required)>'
5: from /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/activesupport-6.1.7.6/lib/active_support/dependencies.rb:332:in `require'
4: from /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/activesupport-6.1.7.6/lib/active_support/dependencies.rb:299:in `load_dependency'
3: from /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/activesupport-6.1.7.6/lib/active_support/dependencies.rb:332:in `block in require'
2: from /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/zeitwerk-2.6.12/lib/zeitwerk/kernel.rb:38:in `require'
1: from /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
/home/vagrant/foreman/.vendor/ruby/2.7.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require': cannot load such file -- vcr (LoadError)
Ah, this is a good point. https://github.com/theforeman/actions/blob/v0/.github/workflows/foreman_plugin.yml#L103 a |
Sounds puppet-katello_devel should handle this https://github.com/theforeman/puppet-katello_devel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm cool with merging this in -- the necessary additions to katello.gemspec.local are likely to cause a bit of confusion among katello devs, but I suppose it doesn't make sense to wait for a new puppet-katello_devel PR first.
* Fixes #37095 - Use shared GitHub workflow to run tests * Refs #37095 - move test dependencies into an own group Also drop some unused dependencies (cherry picked from commit 16be014)
* Fixes #37095 - Use shared GitHub workflow to run tests * Refs #37095 - move test dependencies into an own group Also drop some unused dependencies (cherry picked from commit 16be014)
* Fixes #37095 - Use shared GitHub workflow to run tests * Refs #37095 - move test dependencies into an own group Also drop some unused dependencies (cherry picked from commit 16be014)
What are the changes introduced in this pull request?
Considerations taken when implementing this change?
What are the testing steps for this pull request?