Skip to content

Commit d1d49f8

Browse files
committed
.github/workflows: work around golang/go#51629
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 <[email protected]>
1 parent bd073b8 commit d1d49f8

File tree

5 files changed

+33
-9
lines changed

5 files changed

+33
-9
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env sh
2+
#
3+
# This is a temporary hack to work around
4+
# https://github.com/golang/go/issues/51629 , wherein the stringer
5+
# generator doesn't work with generics.
6+
#
7+
# This script is the equivalent of `go generate ./...`, except that it
8+
# only runs generate on packages that don't try to use stringer.
9+
10+
find . -name '*.go' | xargs grep -l go:generate | xargs -n1 dirname | sort -u | while read dir; do
11+
if ! grep cmd/stringer $dir/*.go; then
12+
set -x
13+
go generate -tags=hermetic $dir
14+
set +x
15+
fi
16+
done

.github/workflows/go_generate.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,13 @@ jobs:
2525
fetch-depth: 0
2626

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

net/dnsfallback/dnsfallback.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:generate go run update-dns-fallbacks.go
6-
75
// Package dnsfallback contains a DNS fallback mechanism
86
// for starting up Tailscale when the system DNS is broken or otherwise unavailable.
97
package dnsfallback

net/dnsfallback/generate.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright (c) 2022 Tailscale Inc & AUTHORS All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
//go:build !hermetic
6+
// +build !hermetic
7+
8+
package dnsfallback
9+
10+
//go:generate go run update-dns-fallbacks.go

net/dnsfallback/update-dns-fallbacks.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
)
2020

2121
func main() {
22+
log.Printf("RUN RUN RUN")
2223
res, err := http.Get("https://login.tailscale.com/derpmap/default")
2324
if err != nil {
2425
log.Fatal(err)

0 commit comments

Comments
 (0)