From 862564749869ba11f670c6b2b80d3c2e75e1bb12 Mon Sep 17 00:00:00 2001 From: Julien Balestra Date: Mon, 14 May 2018 17:17:40 +0200 Subject: [PATCH] Setup circle ci (#20) * scripts: re organize by verify / update verbs * setup circleci * Hardcode the locale to get a stable sort --- .circleci/config.yml | 46 +++++++++++++++++++ LICENSE-3rdparty.csv | 38 +++++++-------- Makefile | 22 ++++++--- scripts/run.sh | 9 ---- scripts/{ => update}/docs.go | 0 scripts/{update-gofmt.sh => update/gofmt.sh} | 4 +- .../{update-license.sh => update/license.sh} | 6 ++- .../docs.sh} | 3 +- scripts/{verify-gofmt.sh => verify/gofmt.sh} | 2 +- scripts/verify/license.sh | 28 +++++++++++ 10 files changed, 118 insertions(+), 40 deletions(-) create mode 100644 .circleci/config.yml delete mode 100644 scripts/run.sh rename scripts/{ => update}/docs.go (100%) rename scripts/{update-gofmt.sh => update/gofmt.sh} (93%) rename scripts/{update-license.sh => update/license.sh} (82%) rename scripts/{verify-generated-docs.sh => verify/docs.sh} (92%) rename scripts/{verify-gofmt.sh => verify/gofmt.sh} (97%) create mode 100755 scripts/verify/license.sh diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..8265bf6 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,46 @@ +version: 2 + +templates: + job_template: &job_template + docker: + - image: golang:1.10 + working_directory: /go/src/github.com/DataDog/pupernetes + +jobs: + build: + <<: *job_template + steps: + - checkout + - run: + name: build + command: make + + tests: + <<: *job_template + steps: + - checkout + - run: + name: run tests + command: make check + + verify: + <<: *job_template + steps: + - checkout + - run: + name: verify-gofmt + command: make verify-gofmt + - run: + name: verify-docs + command: make verify-docs + - run: + name: verify-license + command: make verify-license + +workflows: + version: 2 + build_test_verify: + jobs: + - tests + - verify + - build diff --git a/LICENSE-3rdparty.csv b/LICENSE-3rdparty.csv index 5fff887..6e12382 100644 --- a/LICENSE-3rdparty.csv +++ b/LICENSE-3rdparty.csv @@ -14,21 +14,22 @@ core,"github.com/gogo/protobuf/proto",NewBSD core,"github.com/gogo/protobuf/sortkeys",NewBSD core,"github.com/golang/glog",Apache-2.0 core,"github.com/golang/protobuf/proto",NewBSD +core,"github.com/golang/protobuf/ptypes",NewBSD core,"github.com/golang/protobuf/ptypes/any",NewBSD core,"github.com/golang/protobuf/ptypes/duration",NewBSD -core,"github.com/golang/protobuf/ptypes",NewBSD core,"github.com/golang/protobuf/ptypes/timestamp",NewBSD core,"github.com/golang/snappy",NewBSD +core,"github.com/google/gofuzz",Apache-2.0 +core,"github.com/googleapis/gnostic/OpenAPIv2",Apache-2.0 core,"github.com/googleapis/gnostic/compiler",Apache-2.0 core,"github.com/googleapis/gnostic/extensions",Apache-2.0 -core,"github.com/googleapis/gnostic/OpenAPIv2",Apache-2.0 -core,"github.com/google/gofuzz",Apache-2.0 core,"github.com/gorilla/context",NewBSD core,"github.com/gorilla/mux",NewBSD core,"github.com/hashicorp/errwrap",MPL-2.0 core,"github.com/hashicorp/go-cleanhttp",MPL-2.0 core,"github.com/hashicorp/go-multierror",MPL-2.0 core,"github.com/hashicorp/go-rootcerts",MPL-2.0 +core,"github.com/hashicorp/hcl",MPL-2.0 core,"github.com/hashicorp/hcl/hcl/ast",MPL-2.0 core,"github.com/hashicorp/hcl/hcl/parser",MPL-2.0 core,"github.com/hashicorp/hcl/hcl/printer",MPL-2.0 @@ -38,7 +39,6 @@ core,"github.com/hashicorp/hcl/hcl/token",MPL-2.0 core,"github.com/hashicorp/hcl/json/parser",MPL-2.0 core,"github.com/hashicorp/hcl/json/scanner",MPL-2.0 core,"github.com/hashicorp/hcl/json/token",MPL-2.0 -core,"github.com/hashicorp/hcl",MPL-2.0 core,"github.com/hashicorp/vault/api",MPL-2.0 core,"github.com/hashicorp/vault/helper/compressutil",MPL-2.0 core,"github.com/hashicorp/vault/helper/jsonutil",MPL-2.0 @@ -69,14 +69,14 @@ core,"github.com/stretchr/testify/assert",MIT core,"github.com/stretchr/testify/require",MIT core,"golang.org/x/crypto/ssh/terminal",NewBSD core,"golang.org/x/net/context",NewBSD -core,"golang.org/x/net/http2/hpack",NewBSD core,"golang.org/x/net/http2",NewBSD +core,"golang.org/x/net/http2/hpack",NewBSD core,"golang.org/x/net/idna",NewBSD core,"golang.org/x/net/lex/httplex",NewBSD core,"golang.org/x/sys/unix",NewBSD core,"golang.org/x/sys/windows",NewBSD -core,"golang.org/x/text/collate/build",NewBSD core,"golang.org/x/text/collate",NewBSD +core,"golang.org/x/text/collate/build",NewBSD core,"golang.org/x/text/internal/colltab",NewBSD core,"golang.org/x/text/internal/gen",NewBSD core,"golang.org/x/text/internal/tag",NewBSD @@ -110,12 +110,22 @@ core,"k8s.io/api/certificates/v1beta1",Apache-2.0 core,"k8s.io/api/core/v1",Apache-2.0 core,"k8s.io/api/events/v1beta1",Apache-2.0 core,"k8s.io/api/extensions/v1beta1",Apache-2.0 +core,"k8s.io/api/networking/v1",Apache-2.0 +core,"k8s.io/api/policy/v1beta1",Apache-2.0 +core,"k8s.io/api/rbac/v1",Apache-2.0 +core,"k8s.io/api/rbac/v1alpha1",Apache-2.0 +core,"k8s.io/api/rbac/v1beta1",Apache-2.0 +core,"k8s.io/api/scheduling/v1alpha1",Apache-2.0 +core,"k8s.io/api/settings/v1alpha1",Apache-2.0 +core,"k8s.io/api/storage/v1",Apache-2.0 +core,"k8s.io/api/storage/v1alpha1",Apache-2.0 +core,"k8s.io/api/storage/v1beta1",Apache-2.0 core,"k8s.io/apimachinery/pkg/api/errors",Apache-2.0 core,"k8s.io/apimachinery/pkg/api/meta",Apache-2.0 core,"k8s.io/apimachinery/pkg/api/resource",Apache-2.0 core,"k8s.io/apimachinery/pkg/apis/meta/v1",Apache-2.0 -core,"k8s.io/apimachinery/pkg/apis/meta/v1beta1",Apache-2.0 core,"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured",Apache-2.0 +core,"k8s.io/apimachinery/pkg/apis/meta/v1beta1",Apache-2.0 core,"k8s.io/apimachinery/pkg/conversion",Apache-2.0 core,"k8s.io/apimachinery/pkg/conversion/queryparams",Apache-2.0 core,"k8s.io/apimachinery/pkg/fields",Apache-2.0 @@ -145,16 +155,6 @@ core,"k8s.io/apimachinery/pkg/util/yaml",Apache-2.0 core,"k8s.io/apimachinery/pkg/version",Apache-2.0 core,"k8s.io/apimachinery/pkg/watch",Apache-2.0 core,"k8s.io/apimachinery/third_party/forked/golang/reflect",Apache-2.0 -core,"k8s.io/api/networking/v1",Apache-2.0 -core,"k8s.io/api/policy/v1beta1",Apache-2.0 -core,"k8s.io/api/rbac/v1alpha1",Apache-2.0 -core,"k8s.io/api/rbac/v1",Apache-2.0 -core,"k8s.io/api/rbac/v1beta1",Apache-2.0 -core,"k8s.io/api/scheduling/v1alpha1",Apache-2.0 -core,"k8s.io/api/settings/v1alpha1",Apache-2.0 -core,"k8s.io/api/storage/v1alpha1",Apache-2.0 -core,"k8s.io/api/storage/v1",Apache-2.0 -core,"k8s.io/api/storage/v1beta1",Apache-2.0 core,"k8s.io/client-go/discovery",Apache-2.0 core,"k8s.io/client-go/kubernetes",Apache-2.0 core,"k8s.io/client-go/kubernetes/scheme",Apache-2.0 @@ -178,13 +178,13 @@ core,"k8s.io/client-go/kubernetes/typed/events/v1beta1",Apache-2.0 core,"k8s.io/client-go/kubernetes/typed/extensions/v1beta1",Apache-2.0 core,"k8s.io/client-go/kubernetes/typed/networking/v1",Apache-2.0 core,"k8s.io/client-go/kubernetes/typed/policy/v1beta1",Apache-2.0 -core,"k8s.io/client-go/kubernetes/typed/rbac/v1alpha1",Apache-2.0 core,"k8s.io/client-go/kubernetes/typed/rbac/v1",Apache-2.0 +core,"k8s.io/client-go/kubernetes/typed/rbac/v1alpha1",Apache-2.0 core,"k8s.io/client-go/kubernetes/typed/rbac/v1beta1",Apache-2.0 core,"k8s.io/client-go/kubernetes/typed/scheduling/v1alpha1",Apache-2.0 core,"k8s.io/client-go/kubernetes/typed/settings/v1alpha1",Apache-2.0 -core,"k8s.io/client-go/kubernetes/typed/storage/v1alpha1",Apache-2.0 core,"k8s.io/client-go/kubernetes/typed/storage/v1",Apache-2.0 +core,"k8s.io/client-go/kubernetes/typed/storage/v1alpha1",Apache-2.0 core,"k8s.io/client-go/kubernetes/typed/storage/v1beta1",Apache-2.0 core,"k8s.io/client-go/pkg/apis/clientauthentication",Apache-2.0 core,"k8s.io/client-go/pkg/apis/clientauthentication/v1alpha1",Apache-2.0 diff --git a/Makefile b/Makefile index f610ba3..9de4bd2 100644 --- a/Makefile +++ b/Makefile @@ -14,20 +14,30 @@ clean: re: clean pupernetes -fmt: - ./scripts/update-gofmt.sh +gofmt: + ./scripts/update/gofmt.sh gen-docs: - $(CC) run ./scripts/docs.go + $(CC) run ./scripts/update/docs.go + +gen-license: + ./scripts/update/license.sh PKG=job options setup util $(PKG): %: $(CC) test -v ./pkg/$@ check: $(PKG) -verify: - ./scripts/verify-gofmt.sh - ./scripts/verify-generated-docs.sh +verify-gofmt: + ./scripts/verify/gofmt.sh + +verify-docs: + ./scripts/verify/docs.sh + +verify-license: + ./scripts/verify/license.sh + +verify: verify-gofmt verify-docs verify-license sha512sum: pupernetes $@ ./$^ > $^.$@ diff --git a/scripts/run.sh b/scripts/run.sh deleted file mode 100644 index f92ec97..0000000 --- a/scripts/run.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -set -o pipefail -set -ex - -apt-get update -qq -apt-get install -y make curl unzip - -curl https://get.docker.com | sh diff --git a/scripts/docs.go b/scripts/update/docs.go similarity index 100% rename from scripts/docs.go rename to scripts/update/docs.go diff --git a/scripts/update-gofmt.sh b/scripts/update/gofmt.sh similarity index 93% rename from scripts/update-gofmt.sh rename to scripts/update/gofmt.sh index 39deb3b..83d9a8e 100755 --- a/scripts/update-gofmt.sh +++ b/scripts/update/gofmt.sh @@ -20,8 +20,8 @@ set -o errexit set -o nounset set -o pipefail -PKG=$(dirname $0)/../pkg -CMD=$(dirname $0)/../cmd +PKG=$(dirname $0)/../../pkg +CMD=$(dirname $0)/../../cmd SCRIPT=$(dirname $0) diff --git a/scripts/update-license.sh b/scripts/update/license.sh similarity index 82% rename from scripts/update-license.sh rename to scripts/update/license.sh index 1888b30..95253d2 100755 --- a/scripts/update-license.sh +++ b/scripts/update/license.sh @@ -2,9 +2,11 @@ set -ex -go get -u github.com/frapposelli/wwhrd +export LC_ALL=C -cd $(dirname $0)/.. +go get github.com/frapposelli/wwhrd + +cd $(dirname $0)/../.. wwhrd list diff --git a/scripts/verify-generated-docs.sh b/scripts/verify/docs.sh similarity index 92% rename from scripts/verify-generated-docs.sh rename to scripts/verify/docs.sh index f032cef..dc0564a 100755 --- a/scripts/verify-generated-docs.sh +++ b/scripts/verify/docs.sh @@ -3,8 +3,9 @@ set -o errexit set -o nounset set -o pipefail +set -e -cd $(dirname $0)/.. +cd $(dirname $0)/../.. make gen-docs diff --git a/scripts/verify-gofmt.sh b/scripts/verify/gofmt.sh similarity index 97% rename from scripts/verify-gofmt.sh rename to scripts/verify/gofmt.sh index 03a9043..6f52530 100755 --- a/scripts/verify-gofmt.sh +++ b/scripts/verify/gofmt.sh @@ -20,7 +20,7 @@ set -o errexit set -o nounset set -o pipefail -cd $(dirname "$0}")/.. +cd $(dirname "$0}")/../.. find_files() { diff --git a/scripts/verify/license.sh b/scripts/verify/license.sh new file mode 100755 index 0000000..365a255 --- /dev/null +++ b/scripts/verify/license.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +set -o errexit +set -o nounset +set -o pipefail +set -e + +cd $(dirname $0)/../.. + +make gen-license + +DIFF=$(git --no-pager diff LICENSE-3rdparty.csv) +if [[ "${DIFF}x" != "x" ]] +then + echo "License outdated:" >&2 + git --no-pager diff LICENSE-3rdparty.csv >&2 + exit 2 +fi + +DIFF=$(git ls-files docs/ --exclude-standard --others) +if [[ "${DIFF}x" != "x" ]] +then + echo "License removed:" >&2 + echo ${DIFF} >&2 + exit 2 +fi + +exit 0