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

Add support for ruby 3.3 #11497

Merged
merged 14 commits into from Apr 30, 2024
5 changes: 5 additions & 0 deletions .changeset/friendly-badgers-protect.md
@@ -0,0 +1,5 @@
---
'@vercel/ruby': patch
---

Add support for Ruby 3.3
9 changes: 9 additions & 0 deletions packages/ruby/src/index.ts
Expand Up @@ -73,6 +73,15 @@ async function bundleInstall(
gemfilePath,
gemfileContent.replace('ruby "~> 3.2.x"', 'ruby "~> 3.2.0"')
);
} else if (gemfileContent.includes('ruby "~> 3.3.x"')) {
// Gemfile contains "3.3.x" which will cause an error message:
// "Your Ruby patchlevel is 0, but your Gemfile specified -1"
// See https://github.com/rubygems/bundler/blob/3f0638c6c8d340c2f2405ecb84eb3b39c433e36e/lib/bundler/errors.rb#L49
// We must correct to the actual version in the build container.
await writeFile(
gemfilePath,
gemfileContent.replace('ruby "~> 3.3.x"', 'ruby "~> 3.3.0"')
);
}

const bundlerEnv = cloneEnv(process.env, {
Expand Down
1 change: 1 addition & 0 deletions packages/ruby/src/install-ruby.ts
Expand Up @@ -9,6 +9,7 @@ interface RubyVersion extends NodeVersion {

function getOptions() {
const options = [
{ major: 3, minor: 3, range: '3.3.x', runtime: 'ruby3.3' },
{ major: 3, minor: 2, range: '3.2.x', runtime: 'ruby3.2' },
{
major: 2,
Expand Down
2 changes: 1 addition & 1 deletion packages/ruby/test/fixtures/01-cowsay/Gemfile
Expand Up @@ -2,6 +2,6 @@

source "https://rubygems.org"

ruby "~> 3.2.x"
ruby "~> 3.3.x"

gem "cowsay", "~> 0.3.0"
2 changes: 1 addition & 1 deletion packages/ruby/test/fixtures/02-cowsay-vendored/Gemfile
Expand Up @@ -2,6 +2,6 @@

source "https://rubygems.org"

ruby "~> 3.2.x"
ruby "~> 3.3.x"

gem "cowsay", "~> 0.3.0"
Expand Up @@ -2,6 +2,6 @@

source "https://rubygems.org"

ruby "~> 3.2.x"
ruby "~> 3.3.x"

gem "cowsay", "~> 0.3.0"
2 changes: 1 addition & 1 deletion packages/ruby/test/fixtures/05-sinatra/Gemfile
Expand Up @@ -2,7 +2,7 @@

source "https://rubygems.org"

ruby "~> 3.2.x"
ruby "~> 3.3.x"

gem "cowsay", "~> 0.3.0"

Expand Down
13 changes: 3 additions & 10 deletions packages/ruby/test/test.js
Expand Up @@ -12,7 +12,7 @@ const fixturesPath = path.resolve(__dirname, 'fixtures');
const testsThatFailToBuild = new Map([
[
'11-version-2-5-error',
'Found `Gemfile` with discontinued Ruby version: `ruby "~> 2.5.x".` Please set `ruby "~> 3.2.x"` in your `Gemfile` to use Ruby 3.2.x.',
'Found `Gemfile` with discontinued Ruby version: `ruby "~> 2.5.x".` Please set `ruby "~> 3.3.x"` in your `Gemfile` to use Ruby 3.3.x.',
],
]);

Expand All @@ -26,19 +26,12 @@ for (const fixture of fs.readdirSync(fixturesPath)) {
continue;
}

// Ruby endpoints currently require the AL2 build image
const projectSettings = {
nodeVersion: '18.x',
};

const errMsg = testsThatFailToBuild.get(fixture);
if (errMsg) {
// eslint-disable-next-line no-loop-func
it(`should fail to build ${fixture}`, async () => {
try {
await testDeployment(path.join(fixturesPath, fixture), {
projectSettings,
});
await testDeployment(path.join(fixturesPath, fixture));
} catch (err) {
expect(err).toBeTruthy();
expect(err.deployment).toBeTruthy();
Expand All @@ -50,7 +43,7 @@ for (const fixture of fs.readdirSync(fixturesPath)) {
// eslint-disable-next-line no-loop-func
it(`should build ${fixture}`, async () => {
await expect(
testDeployment(path.join(fixturesPath, fixture), { projectSettings })
testDeployment(path.join(fixturesPath, fixture))
).resolves.toBeDefined();
});
}