Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/PR.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: PR
on: pull_request
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: linters
run: make linters
continue-on-error: false
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ $(BUILD_DIR):
test: $(BUILD_DIR)
@ ./hack/gotest.sh -count=1 -race -short -timeout=90s $(SKAFFOLD_TEST_PACKAGES)
@ ./hack/checks.sh
@ ./hack/linters.sh

.PHONY: coverage
coverage: $(BUILD_DIR)
Expand All @@ -113,6 +114,10 @@ coverage: $(BUILD_DIR)
checks: $(BUILD_DIR)
@ ./hack/checks.sh

.PHONY: linters
linters: $(BUILD_DIR)
@ ./hack/linters.sh

.PHONY: quicktest
quicktest:
@ ./hack/gotest.sh -short -timeout=60s $(SKAFFOLD_TEST_PACKAGES)
Expand Down
4 changes: 0 additions & 4 deletions hack/checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ echo "Running validation scripts..."
scripts=(
"hack/check-schema-changes.sh"
"hack/check-skaffold-builder.sh"
"hack/boilerplate.sh"
"hack/gofmt.sh"
"hack/pedantic-imports.sh"
"hack/linter.sh"
"hack/check-samples.sh"
"hack/check-docs.sh"
"hack/test-generated-proto.sh"
Expand Down
18 changes: 8 additions & 10 deletions hack/linter.sh → hack/golangci-lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,29 @@
set -e -o pipefail

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
BIN=${DIR}/bin
VERSION=1.26.0

function install_linter() {
echo "Installing GolangCI-Lint"
${DIR}/install_golint.sh -b $GOPATH/bin v$VERSION
${DIR}/install_golint.sh -b ${BIN} v$VERSION
}

if ! [ -x "$(command -v golangci-lint)" ] ; then
if ! [ -x "$(command -v ${BIN}/golangci-lint)" ] ; then
install_linter
elif [[ $(golangci-lint --version | grep -c " $VERSION ") -eq 0 ]]
elif [[ $(${BIN}/golangci-lint --version | grep -c " $VERSION ") -eq 0 ]]
then
echo "required golangci-lint: v$VERSION"
echo "current version: $(golangci-lint --version)"
echo "reinstalling..."
rm $(which golangci-lint)
rm $(which ${BIN}/golangci-lint)
install_linter
fi

FLAGS=""
if [[ "${TRAVIS}" == "true" ]]; then
# Use less memory on Travis
# See https://github.com/golangci/golangci-lint#memory-usage-of-golangci-lint
export GOGC=5
FLAGS="-j1 -v --print-resources-usage"
if [[ "${CI}" == "true" ]]; then
FLAGS="-v --print-resources-usage"
fi

$GOPATH/bin/golangci-lint run ${FLAGS} -c ${DIR}/golangci.yml \
${BIN}/golangci-lint run ${FLAGS} -c ${DIR}/golangci.yml \
| awk '/out of memory/ || /Timeout exceeded/ {failed = 1}; {print}; END {exit failed}'
44 changes: 44 additions & 0 deletions hack/linters.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

# Copyright 2019 The Skaffold 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.

RED='\033[0;31m'
GREEN='\033[0;32m'
RESET='\033[0m'

echo "Running linters..."
scripts=(
"hack/boilerplate.sh"
"hack/gofmt.sh"
"hack/pedantic-imports.sh"
"hack/golangci-lint.sh"
)
fail=0
for s in "${scripts[@]}"; do
echo "RUN ${s}"

start=$(date +%s)
./$s
result=$?
end=$(date +%s)

if [[ $result -eq 0 ]]; then
echo -e "${GREEN}PASSED${RESET} ${s} in $((end-start))s"
else
echo -e "${RED}FAILED${RESET} ${s}"
fail=1
fi
done
exit $fail