Skip to content

Commit

Permalink
chore: run buildpack tests on pull
Browse files Browse the repository at this point in the history
  • Loading branch information
kenneth-rosario committed Jul 12, 2023
1 parent c95d90f commit 344b0c4
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 20 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/buildpack-integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ on:
push:
branches:
- main
pull_request:
workflow_dispatch:

# Declare default permissions as read only.
permissions: read-all

jobs:
php74-buildpack-test:
uses: GoogleCloudPlatform/functions-framework-conformance/.github/workflows/[email protected].1
uses: GoogleCloudPlatform/functions-framework-conformance/.github/workflows/[email protected].4
with:
http-builder-source: 'tests/conformance'
http-builder-target: 'declarativeHttpFunc'
Expand All @@ -20,8 +21,9 @@ jobs:
prerun: 'tests/conformance/prerun.sh ${{ github.sha }}'
output-file: 'vendor/bin/function_output.json'
builder-runtime: 'php74'
builder-runtime-version: '">=7.4,<7.5"'
php81-buildpack-test:
uses: GoogleCloudPlatform/functions-framework-conformance/.github/workflows/[email protected].1
uses: GoogleCloudPlatform/functions-framework-conformance/.github/workflows/[email protected].4
with:
http-builder-source: 'tests/conformance'
http-builder-target: 'declarativeHttpFunc'
Expand All @@ -30,8 +32,9 @@ jobs:
prerun: 'tests/conformance/prerun.sh ${{ github.sha }}'
output-file: 'vendor/bin/function_output.json'
builder-runtime: 'php81'
builder-runtime-version: '">=8.1,<8.2"'
php82-buildpack-test:
uses: GoogleCloudPlatform/functions-framework-conformance/.github/workflows/[email protected].1
uses: GoogleCloudPlatform/functions-framework-conformance/.github/workflows/[email protected].4
with:
http-builder-source: 'tests/conformance'
http-builder-target: 'declarativeHttpFunc'
Expand All @@ -40,3 +43,4 @@ jobs:
prerun: 'tests/conformance/prerun.sh ${{ github.sha }}'
output-file: 'vendor/bin/function_output.json'
builder-runtime: 'php82'
builder-runtime-version: '">=8.2,<8.3"'
25 changes: 15 additions & 10 deletions src/Invoker.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Psr7\ServerRequest;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;

// use Psr\Http\Message\ServerRequestInterface;

class Invoker
{
Expand All @@ -44,10 +45,12 @@ public function __construct($target, ?string $signatureType = null)
$this->function = self::$registeredFunctions[$target];
} else {
if (!is_callable($target)) {
throw new InvalidArgumentException(sprintf(
'Function target is not callable: "%s"',
$target
));
throw new InvalidArgumentException(
sprintf(
'Function target is not callable: "%s"',
$target
)
);
}

if ($signatureType === 'http') {
Expand All @@ -60,10 +63,12 @@ public function __construct($target, ?string $signatureType = null)
} elseif ($signatureType === 'typed') {
$this->function = new TypedFunctionWrapper($target);
} else {
throw new InvalidArgumentException(sprintf(
'Invalid signature type: "%s"',
$signatureType
));
throw new InvalidArgumentException(
sprintf(
'Invalid signature type: "%s"',
$signatureType
)
);
}
}

Expand Down Expand Up @@ -118,4 +123,4 @@ public static function registerFunction(string $name, FunctionWrapper $function)
{
self::$registeredFunctions[$name] = $function;
}
}
}
17 changes: 10 additions & 7 deletions tests/conformance/prerun.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,20 @@ set -e

cd $(dirname $0)

if [ -z "${FRAMEWORK_VERSION}" ]
then
echo "Functions Framework version required as first parameter"
exit 1
if [ -z "${FRAMEWORK_VERSION}" ]; then
echo "Functions Framework version required as first parameter"
exit 1
fi

if [ -z "${GITHUB_HEAD_REF}" ]; then
GITHUB_HEAD_REF="main"
fi

echo '{
"require": {
"google/cloud-functions-framework": "dev-main#'${FRAMEWORK_VERSION}'",
"google/cloud-functions-framework": "dev-'${GITHUB_HEAD_REF}'#'${FRAMEWORK_VERSION}'",
"cloudevents/sdk-php": "^1.0"
}
}' > composer.json
}' >composer.json

cat composer.json
cat composer.json

0 comments on commit 344b0c4

Please sign in to comment.