From 420af542505beda3ae29fd2743018dabb505efa7 Mon Sep 17 00:00:00 2001 From: Elijah Oyekunle Date: Mon, 1 Jul 2019 14:29:12 +0100 Subject: [PATCH 1/8] update scripts in package.json --- package.json | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e10e2c157e91..fc1d6de9d7d3 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,9 @@ "cluster:start": "./aio/scripts/start-cluster.sh", "cluster:stop": "./aio/scripts/stop-cluster.sh", "check": "concurrently \"npm run check:backend\" \"npm run check:frontend\" \"npm run check:license\" \"npm run check:i18n\"", - "check:backend": "golangci-lint run -c .golangci.yml src/app/backend/...", + "check:backend": "concurrently \"npm run check:backend:lint\" \"npm run check:backend:vendor\"", + "check:backend:lint": "golangci-lint run -c .golangci.yml src/app/backend/...", + "check:backend:vendor": "./aio/scripts/verify-vendor.sh", "check:frontend": "concurrently \"npm run check:frontend:ts\" \"npm run check:frontend:scss\" \"npm run check:frontend:html\"", "check:frontend:ts": "gts check", "check:frontend:scss": "./aio/scripts/format.sh --styles --check && ./node_modules/sass-lint/bin/sass-lint.js -c .sass-lint.yml 'src/app/frontend/**/*.scss' -v -q", @@ -44,7 +46,9 @@ "check:license": "gulp check-license-headers", "check:i18n": "ng xi18n --outFile ../i18n/messages.xlf", "fix": "concurrently \"npm run fix:backend\" \"npm run fix:frontend\" \"npm run fix:license\" \"npm run fix:i18n\"", - "fix:backend": "golangci-lint run -c .golangci.yml --fix src/app/backend/...", + "fix:backend": "concurrently \"npm run fix:backend:lint\" \"npm run fix:backend:vendor\"", + "fix:backend:lint": "golangci-lint run -c .golangci.yml --fix src/app/backend/...", + "fix:backend:vendor": "./aio/scripts/update-vendor.sh", "fix:frontend": "concurrently \"npm run fix:frontend:ts\" \"npm run fix:frontend:scss\" \"npm run fix:frontend:html\"", "fix:frontend:ts": "gts fix", "fix:frontend:scss": "scssfmt -r 'src/**/*.scss'", From 3a9f90185048dc1650e7cfffd2b45b655c6a06b2 Mon Sep 17 00:00:00 2001 From: Elijah Oyekunle Date: Mon, 1 Jul 2019 14:42:08 +0100 Subject: [PATCH 2/8] remove unnecessary before_install scripts --- .travis.yml | 4 ---- aio/scripts/update-vendor.sh | 1 + aio/scripts/verify-vendor.sh | 1 + 3 files changed, 2 insertions(+), 4 deletions(-) create mode 100644 aio/scripts/update-vendor.sh create mode 100644 aio/scripts/verify-vendor.sh diff --git a/.travis.yml b/.travis.yml index a449e4f817e0..55e20ad203b8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,10 +24,6 @@ before_install: - mkdir -p $GOPATH/src/github.com/ - mv $HOME/build/kubernetes $GOPATH/src/github.com/ - export TRAVIS_BUILD_DIR=$GOPATH/src/github.com/kubernetes/dashboard - - cd $TRAVIS_BUILD_DIR - - mkdir -p $TRAVIS_BUILD_DIR/.tmp/src/github.com/kubernetes/dashboard/src/app - - cp -r $TRAVIS_BUILD_DIR/src/app/backend $TRAVIS_BUILD_DIR/.tmp/src/github.com/kubernetes/dashboard/src/app - - ln -s $TRAVIS_BUILD_DIR/vendor $TRAVIS_BUILD_DIR/.tmp/src/github.com/kubernetes/dashboard/src/app/backend/vendor before_script: - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - diff --git a/aio/scripts/update-vendor.sh b/aio/scripts/update-vendor.sh new file mode 100644 index 000000000000..f1f641af19bf --- /dev/null +++ b/aio/scripts/update-vendor.sh @@ -0,0 +1 @@ +#!/usr/bin/env bash diff --git a/aio/scripts/verify-vendor.sh b/aio/scripts/verify-vendor.sh new file mode 100644 index 000000000000..f1f641af19bf --- /dev/null +++ b/aio/scripts/verify-vendor.sh @@ -0,0 +1 @@ +#!/usr/bin/env bash From a39b45dea9a7bdbe2906083922e10e327f1b1178 Mon Sep 17 00:00:00 2001 From: Elijah Oyekunle Date: Mon, 1 Jul 2019 15:07:19 +0100 Subject: [PATCH 3/8] add vendor verification --- aio/scripts/verify-vendor.sh | 84 ++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/aio/scripts/verify-vendor.sh b/aio/scripts/verify-vendor.sh index f1f641af19bf..658caebe2a0f 100644 --- a/aio/scripts/verify-vendor.sh +++ b/aio/scripts/verify-vendor.sh @@ -1 +1,85 @@ #!/usr/bin/env bash + +# Copyright 2015 The Kubernetes Authors. +# +# 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. + +set -o errexit +set -o nounset +set -o pipefail + +KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/../.. + +# create a nice clean place to put our new licenses +# must be in the user dir (e.g. KUBE_ROOT) in order for the docker volume mount +# to work with docker-machine on macs +mkdir -p "${KUBE_ROOT}/_tmp" +_tmpdir="$(mktemp -d "${KUBE_ROOT}/_tmp/kube-vendor.XXXXXX")" + +if [[ -z ${KEEP_TMP:-} ]]; then + KEEP_TMP=false +fi + +# Copy the contents of the kube directory into the nice clean place (which is NOT shaped like a GOPATH) +_kubetmp="${_tmpdir}" +mkdir -p "${_kubetmp}" +# should create ${_kubectmp}/kubernetes +git archive --format=tar --prefix=kubernetes/ "$(git write-tree)" | (cd "${_kubetmp}" && tar xf -) +_kubetmp="${_kubetmp}/kubernetes" + +pushd "${_kubetmp}" > /dev/null 2>&1 + # Destroy deps in the copy of the kube tree + rm -rf ./vendor + + # Recreate the vendor tree using the nice clean set we just downloaded + aio/scripts/update-vendor.sh +popd > /dev/null 2>&1 + +ret=0 + +pushd "${KUBE_ROOT}" > /dev/null 2>&1 + # Test for diffs + if ! _out="$(diff -Naupr --ignore-matching-lines='^\s*\"GoVersion\":' go.mod "${_kubetmp}/go.mod")"; then + echo "Your go.mod file is different:" >&2 + echo "${_out}" >&2 + echo "Vendor Verify failed." >&2 + echo "If you're seeing this locally, run the below command to fix your go.mod:" >&2 + echo "npm run fix:backend:vendor" >&2 + ret=1 + fi + + if ! _out="$(diff -Naupr -x "BUILD" -x "AUTHORS*" -x "CONTRIBUTORS*" vendor "${_kubetmp}/vendor")"; then + echo "Your vendored results are different:" >&2 + echo "${_out}" >&2 + echo "Vendor Verify failed." >&2 + echo "${_out}" > vendordiff.patch + echo "If you're seeing this locally, run the below command to fix your directories:" >&2 + echo "npm run fix:backend:vendor" >&2 + ret=1 + fi +popd > /dev/null 2>&1 + +if [[ ${ret} -gt 0 ]]; then + exit ${ret} +fi + +chmod -R +w "${_tmpdir}" +if [ "${KEEP_TMP}" == "true" ]; then + echo "Leaving ${_tmpdir} for you to examine or copy. Please delete it manually when finished. (rm -rf ${_tmpdir})" +else + echo "Removing ${_tmpdir}" + rm -rf "${_tmpdir}" +fi + +echo "Vendor Verified." +# ex: ts=2 sw=2 et filetype=sh From 57af412ae8605556d8176b7ed146599102d2bcab Mon Sep 17 00:00:00 2001 From: Elijah Oyekunle Date: Mon, 1 Jul 2019 15:17:15 +0100 Subject: [PATCH 4/8] add vendor update --- aio/scripts/update-vendor.sh | 12 ++++++++++++ aio/scripts/verify-vendor.sh | 8 ++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/aio/scripts/update-vendor.sh b/aio/scripts/update-vendor.sh index f1f641af19bf..35d35aa9afaa 100644 --- a/aio/scripts/update-vendor.sh +++ b/aio/scripts/update-vendor.sh @@ -1 +1,13 @@ #!/usr/bin/env bash + +TMP_DIR="${TMP_DIR:-$(mktemp -d /tmp/update-vendor.XXXX)}" + +go mod tidy -v + +go mod vendor + +# sort recorded packages for a given vendored dependency in modules.txt. +# `go mod vendor` outputs in imported order, which means slight go changes (or different platforms) can result in a differently ordered modules.txt. +# scan | prefix comment lines with the module name | sort field 1 | strip leading text on comment lines +awk '{if($1=="#") print $2 " " $0; else print}' < vendor/modules.txt | sort -k1,1 -s | sed 's/.*#/#/' > "${TMP_DIR}/modules.txt.tmp" +mv "${TMP_DIR}/modules.txt.tmp" vendor/modules.txt \ No newline at end of file diff --git a/aio/scripts/verify-vendor.sh b/aio/scripts/verify-vendor.sh index 658caebe2a0f..24f4aaa95fa8 100644 --- a/aio/scripts/verify-vendor.sh +++ b/aio/scripts/verify-vendor.sh @@ -69,10 +69,6 @@ pushd "${KUBE_ROOT}" > /dev/null 2>&1 fi popd > /dev/null 2>&1 -if [[ ${ret} -gt 0 ]]; then - exit ${ret} -fi - chmod -R +w "${_tmpdir}" if [ "${KEEP_TMP}" == "true" ]; then echo "Leaving ${_tmpdir} for you to examine or copy. Please delete it manually when finished. (rm -rf ${_tmpdir})" @@ -81,5 +77,9 @@ else rm -rf "${_tmpdir}" fi +if [[ ${ret} -gt 0 ]]; then + exit ${ret} +fi + echo "Vendor Verified." # ex: ts=2 sw=2 et filetype=sh From 34307cf0a24541b6795b41cf3f04da4ff939de6f Mon Sep 17 00:00:00 2001 From: Elijah Oyekunle Date: Mon, 1 Jul 2019 15:22:21 +0100 Subject: [PATCH 5/8] add echo statements --- aio/scripts/update-vendor.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/aio/scripts/update-vendor.sh b/aio/scripts/update-vendor.sh index 35d35aa9afaa..071deca2caed 100644 --- a/aio/scripts/update-vendor.sh +++ b/aio/scripts/update-vendor.sh @@ -2,12 +2,16 @@ TMP_DIR="${TMP_DIR:-$(mktemp -d /tmp/update-vendor.XXXX)}" +echo "vendor: running 'go mod tidy'" go mod tidy -v +echo "vendor: running 'go mod vendor'" go mod vendor # sort recorded packages for a given vendored dependency in modules.txt. # `go mod vendor` outputs in imported order, which means slight go changes (or different platforms) can result in a differently ordered modules.txt. # scan | prefix comment lines with the module name | sort field 1 | strip leading text on comment lines awk '{if($1=="#") print $2 " " $0; else print}' < vendor/modules.txt | sort -k1,1 -s | sed 's/.*#/#/' > "${TMP_DIR}/modules.txt.tmp" -mv "${TMP_DIR}/modules.txt.tmp" vendor/modules.txt \ No newline at end of file +mv "${TMP_DIR}/modules.txt.tmp" vendor/modules.txt + +echo "Vendor Updated" \ No newline at end of file From 48c1188e3ae635190cf9bfdd34dd0e93a65df140 Mon Sep 17 00:00:00 2001 From: Elijah Oyekunle Date: Mon, 1 Jul 2019 15:24:19 +0100 Subject: [PATCH 6/8] re-add a travis before_install --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 55e20ad203b8..cea07c22e761 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,6 +24,7 @@ before_install: - mkdir -p $GOPATH/src/github.com/ - mv $HOME/build/kubernetes $GOPATH/src/github.com/ - export TRAVIS_BUILD_DIR=$GOPATH/src/github.com/kubernetes/dashboard + - cd $TRAVIS_BUILD_DIR before_script: - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - From f6f0763e77875bae2cabdc849b7b6df75aa15bf6 Mon Sep 17 00:00:00 2001 From: Elijah Oyekunle Date: Mon, 1 Jul 2019 23:14:27 +0100 Subject: [PATCH 7/8] add vendor/ directory to gitignore --- .gitignore | 1 + .travis.yml | 1 - aio/scripts/update-vendor.sh | 14 ++++++++++++++ aio/scripts/verify-vendor.sh | 0 4 files changed, 15 insertions(+), 1 deletion(-) mode change 100644 => 100755 aio/scripts/update-vendor.sh mode change 100644 => 100755 aio/scripts/verify-vendor.sh diff --git a/.gitignore b/.gitignore index aada8fd38838..e63d24faf8b3 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ src/app/frontend/environments/version.ts # Local copies of dependencies that should stay on developers' local machines: node_modules/ +vendor/ # Build and test artifacts: .go_workspace/ diff --git a/.travis.yml b/.travis.yml index cea07c22e761..34fe33bf3fe8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,7 +40,6 @@ jobs: script: npm run check - script: npm run test:coverage after_success: - - rm -rf $TRAVIS_BUILD_DIR/.tmp - bash <(curl -s https://codecov.io/bash) - script: npm run cluster:start && npm run test:e2e - stage: deploy diff --git a/aio/scripts/update-vendor.sh b/aio/scripts/update-vendor.sh old mode 100644 new mode 100755 index 071deca2caed..88daa7925e09 --- a/aio/scripts/update-vendor.sh +++ b/aio/scripts/update-vendor.sh @@ -1,5 +1,19 @@ #!/usr/bin/env bash +# Copyright 2019 The Kubernetes Authors. +# +# 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. + TMP_DIR="${TMP_DIR:-$(mktemp -d /tmp/update-vendor.XXXX)}" echo "vendor: running 'go mod tidy'" diff --git a/aio/scripts/verify-vendor.sh b/aio/scripts/verify-vendor.sh old mode 100644 new mode 100755 From 064082bf319a8f0ddbf20cb85994c34490147911 Mon Sep 17 00:00:00 2001 From: Elijah Oyekunle Date: Mon, 1 Jul 2019 23:16:10 +0100 Subject: [PATCH 8/8] remove vendor dir verification --- aio/scripts/verify-vendor.sh | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/aio/scripts/verify-vendor.sh b/aio/scripts/verify-vendor.sh index 24f4aaa95fa8..b4d161766c70 100755 --- a/aio/scripts/verify-vendor.sh +++ b/aio/scripts/verify-vendor.sh @@ -20,9 +20,6 @@ set -o pipefail KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/../.. -# create a nice clean place to put our new licenses -# must be in the user dir (e.g. KUBE_ROOT) in order for the docker volume mount -# to work with docker-machine on macs mkdir -p "${KUBE_ROOT}/_tmp" _tmpdir="$(mktemp -d "${KUBE_ROOT}/_tmp/kube-vendor.XXXXXX")" @@ -57,16 +54,6 @@ pushd "${KUBE_ROOT}" > /dev/null 2>&1 echo "npm run fix:backend:vendor" >&2 ret=1 fi - - if ! _out="$(diff -Naupr -x "BUILD" -x "AUTHORS*" -x "CONTRIBUTORS*" vendor "${_kubetmp}/vendor")"; then - echo "Your vendored results are different:" >&2 - echo "${_out}" >&2 - echo "Vendor Verify failed." >&2 - echo "${_out}" > vendordiff.patch - echo "If you're seeing this locally, run the below command to fix your directories:" >&2 - echo "npm run fix:backend:vendor" >&2 - ret=1 - fi popd > /dev/null 2>&1 chmod -R +w "${_tmpdir}"