Skip to content

Commit

Permalink
Update how Mockery mocks are checked for currency.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
M. J. Fromberger committed Jun 3, 2022
1 parent 75a12ea commit 9418c76
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .github/workflows/check-generated.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ jobs:
- name: "Check generated mocks"
run: |
set -euo pipefail
readonly MOCKERY=2.12.3 # N.B. no leading "v"
curl -L "https://github.com/vektra/mockery/releases/download/v${MOCKERY}/mockery_${MOCKERY}_Linux_x86_64.tar.gz" | tar -C /usr/local/bin -xzvf -
make mockery 2>/dev/null
if ! git diff --stat --exit-code ; then
Expand Down
14 changes: 13 additions & 1 deletion scripts/mockery_generate.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
#!/bin/sh
#
# Invoke Mockery v2 to update generated mocks for the given type.
#
# This script runs a locall-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 "$@"

0 comments on commit 9418c76

Please sign in to comment.