Skip to content

Commit 2f5f319

Browse files
authored
feat: add support for conformance testing 'typed' declarative function signature (#121)
* feat: add support for conformance testing 'typed' declarative function signature * expose 'typed' conformance test in github action workflows * Add typed conformance test example to README.md
1 parent 0a94dc6 commit 2f5f319

File tree

14 files changed

+4238
-4423
lines changed

14 files changed

+4238
-4423
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- name: Setup Node.js
1313
uses: actions/setup-node@v1
1414
with:
15-
node-version: 14.x
15+
node-version: 18.x
1616
- name: Build Action
1717
run: cd action && npm i && npm run all
1818
- name: Check if there's a diff

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ Frameworks to the Functions Framework contract.
1717
parameters to JSON in the format:
1818
`{"data": ...data..., "context": ...context...}`
1919
and write the resulting string.
20+
- The `typed` function should accept a JSON request object and should echo
21+
the request object back in the "payload" field of the response. I.e. if
22+
the request is `{"a":"b"}` the response should be `{"payload":{"a":
23+
"b"}}`.
2024

2125
1. Build the test client:
2226

@@ -58,6 +62,15 @@ Frameworks to the Functions Framework contract.
5862
-type=legacyevent \
5963
-buildpacks=false
6064
```
65+
- **Ruby __typed http__** function Example:
66+
67+
```sh
68+
$HOME/functions-framework-conformance/client/client \
69+
-cmd="bundle exec functions-framework-ruby --source test/conformance/app.rb --target typed_func --signature-type http" \
70+
--type=http \
71+
--declarative-type=typed \
72+
-buildpacks=false
73+
```
6174

6275
If there are validation errors, an error will be logged in the output, causing your conformance test to fail.
6376

@@ -68,7 +81,8 @@ Frameworks to the Functions Framework contract.
6881
| Configuration flag | Type | Default | Description |
6982
| --- | --- | --- | --- |
7083
| `-cmd` | string | `"''"` | A string with the command to run a Functions Framework server at `localhost:8080`. Must be wrapped in quotes. Ignored if `-buildpacks=true`. |
71-
| `-type` | string | `"http"` | Type of function to validate (must be `"http"`, `"cloudevent"`, or `"legacyevent"`). |
84+
| `-type` | string | `"http"` | The function signature to use (must be `"http"`, `"cloudevent"`, or `"legacyevent"`). |
85+
| `-declarative-type` | string | `""` | The declarative signature type of the function (must be 'http', 'cloudevent', 'legacyevent', or 'typed'), default matches -type |
7286
| `-validate-mapping` | boolean | `true` | Whether to validate mapping from legacy->cloud events and vice versa (as applicable). |
7387
| `-output-file` | string | `"function_output.json"` | Name of file output by function. |
7488
| `-buildpacks` | boolean | `true` | Whether to use the current release of buildpacks to run the validation. If `true`, `-cmd` is ignored and `--builder-*` flags must be set. |

action/action.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ inputs:
88
description: 'output file from function'
99
default: 'function_output.json'
1010
functionType:
11-
description: 'type of function'
11+
description: 'invocation signature type of function'
1212
default: 'http'
13+
declarativeType:
14+
description: 'declarative type of the function as defined in code i.e. a typed declarative function uses the http invocation type'
15+
default: ''
1316
validateMapping:
1417
description: 'whether to validate mapping from legacy->cloud event and vice versa'
1518
default: true

0 commit comments

Comments
 (0)