Skip to content

Commit

Permalink
Update build pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
hardikdr committed Sep 22, 2020
1 parent a65adfa commit 512a3de
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 24 deletions.
8 changes: 4 additions & 4 deletions .ci/build
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ fi
# The `go <cmd>` commands requires to see the target repository to be part of a
# Go workspace. Thus, if we are not yet in a Go workspace, let's create one
# temporarily by using symbolic links.
if [[ "${SOURCE_PATH}" != *"src/github.com/gardener/autoscaler" ]]; then
SOURCE_SYMLINK_PATH="${SOURCE_PATH}/tmp/src/github.com/gardener/autoscaler"
if [[ "${SOURCE_PATH}" != *"src/k8s.io/autoscaler" ]]; then
SOURCE_SYMLINK_PATH="${SOURCE_PATH}/tmp/src/k8s.io/autoscaler"
if [[ -d "${SOURCE_PATH}/tmp" ]]; then
rm -rf "${SOURCE_PATH}/tmp"
fi
mkdir -p "${SOURCE_PATH}/tmp/src/github.com/gardener"
mkdir -p "${SOURCE_PATH}/tmp/src/k8s.io"
ln -s "${SOURCE_PATH}" "${SOURCE_SYMLINK_PATH}"
cd "${SOURCE_SYMLINK_PATH}"

Expand All @@ -63,7 +63,7 @@ if [[ -z "$LOCAL_BUILD" ]]; then
go build \
-a \
-v \
-o ${BINARY_PATH}/cluster-autoscaler/rel/cluster-autoscaler \
-o ${BINARY_PATH}/cluster-autoscaler/cluster-autoscaler \
cluster-autoscaler/main.go

# If the LOCAL_BUILD environment variable is set, we simply run `go build`.
Expand Down
9 changes: 5 additions & 4 deletions .ci/check
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ fi
# The `go <cmd>` commands requires to see the target repository to be part of a
# Go workspace. Thus, if we are not yet in a Go workspace, let's create one
# temporarily by using symbolic links.
if [[ "${SOURCE_PATH}" != *"src/github.com/gardener/autoscaler" ]]; then
SOURCE_SYMLINK_PATH="${SOURCE_PATH}/tmp/src/github.com/gardener/autoscaler"
if [[ "${SOURCE_PATH}" != *"src/k8s.io/autoscaler" ]]; then
SOURCE_SYMLINK_PATH="${SOURCE_PATH}/tmp/src/k8s.io/autoscaler"
if [[ -d "${SOURCE_PATH}/tmp" ]]; then
rm -rf "${SOURCE_PATH}/tmp"
fi
mkdir -p "${SOURCE_PATH}/tmp/src/github.com/gardener"
mkdir -p "${SOURCE_PATH}/tmp/src/k8s.io"
ln -s "${SOURCE_PATH}" "${SOURCE_SYMLINK_PATH}"
cd "${SOURCE_SYMLINK_PATH}"

Expand All @@ -50,10 +50,11 @@ fi

# Install Golint (linting tool).
go get -u github.com/golang/lint/golint
go get -u golang.org/x/lint/golint

###############################################################################

PACKAGES="$(go list -e ./... | grep -vE '/tmp/|/vendor/')"
LINT_FOLDERS="$(echo ${PACKAGES} | sed "s|github.com/gardener/autoscaler/cluster-autoscaler|.|g")"
LINT_FOLDERS="$(echo ${PACKAGES} | sed "s|k8s.io/autoscaler/cluster-autoscaler|.|g")"

#TODO: To add lint checking, after fixing issues
6 changes: 2 additions & 4 deletions .ci/pipeline_definitions
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@ autoscaler:
dockerfile: 'Dockerfile'
dir: 'cluster-autoscaler'
steps:
check:
image: 'eu.gcr.io/gardener-project/gardener/autoscaler/autoscaling-builder:0.2'
test:
image: 'eu.gcr.io/gardener-project/gardener/autoscaler/autoscaling-builder:0.2'
image: 'golang:1.15.0'
build:
image: 'eu.gcr.io/gardener-project/gardener/autoscaler/autoscaling-builder:0.2'
image: 'golang:1.15.0'
output_dir: 'binary'
jobs:
head-update:
Expand Down
9 changes: 5 additions & 4 deletions .ci/test
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ fi
# The `go <cmd>` commands requires to see the target repository to be part of a
# Go workspace. Thus, if we are not yet in a Go workspace, let's create one
# temporarily by using symbolic links.
if [[ "${SOURCE_PATH}" != *"src/github.com/gardener/autoscaler" ]]; then
SOURCE_SYMLINK_PATH="${SOURCE_PATH}/tmp/src/github.com/gardener/autoscaler"
if [[ "${SOURCE_PATH}" != *"src/k8s.io/autoscaler" ]]; then
SOURCE_SYMLINK_PATH="${SOURCE_PATH}/tmp/src/k8s.io/autoscaler"
if [[ -d "${SOURCE_PATH}/tmp" ]]; then
rm -rf "${SOURCE_PATH}/tmp"
fi
mkdir -p "${SOURCE_PATH}/tmp/src/github.com/gardener"
mkdir -p "${SOURCE_PATH}/tmp/src/k8s.io"
ln -s "${SOURCE_PATH}" "${SOURCE_SYMLINK_PATH}"
cd "${SOURCE_SYMLINK_PATH}"

Expand All @@ -50,7 +50,8 @@ fi

##############################################################################

go test $(go list ./... | grep -v /vendor/)
go test $(go list ./cluster-autoscaler/... | grep -v cloudprovider | grep -v vendor)
go test $(go list ./cluster-autoscaler/cloudprovider/mcm/... | grep -v vendor)

#TODO: Return success failure properly
echo "CI tests are done"
4 changes: 2 additions & 2 deletions cluster-autoscaler/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
# 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.
ARG BASEIMAGE=gcr.io/distroless/static:latest
ARG BASEIMAGE=gcr.io/distroless/base:latest
FROM $BASEIMAGE
LABEL maintainer="Marcin Wielgus <[email protected]>"

COPY cluster-autoscaler /
CMD ["/cluster-autoscaler"]
CMD ["/cluster-autoscaler"]
7 changes: 4 additions & 3 deletions cluster-autoscaler/cloudprovider/mcm/mcm_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"testing"

"github.com/stretchr/testify/assert"
apiv1 "k8s.io/api/core/v1"
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider"
kubeletapis "k8s.io/kubernetes/pkg/kubelet/apis"
)
Expand All @@ -33,9 +34,9 @@ func TestBuildGenericLabels(t *testing.T) {
},
Region: "us-east-1",
}, "sillyname")
assert.Equal(t, "us-east-1", labels[kubeletapis.LabelZoneRegion])
assert.Equal(t, "sillyname", labels[kubeletapis.LabelHostname])
assert.Equal(t, "c4.large", labels[kubeletapis.LabelInstanceType])
assert.Equal(t, "us-east-1", labels[apiv1.LabelZoneRegion])
assert.Equal(t, "sillyname", labels[apiv1.LabelHostname])
assert.Equal(t, "c4.large", labels[apiv1.LabelInstanceType])
assert.Equal(t, cloudprovider.DefaultArch, labels[kubeletapis.LabelArch])
assert.Equal(t, cloudprovider.DefaultOS, labels[kubeletapis.LabelOS])
}
6 changes: 3 additions & 3 deletions cluster-autoscaler/hack/update-vendor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@ set +o errexit
# Add dependencies from go.mod-extra to go.mod
# Propagate require entries to both require and replace
for go_mod_extra in ${GO_MOD_EXTRA_FILES}; do
go mod edit -json ${go_mod_extra} | jq -r '.Require[]? | "-require \(.Path)@\(.Version)"' | xargs -t go mod edit >&${BASH_XTRACEFD} 2>&1
go mod edit -json ${go_mod_extra} | jq -r '.Require[]? | "-replace \(.Path)=\(.Path)@\(.Version)"' | xargs -t go mod edit >&${BASH_XTRACEFD} 2>&1
go mod edit -json ${go_mod_extra} | jq -r '.Require[]? | "-require \(.Path)@\(.Version)"' | xargs -t -r go mod edit >&${BASH_XTRACEFD} 2>&1
go mod edit -json ${go_mod_extra} | jq -r '.Require[]? | "-replace \(.Path)=\(.Path)@\(.Version)"' | xargs -t -r go mod edit >&${BASH_XTRACEFD} 2>&1
# And add explicit replace entries
go mod edit -json ${go_mod_extra} | jq -r '.Replace[]? | "-replace \(.Old.Path)=\(.New.Path)@\(.New.Version)"' | sed "s/@null//g" |xargs -t go mod edit >&${BASH_XTRACEFD} 2>&1
go mod edit -json ${go_mod_extra} | jq -r '.Replace[]? | "-replace \(.Old.Path)=\(.New.Path)@\(.New.Version)"' | sed "s/@null//g" |xargs -t -r go mod edit >&${BASH_XTRACEFD} 2>&1
done
# Add k8s.io/kubernetes dependency
go mod edit -require k8s.io/[email protected]
Expand Down

0 comments on commit 512a3de

Please sign in to comment.