Update how Mockery mocks are checked for currency. (#8697)

The use of "go install" is deprecated as a way of installing and running the
Mockery binary. Update the runner script to depend on an ambient version of the
tool and ensure that in CI it's installed.
This commit is contained in:
M. J. Fromberger
2022-06-03 15:02:04 -07:00
committed by GitHub
parent 75a12ea0c6
commit 48ec78e672
2 changed files with 16 additions and 1 deletions

View File

@@ -25,6 +25,9 @@ jobs:
- name: "Check generated mocks"
run: |
set -euo pipefail
readonly MOCKERY=2.12.3 # N.B. no leading "v"
curl -sL "https://github.com/vektra/mockery/releases/download/v${MOCKERY}/mockery_${MOCKERY}_Linux_x86_64.tar.gz" | tar -C /usr/local/bin -xzf -
make mockery 2>/dev/null
if ! git diff --stat --exit-code ; then

View File

@@ -1,3 +1,15 @@
#!/bin/sh
#
# Invoke Mockery v2 to update generated mocks for the given type.
#
# This script runs a locally-installed "mockery" if available, otherwise it
# runs the published Docker container. This legerdemain is so that the CI build
# and a local build can work off the same script.
#
if ! which mockery ; then
mockery() {
docker run --rm -v "$PWD":/w --workdir=/w vektra/mockery:v2.12.3
}
fi
go run github.com/vektra/mockery/v2 --disable-version-string --case underscore --name $*
mockery --disable-version-string --case underscore --name "$@"