ef1bb5ac16
cibuild.On() returns true for any CI environment that sets CI=true, including Alpine Linux's package build CI. TestTsgoRevInCacheKey was guarded by cibuild.On() (or use of tsgo), so it ran under Alpine's CI with stock Go, where go.toolchain.rev isn't blended into build cache keys, and unsurprisingly failed. Add cibuild.OnTailscaleCI, which keys off GITHUB_REPOSITORY_OWNER to distinguish tailscale/tailscale's own GitHub Actions CI from arbitrary downstream CI, and use it in TestTsgoRevInCacheKey. Fixes #19754 Change-Id: Id31cfe71903a235f1460dca1e2fdf334e3ba1ee5 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
27 lines
1.0 KiB
Go
27 lines
1.0 KiB
Go
// Copyright (c) Tailscale Inc & contributors
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
// Package cibuild reports runtime CI information.
|
|
package cibuild
|
|
|
|
import "os"
|
|
|
|
// On reports whether the current binary is executing on a CI system.
|
|
func On() bool {
|
|
// CI env variable is set by GitHub.
|
|
// https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
|
|
return os.Getenv("GITHUB_ACTIONS") != "" || os.Getenv("CI") == "true"
|
|
}
|
|
|
|
// OnTailscaleCI reports whether the current binary is executing on
|
|
// tailscale/tailscale's own GitHub Actions CI, as opposed to a fork's CI
|
|
// or an unrelated downstream CI (such as a Linux distribution's package
|
|
// build infrastructure) that also sets the generic CI=true environment
|
|
// variable.
|
|
func OnTailscaleCI() bool {
|
|
// GITHUB_REPOSITORY_OWNER is set by GitHub Actions to the owner of
|
|
// the repository whose workflow is running. For pull requests, this
|
|
// is the base repository's owner, not the fork's.
|
|
return os.Getenv("GITHUB_REPOSITORY_OWNER") == "tailscale"
|
|
}
|