-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add buildpacks configuration for ruby27
PiperOrigin-RevId: 326113166 Change-Id: I00b66f0ffd94d180da776f5a7ab1c93f44ea55c8
- Loading branch information
Showing
8 changed files
with
240 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
load("//tools:defs.bzl", "builder") | ||
|
||
package(default_visibility = ["//builders/gcf/ruby27/acceptance:__pkg__"]) | ||
|
||
licenses(["notice"]) | ||
|
||
builder( | ||
name = "builder", | ||
buildpacks = [ | ||
"//cmd/ruby/functions_framework:functions_framework.tgz", | ||
"//cmd/ruby/bundle:bundle.tgz", | ||
"//cmd/utils/archive_source:archive_source.tgz", | ||
"//cmd/utils/label:label.tgz", | ||
], | ||
image = "gcf/ruby27", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") | ||
|
||
licenses(["notice"]) | ||
|
||
exports_files(["config.yaml"]) | ||
|
||
go_library( | ||
name = "acceptance", | ||
srcs = ["acceptance.go"], | ||
importpath = "github.com/GoogleCloudPlatform/buildpacks/" + package_name(), | ||
) | ||
|
||
go_test( | ||
name = "acceptance_test", | ||
size = "enormous", | ||
srcs = ["acceptance_test.go"], | ||
args = [ | ||
"-test-data=$(location //builders/testdata/ruby:functions)", | ||
"-structure-test-config=$(location :config.yaml)", | ||
"-builder-source=$(location //builders/gcf/ruby27:builder.tar)", | ||
"-builder-prefix=gcfruby27-acceptance-test-", | ||
], | ||
data = [ | ||
":config.yaml", | ||
"//builders/gcf/ruby27:builder.tar", | ||
"//builders/testdata/ruby:functions", | ||
], | ||
embed = [":acceptance"], | ||
rundir = ".", | ||
tags = [ | ||
"local", | ||
], | ||
deps = ["//pkg/acceptance"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright 2020 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// Package acceptance implements acceptance tests for a buildpack builder. | ||
package acceptance |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// Copyright 2020 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
package acceptance | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/GoogleCloudPlatform/buildpacks/pkg/acceptance" | ||
) | ||
|
||
func init() { | ||
acceptance.DefineFlags() | ||
} | ||
|
||
func TestAcceptance(t *testing.T) { | ||
builder, cleanup := acceptance.CreateBuilder(t) | ||
t.Cleanup(cleanup) | ||
|
||
testCases := []acceptance.Test{ | ||
{ | ||
Name: "function with dependencies", | ||
App: "with_dependencies", | ||
}, | ||
{ | ||
Name: "function with runtime env var", | ||
App: "with_env_var", | ||
RunEnv: []string{"FOO=foo"}, | ||
}, | ||
{ | ||
Name: "function in fn_source file", | ||
App: "with_fn_source", | ||
Env: []string{"GOOGLE_FUNCTION_SOURCE=sub_dir/custom_file.rb"}, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
tc := tc | ||
t.Run(tc.Name, func(t *testing.T) { | ||
t.Parallel() | ||
|
||
tc.Path = "/testFunction" | ||
tc.Env = append(tc.Env, | ||
"GOOGLE_FUNCTION_TARGET=testFunction", | ||
"GOOGLE_RUNTIME=ruby27", | ||
) | ||
tc.FilesMustExist = append(tc.FilesMustExist, | ||
"/layers/google.utils.archive-source/src/source-code.tar.gz", | ||
"/workspace/.googlebuild/source-code.tar.gz", | ||
) | ||
|
||
acceptance.TestApp(t, builder, tc) | ||
}) | ||
} | ||
} | ||
|
||
func TestFailures(t *testing.T) { | ||
builder, cleanup := acceptance.CreateBuilder(t) | ||
t.Cleanup(cleanup) | ||
|
||
testCases := []acceptance.FailureTest{ | ||
{ | ||
App: "fail_ruby_version", | ||
MustMatch: "but your Gemfile specified", | ||
}, | ||
{ | ||
App: "fail_framework_missing", | ||
MustMatch: "unable to execute functions-framework", | ||
}, | ||
{ | ||
Name: "must fail due to missing source file", | ||
App: "with_dependencies", | ||
Env: []string{"GOOGLE_FUNCTION_SOURCE=missing_file.rb"}, | ||
MustMatch: "GOOGLE_FUNCTION_SOURCE specified file 'missing_file.rb' but it does not exist", | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
tc := tc | ||
t.Run(tc.App, func(t *testing.T) { | ||
t.Parallel() | ||
|
||
tc.Env = append(tc.Env, | ||
"GOOGLE_FUNCTION_TARGET=testFunction", | ||
"GOOGLE_RUNTIME=ruby27", | ||
) | ||
|
||
acceptance.TestBuildFailure(t, builder, tc) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Copyright 2020 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# Test container structure using a centigrate image with a custom entrypoint. | ||
|
||
# See https://github.com/GoogleContainerTools/container-structure-test for the configuration format. | ||
|
||
schemaVersion: '2.0.0' | ||
|
||
metadataTest: | ||
env: | ||
- key: PORT | ||
value: 8080 | ||
exposedPorts: ['8080'] | ||
entrypoint: ['/cnb/lifecycle/launcher'] | ||
cmd: [] | ||
workdir: '/srv' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
description = "Builder for the GCF Ruby 2.6 runtime" | ||
|
||
[[buildpacks]] | ||
id = "google.ruby.bundle" | ||
uri = "bundle.tgz" | ||
|
||
[[buildpacks]] | ||
id = "google.ruby.functions-framework" | ||
uri = "functions_framework.tgz" | ||
|
||
[[buildpacks]] | ||
id = "google.utils.archive-source" | ||
uri = "archive_source.tgz" | ||
|
||
[[buildpacks]] | ||
id = "google.utils.label" | ||
uri = "label.tgz" | ||
|
||
[[order]] | ||
|
||
[[order.group]] | ||
id = "google.utils.archive-source" | ||
|
||
[[order.group]] | ||
id = "google.ruby.bundle" | ||
|
||
[[order.group]] | ||
id = "google.ruby.functions-framework" | ||
|
||
[[order.group]] | ||
id = "google.utils.label" | ||
|
||
[stack] | ||
id = "google.ruby27" | ||
build-image = "gcr.io/gae-runtimes/buildpacks/ruby27/build" | ||
run-image = "gcr.io/gae-runtimes/buildpacks/ruby27/run" | ||
|
||
[lifecycle] | ||
version = "0.9.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters