Skip to content

Commit

Permalink
.github/workflows: work around golang/go#51629
Browse files Browse the repository at this point in the history
honk
Updates #4194

Signed-off-by: David Anderson <danderson@tailscale.com>
  • Loading branch information
danderson committed Mar 17, 2022
1 parent bd073b8 commit e49cd0b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
16 changes: 16 additions & 0 deletions .github/workflows/go-generate-without-stringer.sh
@@ -0,0 +1,16 @@
#!/usr/bin/env sh
#
# This is a temporary hack to work around
# https://github.com/golang/go/issues/51629 , wherein the stringer
# generator doesn't work with generics.
#
# This script is the equivalent of `go generate ./...`, except that it
# only runs generate on packages that don't try to use stringer.

find . -name '*.go' | xargs grep -l go:generate | xargs -n1 dirname | sort -u | while read dir; do
if ! grep cmd/stringer $dir/*.go; then
set -x
go generate -tags=hermetic $dir
set +x
fi
done
6 changes: 5 additions & 1 deletion .github/workflows/go_generate.yml
Expand Up @@ -25,14 +25,18 @@ jobs:
fetch-depth: 0

- name: check 'go generate' is clean
# The shell script invocation below is a temporary hack for
# https://github.com/tailscale/tailscale/issues/4194. When
# that issue is fixed, replace its invocation with:
# go generate --tags=hermetic ./...
run: |
if [[ "${{github.ref}}" == release-branch/* ]]
then
pkgs=$(go list ./... | grep -v dnsfallback)
else
pkgs=$(go list ./... | grep -v dnsfallback)
fi
go generate $pkgs
./.github/workflows/go-generate-without-stringer.sh
echo
echo
git diff --name-only --exit-code || (echo "The files above need updating. Please run 'go generate'."; exit 1)

0 comments on commit e49cd0b

Please sign in to comment.