Merge pull request #16161 from cevich/install_swagger

[CI:DOCS] Add swagger install + allow version updates in CI
This commit is contained in:
OpenShift Merge Robot
2022-10-14 17:53:13 -04:00
committed by GitHub
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