From 38d08b0bd1a8aa931cefd9caf837dbc9a4bb0a37 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Tue, 27 Dec 2016 11:55:13 -0500 Subject: [PATCH] Add validation for compose schema bindata. Signed-off-by: Daniel Nephin --- hack/make.ps1 | 2 +- hack/validate/compose-bindata | 28 ++++++++++++++++++++++++++++ hack/validate/gofmt | 4 +++- hack/validate/swagger-gen | 1 - 4 files changed, 32 insertions(+), 3 deletions(-) create mode 100755 hack/validate/compose-bindata diff --git a/hack/make.ps1 b/hack/make.ps1 index 1d3a4a23bd..429b5cf297 100644 --- a/hack/make.ps1 +++ b/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`:$_" diff --git a/hack/validate/compose-bindata b/hack/validate/compose-bindata new file mode 100755 index 0000000000..26ee0312d7 --- /dev/null +++ b/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 diff --git a/hack/validate/gofmt b/hack/validate/gofmt index f3c6a848de..2040afa09e 100755 --- a/hack/validate/gofmt +++ b/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=() diff --git a/hack/validate/swagger-gen b/hack/validate/swagger-gen index 42c9749360..008abc7e0d 100755 --- a/hack/validate/swagger-gen +++ b/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)"