Skip to content

Commit 1ccaa51

Browse files
author
Kenneth Rosario
authored
fix: conformance client should have support for GOOGLE_RUNTIME_VERSION env var (#123)
1 parent 5f2a796 commit 1ccaa51

File tree

10 files changed

+36
-15
lines changed

10 files changed

+36
-15
lines changed

.github/workflows/buildpack-integration-test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ on:
2222
description: GCF runtime (e.g. 'go116')
2323
type: string
2424
required: true
25+
builder-runtime-version:
26+
description: GCF runtime version (e.g. 3.7.0 for python37 runtime or 1.16 for go116)
27+
type: string
28+
default: ''
29+
required: false
2530
event-builder-source:
2631
description: Background function source; relative to repo root
2732
type: string
@@ -155,6 +160,7 @@ jobs:
155160
-builder-source=${{ matrix.builder-source }} \
156161
-builder-target=${{ matrix.builder-target }} \
157162
-builder-runtime=${{ inputs.builder-runtime }} \
163+
-builder-runtime-version=${{ inputs.builder-runtime-version }}
158164
-builder-tag=${{ inputs.builder-tag }} \
159165
-start-delay=${{ inputs.start-delay }} \
160166
-output-file=${{ inputs.output-file }} \

.github/workflows/main.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,5 @@ jobs:
3939
-validate-mapping=false \
4040
-builder-source='testdata' \
4141
-builder-target='HTTP' \
42-
-builder-runtime='go113'
42+
-builder-runtime='go113' \
43+
-builder-runtime-version='1.13'

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ Frameworks to the Functions Framework contract.
8989
| `-builder-source` | string | `""` | Function source directory to use in building. Required if `-buildpacks=true`. |
9090
| `-builder-target` | string | `""` | Function target to use in building. Required if `-buildpacks=true`. |
9191
| `-builder-runtime` | string | `""` | Runtime to use in building. Required if `-buildpacks=true`. |
92+
| `-builder-runtime-version` | string | `""` | Runtime version used while building. Buildpack will use the latest version if flag is not specified. |
9293
| `-builder-tag` | string | `"latest"` | Builder image tag to use in building. |
9394
| `-start-delay` | uint | `1` | Seconds to wait before sending HTTP request to command process. |
9495
| `-envs` | string | `""` | A comma separated string of additional runtime environment variables. |

action/action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ inputs:
2828
runtime:
2929
description: 'function runtime (e.g. nodejs10, go113)'
3030
default: ''
31+
runtimeVersion:
32+
description: 'function runtime version, uses the latest version if not specified (e.g. 3.7.4 for python37 runtime)'
33+
default: ''
3134
tag:
3235
description: 'GCR tag to use for builder image'
3336
default: 'latest'

action/dist/index.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

action/dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

action/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ async function run() {
2626
const source = core.getInput('source');
2727
const target = core.getInput('target');
2828
const runtime = core.getInput('runtime');
29+
const runtimeVersion = core.getInput('runtimeVersion');
2930
const tag = core.getInput('tag');
3031
const useBuildpacks = core.getInput('useBuildpacks');
3132
const cmd = core.getInput('cmd');
@@ -64,6 +65,7 @@ async function run() {
6465
`-builder-source=${source}`,
6566
`-builder-target=${target}`,
6667
`-builder-runtime=${runtime}`,
68+
`-builder-runtime-version=${runtimeVersion}`,
6769
`-builder-tag=${tag}`,
6870
`-buildpacks=${useBuildpacks}`,
6971
`-cmd=${cmd}`,

client/buildpacks.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ type buildpacksFunctionServer struct {
4242
target string
4343
funcType string
4444
runtime string
45+
runtimeVersion string
4546
tag string
4647
ctID string
4748
logStdout *os.File
@@ -108,6 +109,7 @@ func (b *buildpacksFunctionServer) build(ctx context.Context) error {
108109
"GOOGLE_FUNCTION_TARGET": b.target,
109110
"GOOGLE_FUNCTION_SIGNATURE_TYPE": b.funcType,
110111
"GOOGLE_RUNTIME": b.runtime,
112+
"GOOGLE_RUNTIME_VERSION": b.runtimeVersion,
111113
"X_GOOGLE_TARGET_PLATFORM": gcfTargetPlatform,
112114
},
113115
})

client/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ var (
3434
target = flag.String("builder-target", "", "function target to use in building. Required if -buildpacks=true")
3535
runtime = flag.String("builder-runtime", "", "runtime to use in building. Required if -buildpacks=true")
3636
tag = flag.String("builder-tag", "latest", "builder image tag to use in building")
37+
runtimeVersion = flag.String("builder-runtime-version", "", "runtime version used when building.")
3738
startDelay = flag.Uint("start-delay", 1, "Seconds to wait before sending HTTP request to command process")
3839
validateConcurrencyFlag = flag.Bool("validate-concurrency", false, "whether to validate concurrent requests can be handled, requires a function that sleeps for 1 second ")
3940
envs = flag.String("envs", "", "a comma separated string of additional runtime environment variables")
@@ -64,6 +65,7 @@ func main() {
6465
source: *source,
6566
target: *target,
6667
runtime: *runtime,
68+
runtimeVersion: *runtimeVersion,
6769
functionSignature: *functionSignature,
6870
declarativeSignature: *declarativeSignature,
6971
tag: *tag,

client/validate.go

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ type validatorParams struct {
3333
source string
3434
target string
3535
runtime string
36+
runtimeVersion string
3637
tag string
3738
functionSignature string
3839
declarativeSignature string
@@ -53,13 +54,13 @@ type validator struct {
5354

5455
func newValidator(params validatorParams) *validator {
5556
v := validator{
56-
validateMapping: params.validateMapping,
57-
validateConcurrency: params.validateConcurrency,
58-
functionSignature: params.functionSignature,
57+
validateMapping: params.validateMapping,
58+
validateConcurrency: params.validateConcurrency,
59+
functionSignature: params.functionSignature,
5960
declarativeSignature: params.declarativeSignature,
60-
functionOutputFile: params.outputFile,
61-
stdoutFile: defaultStdoutFile,
62-
stderrFile: defaultStderrFile,
61+
functionOutputFile: params.outputFile,
62+
stdoutFile: defaultStdoutFile,
63+
stderrFile: defaultStderrFile,
6364
}
6465

6566
if !params.useBuildpacks {
@@ -75,12 +76,13 @@ func newValidator(params validatorParams) *validator {
7576
}
7677

7778
v.funcServer = &buildpacksFunctionServer{
78-
source: params.source,
79-
target: params.target,
80-
runtime: params.runtime,
81-
tag: params.tag,
82-
funcType: params.functionSignature,
83-
envs: params.envs,
79+
source: params.source,
80+
target: params.target,
81+
runtime: params.runtime,
82+
runtimeVersion: params.runtimeVersion,
83+
tag: params.tag,
84+
funcType: params.functionSignature,
85+
envs: params.envs,
8486
}
8587
return &v
8688
}
@@ -194,7 +196,7 @@ func (v validator) validateTyped(url string) error {
194196
if !reflect.DeepEqual(resJson.Payload, req) {
195197
return fmt.Errorf("Got response.Payload = %v, wanted %v", resJson.Payload, req)
196198
}
197-
199+
198200
return nil
199201
}
200202

0 commit comments

Comments
 (0)