Skip to content

Commit

Permalink
chore: run integration tests on pull request
Browse files Browse the repository at this point in the history
  • Loading branch information
kenneth-rosario committed Jul 11, 2023
1 parent b16760a commit f27c4bd
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 51 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/buildpack-integration-test-base.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Buildpack Integration Test
on:
workflow_call:
inputs:
commit-sha:
description: Commit sha of the functions framework to be used
type: string
required: true
jobs:
go113-buildpack-test:
uses: GoogleCloudPlatform/functions-framework-conformance/.github/workflows/buildpack-integration-test.yml@v1.8.4
with:
http-builder-source: 'testdata/conformance/function'
http-builder-target: 'declarativeHTTP'
cloudevent-builder-source: 'testdata/conformance/function'
cloudevent-builder-target: 'declarativeCloudEvent'
prerun: 'testdata/conformance/prerun.sh ${{ inputs.commit-sha }} testdata/conformance/function'
builder-runtime: 'go113'
builder-runtime-version: '1.13'
go116-buildpack-test:
uses: GoogleCloudPlatform/functions-framework-conformance/.github/workflows/buildpack-integration-test.yml@v1.8.4
with:
http-builder-source: 'testdata/conformance/function'
http-builder-target: 'declarativeHTTP'
cloudevent-builder-source: 'testdata/conformance/function'
cloudevent-builder-target: 'declarativeCloudEvent'
prerun: 'testdata/conformance/prerun.sh ${{ inputs.commit-sha }} testdata/conformance/function'
builder-runtime: 'go116'
builder-runtime-version: '1.16'
non-declarative-buildpack-test:
uses: GoogleCloudPlatform/functions-framework-conformance/.github/workflows/buildpack-integration-test.yml@v1.8.4
with:
http-builder-source: 'testdata/conformance/nondeclarative'
http-builder-target: 'HTTP'
cloudevent-builder-source: 'testdata/conformance/nondeclarative'
cloudevent-builder-target: 'CloudEvent'
prerun: 'testdata/conformance/prerun.sh ${{ inputs.commit-sha }} testdata/conformance/nondeclarative'
builder-runtime: 'go116'
builder-runtime-version: '1.16'
20 changes: 20 additions & 0 deletions .github/workflows/buildpack-integration-test-postsubmit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

# Validates Functions Framework with GCF buildpacks.
name: Buildpack Integration Test Post-Submit
on:
push:
branches:
- master
workflow_dispatch:
# Runs every day on 12:00 AM PST
schedule:
- cron: "0 0 * * *"

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

jobs:
buildpack-postsubmit-test:
uses: ./.github/workflows/re-usable/buildpack-integration-test-base.yml
with:
commit-sha: ${{ github.sha }}
14 changes: 14 additions & 0 deletions .github/workflows/buildpack-integration-test-presubmit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

# Validates Functions Framework with GCF buildpacks.
name: Buildpack Integration Test Pre-Submit
on:
pull_request:

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

jobs:
buildpack-presubmit-test:
uses: ./.github/workflows/re-usable/buildpack-integration-test-base.yml
with:
commit-sha: ${{ github.event.pull_request.head.sha }}
40 changes: 0 additions & 40 deletions .github/workflows/buildpack-integration-test.yml

This file was deleted.

23 changes: 12 additions & 11 deletions testdata/conformance/prerun.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@ TARGET_DIRECTORY=$2 # relative to repo root
# exit when any command fails
set -e

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 "${TARGET_DIRECTORY}" ]
then
echo "Target directory required as second parameter"
exit 1
if [ -z "${TARGET_DIRECTORY}" ]; then
echo "Target directory required as second parameter"
exit 1
fi

cd $(dirname $0)
Expand All @@ -38,8 +36,11 @@ go 1.13
require (
cloud.google.com/go/functions v1.0.0
github.com/GoogleCloudPlatform/functions-framework-go $FRAMEWORK_VERSION
github.com/cloudevents/sdk-go/v2 v2.6.1
)" >> $TARGET_DIRECTORY/go.mod
)" >>$TARGET_DIRECTORY/go.mod

cat $TARGET_DIRECTORY/go.mod
cd $TARGET_DIRECTORY

go mod edit -require github.com/GoogleCloudPlatform/functions-framework-go@$FRAMEWORK_VERSION

cat go.mod

0 comments on commit f27c4bd

Please sign in to comment.