Skip to content

Commit

Permalink
.github/workflows: work around golang/go#51629
Browse files Browse the repository at this point in the history
Incidentally, simplify the go generate CI workflow, by
marking the dnsfallback update non-hermetic (so CI will
skip it) rather than manually filter it out of `go list`.

Updates #4194

Signed-off-by: David Anderson <danderson@tailscale.com>
  • Loading branch information
danderson committed Mar 18, 2022
1 parent 1881876 commit 2a412ac
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/go-generate-without-stringer.sh
@@ -0,0 +1,18 @@
#!/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.

set -e

find . -name '*.go' | xargs grep -l go:generate | xargs -n1 dirname | sort -u | while read dir; do
if ! egrep "cmd/(stringer|cloner)" $dir/*.go; then
set -x
go generate -tags=hermetic $dir
set +x
fi
done
13 changes: 6 additions & 7 deletions .github/workflows/go_generate.yml
Expand Up @@ -25,14 +25,13 @@ 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
set -e
./.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)
2 changes: 0 additions & 2 deletions net/dnsfallback/dnsfallback.go
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:generate go run update-dns-fallbacks.go

// Package dnsfallback contains a DNS fallback mechanism
// for starting up Tailscale when the system DNS is broken or otherwise unavailable.
package dnsfallback
Expand Down
10 changes: 10 additions & 0 deletions net/dnsfallback/generate.go
@@ -0,0 +1,10 @@
// Copyright (c) 2022 Tailscale Inc & AUTHORS All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build !hermetic
// +build !hermetic

package dnsfallback

//go:generate go run update-dns-fallbacks.go

0 comments on commit 2a412ac

Please sign in to comment.