generate-swagger / drone build broken on most up to date go-swagger #3535

Closed
opened 2025-11-02 05:16:10 -06:00 by GiteaMirror · 14 comments
Owner

Originally created by @Cherrg on GitHub (Jul 4, 2019).

drone build breaks on

make swagger-check

unfortunately I can't reproduce the error on my local machine

Originally created by @Cherrg on GitHub (Jul 4, 2019). drone build breaks on `make swagger-check` unfortunately I can't reproduce the error on my local machine
GiteaMirror added the issue/criticaltopic/build labels 2025-11-02 05:16:10 -06:00
Author
Owner

@zeripath commented on GitHub (Jul 4, 2019):

I can reproduce this now after having re-run go get -u github.com/go-swagger/go-swagger/cmd/swagger

@zeripath commented on GitHub (Jul 4, 2019): I can reproduce this now after having re-run `go get -u github.com/go-swagger/go-swagger/cmd/swagger`
Author
Owner

@zeripath commented on GitHub (Jul 4, 2019):

OK, so running DEBUG=1 swagger generate spec -o './templates/swagger/v1_json.tmpl' seems to reveal multiple problems.

@zeripath commented on GitHub (Jul 4, 2019): OK, so running `DEBUG=1 swagger generate spec -o './templates/swagger/v1_json.tmpl'` seems to reveal multiple problems.
Author
Owner

@silverwind commented on GitHub (Jul 5, 2019):

Shouldn't go.sum prevent such unwanted dependency updates?

@silverwind commented on GitHub (Jul 5, 2019): Shouldn't `go.sum` prevent such unwanted dependency updates?
Author
Owner

@silverwind commented on GitHub (Jul 5, 2019):

Ah, I see swagger cli is not tracked in go.sum because make swagger-check fetches the latest version in case the global swagger command is absent. Wonder if there is a way to lock such binary golang dependencies in a similar way than we do with npm dependencies and call those binaries from the locally installed modules like we do via npx.

@silverwind commented on GitHub (Jul 5, 2019): Ah, I see `swagger` cli is not tracked in `go.sum` because `make swagger-check` fetches the latest version in case the global `swagger` command is absent. Wonder if there is a way to lock such binary golang dependencies in a similar way than we do with npm dependencies and call those binaries from the locally installed modules like we do via `npx`.
Author
Owner

@lunny commented on GitHub (Jul 5, 2019):

We can

git clone git@github.com:go-swagger/go-swagger $GOPATH/src/github.com/go-swagger/go-swagger
cd $GOPATH/src/github.com/go-swagger/go-swagger/cmd/swagger
go install
@lunny commented on GitHub (Jul 5, 2019): We can ``` git clone git@github.com:go-swagger/go-swagger $GOPATH/src/github.com/go-swagger/go-swagger cd $GOPATH/src/github.com/go-swagger/go-swagger/cmd/swagger go install ```
Author
Owner

@silverwind commented on GitHub (Jul 5, 2019):

@lunny that would still install the latest version which may not be compatible with the last version we tested. If you want to do it via git, I'd say check out a specific revision/tag instead of master.

@silverwind commented on GitHub (Jul 5, 2019): @lunny that would still install the latest version which may not be compatible with the last version we tested. If you want to do it via git, I'd say check out a specific revision/tag instead of master.
Author
Owner

@Cherrg commented on GitHub (Jul 5, 2019):

We can

git clone git@github.com:go-swagger/go-swagger $GOPATH/src/github.com/go-swagger/go-swagger
cd $GOPATH/src/github.com/go-swagger/go-swagger/cmd/swagger
go install

Maybe it is possible to select specific version with something like
go get -u github.com/go-swagger/go-swagger/cmd/swagger@<branch/release/tag/commit>
too.

(i'm not sure if the position of @ is right there)

This will require at least go 1.11. see https://github.com/golang/go/wiki/Modules#daily-workflow

@Cherrg commented on GitHub (Jul 5, 2019): > We can > > ``` > git clone git@github.com:go-swagger/go-swagger $GOPATH/src/github.com/go-swagger/go-swagger > cd $GOPATH/src/github.com/go-swagger/go-swagger/cmd/swagger > go install > ``` Maybe it is possible to select specific version with something like `go get -u github.com/go-swagger/go-swagger/cmd/swagger@<branch/release/tag/commit>` too. (i'm not sure if the position of @ is right there) This will require at least go 1.11. see https://github.com/golang/go/wiki/Modules#daily-workflow
Author
Owner

@Cherrg commented on GitHub (Jul 5, 2019):

@lunny that would still install the latest version which may not be compatible with the last version we tested. If you want to do it via git, I'd say check out a specific revision/tag instead of master.

just add git checkout <tag/commit/branch> before go install to select specific version.

@Cherrg commented on GitHub (Jul 5, 2019): > @lunny that would still install the latest version which may not be compatible with the last version we tested. If you want to do it via git, I'd say check out a specific revision/tag instead of master. just add `git checkout <tag/commit/branch>` before `go install` to select specific version.
Author
Owner

@lunny commented on GitHub (Jul 5, 2019):

@Cherrg right. I missed that.

@lunny commented on GitHub (Jul 5, 2019): @Cherrg right. I missed that.
Author
Owner

@silverwind commented on GitHub (Jul 5, 2019):

I really think golang should provide a way to run a dependency's binary. Very hackish way to accomplish it may be as follows:

  • add go-swagger as module dependency
  • parse commit hash from go.mod
  • install go-swagger via above methods, checking out the hash and build/run it

This method should be applied to everything that is installed in Makefile via go get.

@silverwind commented on GitHub (Jul 5, 2019): I really think golang should provide a way to run a dependency's binary. Very hackish way to accomplish it may be as follows: - add go-swagger as module dependency - parse commit hash from `go.mod` - install go-swagger via above methods, checking out the hash and build/run it This method should be applied to everything that is installed in `Makefile` via `go get`.
Author
Owner

@Cherrg commented on GitHub (Jul 5, 2019):

it seems build is broken only on master branch of go-swagger. The latest release works fine.

@Cherrg commented on GitHub (Jul 5, 2019): it seems build is broken only on master branch of go-swagger. The latest release works fine.
Author
Owner

@zeripath commented on GitHub (Jul 6, 2019):

OK I've git bisected to find the bad commit in go-swagger that breaks:

abb699c1305f28328fdb644d6e08556efefc13cf is the first bad commit
commit abb699c1305f28328fdb644d6e08556efefc13cf
Author: Ivan Porto Carrero <ivan@flanders.co.nz>
Date:   Sun Jun 30 10:24:08 2019 -0700

    add codescanner that is go modules aware
    
    Signed-off-by: Ivan Porto Carrero <ivan@flanders.co.nz>

:100644 100644 aa0d6625a8eb94c1823d46a374c753bcb8d8ca0d b3e5b5c9c0c7b3d212764c2346ffab86b5f30259 M	.golangci.yml
:100644 100644 52b955942f43b0140eef9c3a30a8934cc336c31e c12083141e5ed1bb0d8f1d617a45483c70f67e27 M	Dockerfile.ci
:040000 040000 ffb16430b1d3dbdb7a262be0af5501d3b70374af a6f164e2f402f430afc30717c639aea86071adc3 M	cmd
:000000 040000 0000000000000000000000000000000000000000 ac7627814096421c84d1fd3d4b38e5203ebd81ab A	codescan
:100644 100644 53a781bd5dd44c380ea57930853ad71ef5423c71 47a586d56774496694b3bab9dbd93ac856b2d8ff M	go.mod
:100644 100644 59a4cf664dbea272c19f81cd4a62f000b0e78395 0b6bf8196be356b008d7737328286d9774e4a568 M	go.sum
:040000 040000 55718e7777c34ca547c92a05a4f39285fdb62550 76e98bf3fd8725b96890ebaaafd80d3f7b6d1780 M	hack
:040000 040000 d1fe92ecdecb107b7493261cc3a1637668548c96 38f13f7c4cdbf7f182102a2dd127b820b008fcad M	vendor
@zeripath commented on GitHub (Jul 6, 2019): OK I've git bisected to find the bad commit in go-swagger that breaks: ``` abb699c1305f28328fdb644d6e08556efefc13cf is the first bad commit commit abb699c1305f28328fdb644d6e08556efefc13cf Author: Ivan Porto Carrero <ivan@flanders.co.nz> Date: Sun Jun 30 10:24:08 2019 -0700 add codescanner that is go modules aware Signed-off-by: Ivan Porto Carrero <ivan@flanders.co.nz> :100644 100644 aa0d6625a8eb94c1823d46a374c753bcb8d8ca0d b3e5b5c9c0c7b3d212764c2346ffab86b5f30259 M .golangci.yml :100644 100644 52b955942f43b0140eef9c3a30a8934cc336c31e c12083141e5ed1bb0d8f1d617a45483c70f67e27 M Dockerfile.ci :040000 040000 ffb16430b1d3dbdb7a262be0af5501d3b70374af a6f164e2f402f430afc30717c639aea86071adc3 M cmd :000000 040000 0000000000000000000000000000000000000000 ac7627814096421c84d1fd3d4b38e5203ebd81ab A codescan :100644 100644 53a781bd5dd44c380ea57930853ad71ef5423c71 47a586d56774496694b3bab9dbd93ac856b2d8ff M go.mod :100644 100644 59a4cf664dbea272c19f81cd4a62f000b0e78395 0b6bf8196be356b008d7737328286d9774e4a568 M go.sum :040000 040000 55718e7777c34ca547c92a05a4f39285fdb62550 76e98bf3fd8725b96890ebaaafd80d3f7b6d1780 M hack :040000 040000 d1fe92ecdecb107b7493261cc3a1637668548c96 38f13f7c4cdbf7f182102a2dd127b820b008fcad M vendor ```
Author
Owner

@lunny commented on GitHub (Jul 6, 2019):

Closed by #7362

@lunny commented on GitHub (Jul 6, 2019): Closed by #7362
Author
Owner

@casualjim commented on GitHub (Jul 8, 2019):

This should be fixed now in go-swagger with the version that's on master

but you may want to change how you get the binary for go-swagger because we no longer use a vendor directory.

Install latest binary to $GOPATH/bin

download_url=$(curl -s https://api.github.com/repos/go-swagger/go-swagger/releases/latest | \
  jq -r '.assets[] | select(.name | contains("'"$(uname | tr '[:upper:]' '[:lower:]')"'_amd64")) | .browser_download_url')
curl -o $(go env GOPATH)/bin/swagger -L'#' "$download_url"
chmod +x $(go env GOPATH)/bin/swagger

or build from source:

dir=$(mktemp -d) 
git clone https://github.com/go-swagger/go-swagger "$dir" 
cd "$dir"
go install ./cmd/swagger
@casualjim commented on GitHub (Jul 8, 2019): This should be fixed now in go-swagger with the version that's on master but you may want to change how you get the binary for go-swagger because we no longer use a vendor directory. Install latest binary to $GOPATH/bin ```sh download_url=$(curl -s https://api.github.com/repos/go-swagger/go-swagger/releases/latest | \ jq -r '.assets[] | select(.name | contains("'"$(uname | tr '[:upper:]' '[:lower:]')"'_amd64")) | .browser_download_url') curl -o $(go env GOPATH)/bin/swagger -L'#' "$download_url" chmod +x $(go env GOPATH)/bin/swagger ``` or build from source: ```sh dir=$(mktemp -d) git clone https://github.com/go-swagger/go-swagger "$dir" cd "$dir" go install ./cmd/swagger ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#3535