Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/buildpack-integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ on:
type: string
default: ''
required: false
builder-url:
description: Builder image including builder tag to use while building. (e.g. gcr.io/gae-runtimes/buildpacks/go/builder:latest or gcr.io/buildpacks/builder:latest )
type: string
default: ''
required: false
event-builder-source:
description: Background function source; relative to repo root
type: string
Expand Down Expand Up @@ -162,6 +167,7 @@ jobs:
-builder-runtime=${{ inputs.builder-runtime }} \
-builder-runtime-version=${{ inputs.builder-runtime-version }} \
-builder-tag=${{ inputs.builder-tag }} \
-builder-url=${{ inputs.builder-url }} \
-start-delay=${{ inputs.start-delay }} \
-output-file=${{ inputs.output-file }} \
-validate-mapping=false
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/buildpack-integration-workflow-validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Buildpack Integration Test Workflow Validation
on:
push:
branches:
- main
pull_request:
jobs:
validate-workflow:
strategy:
matrix:
builder-url: ['gcr.io/gae-runtimes/buildpacks/go/builder:latest', '']
uses: ./.github/workflows/buildpack-integration-test.yml
with:
builder-runtime: 'go113'
builder-runtime-version: '1.13'
http-builder-source: 'testdata'
http-builder-target: 'HTTP'
cloudevent-builder-source: ''
cloudevent-builder-target: ''
builder-url: ${{ matrix.builder-url }}
conformance-client-version: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ jobs:
-builder-source='testdata' \
-builder-target='HTTP' \
-builder-runtime='go113' \
-builder-runtime-version='1.13'
-builder-runtime-version='1.13' \
-builder-url='gcr.io/gae-runtimes/buildpacks/go/builder:latest'
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ Frameworks to the Functions Framework contract.
| `-builder-target` | string | `""` | Function target to use in building. Required if `-buildpacks=true`. |
| `-builder-runtime` | string | `""` | Runtime to use in building. Required if `-buildpacks=true`. |
| `-builder-runtime-version` | string | `""` | Runtime version used while building. Buildpack will use the latest version if flag is not specified. |
| `-builder-tag` | string | `"latest"` | Builder image tag to use in building. |
| `-builder-tag` | string | `"latest"` | Builder image tag to use in building. Ignored if `-builder-url` is specified. |
| `-builder-url` | string | `""` | Builder image url to use in building including tag. Client defaults to `gcr.io/gae-runtimes/buildpacks/<language>/builder:<builder-tag>` if none is specified. |
| `-start-delay` | uint | `1` | Seconds to wait before sending HTTP request to command process. |
| `-envs` | string | `""` | A comma separated string of additional runtime environment variables. |

Expand Down
3 changes: 3 additions & 0 deletions action/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ inputs:
runtimeVersion:
description: 'function runtime version, uses the latest version if not specified (e.g. 3.7.4 for python37 runtime)'
default: ''
builderURL:
description: 'builder url to use when building'
default: ''
tag:
description: 'GCR tag to use for builder image'
default: 'latest'
Expand Down
2 changes: 2 additions & 0 deletions action/dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion action/dist/index.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions action/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ async function run() {
const target = core.getInput('target');
const runtime = core.getInput('runtime');
const runtimeVersion = core.getInput('runtimeVersion');
const builderURL = core.getInput('builderURL');
const tag = core.getInput('tag');
const useBuildpacks = core.getInput('useBuildpacks');
const cmd = core.getInput('cmd');
Expand Down Expand Up @@ -67,6 +68,7 @@ async function run() {
`-builder-runtime=${runtime}`,
`-builder-runtime-version=${runtimeVersion}`,
`-builder-tag=${tag}`,
`-builder-url=${builderURL}`,
`-buildpacks=${useBuildpacks}`,
`-cmd=${cmd}`,
`-start-delay=${startDelay}`,
Expand Down
14 changes: 9 additions & 5 deletions client/buildpacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ import (
)

const (
image = "conformance-test-func"
builderURL = "gcr.io/gae-runtimes/buildpacks/%s/builder:%s"
gcfTargetPlatform = "gcf"
image = "conformance-test-func"
defaultBuilderURLTemplate = "gcr.io/gae-runtimes/buildpacks/%s/builder:%s"
gcfTargetPlatform = "gcf"
)

type buildpacksFunctionServer struct {
Expand All @@ -49,6 +49,7 @@ type buildpacksFunctionServer struct {
logStderr *os.File
stdoutFile string
stderrFile string
builderURL string
envs []string
}

Expand Down Expand Up @@ -123,11 +124,14 @@ func (b *buildpacksFunctionServer) build(ctx context.Context) error {
var runtimeLanguageRegexp = regexp.MustCompile(`^[a-zA-Z]+`)

func (b *buildpacksFunctionServer) buildpackBuilderImage() (string, error) {
if b.builderURL != "" {
return b.builderURL, nil
}
runtimeLanguage := runtimeLanguageRegexp.FindString(b.runtime)
if runtimeLanguage == "" {
return "", fmt.Errorf("Invalid runtime format. Runtime should start with language followed by version. Example: go119, python311. Got %q", b.runtime)
return "", fmt.Errorf("invalid runtime format. Runtime should start with language followed by version. Example: go119, python311. Got %q", b.runtime)
}
return fmt.Sprintf(builderURL, runtimeLanguage, b.tag), nil
return fmt.Sprintf(defaultBuilderURLTemplate, runtimeLanguage, b.tag), nil
}

func (b *buildpacksFunctionServer) run() (func(), error) {
Expand Down
8 changes: 4 additions & 4 deletions client/buildpacks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestBuildpackBuilderImage(t *testing.T) {
name: "Extracts go from go119",
runtime: "go119",
tag: "1.2.3",
wantBuilderURL: fmt.Sprintf(builderURL, "go", "1.2.3"),
wantBuilderURL: fmt.Sprintf(defaultBuilderURLTemplate, "go", "1.2.3"),
},
{
name: "Fails with incorrect runtime format",
Expand All @@ -29,19 +29,19 @@ func TestBuildpackBuilderImage(t *testing.T) {
name: "Extracts php from php82",
runtime: "php82",
tag: "latest",
wantBuilderURL: fmt.Sprintf(builderURL, "php", "latest"),
wantBuilderURL: fmt.Sprintf(defaultBuilderURLTemplate, "php", "latest"),
},
{
name: "Extracts nodejs from nodejs18",
runtime: "nodejs18",
tag: "18",
wantBuilderURL: fmt.Sprintf(builderURL, "nodejs", "18"),
wantBuilderURL: fmt.Sprintf(defaultBuilderURLTemplate, "nodejs", "18"),
},
{
name: "Extracts dotnet from dotnet6",
runtime: "dotnet6",
tag: "123",
wantBuilderURL: fmt.Sprintf(builderURL, "dotnet", "123"),
wantBuilderURL: fmt.Sprintf(defaultBuilderURLTemplate, "dotnet", "123"),
},
}

Expand Down
2 changes: 2 additions & 0 deletions client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var (
runtime = flag.String("builder-runtime", "", "runtime to use in building. Required if -buildpacks=true")
tag = flag.String("builder-tag", "latest", "builder image tag to use in building")
runtimeVersion = flag.String("builder-runtime-version", "", "runtime version used when building.")
builderURL = flag.String("builder-url", "", "builder image url used when building docker container with pack.")
startDelay = flag.Uint("start-delay", 1, "Seconds to wait before sending HTTP request to command process")
validateConcurrencyFlag = flag.Bool("validate-concurrency", false, "whether to validate concurrent requests can be handled, requires a function that sleeps for 1 second ")
envs = flag.String("envs", "", "a comma separated string of additional runtime environment variables")
Expand Down Expand Up @@ -71,6 +72,7 @@ func main() {
tag: *tag,
validateConcurrency: *validateConcurrencyFlag,
envs: validationRuntimeEnv,
builderURL: *builderURL,
})

if err := v.runValidation(); err != nil {
Expand Down
2 changes: 2 additions & 0 deletions client/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type validatorParams struct {
target string
runtime string
runtimeVersion string
builderURL string
tag string
functionSignature string
declarativeSignature string
Expand Down Expand Up @@ -83,6 +84,7 @@ func newValidator(params validatorParams) *validator {
tag: params.tag,
funcType: params.functionSignature,
envs: params.envs,
builderURL: params.builderURL,
}
return &v
}
Expand Down