Add swagger install + allow version updates in CI

Support swagger testing and optional runtime updates similar to
the current golangci-lint tool.  This allows developers to update the
version of swagger at runtime if needed.  Otherwise new CI VM images
will pick up the prescribed version at image build-time via
`make install.tools`.

Signed-off-by: Chris Evich <cevich@redhat.com>
This commit is contained in:
Chris Evich 2022-10-13 12:58:21 -04:00
parent 2a622c8af4
commit bb2b47dc70
No known key found for this signature in database
GPG key ID: 03EDC70FD578067F
4 changed files with 46 additions and 2 deletions

View file

@ -849,7 +849,7 @@ install.systemd:
endif
.PHONY: install.tools
install.tools: .install.ginkgo .install.golangci-lint ## Install needed tools
install.tools: .install.ginkgo .install.golangci-lint .install.swagger ## Install needed tools
$(MAKE) -C test/tools
.PHONY: .install.goimports
@ -868,6 +868,14 @@ install.tools: .install.ginkgo .install.golangci-lint ## Install needed tools
.install.golangci-lint:
VERSION=1.46.2 ./hack/install_golangci.sh
.PHONY: .install.swagger
.install.swagger:
env VERSION=0.30.3 \
BINDIR=$(BINDIR) \
GOOS=$(GOOS) \
GOARCH=$(GOARCH) \
./hack/install_swagger.sh
.PHONY: .install.md2man
.install.md2man:
if [ ! -x "$(GOMD2MAN)" ]; then \

View file

@ -363,7 +363,9 @@ case "$TEST_FLAVOR" in
showrun $ssh podman tag $helper_fqin \
docker.io/gitlab/gitlab-runner-helper:x86_64-latest-pwsh
;;
swagger) ;& # use next item
swagger)
make .install.swagger
;;
release) ;;
*) die_unknown TEST_FLAVOR
esac

View file

@ -1,5 +1,8 @@
#!/usr/bin/env bash
# This script is intended to be a convenience, to be called from the
# Makefile `.install.golangci-lint` target. Any other usage is not recommended.
die() { echo "${1:-No error message given} (from $(basename $0))"; exit 1; }
[ -n "$VERSION" ] || die "\$VERSION is empty or undefined"

31
hack/install_swagger.sh Executable file
View file

@ -0,0 +1,31 @@
#!/usr/bin/env bash
# This script is intended to be a convenience, to be called from the
# Makefile `.install.swagger` target. Any other usage is not recommended.
BIN="$BINDIR/swagger"
die() { echo "${1:-No error message given} (from $(basename $0))"; exit 1; }
function install() {
echo "Installing swagger v$VERSION into $BIN"
curl -sS --retry 5 --location -o $BIN \
https://github.com/go-swagger/go-swagger/releases/download/v$VERSION/swagger_${GOOS}_${GOARCH}
chmod +x $BIN
$BIN version
}
for req_var in VERSION BINDIR GOOS GOARCH; do
[[ -n "${!req_var}" ]] || die "\$$req_var is empty or undefined"
done
if [ ! -x "$BIN" ]; then
install
else
$BIN version | grep "$VERSION"
if [[ "$?" -eq 0 ]]; then
echo "Using existing $BIN"
else
install
fi
fi