Pārlūkot izejas kodu

Add validation for compose schema bindata.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
Daniel Nephin 8 gadi atpakaļ
vecāks
revīzija
38d08b0bd1
4 mainītis faili ar 32 papildinājumiem un 3 dzēšanām
  1. 1 1
      hack/make.ps1
  2. 28 0
      hack/validate/compose-bindata
  3. 3 1
      hack/validate/gofmt
  4. 0 1
      hack/validate/swagger-gen

+ 1 - 1
hack/make.ps1

@@ -261,7 +261,7 @@ Function Validate-GoFormat($headCommit, $upstreamCommit) {
 
     # Get a list of all go source-code files which have changed.  Ignore exit code on next call - always process regardless
     $files=@(); $files = Invoke-Expression "git diff $upstreamCommit...$headCommit --diff-filter=ACMR --name-only -- `'*.go`'"
-    $files = $files | Select-String -NotMatch "^vendor/"
+    $files = $files | Select-String -NotMatch "^vendor/" | Select-String -NotMatch "^cli/compose/schema/bindata.go"
     $badFiles=@(); $files | %{
         # Deliberately ignore error on next line - treat as failed
         $content=Invoke-Expression "git show $headCommit`:$_"

+ 28 - 0
hack/validate/compose-bindata

@@ -0,0 +1,28 @@
+#!/bin/bash
+
+export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+source "${SCRIPTDIR}/.validate"
+
+IFS=$'\n'
+files=( $(validate_diff --diff-filter=ACMR --name-only -- 'cli/compose/schema/data' || true) )
+unset IFS
+
+if [ ${#files[@]} -gt 0 ]; then
+	go generate github.com/docker/docker/cli/compose/schema 2> /dev/null
+	# Let see if the working directory is clean
+	diffs="$(git status --porcelain -- api/types/ 2>/dev/null)"
+	if [ "$diffs" ]; then
+		{
+			echo 'The result of `go generate github.com/docker/docker/cli/compose/schema` differs'
+			echo
+			echo "$diffs"
+			echo
+			echo 'Please run `go generate github.com/docker/docker/cli/compose/schema`'
+		} >&2
+		false
+	else
+		echo 'Congratulations! cli/compose/schema/bindata.go is up-to-date.'
+	fi
+else
+    echo 'No cli/compose/schema/data changes in diff.'
+fi

+ 3 - 1
hack/validate/gofmt

@@ -4,7 +4,9 @@ export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 source "${SCRIPTDIR}/.validate"
 
 IFS=$'\n'
-files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/' || true) )
+files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' |
+    grep -v '^vendor/' |
+    grep -v '^cli/compose/schema/bindata.go' || true) )
 unset IFS
 
 badFiles=()

+ 0 - 1
hack/validate/swagger-gen

@@ -8,7 +8,6 @@ files=( $(validate_diff --diff-filter=ACMR --name-only -- 'api/types/' 'api/swag
 unset IFS
 
 if [ ${#files[@]} -gt 0 ]; then
-	# We run vndr to and see if we have a diff afterwards
 	${SCRIPTDIR}/../generate-swagger-api.sh 2> /dev/null
 	# Let see if the working directory is clean
 	diffs="$(git status --porcelain -- api/types/ 2>/dev/null)"