mirror of
https://github.com/ko-build/ko.git
synced 2025-11-06 09:19:12 +02:00
* Add trimpath arg to gobuild * Add build constraints for trimpath usage * Reduce duplications across go versions * Change trimpath fn-files for better names * Attempt to apply with minikube on Travis * Attempt to apply with KinD on Travis * Install kind thru curl to not affect build
This commit is contained in:
committed by
jonjohnsonjr
parent
a6277d0a45
commit
be4e1ffdd6
22
.travis.yml
22
.travis.yml
@@ -1,18 +1,30 @@
|
||||
sudo: false
|
||||
sudo: required
|
||||
|
||||
dist: trusty
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
language:
|
||||
- go
|
||||
|
||||
go:
|
||||
- "1.12"
|
||||
- "1.13"
|
||||
- '1.12'
|
||||
- '1.13'
|
||||
|
||||
git:
|
||||
depth: 1
|
||||
|
||||
install: true
|
||||
install: true # skipping the default go dependencies install step
|
||||
|
||||
before_script:
|
||||
# Download and install kubectl
|
||||
- curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
|
||||
# Download and install KinD
|
||||
- curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/v0.5.1/kind-$(uname)-amd64 && chmod +x ./kind && sudo mv kind /usr/local/bin/
|
||||
# Create a new Kubernetes cluster using KinD
|
||||
- kind create cluster
|
||||
- export KUBECONFIG=$(kind get kubeconfig-path)
|
||||
|
||||
script:
|
||||
# Verify that all source files are correctly formatted.
|
||||
@@ -20,7 +32,7 @@ script:
|
||||
|
||||
- go clean -i
|
||||
- go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...
|
||||
|
||||
- bash integration_test.sh
|
||||
# TODO: Set up coverage.
|
||||
#after_success:
|
||||
# - bash <(curl -s https://codecov.io/bash)
|
||||
|
||||
2
integration_test.sh
Normal file
2
integration_test.sh
Normal file
@@ -0,0 +1,2 @@
|
||||
go install ./cmd/ko
|
||||
ko apply -f ./cmd/ko/test -L
|
||||
@@ -154,13 +154,14 @@ func build(ip string, platform v1.Platform, disableOptimizations bool) (string,
|
||||
}
|
||||
file := filepath.Join(tmpDir, "out")
|
||||
|
||||
args := make([]string, 0, 6)
|
||||
args := make([]string, 0, 7)
|
||||
args = append(args, "build")
|
||||
if disableOptimizations {
|
||||
// Disable optimizations (-N) and inlining (-l).
|
||||
args = append(args, "-gcflags", "all=-N -l")
|
||||
}
|
||||
args = append(args, "-o", file)
|
||||
args = addGo113TrimPathFlag(args)
|
||||
args = append(args, ip)
|
||||
cmd := exec.Command("go", args...)
|
||||
|
||||
|
||||
22
pkg/build/trimpath_113.go
Normal file
22
pkg/build/trimpath_113.go
Normal file
@@ -0,0 +1,22 @@
|
||||
// Copyright 2018 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.
|
||||
//
|
||||
// house flag adding function for go1.13 and later version with -trimpath available
|
||||
// +build go1.13
|
||||
|
||||
package build
|
||||
|
||||
func addGo113TrimPathFlag(args []string) []string {
|
||||
return append(args, "-trimpath")
|
||||
}
|
||||
22
pkg/build/trimpath_pre113.go
Normal file
22
pkg/build/trimpath_pre113.go
Normal file
@@ -0,0 +1,22 @@
|
||||
// Copyright 2018 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.
|
||||
//
|
||||
// house placeholder function for go1.12 and earlier version without -trimpath
|
||||
// +build !go1.13
|
||||
|
||||
package build
|
||||
|
||||
func addGo113TrimPathFlag(args []string) []string {
|
||||
return args
|
||||
}
|
||||
Reference in New Issue
Block a user