Parcourir la source

Validate toml

Docker-DCO-1.1-Signed-off-by: Jessie Frazelle <princess@docker.com> (github: jfrazelle)

Docker-DCO-1.1-Signed-off-by: Jessie Frazelle <hugs@docker.com> (github: jfrazelle)
Jessica Frazelle il y a 10 ans
Parent
commit
d245a8a706
5 fichiers modifiés avec 37 ajouts et 2 suppressions
  1. 1 1
      .drone.yml
  2. 4 0
      Dockerfile
  3. 1 1
      Makefile
  4. 1 0
      project/make.sh
  5. 30 0
      project/make/validate-toml

+ 1 - 1
.drone.yml

@@ -10,5 +10,5 @@ script:
   - rm integration-cli/docker_cli_daemon_test.go
   - rm integration-cli/docker_cli_daemon_test.go
   - rm integration-cli/docker_cli_exec_test.go 
   - rm integration-cli/docker_cli_exec_test.go 
 # Validate and test.
 # 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
   - hack/make.sh binary cross test-unit test-integration-cli test-integration test-docker-py

+ 4 - 0
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 \
 	&& 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
 	&& 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
 # Wrap all commands in the "docker-in-docker" script to allow nested containers
 ENTRYPOINT ["hack/dind"]
 ENTRYPOINT ["hack/dind"]
 
 

+ 1 - 1
Makefile

@@ -74,7 +74,7 @@ test-docker-py: build
 	$(DOCKER_RUN_DOCKER) hack/make.sh binary test-docker-py
 	$(DOCKER_RUN_DOCKER) hack/make.sh binary test-docker-py
 
 
 validate: build
 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
 shell: build
 	$(DOCKER_RUN_DOCKER) bash
 	$(DOCKER_RUN_DOCKER) bash

+ 1 - 0
project/make.sh

@@ -44,6 +44,7 @@ echo
 DEFAULT_BUNDLES=(
 DEFAULT_BUNDLES=(
 	validate-dco
 	validate-dco
 	validate-gofmt
 	validate-gofmt
+	validate-toml
 
 
 	binary
 	binary
 
 

+ 30 - 0
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