diff --git a/.drone.yml b/.drone.yml index 8da7133eec..0b8625d2aa 100755 --- a/.drone.yml +++ b/.drone.yml @@ -10,5 +10,5 @@ script: - rm integration-cli/docker_cli_daemon_test.go - rm integration-cli/docker_cli_exec_test.go # Validate and test. - - hack/make.sh validate-dco validate-gofmt + - hack/make.sh validate-dco validate-gofmt validate-toml - hack/make.sh binary cross test-unit test-integration-cli test-integration test-docker-py diff --git a/Dockerfile b/Dockerfile index 67b9ea1690..fdf35227fc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -155,6 +155,10 @@ RUN set -x \ && git clone -b v1.2 https://github.com/russross/blackfriday.git /go/src/github.com/russross/blackfriday \ && go install -v github.com/cpuguy83/go-md2man +# install toml validator +RUN git clone -b v0.1.0 https://github.com/BurntSushi/toml.git /go/src/github.com/BurntSushi/toml \ + && go install -v github.com/BurntSushi/toml/cmd/tomlv + # Wrap all commands in the "docker-in-docker" script to allow nested containers ENTRYPOINT ["hack/dind"] diff --git a/Makefile b/Makefile index 13e0fa9e8a..266fa2a9a4 100644 --- a/Makefile +++ b/Makefile @@ -74,7 +74,7 @@ test-docker-py: build $(DOCKER_RUN_DOCKER) hack/make.sh binary test-docker-py validate: build - $(DOCKER_RUN_DOCKER) hack/make.sh validate-gofmt validate-dco + $(DOCKER_RUN_DOCKER) hack/make.sh validate-gofmt validate-dco validate-toml shell: build $(DOCKER_RUN_DOCKER) bash diff --git a/project/make.sh b/project/make.sh index 97751cb67c..f1e60cc34a 100755 --- a/project/make.sh +++ b/project/make.sh @@ -44,6 +44,7 @@ echo DEFAULT_BUNDLES=( validate-dco validate-gofmt + validate-toml binary diff --git a/project/make/validate-toml b/project/make/validate-toml new file mode 100644 index 0000000000..46ece77980 --- /dev/null +++ b/project/make/validate-toml @@ -0,0 +1,30 @@ +#!/bin/bash + +source "$(dirname "$BASH_SOURCE")/.validate" + +IFS=$'\n' +files=( $(validate_diff --diff-filter=ACMR --name-only -- 'MAINTAINERS' || true) ) +unset IFS + +badFiles=() +for f in "${files[@]}"; do + # we use "git show" here to validate that what's committed is formatted + if [ "$(git show "$VALIDATE_HEAD:$f" | tomlv)" ]; then + badFiles+=( "$f" ) + fi +done + +if [ ${#badFiles[@]} -eq 0 ]; then + echo 'Congratulations! All toml source files have valid syntax.' +else + { + echo "These files are not valid toml:" + for f in "${badFiles[@]}"; do + echo " - $f" + done + echo + echo 'Please reformat the above files as valid toml' + echo + } >&2 + false +fi