gates

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package gates is "ypy ci": the checks every change passes before it is pushed. Each gate is a small function with a name; "ypy ci" runs them in order and prints a summary. The same command runs in the GitHub workflow.

Index

Constants

View Source
const RequireFirefoxEnv = "YPY_REQUIRE_FIREFOX"

RequireFirefoxEnv, when set to 1, makes a missing Firefox or geckodriver fail the browser gate instead of falling back to Chrome. The GitHub workflow sets it.

Variables

This section is empty.

Functions

func Command

func Command() cli.Command

Command is the "ci" subcommand.

func ResolveBrowsers

func ResolveBrowsers(requested string, firefoxReady bool, why string, require bool) (list, warning string, err error)

ResolveBrowsers turns the --browsers option into the list the browser gate runs.

Without an explicit list the default is chrome and, when Firefox can be driven, firefox. When it cannot: with require it is an error, otherwise the list is chrome and the warning says why Firefox was left out. An explicit list is used as given, except that with require the list must include firefox and Firefox must be ready.

Types

type Env

type Env struct {
	Root string
	Out  io.Writer
	Err  io.Writer
	IO   cli.IO
	// Browser options, passed to the "browser" and "e2e" gates.
	Browsers   string
	ChromePath string
	Port       int
	Strict     bool
}

Env is what a gate may use.

type Gate

type Gate struct {
	Name    string
	Summary string
	Run     func(ctx context.Context, e *Env) Result
}

Gate is one check.

func All

func All() []Gate

All returns the gates in the order "ypy ci" runs them: the cheap ones first.

func OptIn

func OptIn() []Gate

OptIn returns the gates that "ypy ci" does not run unless they are named: they are slower or need a reference, so they are off by default.

type Result

type Result struct {
	Err      error
	Warnings []string
	// Skipped, when not empty, says why the gate did not run.
	Skipped string
}

Result of a gate. A nil Err passes; Warnings are shown but do not fail.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL