Documentation
¶
Index ¶
- func BuildTestID(filePath string, titleParts []string) string
- func Log(msg string)
- func Logf(format string, args ...any)
- func NormalizeTestID(id string) string
- func ScanPackageTests() []string
- func Warn(msg string)
- type Base64Credentials
- type CacheManager
- func (CacheManager) Cleanup(dir string) error
- func (CacheManager) MergeDiscoveredIDs(dir string) ([]string, error)
- func (CacheManager) ReadResolverCache(cacheFile string) ([]byte, error)
- func (CacheManager) WriteDiscoveredIDs(dir string, ids []string) error
- func (CacheManager) WriteResolverCache(data []byte) (string, error)
- type Credentials
- type FetchAllResult
- type FileCredentials
- type ServiceAccountCredentials
- type SheetFetchResult
- type SheetsClient
- type SheetsWriter
- type SkipperConfig
- type SkipperMode
- type SkipperResolver
- type TestEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildTestID ¶
BuildTestID constructs a test ID in the format:
"{relative/path/to/file_test.go} > {titleParts[0]} > ... > {titleParts[n]}"
If filePath is absolute, it is made relative to the current working directory. Path separators are normalized to forward slashes.
func NormalizeTestID ¶
NormalizeTestID lowercases a test ID and collapses multiple whitespace characters into a single space. Used for case-insensitive matching.
func ScanPackageTests ¶
func ScanPackageTests() []string
ScanPackageTests scans the *_test.go files in the current working directory and returns test IDs for all top-level TestXxx functions found. Intended for use in TestMain / suite setup to pre-discover tests that do not explicitly call SkipIfDisabled, so they appear in the spreadsheet in sync mode.
Types ¶
type Base64Credentials ¶
type Base64Credentials struct {
Encoded string
}
Base64Credentials decodes a base64-encoded service account JSON string. Useful for passing credentials via environment variables in CI/CD.
func (Base64Credentials) Resolve ¶
func (c Base64Credentials) Resolve() ([]byte, error)
type CacheManager ¶
type CacheManager struct{}
CacheManager manages the temporary directory used to share resolver state between the main test process and any parallel worker processes.
func (CacheManager) Cleanup ¶
func (CacheManager) Cleanup(dir string) error
Cleanup removes the temp directory and all its contents.
func (CacheManager) MergeDiscoveredIDs ¶
func (CacheManager) MergeDiscoveredIDs(dir string) ([]string, error)
MergeDiscoveredIDs reads all per-process discovered ID files from dir, deduplicates them, and returns the combined list.
func (CacheManager) ReadResolverCache ¶
func (CacheManager) ReadResolverCache(cacheFile string) ([]byte, error)
ReadResolverCache reads the serialized resolver data from the given file path.
func (CacheManager) WriteDiscoveredIDs ¶
func (CacheManager) WriteDiscoveredIDs(dir string, ids []string) error
WriteDiscoveredIDs writes a list of discovered test IDs to an individual file inside dir. File names include the process ID and a random suffix to avoid collisions in parallel test environments.
func (CacheManager) WriteResolverCache ¶
func (CacheManager) WriteResolverCache(data []byte) (string, error)
WriteResolverCache writes serialized resolver data to a new temp directory and returns the directory path. Set SKIPPER_CACHE_FILE to dir/cache.json so worker processes can rehydrate the resolver.
type Credentials ¶
Credentials resolves to a Google service account JSON map.
type FetchAllResult ¶
type FetchAllResult struct {
Primary SheetFetchResult
Entries []TestEntry // merged from primary + reference sheets (most restrictive wins)
Service *sheets.Service
}
FetchAllResult holds data from all sheets and the authenticated Sheets service so it can be reused by SheetsWriter without re-authenticating.
type FileCredentials ¶
type FileCredentials struct {
Path string
}
FileCredentials reads a service account JSON from a file path.
func (FileCredentials) Resolve ¶
func (c FileCredentials) Resolve() ([]byte, error)
type ServiceAccountCredentials ¶
type ServiceAccountCredentials struct {
Type string `json:"type"`
ProjectID string `json:"project_id"`
PrivateKeyID string `json:"private_key_id"`
PrivateKey string `json:"private_key"`
ClientEmail string `json:"client_email"`
ClientID string `json:"client_id"`
AuthURI string `json:"auth_uri"`
TokenURI string `json:"token_uri"`
AuthProviderX509CertURL string `json:"auth_provider_x509_cert_url"`
ClientX509CertURL string `json:"client_x509_cert_url"`
}
ServiceAccountCredentials holds the parsed service account fields inline.
func (ServiceAccountCredentials) Resolve ¶
func (c ServiceAccountCredentials) Resolve() ([]byte, error)
type SheetFetchResult ¶
SheetFetchResult holds the parsed data from a single sheet.
type SheetsClient ¶
type SheetsClient struct {
// contains filtered or unexported fields
}
SheetsClient authenticates and fetches data from a Google Spreadsheet.
func NewSheetsClient ¶
func NewSheetsClient(config SkipperConfig) *SheetsClient
NewSheetsClient creates a new SheetsClient.
func (*SheetsClient) FetchAll ¶
func (c *SheetsClient) FetchAll(ctx context.Context) (*FetchAllResult, error)
FetchAll fetches all relevant sheets and returns merged entries. The returned FetchAllResult.Service can be reused by SheetsWriter.
type SheetsWriter ¶
type SheetsWriter struct {
// contains filtered or unexported fields
}
SheetsWriter reconciles a Google Spreadsheet with a set of discovered test IDs.
func NewSheetsWriter ¶
func NewSheetsWriter(config SkipperConfig) *SheetsWriter
NewSheetsWriter creates a new SheetsWriter.
type SkipperConfig ¶
type SkipperConfig struct {
SpreadsheetID string
Credentials Credentials
SheetName string // empty → use first sheet
ReferenceSheets []string // read-only sheets merged into the resolver cache
TestIDColumn string // default: "testId"
DisabledUntilColumn string // default: "disabledUntil"
}
SkipperConfig holds the complete configuration for a Skipper resolver.
type SkipperMode ¶
type SkipperMode string
SkipperMode controls whether Skipper only reads from the spreadsheet or also syncs discovered test IDs back to it.
const ( // SkipperModeReadOnly fetches the spreadsheet and skips disabled tests. // This is the default mode. SkipperModeReadOnly SkipperMode = "read-only" // SkipperModeSync fetches the spreadsheet, skips disabled tests, and // then reconciles the spreadsheet with the set of discovered test IDs. SkipperModeSync SkipperMode = "sync" )
func SkipperModeFromEnv ¶
func SkipperModeFromEnv() SkipperMode
SkipperModeFromEnv returns the mode configured via the SKIPPER_MODE env var. Defaults to SkipperModeReadOnly.
type SkipperResolver ¶
type SkipperResolver struct {
// contains filtered or unexported fields
}
SkipperResolver fetches a Google Spreadsheet and determines whether individual tests should run based on their disabledUntil dates.
func FromMarshaledCache ¶
func FromMarshaledCache(data []byte) (*SkipperResolver, error)
FromMarshaledCache rehydrates a SkipperResolver from JSON bytes produced by MarshalCache. The resulting resolver does not need Initialize to be called again.
func NewSkipperResolver ¶
func NewSkipperResolver(config SkipperConfig) *SkipperResolver
NewSkipperResolver creates a new resolver. Call Initialize before use.
func (*SkipperResolver) GetDisabledUntil ¶
func (r *SkipperResolver) GetDisabledUntil(testID string) *time.Time
GetDisabledUntil returns the disabledUntil date for a test ID, or nil if the test is not in the spreadsheet or has no date set.
func (*SkipperResolver) Initialize ¶
func (r *SkipperResolver) Initialize(ctx context.Context) error
Initialize fetches the spreadsheet and populates the internal cache. Must be called once before IsTestEnabled.
func (*SkipperResolver) IsTestEnabled ¶
func (r *SkipperResolver) IsTestEnabled(testID string) bool
IsTestEnabled reports whether a test should run.
- Tests not in the spreadsheet always run (opt-out model).
- Tests with a nil or past disabledUntil date run normally.
- Tests with a future disabledUntil date are skipped.
func (*SkipperResolver) MarshalCache ¶
func (r *SkipperResolver) MarshalCache() ([]byte, error)
MarshalCache serializes the resolver cache to JSON bytes for sharing with worker processes via a temp file.