Skip to content

Commit

Permalink
Merge pull request #912 from frozenbonito/support-ruby2.7
Browse files Browse the repository at this point in the history
Support ruby2.7
  • Loading branch information
dherault committed Mar 17, 2020
2 parents 33ae3b5 + 4b01ed7 commit 95ec5c4
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/config/supportedRuntimes.js
Expand Up @@ -41,7 +41,7 @@ export const supportedPython = new Set([
])

// RUBY
export const supportedRuby = new Set(['ruby2.5'])
export const supportedRuby = new Set(['ruby2.5', 'ruby2.7'])

// deprecated runtimes
// https://docs.aws.amazon.com/lambda/latest/dg/runtime-support-policy.html
Expand Down
4 changes: 3 additions & 1 deletion tests/integration/docker/ruby/ruby2.5/dockerRuby2.5.test.js
@@ -1,5 +1,6 @@
import { resolve } from 'path'
import fetch from 'node-fetch'
import { satisfies } from 'semver'
import { joinUrl, setup, teardown } from '../../../_testHelpers/index.js'

jest.setTimeout(120000)
Expand Down Expand Up @@ -33,7 +34,8 @@ _describe('Ruby 2.5 with Docker tests', () => {
const response = await fetch(url)
const json = await response.json()

expect(json).toEqual(expected)
expect(json.message).toEqual(expected.message)
expect(satisfies(json.version, '2.5')).toEqual(true)
})
})
})
8 changes: 7 additions & 1 deletion tests/integration/docker/ruby/ruby2.5/handler.rb
@@ -1,5 +1,11 @@
require 'json'

def hello(event:, context:)
{ body: JSON.generate({'message' => 'Hello Ruby 2.5!'}), statusCode: 200 }
{
body: JSON.generate({
message: 'Hello Ruby 2.5!',
version: RUBY_VERSION,
}),
statusCode: 200,
}
end
41 changes: 41 additions & 0 deletions tests/integration/docker/ruby/ruby2.7/dockerRuby2.7.test.js
@@ -0,0 +1,41 @@
import { resolve } from 'path'
import fetch from 'node-fetch'
import { satisfies } from 'semver'
import { joinUrl, setup, teardown } from '../../../_testHelpers/index.js'

jest.setTimeout(120000)

// "Could not find 'Docker', skipping 'Docker' tests."
const _describe = process.env.DOCKER_DETECTED ? describe : describe.skip

_describe('Ruby 2.7 with Docker tests', () => {
// init
beforeAll(() =>
setup({
servicePath: resolve(__dirname),
}),
)

// cleanup
afterAll(() => teardown())

//
;[
{
description: 'should work with ruby2.7 in docker container',
expected: {
message: 'Hello Ruby 2.7!',
},
path: '/dev/hello',
},
].forEach(({ description, expected, path }) => {
test(description, async () => {
const url = joinUrl(TEST_BASE_URL, path)
const response = await fetch(url)
const json = await response.json()

expect(json.message).toEqual(expected.message)
expect(satisfies(json.version, '2.7')).toEqual(true)
})
})
})
11 changes: 11 additions & 0 deletions tests/integration/docker/ruby/ruby2.7/handler.rb
@@ -0,0 +1,11 @@
require 'json'

def hello(event:, context:)
{
body: JSON.generate({
message: 'Hello Ruby 2.7!',
version: RUBY_VERSION,
}),
statusCode: 200,
}
end
24 changes: 24 additions & 0 deletions tests/integration/docker/ruby/ruby2.7/serverless.yml
@@ -0,0 +1,24 @@
service: docker-ruby2.7-tests

plugins:
- ./../../../../../

provider:
memorySize: 128
name: aws
region: us-east-1 # default
runtime: ruby2.7
stage: dev
versionFunctions: false

custom:
serverless-offline:
useDocker: true

functions:
hello:
events:
- http:
method: get
path: hello
handler: handler.hello
2 changes: 1 addition & 1 deletion tests/integration/ruby/serverless.yml
Expand Up @@ -7,7 +7,7 @@ provider:
memorySize: 128
name: aws
region: us-east-1 # default
runtime: ruby2.5
runtime: ruby2.7
stage: dev
versionFunctions: false

Expand Down
2 changes: 1 addition & 1 deletion tests/manual/ruby/serverless.yml
Expand Up @@ -22,7 +22,7 @@ plugins:

provider:
name: aws
runtime: ruby2.5
runtime: ruby2.7

# you can overwrite defaults here
# stage: dev
Expand Down

0 comments on commit 95ec5c4

Please sign in to comment.