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

Fix CI (bumping minimum versions of Ruby and govuk_publishing_components) #381

Merged
merged 5 commits into from
Jan 27, 2025

Conversation

mike3985
Copy link
Contributor

@mike3985 mike3985 commented Jan 23, 2025

In some tests we're using string matching/regex to make assertions about
rendered HTML. Those assertions can be overly sensitive to, say, the
order that an HTML element's attributes are listed in.

This is particularly an issue where Govspeak invokes
GovukPublishingComponents, since we no longer pin the version of that
dependency and different versions can produce different HTML.

Parsing the HTML string and making assertions against an object
representation is likely to be more reliable.

---

For this method, I've copied an approach taken in one of the assertions
provided by the existing GovspeakTestHelper. GovspeakTestHelper is
designed in such a way that our tests that make use of it need to be
written in quite a rigid format. It has been suggested once in a while
that we revisit the design of this gem's tests and test helpers
generally. For now, this new method is standalone and flexible enough to
just insert into our more vanilla tests.
This isn't an exhaustive update, I'm only changing the ones that're
making the CI build fail right now.

A change in the order of an HTML element's attributes has caused the
build to start failing. The regex pattern expects the class name to
immediately follow the tag name, but that's no longer true -- due to
a change in our (unpinned) govuk_publishing_components dependency.

This new assertion works with older and newer versions of the components
gem.
We're looking into compatibility issues with a recent release of the
govuk_publishing_components gem. Unfortunately, since the components gem
dropped support for Ruby <3.2 in its own 41.1.0 release (August 2024),
we need to use a newer version of Ruby to be able to actually reproduce
the problem.

While updating the .ruby-version (to 3.2.2, same as
govuk_publishing_components), it seems sensible to update the minimum
supported Ruby version to match it.
I've based this new minimum requirement on the oldest versions listed in
the GOV.UK dependency management spreadsheet[1] for projects that're
also using Govspeak. It also needed to be >38.4.1 because of
backwards-incompatible changes we've since made to our tests[2]

[1]: https://docs.google.com/spreadsheets/d/137KZhjctJ8qTKYPnq2QNVkyoIC6ok7KA2G1vErNC6Oo/edit?gid=1160366178#gid=1160366178
[2]: be27793
Bumping the minimum required versions of Ruby and
govuk_publishing_components. This should be uneventful, but it seems
worthy of a major version to me.
@mike3985 mike3985 changed the title Failing ci Fix CI (bumping minimum versions of Ruby and govuk_publishing_components) Jan 24, 2025
@mike3985 mike3985 marked this pull request as ready for review January 24, 2025 14:28
Copy link
Member

@brucebolt brucebolt left a comment

Choose a reason for hiding this comment

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

Nice approach! This should save us a lot of time going forward.

@mike3985 mike3985 merged commit 534ce41 into main Jan 27, 2025
8 checks passed
@mike3985 mike3985 deleted the failing-ci branch January 27, 2025 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants