Skip to content

Commit

Permalink
generate bindata with kevinburkes fork
Browse files Browse the repository at this point in the history
address most shellcheck warnings
build with go1.11

Signed-off-by: Ivan Porto Carrero <ivan@flanders.co.nz>
  • Loading branch information
casualjim committed Sep 22, 2018
1 parent e13f855 commit c6ce75e
Show file tree
Hide file tree
Showing 19 changed files with 263 additions and 227 deletions.
2 changes: 1 addition & 1 deletion .circleci/build-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repo_pref="github.com/${CIRCLE_PROJECT_USERNAME-"$(basename `pwd`)"}/${CIRCLE_PR
for dir in $(go list ./... | grep -v -E 'vendor|fixtures|examples')
do
pth="${dir//*$repo_pref}"
go test -tags netgo -installsuffix netgo -covermode=${GOCOVMODE-atomic} -coverprofile=${pth}/profile.tmp $dir
go test -vet off -tags netgo -installsuffix netgo -covermode=${GOCOVMODE-atomic} -coverprofile=${pth}/profile.tmp $dir
if [ -f $pth/profile.tmp ]
then
cat $pth/profile.tmp | tail -n +2 >> coverage.txt
Expand Down
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ jobs:
build:
working_directory: /go/src/github.com/go-swagger/go-swagger
docker:
- image: goswagger/builder:20180825
- image: goswagger/builder:20180921
steps:
- checkout

Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.ci
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ FROM golang:alpine

ENV GOCOVMODE atomic

RUN apk add -U --no-cache bash tar gzip xz procps git curl ruby ruby-dev alpine-sdk libffi-dev rpm dpkg openssh-client &&\
curl -sSL https://download.docker.com/linux/static/stable/x86_64/docker-18.03.1-ce.tgz | tar -C /usr/bin --strip-components=1 -xzf -
RUN apk add -U --no-cache bash tar gzip xz procps git curl ruby ruby-dev alpine-sdk libffi-dev rpm dpkg openssh-client ncurses &&\
curl -sSL https://download.docker.com/linux/static/stable/x86_64/docker-18.06.1-ce.tgz | tar -C /usr/bin --strip-components=1 -xzf -

RUN set -e -x \
&& mkdir -p /usr/share/coverage /usr/share/testresults /usr/share/dist \
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ build_script:
- echo %GOPATH%

test_script:
- ps: go test -timeout 20m -v $(go list ./... | sls -n "vendor|fixtures|examples")
- ps: go test -vet off -timeout 20m -v $(go list ./... | sls -n "vendor|fixtures|examples")

#artifacts:
# - path: '%GOPATH%\bin\*.exe'
Expand Down
2 changes: 1 addition & 1 deletion cmd/swagger/commands/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func TestCmd_Validate_Issue342_CannotUnmarshal(t *testing.T) {
result := v.Execute([]string{specDoc})
if assert.Error(t, result, "This spec should not pass validation") {
// assert.Contains(t, result.Error(), "is invalid against swagger specification 2.0")
assert.Contains(t, result.Error(), "json: cannot unmarshal object into Go struct field SwaggerProps.paths of type []spec.Parameter")
assert.Contains(t, result.Error(), "json: cannot unmarshal object into Go struct field OperationProps.parameters of type []spec.Parameter")
}
}

Expand Down
6 changes: 3 additions & 3 deletions fixtures/bugs/1084/gen-fixtures.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ fixture=fixture-1084.yaml
verifier=unmarshal_test.go
target=gen-fixture-1084
if [[ ! -f $verifier ]] ; then
mv ${verifier%.go}.gol ${verifier%.go}.go
mv ${verifier%.go}.gol ${verifier%.go}.go
fi
if [[ ! -d $target ]] ; then
if [[ ! -d $target ]] ; then
mkdir $target
fi
swagger generate model --spec=$fixture --target=$target --quiet
go test -v
go test -vet off -v
ret=$?
if [[ $1 == "--clean" ]] ; then
rm -rf $target
Expand Down
2 changes: 1 addition & 1 deletion fixtures/bugs/1571/go-test.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#! /bin/bash
go test -v -tags integration
go test -vet off -v -tags integration
287 changes: 177 additions & 110 deletions generator/bindata.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion hack/add-license.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/zsh
setopt extended_glob
echo '
// Copyright 2015 go-swagger maintainers
// Copyright 2018 go-swagger maintainers
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion hack/build-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Bails on any command failure
set -e -o pipefail -x

cd `git rev-parse --show-toplevel`
cd $(git rev-parse --show-toplevel)
echo "Building swagger from $(pwd)..."

if [[ ${1} == "--circleci" ]] ; then
Expand Down
81 changes: 39 additions & 42 deletions hack/codegen-nonreg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# for non regression testing of codegen
shopt -s extglob

function initColors() {
if [[ -z ${MONO} ]]; then
# function initColors() {
if [[ -z "${MONO}" ]]; then
normal=$(tput sgr0)
red=$(tput setaf 1)
green=$(tput setaf 2)
Expand All @@ -19,7 +19,7 @@ else
blue=""
bold=""
fi
}
# }

function okcr() {
ok "$*"; printf "\n"
Expand Down Expand Up @@ -57,8 +57,8 @@ if [ ! -f `which swagger` ]; then
exit 1
fi

# NOTE(fredbi):
# The following ones fail generation:
# NOTE(fredbi):
# The following ones fail generation:
# - existing-model.yml requires pregeneration (not supported yet by this script)
# - issue72: model works with --skip-validation. Invalid spec (duplicate operationID)
# - todolist.simple.yml: invalid default values put on purpose for UT (provided fixed version for testing)
Expand Down Expand Up @@ -141,33 +141,33 @@ else
fi

# A little chrome does not hurt...
initColors
# initColors

# All fixtures in ./fixtures/codegen + some others
cd ${0%/*}
specdir="../fixtures/codegen ../fixtures/bugs/909 ../fixtures/bugs/1437 ../fixtures/bugs/1314 ../fixtures/bugs/1062/eve-online-esi.json"
specdir=${specdir}" ../fixtures/bugs/1392"
specdir=${specdir}" ../fixtures/bugs/1277"
specdir=${specdir}" ../fixtures/bugs/1536"
specdir=${specdir}" ../fixtures/bugs/1487"
specdir=${specdir}" ../fixtures/bugs/1571"
specdir=${specdir}" ../fixtures/bugs/957"
specdir=${specdir}" ../fixtures/bugs/1614"
specdir=${specdir}" ../fixtures/bugs/931"
cd $(git rev-parse --show-toplevel)
specdir="fixtures/codegen fixtures/bugs/909 fixtures/bugs/1437 fixtures/bugs/1314 fixtures/bugs/1062/eve-online-esi.json"
specdir=${specdir}" fixtures/bugs/1392"
specdir=${specdir}" fixtures/bugs/1277"
specdir=${specdir}" fixtures/bugs/1536"
specdir=${specdir}" fixtures/bugs/1487"
specdir=${specdir}" fixtures/bugs/1571"
specdir=${specdir}" fixtures/bugs/957"
specdir=${specdir}" fixtures/bugs/1614"
specdir=${specdir}" fixtures/bugs/931"
gendir=./tmp-gen
rm -rf ${gendir}

check_list=`for d in ${specdir}; do ls $d/*.yml;ls $d/*.json;ls $d/*.yaml;done 2>/dev/null`
# there are several subspecs there: we just want the master
check_list=${check_list}" ../fixtures/bugs/1621/fixture-1621.yaml"
check_list=${check_list}" fixtures/bugs/1621/fixture-1621.yaml"

list=( $check_list )
fixtures_count=${#list[@]}
okcr "Running codegen for ${fixtures_count} specs"

for spec in ${check_list}; do
for spec in ${check_list}; do
testcase=${spec##*/}
case ${testcase} in
case ${testcase} in
${known_failed})
warncr "[`date +%T`]${spec}: not tested against full build because of known issues."
run="false"
Expand Down Expand Up @@ -210,7 +210,7 @@ for spec in ${check_list}; do
for preprocessingOpts in ${OPTS} ; do
index+=1
infocr "Generation with options: ${preprocessingOpts} ${opts}"

# Do not attempt to generate on expanded specs when there is a discriminator specified
grep -q discriminator ${spec}
discriminated=$?
Expand All @@ -221,69 +221,66 @@ for spec in ${check_list}; do
if [[ ${noexpand} != "true" && ${preprocessingOpts} == "--with-flatten=expand" ]] ; then
continue
fi

target=${gendir}/gen-${testcase%.*}${index}
target_client=${gendir}/gen-${testcase%.*}${index}"-client"

server_name="nrcodegen"
client_name="nrcodegen"
errlog=${gendir}/stderr.log

rm -rf ${target} ${target_client}
mkdir -p ${target} ${target_client}
rm -f ${errlog}

# Gen server
swagger generate server --spec ${spec} --target ${target} --name=${server_name} --quiet ${opts} ${preprocessingOpts} 2>${errlog}
if [[ $? != 0 ]] ; then
if ! swagger generate server --spec ${spec} --target ${target} --name=${server_name} --quiet ${opts} ${preprocessingOpts} 2>${errlog} ; then
errcr "Generation Failed"
if [[ -f ${errlog} ]] ; then errcr `cat ${errlog}` ; rm ${errlog};fi
if [[ -f ${errlog} ]] ; then errcr "$(cat ${errlog})" ; rm ${errlog};fi
exit 1
fi
ok `printf " %s..." "Generation server OK"`
okcr "Generation server OK"
rm -f ${errlog}
# Gen client
swagger generate client --spec ${spec} --target ${target_client} --name=${client_name} --quiet ${opts} ${preprocessingOpts} 2>${errlog}
if [[ $? != 0 ]] ; then

if ! swagger generate client --spec "${spec}" --target "${target_client}" --name "${client_name}" --quiet ${opts} "${preprocessingOpts}" 2>${errlog}; then
errcr "Generation Failed"
if [[ -f ${errlog} ]] ; then errcr `cat ${errlog}` ; rm ${errlog};fi
exit 1
fi
ok `printf " %s..." "Generation client OK"`
okcr "Generation client OK"

#
# Check build on generated artifacts
#

# Build server
(cd ${target}/cmd/${server_name}"-server"; go build) 2>${errlog}
if [[ $? != 0 ]] ; then
if ! (cd ${target}/cmd/${server_name}"-server"; go build) 2>${errlog} ; then
errcr "Server build Failed"
if [[ -f ${errlog} ]] ; then errcr `cat ${errlog}` ; rm ${errlog};fi
exit 1
fi
ok `printf " %s..." "Server build OK"`
# Build models if any produced
if [[ -d ${target}/models ]] ; then
(cd ${target}/models ; go build) 2>${errlog}
if [[ $? != 0 ]] ; then
okcr "Server build OK"
# Build models if any produced
if [[ -d ${target}/models ]] ; then

if ! (cd ${target}/models ; go build) 2>${errlog}; then
errcr "Model build Failed"
if [[ -f ${errlog} ]] ; then errcr `cat ${errlog}` ; rm ${errlog};fi
exit 1
fi
fi
ok `printf " %s..." "Models build OK"`
okcr "Models build OK"
# Build client
if [[ ${buildClient} == "false" ]] ; then
warn "(no client built)"
warncr "(no client built)"
else
(cd ${target_client}/client ; go build) 2>${errlog}
if [[ $? != 0 ]] ; then
if ! (cd ${target_client}/client ; go build) 2>${errlog} ; then
errcr "Client build Failed"
if [[ -f ${errlog} ]] ; then errcr `cat ${errlog}` ; rm ${errlog};fi
exit 1
fi
ok `printf " %s..." "Client build OK"`
okcr "Client build OK"
fi
successcr " [All builds for ${spec}: OK]"
rm -f ${errlog}
Expand Down
2 changes: 1 addition & 1 deletion hack/cover.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ echo "mode: $mode" > "$profile"
for dir in $(go list ./... | grep -v -E 'vendor|fixtures|examples')
do
f="$workdir/$(echo "$dir" | tr / -).cover"
go test -tags netgo -installsuffix netgo -covermode="$mode" -coverprofile="$f" "$dir"
go test -vet off -tags netgo -installsuffix netgo -covermode="$mode" -coverprofile="$f" "$dir"
if [ -f "$f" ]
then
cat "$f" | tail -n +2 >> "$profile"
Expand Down
4 changes: 2 additions & 2 deletions hack/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -eu -o pipefail

prjdir=`git rev-parse --show-toplevel`
prjdir=$(git rev-parse --show-toplevel)

build_binary() {
LDFLAGS="-s -w -X github.com/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/cmd/swagger/commands.Commit=${CIRCLE_SHA1}"
Expand Down Expand Up @@ -32,7 +32,7 @@ upload_to_github() {
sha256sum * > sha256sum.txt

github-release release -u $CIRCLE_PROJECT_USERNAME -r $CIRCLE_PROJECT_REPONAME -t $CIRCLE_TAG -d "$(cat $prjdir/notes/v${CIRCLE_TAG}.md)"
for f in $(ls .); do
for f in *; do
github-release upload -u $CIRCLE_PROJECT_USERNAME -r $CIRCLE_PROJECT_REPONAME -t $CIRCLE_TAG -n $f -f $f
done
}
Expand Down
21 changes: 3 additions & 18 deletions hack/devtools.ps1
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
go get -u -v github.com/alecthomas/gometalinter
go get -u -v golang.org/x/tools/cmd/...
go get -u -v github.com/FiloSottile/gvt
go get -u -v github.com/jteeuwen/go-bindata/...
go get -u -v github.com/kevinburke/go-bindata/go-bindata
go get -u -v github.com/elazarl/go-bindata-assetfs/...
go get -u -v github.com/golang/mock/gomock
go get -u -v github.com/golang/mock/mockgen
go get -u -v github.com/axw/gocov/gocov
go get -u -v gopkg.in/matm/v1/gocov-html
go get -u -v github.com/AlekSi/gocov-xml
go get -u -v github.com/nsf/gocode
go get -u -v github.com/jstemmer/gotags
go get -u -v github.com/rogpeppe/godef
go get -u -v github.com/pquerna/ffjson
go get -u -v github.com/nathany/looper
go get -u -v github.com/kylelemons/godebug/...
go get -u -v github.com/aktau/github-release
go get -u -v github.com/sqs/goreturns
go get -u -v github.com/tpng/gopkgs
go get -u -v github.com/lukehoban/go-outline
go get -u -v github.com/newhook/go-symbols

# install all the linters
gometalinter --install --update
go get -u -v github.com/mitchellh/gox
go get -u -v github.com/golang/dep/cmd/dep
20 changes: 2 additions & 18 deletions hack/devtools.sh
Original file line number Diff line number Diff line change
@@ -1,28 +1,12 @@
#!/bin/sh

go get -u -v github.com/alecthomas/gometalinter
go get -u -v golang.org/x/tools/cmd/...
go get -u -v github.com/FiloSottile/gvt
go get -u -v github.com/jteeuwen/go-bindata/...
go get -u -v github.com/kevinburke/go-bindata/go-bindata
go get -u -v github.com/elazarl/go-bindata-assetfs/...
go get -u -v github.com/golang/mock/gomock
go get -u -v github.com/golang/mock/mockgen
go get -u -v github.com/axw/gocov/gocov
go get -u -v gopkg.in/matm/v1/gocov-html
go get -u -v github.com/AlekSi/gocov-xml
go get -u -v github.com/nsf/gocode
go get -u -v github.com/jstemmer/gotags
go get -u -v github.com/rogpeppe/godef
go get -u -v github.com/pquerna/ffjson
go get -u -v github.com/nathany/looper
go get -u -v github.com/kylelemons/godebug/...
go get -u -v github.com/aktau/github-release
go get -u -v github.com/sqs/goreturns
go get -u -v github.com/tpng/gopkgs
go get -u -v github.com/lukehoban/go-outline
go get -u -v github.com/newhook/go-symbols
go get -u -v github.com/mitchellh/gox
go get -u github.com/golang/dep/cmd/dep
go get -u -v github.com/golang/dep/cmd/dep

# install all the linters
gometalinter --install --update
4 changes: 2 additions & 2 deletions hack/regen-samples.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

examples=`git rev-parse --show-toplevel`/examples
examples=$(git rev-parse --show-toplevel)/examples

# go to project root
cd "${examples}/generated"
Expand Down Expand Up @@ -62,4 +62,4 @@ swagger generate client -A Petstore --template stratoscale
swagger generate server -A Petstore --template stratoscale

cd ${examples}
go test -v ./...
go test -vet off -v ./...
Loading

0 comments on commit c6ce75e

Please sign in to comment.