1
0
mirror of https://github.com/ko-build/ko.git synced 2025-02-07 19:30:23 +02:00

Add integration test config to repo

Add files to repo instead of dynamically generate during the integration
test.

Also document default values of `dir` and `main`.
This commit is contained in:
Halvard Skogsrud 2021-10-26 18:27:51 +11:00
parent 103ff5b2a8
commit 00d0a34583
7 changed files with 101 additions and 29 deletions

View File

@ -135,7 +135,7 @@ configuration section in your `.ko.yaml`.
```yaml
builds:
- id: foo
dir: .
dir: . # default is .
main: ./foobar/foo
env:
- GOPRIVATE=git.internal.example.com,source.developers.google.com
@ -148,7 +148,7 @@ builds:
- -X main.version={{.Env.VERSION}}
- id: bar
dir: ./bar
main: .
main: . # default is .
env:
- GOCACHE=/workspace/.gocache
ldflags:

View File

@ -95,37 +95,12 @@ GO111MODULE=on ./ko/ko build --local github.com/go-training/helloworld && exit 1
popd || exit 1
echo "8. On outside with build config specifying the test module builds."
ko_exec_dir=$(pwd)
pushd "$(mktemp -d)" || exit 1
for app in foo bar ; do
mkdir -p $app/cmd || exit 1
pushd $app || exit 1
GO111MODULE=on go mod init example.com/$app || exit 1
cat << EOF > ./cmd/main.go || exit 1
package main
import "fmt"
func main() {
fmt.Println("$app")
}
EOF
popd || exit 1
done
cat << EOF > .ko.yaml || exit 1
builds:
- id: foo-app
dir: ./foo
main: ./cmd
- id: bar-app
dir: ./bar
main: ./cmd
EOF
pushd test/build-configs || exit 1
for app in foo bar ; do
# test both local and fully qualified import paths
for prefix in example.com . ; do
import_path=$prefix/$app/cmd
RESULT="$(GO111MODULE=on GOFLAGS="" "$ko_exec_dir"/ko publish --local $import_path | grep "$FILTER" | xargs -I% docker run %)"
RESULT="$(GO111MODULE=on GOFLAGS="" ../../ko build --local $import_path | grep "$FILTER" | xargs -I% docker run %)"
if [[ "$RESULT" != *"$app"* ]]; then
echo "Test FAILED for $import_path. Saw $RESULT but expected $app" && exit 1
else

View File

@ -0,0 +1,21 @@
# Copyright 2021 Google LLC All Rights Reserved.
#
# 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.
builds:
- id: foo-app
dir: ./foo
main: ./cmd
- id: bar-app
dir: ./bar
main: ./cmd

View File

@ -0,0 +1,21 @@
// Copyright 2021 Google LLC All Rights Reserved.
//
// 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 main
import "fmt"
func main() {
fmt.Println("bar")
}

View File

@ -0,0 +1,17 @@
// Copyright 2021 Google LLC All Rights Reserved.
//
// 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.
module example.com/bar
go 1.16

View File

@ -0,0 +1,21 @@
// Copyright 2021 Google LLC All Rights Reserved.
//
// 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 main
import "fmt"
func main() {
fmt.Println("foo")
}

View File

@ -0,0 +1,17 @@
// Copyright 2021 Google LLC All Rights Reserved.
//
// 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.
module example.com/foo
go 1.16