ghworkflow

package
v0.0.0-...-f249b6c Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package ghworkflow implements output to .github/workflows/ci.yaml.

Index

Constants

View Source
const (
	// HostedRunner is the name of the hosted runner.
	HostedRunner = "self-hosted"
	// GenericRunner is the name of the generic runner.
	GenericRunner = "generic"
	// PkgsRunner is the name of the default runner for packages.
	PkgsRunner = "pkgs"
	// DefaultSkipCondition is the default condition to skip the workflow.
	DefaultSkipCondition = "(!startsWith(github.head_ref, 'renovate/') && !startsWith(github.head_ref, 'dependabot/'))"

	// IssueLabelRetrieveScript is the default script to retrieve issue labels.
	IssueLabelRetrieveScript = `` /* 256-byte string literal not displayed */

	// SystemInfoPrintScript is the script to print system info.
	SystemInfoPrintScript = `` /* 669-byte string literal not displayed */

)

Variables

This section is empty.

Functions

func DefaultJobPermissions

func DefaultJobPermissions() map[string]string

DefaultJobPermissions returns default job permissions.

func DefaultServices

func DefaultServices() map[string]Service

DefaultServices returns default services for the workflow.

Types

type Branches

type Branches []string

Branches represents GitHub Actions branch filters.

type Compiler

type Compiler interface {
	CompileGitHubWorkflow(*Output) error
}

Compiler is implemented by project blocks which support GitHub Actions config generation.

type Concurrency

type Concurrency struct {
	Group            string `yaml:"group"`
	CancelInProgress bool   `yaml:"cancel-in-progress"`
}

Concurrency represents GitHub Actions concurrency.

type Job

type Job struct {
	Permissions map[string]string  `yaml:"permissions,omitempty"`
	RunsOn      []string           `yaml:"runs-on"`
	If          string             `yaml:"if,omitempty"`
	Needs       []string           `yaml:"needs,omitempty"`
	Outputs     map[string]string  `yaml:"outputs,omitempty"`
	Services    map[string]Service `yaml:"services,omitempty"`
	Steps       []*JobStep         `yaml:"steps"`
}

Job represents GitHub Actions job.

func (*Job) SetConditions

func (job *Job) SetConditions(conditions ...string) error

SetConditions sets job conditions.

type JobStep

type JobStep struct {
	Name            string            `yaml:"name"`
	ID              string            `yaml:"id,omitempty"`
	If              string            `yaml:"if,omitempty"`
	Uses            string            `yaml:"uses,omitempty"`
	With            map[string]string `yaml:"with,omitempty"`
	Env             map[string]string `yaml:"env,omitempty"`
	Run             string            `yaml:"run,omitempty"`
	ContinueOnError bool              `yaml:"continue-on-error,omitempty"`
	TimeoutMinutes  int               `yaml:"timeout-minutes,omitempty"`
}

JobStep represents GitHub Actions job step.

func CommonSteps

func CommonSteps() []*JobStep

CommonSteps returns common steps for the workflow.

func DefaultPkgsSteps

func DefaultPkgsSteps() []*JobStep

DefaultPkgsSteps returns default pkgs steps for the workflow.

func DefaultSteps

func DefaultSteps() []*JobStep

DefaultSteps returns default steps for the workflow.

func SOPSSteps

func SOPSSteps() []*JobStep

SOPSSteps returns SOPS steps for the workflow.

func Step

func Step(name string) *JobStep

Step creates a step with name.

func (*JobStep) SetCommand

func (step *JobStep) SetCommand(command string) *JobStep

SetCommand sets step command.

func (*JobStep) SetConditionOnlyOnBranch

func (step *JobStep) SetConditionOnlyOnBranch(name string) *JobStep

SetConditionOnlyOnBranch adds condition to run step only on a specific branch name.

func (*JobStep) SetConditions

func (step *JobStep) SetConditions(conditions ...string) error

SetConditions sets step conditions.

func (*JobStep) SetContinueOnError

func (step *JobStep) SetContinueOnError() *JobStep

SetContinueOnError sets step to continue on error.

func (*JobStep) SetCustomCondition

func (step *JobStep) SetCustomCondition(condition string) *JobStep

SetCustomCondition sets a custom condition clearing out any previously set conditions.

func (*JobStep) SetEnv

func (step *JobStep) SetEnv(name, value string) *JobStep

SetEnv sets step environment variables.

func (*JobStep) SetID

func (step *JobStep) SetID(id string) *JobStep

SetID sets step ID.

func (*JobStep) SetMakeStep

func (step *JobStep) SetMakeStep(target string, args ...string) *JobStep

SetMakeStep sets step to run make command.

func (*JobStep) SetSudo

func (step *JobStep) SetSudo() *JobStep

SetSudo sets step to run with sudo.

func (*JobStep) SetTimeoutMinutes

func (step *JobStep) SetTimeoutMinutes(minutes int) *JobStep

SetTimeoutMinutes sets step timeout in minutes.

func (*JobStep) SetUses

func (step *JobStep) SetUses(uses string) *JobStep

SetUses sets step to use action.

func (*JobStep) SetWith

func (step *JobStep) SetWith(key, value string) *JobStep

SetWith sets step with key and value.

type On

type On struct {
	Push        `yaml:"push,omitempty"`
	PullRequest `yaml:"pull_request,omitempty"`
	Schedule    []Schedule `yaml:"schedule,omitempty"`
	WorkFlowRun `yaml:"workflow_run,omitempty"`
}

On represents GitHub Actions event triggers.

type Output

type Output struct {
	output.FileAdapter
	// contains filtered or unexported fields
}

Output implements GitHub Actions project config generation.

func NewOutput

func NewOutput(mainBranch string, withDefaultJob bool) *Output

NewOutput creates new .github/workflows/ci.yaml output.

func (*Output) AddJob

func (o *Output) AddJob(name string, job *Job)

AddJob adds job to the default workflow.

func (*Output) AddOutputs

func (o *Output) AddOutputs(jobName string, outputs map[string]string)

AddOutputs adds outputs to the job.

func (*Output) AddSlackNotify

func (o *Output) AddSlackNotify(workflow string)

AddSlackNotify adds the workflow to notify slack dependencies.

func (*Output) AddStep

func (o *Output) AddStep(jobName string, steps ...*JobStep)

AddStep adds step to the job.

func (*Output) AddStepAfter

func (o *Output) AddStepAfter(jobName, afterStepID string, steps ...*JobStep)

AddStepAfter adds step after another step in the job.

func (*Output) AddStepBefore

func (o *Output) AddStepBefore(jobName, beforeStepID string, steps ...*JobStep)

AddStepBefore adds step before another step in the job.

func (*Output) AddWorkflow

func (o *Output) AddWorkflow(name string, workflow *Workflow)

AddWorkflow adds workflow to the output.

func (*Output) Compile

func (o *Output) Compile(compiler Compiler) error

Compile implements output.TypedWriter interface.

func (*Output) Filenames

func (o *Output) Filenames() []string

Filenames implements output.FileWriter interface.

func (*Output) GenerateFile

func (o *Output) GenerateFile(filename string, w io.Writer) error

GenerateFile implements output.FileWriter interface.

func (*Output) SetOptionsForPkgs

func (o *Output) SetOptionsForPkgs()

SetOptionsForPkgs overwrites default job steps and services for pkgs. Note that calling this method will overwrite any existing steps.

func (*Output) SetRunners

func (o *Output) SetRunners(runners ...string)

SetRunners allows to set custom runners for the default job. If runners are not provided, the default runners will be used.

type PullRequest

type PullRequest struct {
	Branches `yaml:"branches,omitempty"`
	Types    []string `yaml:"types,omitempty"`
}

PullRequest represents GitHub Actions pull request filters.

type PullRequestTarget

type PullRequestTarget struct{}

PullRequestTarget represents GitHub Actions pull request target filters.

type Push

type Push struct {
	Branches `yaml:"branches"`
	Tags     []string `yaml:"tags,omitempty"`
}

Push represents GitHub Actions push filters.

type Schedule

type Schedule struct {
	Cron string `yaml:"cron"`
}

Schedule represents GitHub Actions schedule filters.

type Service

type Service struct {
	Image   string   `yaml:"image"`
	Options string   `yaml:"options,omitempty"`
	Ports   []string `yaml:"ports,omitempty"`
	Volumes []string `yaml:"volumes,omitempty"`
}

Service represents GitHub Actions service.

type WorkFlowRun

type WorkFlowRun struct {
	Workflows []string `yaml:"workflows"`
	Types     []string `yaml:"types"`
}

WorkFlowRun represents GitHub Actions workflow_run filters.

type Workflow

type Workflow struct {
	Name        string `yaml:"name"`
	Concurrency `yaml:"concurrency,omitempty"`
	On          `yaml:"on"`
	Env         map[string]string `yaml:"env,omitempty"`
	Jobs        map[string]*Job   `yaml:"jobs"`
}

Workflow represents Github Actions workflow.

Jump to

Keyboard shortcuts

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