Skip to content

Commit 5f2a796

Browse files
authored
fix: conformance test should set env variables that reflect prod (#122)
* fix: conformance test should set env variables that reflect prod * expose 'envs' option to allow overriding runtime env
1 parent 2f5f319 commit 5f2a796

File tree

6 files changed

+14
-2
lines changed

6 files changed

+14
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ Frameworks to the Functions Framework contract.
9191
| `-builder-runtime` | string | `""` | Runtime to use in building. Required if `-buildpacks=true`. |
9292
| `-builder-tag` | string | `"latest"` | Builder image tag to use in building. |
9393
| `-start-delay` | uint | `1` | Seconds to wait before sending HTTP request to command process. |
94+
| `-envs` | string | `""` | A comma separated string of additional runtime environment variables. |
9495

9596
</nobr>
9697

action/action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ inputs:
4343
workingDirectory:
4444
description: 'The subdirectory in which the conformance tests should run'
4545
default: ""
46+
runtimeEnvs:
47+
description: 'A comma separated list of runtime environment variable overrides'
48+
default: ""
4649
runs:
4750
using: 'node12'
4851
main: 'dist/index.js'

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
@@ -31,6 +31,7 @@ async function run() {
3131
const cmd = core.getInput('cmd');
3232
const startDelay = core.getInput('startDelay');
3333
const workingDirectory = core.getInput('workingDirectory');
34+
const runtimeEnvs = core.getInput('runtimeEnvs');
3435

3536
let cwd = process.cwd();
3637

@@ -67,6 +68,7 @@ async function run() {
6768
`-buildpacks=${useBuildpacks}`,
6869
`-cmd=${cmd}`,
6970
`-start-delay=${startDelay}`,
71+
`-envs=${runtimeEnvs}`,
7072
].filter((x) => !!x).join(' '));
7173
}
7274

client/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ func main() {
5252
*declarativeSignature = *functionSignature
5353
}
5454

55+
// Set runtime env vars that reflect https://cloud.google.com/functions/docs/configuring/env-var
56+
validationRuntimeEnv := []string{"FUNCTION_SIGNATURE_TYPE=" + *functionSignature}
57+
validationRuntimeEnv = append(validationRuntimeEnv, strings.Split(*envs, ",")...)
58+
5559
v := newValidator(validatorParams{
5660
validateMapping: *validateMapping,
5761
useBuildpacks: *useBuildpacks,
@@ -64,7 +68,7 @@ func main() {
6468
declarativeSignature: *declarativeSignature,
6569
tag: *tag,
6670
validateConcurrency: *validateConcurrencyFlag,
67-
envs: strings.Split(*envs, ","),
71+
envs: validationRuntimeEnv,
6872
})
6973

7074
if err := v.runValidation(); err != nil {

0 commit comments

Comments
 (0)