-
Notifications
You must be signed in to change notification settings - Fork 38
feat: introduce declarative function signatures #116
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
27b78e6
feat: introduce declarative function signatures
anniefu 277e346
Move reading FUNCTION_SIGNATURE_TYPE back to router.php
anniefu 75a6778
idea for declarative implementation
bshaffer e4ca54a
WIP
bshaffer 2876968
cleanup
bshaffer 66f1122
Merge pull request #2 from bshaffer/rfc-for-declarative-design
anniefu 2fe53ca
Remove unnecessary use statement from router.php
anniefu c1f4059
Address PR
anniefu 6d8a483
PR
anniefu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,25 +36,48 @@ jobs: | |
go-version: '1.15' | ||
|
||
- name: Run HTTP conformance tests | ||
uses: GoogleCloudPlatform/functions-framework-conformance/[email protected].0 | ||
uses: GoogleCloudPlatform/functions-framework-conformance/[email protected].1 | ||
env: | ||
FUNCTION_TARGET: 'httpFunc' | ||
FUNCTION_SIGNATURE_TYPE: 'http' | ||
FUNCTION_SOURCE: ${{ github.workspace }}/tests/conformance/index.php | ||
with: | ||
version: 'v1.0.0' | ||
version: 'v1.2.1' | ||
functionType: 'http' | ||
useBuildpacks: false | ||
cmd: "'php -S localhost:8080 router.php'" | ||
|
||
- name: Run Declarative HTTP conformance tests | ||
uses: GoogleCloudPlatform/functions-framework-conformance/[email protected] | ||
env: | ||
FUNCTION_TARGET: 'declarativeHttpFunc' | ||
FUNCTION_SOURCE: ${{ github.workspace }}/tests/conformance/index.php | ||
with: | ||
version: 'v1.2.1' | ||
functionType: 'http' | ||
useBuildpacks: false | ||
cmd: "'php -S localhost:8080 router.php'" | ||
|
||
- name: Run CloudEvent conformance tests | ||
uses: GoogleCloudPlatform/functions-framework-conformance/[email protected].0 | ||
uses: GoogleCloudPlatform/functions-framework-conformance/[email protected].1 | ||
env: | ||
FUNCTION_TARGET: 'cloudEventFunc' | ||
FUNCTION_SIGNATURE_TYPE: 'cloudevent' | ||
FUNCTION_SOURCE: ${{ github.workspace }}/tests/conformance/index.php | ||
with: | ||
version: 'v1.0.0' | ||
version: 'v1.2.1' | ||
functionType: 'cloudevent' | ||
useBuildpacks: false | ||
validateMapping: true | ||
cmd: "'php -S localhost:8080 router.php'" | ||
|
||
- name: Run Declarative CloudEvent conformance tests | ||
uses: GoogleCloudPlatform/functions-framework-conformance/[email protected] | ||
env: | ||
FUNCTION_TARGET: 'declarativeCloudEventFunc' | ||
FUNCTION_SOURCE: ${{ github.workspace }}/tests/conformance/index.php | ||
with: | ||
version: 'v1.2.1' | ||
functionType: 'cloudevent' | ||
useBuildpacks: false | ||
validateMapping: true | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/bash | ||
# Runs the conformance tests locally from https://github.com/GoogleCloudPlatform/functions-framework-conformance. | ||
# Requires Go 1.16+ to run. | ||
# | ||
# Servers may fail to shutdown between tests on error, leaving port 8080 bound. | ||
# You can see what's running on port 8080 by running `lsof -i :8080`. You can | ||
# run `kill -9 <PID>` to terminate a process. | ||
# | ||
# USAGE: | ||
# ./run_conformance_tests.sh [client_version] | ||
# | ||
# client_version (optional): | ||
# The version of the conformance tests client to use, formatted as "vX.X.X". | ||
# Defaults to the latest version of the repo, which may be ahead of the | ||
# latest release. | ||
|
||
CLIENT_VERSION=$1 | ||
if [ $CLIENT_VERSION ]; then | ||
CLIENT_VERSION="@$CLIENT_VERSION" | ||
else | ||
echo "Defaulting to latest client." | ||
echo "Use './run_conformance_tests vX.X.X' to specify a specific release version." | ||
CLIENT_VERSION="@latest" | ||
fi | ||
|
||
function print_header() { | ||
echo | ||
echo "========== $1 ==========" | ||
} | ||
|
||
# Fail if any command fails | ||
set -e | ||
|
||
print_header "INSTALLING CLIENT$CLIENT_VERSION" | ||
echo "Note: only works with Go 1.16+ by default, see run_conformance_tests.sh for more information." | ||
# Go install @version only works on go 1.16+, if using a lower Go version | ||
# replace command with: | ||
# go get github.com/GoogleCloudPlatform/functions-framework-conformance/client$CLIENT_VERSION && go install github.com/GoogleCloudPlatform/functions-framework-conformance/client | ||
go install github.com/GoogleCloudPlatform/functions-framework-conformance/client$CLIENT_VERSION | ||
echo "Done installing client$CLIENT_VERSION" | ||
|
||
print_header "HTTP CONFORMANCE TESTS" | ||
FUNCTION_TARGET='httpFunc' FUNCTION_SIGNATURE_TYPE='http' FUNCTION_SOURCE=$(realpath tests/conformance/index.php) client -buildpacks=false -type=http -cmd='php -S localhost:8080 router.php' -start-delay 5 -validate-mapping=true | ||
|
||
print_header "DECLARATIVE HTTP CONFORMANCE TESTS" | ||
FUNCTION_TARGET='declarativeHttpFunc' FUNCTION_SIGNATURE_TYPE= FUNCTION_SOURCE=$(realpath tests/conformance/index.php) client -buildpacks=false -type=http -cmd='php -S localhost:8080 router.php' -start-delay 5 -validate-mapping=true | ||
|
||
print_header "CLOUDEVENT CONFORMANCE TESTS" | ||
FUNCTION_TARGET='cloudEventFunc' FUNCTION_SIGNATURE_TYPE='cloudevent' FUNCTION_SOURCE=$(realpath tests/conformance/index.php) client -buildpacks=false -type=cloudevent -cmd='php -S localhost:8080 router.php' -start-delay 5 -validate-mapping=true | ||
|
||
print_header "DECLARATIVE CLOUDEVENT CONFORMANCE TESTS" | ||
FUNCTION_TARGET='declarativeCloudEventFunc' FUNCTION_SIGNATURE_TYPE= FUNCTION_SOURCE=$(realpath tests/conformance/index.php) client -buildpacks=false -type=cloudevent -cmd='php -S localhost:8080 router.php' -start-delay 5 -validate-mapping=true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright 2021 Google LLC. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
namespace Google\CloudFunctions; | ||
|
||
class FunctionsFramework | ||
{ | ||
private function __construct() | ||
{ | ||
// Constructor disabled because this class should only be used statically. | ||
} | ||
|
||
public static function http(string $name, callable $fn) | ||
{ | ||
Invoker::registerFunction($name, new HttpFunctionWrapper($fn)); | ||
} | ||
|
||
public static function cloudEvent(string $name, callable $fn) | ||
{ | ||
Invoker::registerFunction($name, new CloudEventFunctionWrapper($fn, true)); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.