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

Use appraisal gem in CI #1308

Merged
merged 1 commit into from
Jan 6, 2024
Merged

Use appraisal gem in CI #1308

merged 1 commit into from
Jan 6, 2024

Conversation

boardfish
Copy link
Collaborator

@boardfish boardfish commented Mar 14, 2022

Supersedes #1230

Uses appraisal ~> 2.5 to run against an array of Rails minor versions from 6.1 onwards. Also moves us away from manually caching gem dependencies, as that can now be handled by the setup-ruby action.

@boardfish boardfish changed the title Fix appraisal ci boardfish Fix appraisal in CI Mar 14, 2022
@boardfish boardfish marked this pull request as ready for review March 15, 2022 10:42
@boardfish boardfish requested review from Spone and a team as code owners March 15, 2022 10:42
@Spone
Copy link
Collaborator

Spone commented Mar 16, 2022

Looking good, thanks for wrapping this up! 🎉

While re-reading #1230, I noticed there was one last thing to decide. Do we want to:

Happy to hear what you think @joelhawksley @boardfish @BlakeWilliams

@Spone Spone mentioned this pull request Mar 16, 2022
@boardfish
Copy link
Collaborator Author

I'm leaning towards that first option. I think we should prioritize ensuring that running the tests works the same way in dev as it does in CI. It may be a good idea in the long run to mirror @excid3's fork to @github so we can ensure that version of the code remains publicly available until @excid3's PR is merged.

Copy link
Contributor

@camertron camertron left a comment

Choose a reason for hiding this comment

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

Nice this is great! I'm a big fan of appraisal :)

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
rails_version: ['5.2.6', '6.0.4.4', '6.1.4.4', '7.0.1', 'main']
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a heads-up a repo admin will need to adjust the "required checks" after merging in order to accommodate the different labels here.

@Spone
Copy link
Collaborator

Spone commented Jun 2, 2022

@joelhawksley would you mind giving us your feedback on this? (See my latest comment above). I think we should try to merge this soon.

Copy link
Member

@joelhawksley joelhawksley left a comment

Choose a reason for hiding this comment

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

@Spone IMO we need to be cautious of depending on a long-running upstream PR on Appraisal.

Let's take another approach, or work to get the upstream PR merged.

@allmarkedup
Copy link
Contributor

FWIW, I've just gone through the fun process of trying to get Lookbook CI working with Appraisal - I took a slightly different approach (and with a smaller matrix of ruby/rails versions for now) but I finally got it working. Just in case it's useful to have an example which uses the matrix approach but doesn't require the Appraisal fork: https://github.com/allmarkedup/lookbook/blob/main/.github/workflows/ci.yml

@Spone
Copy link
Collaborator

Spone commented Jan 18, 2023

There is a new PR on Appraisal that could fix the issue and allow us to move forward with this approach.

If it does not, I'll take some time to mirror @allmarkedup's method.

@nickcharlton
Copy link

Appraisal maintainer here! 👋

I've just merged that PR mentioned above (thoughtbot/appraisal#202), which I'm hoping can help you out here. In a few days I'll cut a new release.

We'd been a bit stuck with a good solution to that problem, but let us know over there if you're having problems.

@Spone
Copy link
Collaborator

Spone commented Jan 27, 2023

Awesome @nickcharlton! I'll try it out next week. Thanks for the heads up!

Gemfile Outdated
@@ -17,6 +17,10 @@ group :test do
gem "selenium-webdriver", "~> 4"
end

group :development, :test do
gem "appraisal", github: "thoughtbot/appraisal"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm targeting main for now, but we'll be able to use the next version when it's released.

@Spone
Copy link
Collaborator

Spone commented Feb 6, 2023

I thought it was time to get this in shape for v3.0.0 :)

Do not forget this after merging: #1308 (comment)

Thanks a lot @boardfish for your help on this!

@Spone
Copy link
Collaborator

Spone commented Feb 23, 2023

Do you want to review this again @joelhawksley @camertron? Else I think I'll merge this in the coming days.

@joelhawksley
Copy link
Member

@Spone I'd prefer we wait for the Appraisal release instead of depending on a branch.

@joelhawksley
Copy link
Member

@boardfish thoughts on testing this against thoughtbot/appraisal#204 (comment)? Perhaps we don't need to wait for 3.0?

@boardfish
Copy link
Collaborator Author

Yeah, that sounds good!

@joelhawksley
Copy link
Member

@boardfish cool, would you be up for bringing this PR up to date?

@boardfish
Copy link
Collaborator Author

Sure! I can have a crack at that sometime in the next week.

@boardfish boardfish self-assigned this Dec 15, 2023
@boardfish boardfish removed the blocked label Dec 15, 2023
@boardfish boardfish force-pushed the fix-appraisal-ci-boardfish branch 2 times, most recently from d1d26ad to edb5fb7 Compare December 17, 2023 11:15
@boardfish boardfish added the github_actions Pull requests that update GitHub Actions code label Dec 18, 2023
Copy link
Contributor

@camertron camertron left a comment

Choose a reason for hiding this comment

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

LGTM! Can you merge main?

@camertron
Copy link
Contributor

Ugh sorry @boardfish, could you fix these merge conflicts? I'm not sure how to resolve the difference in the Gemfile 😓

@boardfish boardfish marked this pull request as draft January 3, 2024 09:45
@boardfish boardfish force-pushed the fix-appraisal-ci-boardfish branch 4 times, most recently from 7146d23 to 6891bba Compare January 3, 2024 13:52
@boardfish boardfish marked this pull request as ready for review January 3, 2024 15:29
gemfiles/rails_main.gemfile Outdated Show resolved Hide resolved
Comment on lines +255 to +270
# :nocov:
raise "`render_preview` expected a described_class, but it is nil." if described_class.nil?

"#{described_class}Preview"
# :nocov:
else
self.class.name.gsub("Test", "Preview")
end
result = result.constantize
rescue NameError
raise NameError, "`render_preview` expected to find #{result}, but it does not exist."
end
# :nocov:
Copy link
Member

@joelhawksley joelhawksley Jan 3, 2024

Choose a reason for hiding this comment

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

Why were these changes necessary? I'd really prefer to avoid adding these comments.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll try dropping them, but runs were failing due to coverage errors. I think this was the cause, though I'm not sure if anything in this PR in particular would've triggered it.

.github/workflows/ci.yml Outdated Show resolved Hide resolved
Comment on lines -72 to +65
- uses: actions/cache@v3
with:
path: vendor/bundle
key: gems-build-rails-${{ matrix.rails_version }}-ruby-${{ matrix.ruby_version }}-${{ hashFiles('**/Gemfile.lock') }}
bundler-cache: true
Copy link
Contributor

Choose a reason for hiding this comment

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

😎

@boardfish boardfish force-pushed the fix-appraisal-ci-boardfish branch 2 times, most recently from 07fa887 to beb9857 Compare January 4, 2024 09:20
@boardfish
Copy link
Collaborator Author

boardfish commented Jan 4, 2024

@joelhawksley Looks like we do still get coverage-related failures without those nocov comments. Not sure why, though – maybe there's a discrepancy in the running environment between the runs on main vs. on this branch.

I feel like we should merge this and follow up to resolve that. What do you reckon?

@joelhawksley
Copy link
Member

@boardfish I'm happy to merge and revisit given the complexity of this PR.

@boardfish
Copy link
Collaborator Author

Awesome. I'll get rid of those merge conflicts and merge this in myself later, then 👍

Appraisal allows us to test with different versions of gems. In addition to GitHub Actions' matrix functionality, we can use this to test against different combinations of Ruby and Rails versions.

As part of this, we've also made the following changes to our CI pipeline:

Rename Appraisal rails-head to rails-main

Loosen version constraints to minor versions

Use setup-ruby's caching mechanism

  Means we don't need to configure vendor/bundle as the path here. We should probably do this for other workflows too.

Don't trigger CI twice on PRs

Co-authored-by: Simon Fish <si@mon.fish>
@boardfish boardfish changed the title Fix appraisal in CI Use appraisal gem in CI Jan 6, 2024
@boardfish boardfish merged commit d76f5db into main Jan 6, 2024
40 checks passed
@boardfish boardfish deleted the fix-appraisal-ci-boardfish branch January 6, 2024 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
github_actions Pull requests that update GitHub Actions code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants