Browse code

Add validation for compose schema bindata.

Signed-off-by: Daniel Nephin <dnephin@docker.com>

Daniel Nephin authored on 2016/12/28 01:55:13
Showing 4 changed files
... ...
@@ -261,7 +261,7 @@ Function Validate-GoFormat($headCommit, $upstreamCommit) {
261 261
 
262 262
     # Get a list of all go source-code files which have changed.  Ignore exit code on next call - always process regardless
263 263
     $files=@(); $files = Invoke-Expression "git diff $upstreamCommit...$headCommit --diff-filter=ACMR --name-only -- `'*.go`'"
264
-    $files = $files | Select-String -NotMatch "^vendor/"
264
+    $files = $files | Select-String -NotMatch "^vendor/" | Select-String -NotMatch "^cli/compose/schema/bindata.go"
265 265
     $badFiles=@(); $files | %{
266 266
         # Deliberately ignore error on next line - treat as failed
267 267
         $content=Invoke-Expression "git show $headCommit`:$_"
268 268
new file mode 100755
... ...
@@ -0,0 +1,28 @@
0
+#!/bin/bash
1
+
2
+export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
3
+source "${SCRIPTDIR}/.validate"
4
+
5
+IFS=$'\n'
6
+files=( $(validate_diff --diff-filter=ACMR --name-only -- 'cli/compose/schema/data' || true) )
7
+unset IFS
8
+
9
+if [ ${#files[@]} -gt 0 ]; then
10
+	go generate github.com/docker/docker/cli/compose/schema 2> /dev/null
11
+	# Let see if the working directory is clean
12
+	diffs="$(git status --porcelain -- api/types/ 2>/dev/null)"
13
+	if [ "$diffs" ]; then
14
+		{
15
+			echo 'The result of `go generate github.com/docker/docker/cli/compose/schema` differs'
16
+			echo
17
+			echo "$diffs"
18
+			echo
19
+			echo 'Please run `go generate github.com/docker/docker/cli/compose/schema`'
20
+		} >&2
21
+		false
22
+	else
23
+		echo 'Congratulations! cli/compose/schema/bindata.go is up-to-date.'
24
+	fi
25
+else
26
+    echo 'No cli/compose/schema/data changes in diff.'
27
+fi
... ...
@@ -4,7 +4,9 @@ export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
4 4
 source "${SCRIPTDIR}/.validate"
5 5
 
6 6
 IFS=$'\n'
7
-files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/' || true) )
7
+files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' |
8
+    grep -v '^vendor/' |
9
+    grep -v '^cli/compose/schema/bindata.go' || true) )
8 10
 unset IFS
9 11
 
10 12
 badFiles=()
... ...
@@ -8,7 +8,6 @@ files=( $(validate_diff --diff-filter=ACMR --name-only -- 'api/types/' 'api/swag
8 8
 unset IFS
9 9
 
10 10
 if [ ${#files[@]} -gt 0 ]; then
11
-	# We run vndr to and see if we have a diff afterwards
12 11
 	${SCRIPTDIR}/../generate-swagger-api.sh 2> /dev/null
13 12
 	# Let see if the working directory is clean
14 13
 	diffs="$(git status --porcelain -- api/types/ 2>/dev/null)"