Skip to content

Commit 3381d5f

Browse files
authored
fix: enable typed function compatibility with http signature (#174)
* Enable typed function compatibility with http signature * Add conformance test coverage for 'typed' function signature * Apply rubocop lint fixes
1 parent 15e0a85 commit 3381d5f

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

.github/workflows/conformance.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,30 @@ jobs:
4545
ruby-version: ${{ matrix.ruby }}
4646
bundler-cache: true
4747
- name: Run HTTP conformance tests
48-
uses: GoogleCloudPlatform/functions-framework-conformance/action@1975792fb34ebbfa058d690666186d669d3a5977 # v1.8.0
48+
uses: GoogleCloudPlatform/functions-framework-conformance/action@2f5f319c06a3531be7f75dc5acf6bd00417ff76e # v1.8.3
4949
with:
5050
functionType: 'http'
5151
useBuildpacks: false
5252
cmd: "'bundle exec functions-framework-ruby --source test/conformance/app.rb --target http_func --signature-type http'"
53+
- name: Run Typed conformance tests
54+
uses: GoogleCloudPlatform/functions-framework-conformance/action@2f5f319c06a3531be7f75dc5acf6bd00417ff76e # v1.8.3
55+
with:
56+
functionType: 'http'
57+
declarativeType: 'typed'
58+
useBuildpacks: false
59+
cmd: "'bundle exec functions-framework-ruby --source test/conformance/app.rb --target typed_func --signature-type http'"
5360
- name: Run CloudEvent conformance tests
54-
uses: GoogleCloudPlatform/functions-framework-conformance/action@1975792fb34ebbfa058d690666186d669d3a5977 # v1.8.0
61+
uses: GoogleCloudPlatform/functions-framework-conformance/action@2f5f319c06a3531be7f75dc5acf6bd00417ff76e # v1.8.3
5562
with:
5663
functionType: 'cloudevent'
5764
useBuildpacks: false
5865
validateMapping: true
5966
cmd: "'bundle exec functions-framework-ruby --source test/conformance/app.rb --target cloudevent_func --signature-type cloudevent'"
6067
- name: Run HTTP concurrency tests
61-
uses: GoogleCloudPlatform/functions-framework-conformance/action@1975792fb34ebbfa058d690666186d669d3a5977 # v1.8.0
68+
uses: GoogleCloudPlatform/functions-framework-conformance/action@2f5f319c06a3531be7f75dc5acf6bd00417ff76e # v1.8.3
6269
with:
6370
functionType: 'http'
6471
useBuildpacks: false
6572
validateConcurrency: true
6673
cmd: "'bundle exec functions-framework-ruby --source test/conformance/app.rb --target concurrent_http_func --signature-type http'"
74+

lib/functions_framework/cli.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ def load_function
197197
raise "Undefined function: #{@target.inspect}" if function.nil?
198198
unless @signature_type.nil? ||
199199
(@signature_type == "http" && function.type == :http) ||
200+
(@signature_type == "http" && function.type == :typed) ||
200201
(["cloudevent", "event"].include?(@signature_type) && function.type == :cloud_event)
201202
raise "Function #{@target.inspect} does not match type #{@signature_type}"
202203
end

test/conformance/app.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,9 @@
2626
sleep 1
2727
"ok"
2828
end
29+
30+
FunctionsFramework.typed "typed_func" do |request|
31+
return {
32+
payload: request
33+
}
34+
end

0 commit comments

Comments
 (0)