From 6ec6e3d88ef4de679c486e8e81d43374ddf87a6d Mon Sep 17 00:00:00 2001 From: Tariq Ibrahim Date: Thu, 20 Aug 2020 16:32:41 -0700 Subject: [PATCH] add license header check to the CI --- Makefile | 22 ++++++++++++++++++++-- internal/config/config.go | 16 ++++++++++++++++ internal/testutils/init.go | 16 ++++++++++++++++ provider/scaleway/interface.go | 16 ++++++++++++++++ provider/scaleway/scaleway_test.go | 16 ++++++++++++++++ source/node_test.go | 16 ++++++++++++++++ 6 files changed, 100 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index c927ee71a..06f6bea34 100644 --- a/Makefile +++ b/Makefile @@ -27,11 +27,29 @@ cover: cover-html: cover go tool cover -html cover.out +.PHONY: go-lint + +# Run the golangci-lint tool +go-lint: + golangci-lint run --timeout=15m ./... + +.PHONY: licensecheck + +# Run the licensecheck script to check for license headers +licensecheck: + @echo ">> checking license header" + @licRes=$$(for file in $$(find . -type f -iname '*.go' ! -path './vendor/*') ; do \ + awk 'NR<=5' $$file | grep -Eq "(Copyright|generated|GENERATED)" || echo $$file; \ + done); \ + if [ -n "$${licRes}" ]; then \ + echo "license header checking failed:"; echo "$${licRes}"; \ + exit 1; \ + fi + .PHONY: lint # Run all the linters -lint: - golangci-lint run --timeout=15m ./... +lint: licensecheck go-lint # The verify target runs tasks similar to the CI tasks, but without code coverage diff --git a/internal/config/config.go b/internal/config/config.go index 7a05f36e2..28f042793 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -1,3 +1,19 @@ +/* +Copyright 2020 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. +*/ + package config // FastPoll used for fast testing diff --git a/internal/testutils/init.go b/internal/testutils/init.go index be154e328..a2c1bce5d 100644 --- a/internal/testutils/init.go +++ b/internal/testutils/init.go @@ -1,3 +1,19 @@ +/* +Copyright 2020 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. +*/ + package testutils import ( diff --git a/provider/scaleway/interface.go b/provider/scaleway/interface.go index e9060878d..671b05b43 100644 --- a/provider/scaleway/interface.go +++ b/provider/scaleway/interface.go @@ -1,3 +1,19 @@ +/* +Copyright 2020 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. +*/ + package scaleway import ( diff --git a/provider/scaleway/scaleway_test.go b/provider/scaleway/scaleway_test.go index 92257de49..56b5f45d7 100644 --- a/provider/scaleway/scaleway_test.go +++ b/provider/scaleway/scaleway_test.go @@ -1,3 +1,19 @@ +/* +Copyright 2020 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. +*/ + package scaleway import ( diff --git a/source/node_test.go b/source/node_test.go index 1a9aa1d65..d82425c47 100644 --- a/source/node_test.go +++ b/source/node_test.go @@ -1,3 +1,19 @@ +/* +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. +*/ + package source import (