openproject icon indicating copy to clipboard operation
openproject copied to clipboard

Update Ruby to 3.3.1

Open klaustopher opened this issue 10 months ago • 5 comments

Updating to Ruby 3.3.1

  • [x] Make cache on GitHub actions work with ruby version updates
  • [ ] Ruby Parser gem does not support 3.3.1 yet, but as we are not using the fixed syntax, it's not a problem. See https://github.com/whitequark/parser/issues/963

Optional

  • [ ] Enable YJIT because it can give real performance improvements

Implements https://community.openproject.org/projects/openproject/work_packages/details/54458

klaustopher avatar Apr 25 '24 06:04 klaustopher

I am a bit confused here. The cache includes the .ruby-version file as a cache key, but it does not invalidate the cache. That's why the runs like https://github.com/opf/openproject/actions/runs/8828307074/job/24237045450 failed. When I completely disable the cache, it works nicely.

@machisuji or @crohr do you maybe have an idea why that's the case?

klaustopher avatar Apr 25 '24 07:04 klaustopher

I am a bit confused here. The cache includes the .ruby-version file as a cache key, but it does not invalidate the cache. That's why the runs like https://github.com/opf/openproject/actions/runs/8828307074/job/24237045450 failed. When I completely disable the cache, it works nicely.

@machisuji or @crohr do you maybe have an idea why that's the case?

restore-keys - An ordered list of prefix-matched keys to use for restoring stale cache if no cache hit occurred for key.

You have that set. So if no previous cache with the same ruby version and Gemfile.lock exists, any other one will be used.

Fix would be to has the ruby version and lockfile separately and add the version hash to restore-keys too.

AaronDewes avatar Apr 25 '24 10:04 AaronDewes

Fix would be to has the ruby version and lockfile separately and add the version hash to restore-keys too.

Isn't that the case with key: gem-${{ hashFiles('Gemfile.lock', '.ruby-version') }}? IMHO this should add the content of the .ruby-version file to the cache key and if we change the content of that file, the cache key should be a new one and the cache lookup should miss?

klaustopher avatar Apr 25 '24 11:04 klaustopher

Vielleicht kann ich es auf Deutsch besser erklären als auf Englisch: restore-keys ist eine Liste von Prefixen für den key. Wenn du also als key den Wert gem-${{ hashFiles('Gemfile.lock', '.ruby-version') }} hast, dann überprüft es erst, ob es ein Cache mit dem Key gem-${{ hashFiles('Gemfile.lock', '.ruby-version') }} schon gibt. Wenn ja, nimmt es immer den. Wenn nein, kann es den ja nicht nehmen.

Aber weil gem- ohne sonst etwas in den restore-keys steht, nimmt es dann einfach irgendein Cache, dessen key auch mit gem- beginnt. Und das kann eine andere Ruby-Version sein.

AaronDewes avatar Apr 25 '24 11:04 AaronDewes

Ahhh! Thank you, that makes a lot of sense!

klaustopher avatar Apr 25 '24 11:04 klaustopher

Parser gem was updated, so we can go ahead and merge this

klaustopher avatar Apr 29 '24 06:04 klaustopher