Skip to content

Commit

Permalink
Add swagger install + allow version updates in CI
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
cevich authored and mheon committed Oct 18, 2022
1 parent 78d4af8 commit 1a55064
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 \
Expand Down
4 changes: 3 additions & 1 deletion contrib/cirrus/setup_environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions hack/install_golangci.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
31 changes: 31 additions & 0 deletions hack/install_swagger.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1a55064

Please sign in to comment.