ci

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 13 Imported by: 2 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ci renders the application's CI workflows from the code, and owns them: .github/workflows/ci.yml, the checks on every pull request; .github/workflows/ci-cache.yml, the run after a push to the default branch or a patch release branch that fills the caches the checks restore; and .github/workflows/security-scan.yml, the daily run of the vulnerability check and the image scan over the default branch and the latest release, which reports to an issue of the repository. impulse render writes them (impulse new, add site and remove site write them as part of their change), impulse check compares the committed files with what the code renders and fails a hand edit, and bedrock reads the job ids as the check names its repository rule requires. The workflows are plain jobs with fixed ids; no job calls a reusable workflow of another repository, no job posts anywhere outside the repository, every action is pinned by commit with its tag in a comment, and every tool version is a constant here, so a change to a check is an impulse release and the pins move with it.

The caches never serve a stale result. The Go module cache holds downloads go.sum names, each verified against it when read, and the Go build cache is addressed by the hash of an action's inputs (the toolchain, the flags, the sources, the dependencies' outputs), so an entry from an older commit is either exactly what the current one would compute or unused; the jobs restore the nearest entry they find for that reason. Go's cached test results are the one reuse whose inputs Go cannot see in full (a test that reads a running emulator, say), so they are off unless the application's //impulse:ci line turns them on. Nothing else is cached: the image build compiles fresh by design (its download stages are a minute of the job, and the Actions cache's export of them cost more than it saved), and the vulnerability databases, Semgrep's rules and the emulator images are fetched when the job runs.

Index

Constants

View Source
const (
	// GolangciLint is the golangci-lint release the skeleton's .golangci.yml is written for.
	GolangciLint = "v2.14.0"
	// Bun is the Bun that wrote the skeleton's bun.lock, so CI installs with the same one.
	Bun = "1.4.0"
	// Govulncheck is the govulncheck release run over the module.
	Govulncheck = "v1.8.0"
	// Semgrep is the Semgrep release, and SemgrepDigest the digest of the semgrep/semgrep
	// image at that tag (the manifest list, so the runner's platform resolves), since an
	// image tag can move and a digest cannot.
	Semgrep       = "1.179.0"
	SemgrepDigest = "sha256:93963d9295a366f59e4850127b1550400ee7b388f04fe144e4a1f6325d96e01b"
	// TruffleHog is the TruffleHog release: the action is pinned at it, and the action's
	// version input runs the scanner at it too, since the action alone would run latest.
	TruffleHog = "3.95.7"
)

The tool versions the workflow pins. Each is written here once and read into the template, so a bump is one edit and an impulse release.

View Source
const CacheFile = ".github/workflows/ci-cache.yml"

CacheFile is where the cache-filling workflow lives: the run after a push to the default branch (main or master) or a patch branch that builds and tests at the branch's head, as the pull request jobs do, and saves the caches under the same keys they restore, so a pull request's first run starts from the branch it targets. The tests run rather than compile, since what a test builds as it runs (the generators' tests build code) is in the cache only when it ran.

View Source
const File = ".github/workflows/ci.yml"

File is where the pull request workflow lives in an application, root-relative.

View Source
const LargeRunnerVariable = "CI_LARGE_RUNNER"

LargeRunnerVariable is the GitHub Actions variable (on the repository or the organization) naming the larger runner: a runner label or a runner group. The jobs the application's //impulse:ci line lists under large-runner (DefaultLargeRunner without one) run on it while it is set, and on GitHub's standard runner while it is unset, as every other job does.

View Source
const ScanFile = ".github/workflows/security-scan.yml"

ScanFile is where the security scan lives: the run every day at ScanSchedule, and on demand, of govulncheck over the module and Grype over the built image at the default branch and at the latest release, since nothing else rescans either between pull requests and a vulnerability is published on its own day. A failed check or scan opens one issue of the repository under ScanIssueTitle (or comments on the open one), and a run that passes closes it; the workflow calls no reusable workflow and posts nowhere else.

View Source
const ScanIssueTitle = "Security scan: a vulnerability check or an image scan failed"

ScanIssueTitle is the title of the one issue the security scan reports to: the report job finds the open issue by this title exactly, so the title is fixed.

View Source
const ScanSchedule = "0 14 * * *"

ScanSchedule is when the security scan runs, as cron reads it: 14:00 UTC every day.

View Source
const StandardRunner = "ubuntu-latest"

StandardRunner is the runner every job runs on while LargeRunnerVariable is unset, and the jobs not on the larger runner always.

Variables

View Source
var (
	DefaultBranches = []string{"main", "master"}
	PatchBranches   = "patch/**"
)

DefaultBranches are the names the cache-filling workflow runs on when the application's //impulse:ci line declares no default-branch: GitHub's two usual names, of which a repository has one, so the other is never pushed to. PatchBranches is the pattern of the patch lines bedrock's patch command creates, which the workflow runs on too.

View Source
var CachedJobs = []CachedJob{
	{Job: goBuild, From: goBuild, Saves: true},
	{Job: goTest, From: goTest, Saves: true},
	{Job: goTestSkipAuth, From: goTestSkipAuth, Saves: true},
	{Job: goLint, From: goBuild},
	{Job: goLintSkipAuth, From: goBuild},
	{Job: goVuln, From: goBuild},
	{Job: goCheck, From: goBuild},
}

CachedJobs lists the Go legs that restore the saved Go caches (the module cache and the build cache), in the file's order: go-build, go-test and go-test-skipauth each restore the nearest entry of their own lineage and save one when no entry for their go.sum existed, since their builds differ (the race detector, the tags); the two lint legs, go-vuln and go-check restore go-build's, which holds what their compiles share with it, and save nothing. golangci-lint loads every package through that compile, so a lint leg that started from nothing after a dependency change ran past its timeout on a cold runner; the lint legs keep golangci-lint's own cache beside the restored entry.

View Source
var DefaultLargeRunner = []string{goTest, goTestSkipAuth, image}

DefaultLargeRunner are the jobs on the larger runner when the application's //impulse:ci line does not say: the two test legs and the image build, the jobs that take the most machine.

Files are the workflows impulse owns, in the order Write writes and Compare reads them.

View Source
var FixedChecks = []string{"title", goGate, webGate, image, "secrets", "migrations"}

FixedChecks are the job ids every application's workflow carries, in the file's order with the Go legs and the browser jobs left out (the legs precede go, the gate over them; the browser jobs follow go and are per application, and web, the gate over them, follows them and is fixed). A required-checks rule names these.

View Source
var GoJobs = []string{goBuild, goTest, goTestSkipAuth, goLint, goLintSkipAuth, goVuln, "go-semgrep", goCheck}

GoJobs are the Go legs, in the file's order: the jobs the go gate needs, each running at once with the others.

View Source
var TitleTypes = []string{"feat", "feature", "fix", "perf", "revert", "docs", "deps", "upgrade", "infra", "config", "style", "chore", "refactor", "cleanup", "test", "build", "ci"}

TitleTypes are the conventional-commit types the title check accepts, in the order the workflow lists them: first the types a merge of which releases (feat and feature a minor version, the rest a patch), then the types release-please hides, a merge of which alone opens no release pull request. bedrock seeds a changelog section per type into release-please-config.json and its check refuses a configuration missing one, since release-please drops a merge whose type has no section exactly as it drops a hidden one, so a merge of only such titles would never deploy.

Functions

func Checks

func Checks(a *app.App) []string

Checks lists the job ids of the workflow Render produces for the application, in the file's order: title, the Go legs, go, one job per browser workspace, web, image, secrets, migrations. These are the check names the pull request reports.

func List

func List(names []string) string

List writes names as prose: a; a and b; a, b and c.

func Render

func Render(a *app.App) ([]byte, error)

Render produces the pull request workflow (File) for the application: deterministic for one application and one impulse.

func RenderFile

func RenderFile(a *app.App, file string) ([]byte, error)

RenderFile produces one owned workflow, File, CacheFile or ScanFile.

Types

type CachedJob

type CachedJob struct {
	// Job is the leg; From is the job whose entries it restores (itself, or go-build);
	// Saves reports that the pull request run saves an entry of its own when it found
	// none for its go.sum.
	Job, From string
	Saves     bool
}

CachedJob is one Go leg's use of the saved Go caches.

type Difference

type Difference struct {
	// File is the owned file that differs.
	File string
	// Missing reports that the application has no such file at all.
	Missing bool
	// Line is the first differing line, counting from 1 (0 when Missing). Want is that
	// line as the code renders it and Got as the file has it; either is empty when that
	// side ended first.
	Line int
	Want string
	Got  string
}

Difference is how a committed workflow departs from what the code renders.

func Compare

func Compare(a *app.App) (*Difference, error)

Compare reads the committed workflows and compares each with what the code renders: nil when all are equal, otherwise the first difference, in Files' order.

func (*Difference) String

func (d *Difference) String() string

String says what differs in one line, for a check to print: the file and line, what the code renders there and what the file has (an empty string where either side has ended).

type FileOutcome

type FileOutcome struct {
	File    string
	Written bool
}

FileOutcome is Write's outcome for one owned file.

type Outcome

type Outcome struct {
	// Written is true when a file was created or changed, false when every file
	// already read as the code renders.
	Written bool
	// Files says it per file, in Files' order.
	Files []FileOutcome
}

Outcome reports what Write did.

func Write

func Write(a *app.App) (Outcome, error)

Write renders the workflows and writes each at its path when the committed file differs or is missing, creating .github/workflows. The files are project files a person reads and commits, so they take the conventional 0644.

func (Outcome) WrittenFiles

func (o Outcome) WrittenFiles() []string

WrittenFiles lists the files Write created or changed, in Files' order.

type Settings

type Settings struct {
	// LargeRunner are the jobs that run on the runner LargeRunnerVariable names, by job
	// id: DefaultLargeRunner, or the line's large-runner (none is an empty list).
	LargeRunner []string
	// DefaultBranches are the branches the cache-filling workflow runs on besides the
	// patch lines: DefaultBranches, or the one branch the line's default-branch names.
	DefaultBranches []string
	// TestCache reports that the test legs reuse Go's cached test results, which carry
	// over between runs in the saved build cache: off (go test -count=1) unless the line
	// says test-cache=on. Go reuses a passed test's result when the test binary, the
	// files it read and the environment it read are unchanged; it cannot see a running
	// emulator's image, so an application turns this on when its tests' inputs are all
	// in the tree or pinned by digest.
	TestCache bool
}

Settings are what the application's //impulse:ci line decides, with impulse's defaults where the line, or the application, says nothing.

func SettingsOf

func SettingsOf(a *app.App) (Settings, error)

SettingsOf reads the application's //impulse:ci line into Settings, filling the defaults, and refuses a large-runner job the workflow does not render: a job id must be one of Checks(a) and not a gate (go and web run nothing).

type Workspace

type Workspace struct {
	// Dir is the workspace directory, root-relative (where angular.json is).
	Dir string
	// Job is the id of its job in the workflow, and so the check name the pull request
	// reports.
	Job string
}

Workspace is one browser workspace with the id of the job that installs, builds, lints and tests it.

func Workspaces

func Workspaces(a *app.App) []Workspace

Workspaces lists the application's browser workspaces, sorted by directory, each with its job id: angular-web for the workspace at web, angular-<site> for apps/<site>/web (the directory impulse add site gives a site's workspace), and for any other directory angular- followed by the path's segments joined with -, a trailing web dropped (web/console is angular-web-console, apps/pilots/gui is angular-apps-pilots-gui); a workspace at the application root is angular-root.

Jump to

Keyboard shortcuts

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