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

Fixes #37095 - Use shared GitHub workflow to run tests #10780

Merged
merged 2 commits into from
Feb 2, 2024

Conversation

evgeni
Copy link
Member

@evgeni evgeni commented Oct 27, 2023

What are the changes introduced in this pull request?

Considerations taken when implementing this change?

What are the testing steps for this pull request?

@ekohl
Copy link
Member

ekohl commented Nov 1, 2023

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.

katello.gemspec Outdated
Comment on lines 76 to 74
gem.add_dependency "simplecov"
gem.add_dependency "simplecov-rcov"
Copy link
Member Author

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:

  1. install development group (and pull in all those really dev-only deps of foreman, meh)
  2. 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
  3. provide a gemfile.d/test.rb that clearly defines the test deps in the test group.

I think 3 is the cleanest, but will also require the most changes (to every plugin that needs to define test deps)

Copy link
Member Author

Choose a reason for hiding this comment

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

@evgeni evgeni force-pushed the gha-plugin-test branch 3 times, most recently from de136b5 to 74b48d8 Compare November 28, 2023 10:27
katello.gemspec Outdated Show resolved Hide resolved
gemfile.d/test.rb Outdated Show resolved Hide resolved
@@ -1,3 +1,7 @@
source 'https://rubygems.org'

gemspec

Dir[File.join(__dir__, 'gemfile.d', '*.rb')].each do |bundle|
eval_gemfile(bundle)
Copy link
Member

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.

Copy link
Member Author

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.

.github/workflows/ruby.yml Outdated Show resolved Hide resolved
gemfile.d/test.rb Outdated Show resolved Hide resolved
gemfile.d/test.rb Outdated Show resolved Hide resolved
.github/workflows/ruby.yml Outdated Show resolved Hide resolved
@@ -0,0 +1,7 @@
group :test do
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member Author

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)

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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

Copy link
Member Author

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.

Copy link
Member Author

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"?

Copy link
Member

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.

@evgeni evgeni force-pushed the gha-plugin-test branch 2 times, most recently from 94f345d to c37ba65 Compare January 9, 2024 14:53
@ianballou
Copy link
Member

When a redmine gets created for this, mind linking this redmine to the new one? https://projects.theforeman.org/issues/36998

.github/workflows/ruby.yml Outdated Show resolved Hide resolved
@evgeni
Copy link
Member Author

evgeni commented Jan 23, 2024

Because the issue is getting quite long, a list of split off PRs:

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 test_existing_database: false.

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"
Copy link
Member Author

Choose a reason for hiding this comment

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

@evgeni evgeni changed the title use shared github workflow to run tests Fixes #37095 - Use shared GitHub workflow to run tests Jan 24, 2024
@evgeni evgeni marked this pull request as ready for review January 24, 2024 08:14
@evgeni evgeni closed this Jan 24, 2024
@evgeni evgeni reopened this Jan 24, 2024
@evgeni
Copy link
Member Author

evgeni commented Jan 24, 2024

This is now 🍏 and ready!

katello.gemspec Outdated
Comment on lines 69 to 73
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"
Copy link
Member Author

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.

Comment on lines +22 to +27
uses: theforeman/actions/.github/workflows/foreman_plugin.yml@v0
with:
plugin: katello
postgresql_container: ghcr.io/theforeman/postgresql-evr
test_existing_database: false
Copy link
Member Author

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 ;-)

Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member

@ianballou ianballou left a 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)

@evgeni
Copy link
Member Author

evgeni commented Jan 30, 2024

Does this require a matching Foreman PR to work? I'm hitting issues loading vcr now when running tests locally:

Ah, this is a good point.
You (or whatever sets up the devel box) would need to know about gemfile.d too.

https://github.com/theforeman/actions/blob/v0/.github/workflows/foreman_plugin.yml#L103

a cat like this could do (or a symlink, then changes to the file would propagate automatically)

@ianballou
Copy link
Member

a cat like this could do (or a symlink, then changes to the file would propagate automatically)

Sounds puppet-katello_devel should handle this https://github.com/theforeman/puppet-katello_devel

Copy link
Member

@ianballou ianballou left a 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.

@jeremylenz jeremylenz merged commit 16be014 into Katello:master Feb 2, 2024
11 of 12 checks passed
ekohl pushed a commit to ekohl/katello that referenced this pull request Apr 19, 2024
* 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)
chris1984 pushed a commit that referenced this pull request Apr 19, 2024
* 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)
m-bucher pushed a commit to ATIX-AG/katello that referenced this pull request Jun 21, 2024
* 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants