actions

package
v1.21.7 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: MIT Imports: 32 Imported by: 14

Documentation

Index

Constants

View Source
const (
	RunnerOfflineTime = time.Minute
	RunnerIdleTime    = 10 * time.Second
)

Variables

This section is empty.

Functions

func CancelRunningJobs added in v1.21.0

func CancelRunningJobs(ctx context.Context, repoID int64, ref, workflowID string, event webhook_module.HookEventType) error

CancelRunningJobs cancels all running and waiting jobs associated with a specific workflow.

func CleanRepoScheduleTasks added in v1.21.4

func CleanRepoScheduleTasks(ctx context.Context, repo *repo_model.Repository) error

func CountRunJobs

func CountRunJobs(ctx context.Context, opts FindRunJobOptions) (int64, error)

func CountRunners

func CountRunners(ctx context.Context, opts FindRunnerOptions) (int64, error)

func CountRunnersWithoutBelongingOwner added in v1.21.0

func CountRunnersWithoutBelongingOwner(ctx context.Context) (int64, error)

func CountRuns

func CountRuns(ctx context.Context, opts FindRunOptions) (int64, error)

func CountSchedules added in v1.21.0

func CountSchedules(ctx context.Context, opts FindScheduleOptions) (int64, error)

func CountSpecs added in v1.21.0

func CountSpecs(ctx context.Context, opts FindSpecOptions) (int64, error)

func CountTasks

func CountTasks(ctx context.Context, opts FindTaskOptions) (int64, error)

func CreateRunner

func CreateRunner(ctx context.Context, t *ActionRunner) error

CreateRunner creates new runner.

func CreateScheduleTask added in v1.21.0

func CreateScheduleTask(ctx context.Context, rows []*ActionSchedule) error

CreateScheduleTask creates new schedule task.

func DeleteRunner

func DeleteRunner(ctx context.Context, id int64) error

DeleteRunner deletes a runner by given ID.

func DeleteScheduleTaskByRepo added in v1.21.0

func DeleteScheduleTaskByRepo(ctx context.Context, id int64) error

func FindTaskOutputKeyByTaskID added in v1.20.0

func FindTaskOutputKeyByTaskID(ctx context.Context, taskID int64) ([]string, error)

FindTaskOutputKeyByTaskID returns the keys of the outputs of the task.

func FixRunnersWithoutBelongingOwner added in v1.21.0

func FixRunnersWithoutBelongingOwner(ctx context.Context) (int64, error)

func GetActors added in v1.21.0

func GetActors(ctx context.Context, repoID int64) ([]*user_model.User, error)

GetActors returns a slice of Actors

func GetReposMapByIDs added in v1.21.0

func GetReposMapByIDs(ctx context.Context, ids []int64) (map[int64]*repo_model.Repository, error)

GetReposMapByIDs returns the repos by given id slice.

func GetSchedulesMapByIDs added in v1.21.0

func GetSchedulesMapByIDs(ctx context.Context, ids []int64) (map[int64]*ActionSchedule, error)

GetSchedulesMapByIDs returns the schedules by given id slice.

func GetTasksVersionByScope added in v1.21.0

func GetTasksVersionByScope(ctx context.Context, ownerID, repoID int64) (int64, error)

func IncreaseTaskVersion added in v1.21.0

func IncreaseTaskVersion(ctx context.Context, ownerID, repoID int64) error

func InsertRun

func InsertRun(ctx context.Context, run *ActionRun, jobs []*jobparser.SingleWorkflow) error

InsertRun inserts a run

func InsertTaskOutputIfNotExist added in v1.20.0

func InsertTaskOutputIfNotExist(ctx context.Context, taskID int64, key, value string) error

InsertTaskOutputIfNotExist inserts a new task output if it does not exist.

func SetArtifactExpired added in v1.21.0

func SetArtifactExpired(ctx context.Context, artifactID int64) error

SetArtifactExpired sets an artifact to expired

func StopTask

func StopTask(ctx context.Context, taskID int64, status Status) error

func UpdateArtifactByID added in v1.20.0

func UpdateArtifactByID(ctx context.Context, id int64, art *ActionArtifact) error

UpdateArtifactByID updates an artifact by id

func UpdateRun

func UpdateRun(ctx context.Context, run *ActionRun, cols ...string) error

UpdateRun updates a run. It requires the inputted run has Version set. It will return error if the version is not matched (it means the run has been changed after loaded).

func UpdateRunJob

func UpdateRunJob(ctx context.Context, job *ActionRunJob, cond builder.Cond, cols ...string) (int64, error)

func UpdateRunner

func UpdateRunner(ctx context.Context, r *ActionRunner, cols ...string) error

UpdateRunner updates runner's information.

func UpdateRunnerToken

func UpdateRunnerToken(ctx context.Context, r *ActionRunnerToken, cols ...string) (err error)

UpdateRunnerToken updates runner token information.

func UpdateScheduleSpec added in v1.21.0

func UpdateScheduleSpec(ctx context.Context, spec *ActionScheduleSpec, cols ...string) error

func UpdateTask

func UpdateTask(ctx context.Context, task *ActionTask, cols ...string) error

func UpdateVariable added in v1.21.0

func UpdateVariable(ctx context.Context, variable *ActionVariable) (bool, error)

Types

type ActionArtifact added in v1.20.0

type ActionArtifact struct {
	ID                 int64 `xorm:"pk autoincr"`
	RunID              int64 `xorm:"index unique(runid_name_path)"` // The run id of the artifact
	RunnerID           int64
	RepoID             int64 `xorm:"index"`
	OwnerID            int64
	CommitSHA          string
	StoragePath        string             // The path to the artifact in the storage
	FileSize           int64              // The size of the artifact in bytes
	FileCompressedSize int64              // The size of the artifact in bytes after gzip compression
	ContentEncoding    string             // The content encoding of the artifact
	ArtifactPath       string             `xorm:"index unique(runid_name_path)"` // The path to the artifact when runner uploads it
	ArtifactName       string             `xorm:"index unique(runid_name_path)"` // The name of the artifact when runner uploads it
	Status             int64              `xorm:"index"`                         // The status of the artifact, uploading, expired or need-delete
	CreatedUnix        timeutil.TimeStamp `xorm:"created"`
	UpdatedUnix        timeutil.TimeStamp `xorm:"updated index"`
	ExpiredUnix        timeutil.TimeStamp `xorm:"index"` // The time when the artifact will be expired
}

ActionArtifact is a file that is stored in the artifact storage.

func CreateArtifact added in v1.20.0

func CreateArtifact(ctx context.Context, t *ActionTask, artifactName, artifactPath string, expiredDays int64) (*ActionArtifact, error)

func GetArtifactByID added in v1.20.0

func GetArtifactByID(ctx context.Context, id int64) (*ActionArtifact, error)

GetArtifactByID returns an artifact by id

func ListArtifactsByRepoID added in v1.20.0

func ListArtifactsByRepoID(ctx context.Context, repoID int64) ([]*ActionArtifact, error)

ListArtifactsByRepoID returns all artifacts of a repo

func ListArtifactsByRunID added in v1.20.0

func ListArtifactsByRunID(ctx context.Context, runID int64) ([]*ActionArtifact, error)

ListArtifactsByRunID returns all artifacts of a run

func ListArtifactsByRunIDAndArtifactName added in v1.21.0

func ListArtifactsByRunIDAndArtifactName(ctx context.Context, runID int64, artifactName string) ([]*ActionArtifact, error)

ListArtifactsByRunIDAndArtifactName returns an artifacts of a run by artifact name

func ListArtifactsByRunIDAndName added in v1.21.0

func ListArtifactsByRunIDAndName(ctx context.Context, runID int64, name string) ([]*ActionArtifact, error)

ListArtifactsByRunIDAndName returns artifacts by name of a run

func ListNeedExpiredArtifacts added in v1.21.0

func ListNeedExpiredArtifacts(ctx context.Context) ([]*ActionArtifact, error)

ListNeedExpiredArtifacts returns all need expired artifacts but not deleted

func ListUploadedArtifactsByRunID added in v1.20.0

func ListUploadedArtifactsByRunID(ctx context.Context, runID int64) ([]*ActionArtifact, error)

ListUploadedArtifactsByRunID returns all uploaded artifacts of a run

type ActionArtifactMeta added in v1.21.0

type ActionArtifactMeta struct {
	ArtifactName string
	FileSize     int64
	Status       int64
}

ActionArtifactMeta is the meta data of an artifact

func ListUploadedArtifactsMeta added in v1.21.0

func ListUploadedArtifactsMeta(ctx context.Context, runID int64) ([]*ActionArtifactMeta, error)

ListUploadedArtifactsMeta returns all uploaded artifacts meta of a run

type ActionJobList

type ActionJobList []*ActionRunJob

func FindRunJobs

func FindRunJobs(ctx context.Context, opts FindRunJobOptions) (ActionJobList, int64, error)

func (ActionJobList) GetRunIDs

func (jobs ActionJobList) GetRunIDs() []int64

func (ActionJobList) LoadAttributes

func (jobs ActionJobList) LoadAttributes(ctx context.Context, withRepo bool) error

func (ActionJobList) LoadRuns

func (jobs ActionJobList) LoadRuns(ctx context.Context, withRepo bool) error

type ActionRun

type ActionRun struct {
	ID                int64
	Title             string
	RepoID            int64                  `xorm:"index unique(repo_index)"`
	Repo              *repo_model.Repository `xorm:"-"`
	OwnerID           int64                  `xorm:"index"`
	WorkflowID        string                 `xorm:"index"`                    // the name of workflow file
	Index             int64                  `xorm:"index unique(repo_index)"` // a unique number for each run of a repository
	TriggerUserID     int64                  `xorm:"index"`
	TriggerUser       *user_model.User       `xorm:"-"`
	ScheduleID        int64
	Ref               string `xorm:"index"` // the commit/tag/… that caused the run
	CommitSHA         string
	IsForkPullRequest bool                         // If this is triggered by a PR from a forked repository or an untrusted user, we need to check if it is approved and limit permissions when running the workflow.
	NeedApproval      bool                         // may need approval if it's a fork pull request
	ApprovedBy        int64                        `xorm:"index"` // who approved
	Event             webhook_module.HookEventType // the webhook event that causes the workflow to run
	EventPayload      string                       `xorm:"LONGTEXT"`
	TriggerEvent      string                       // the trigger event defined in the `on` configuration of the triggered workflow
	Status            Status                       `xorm:"index"`
	Version           int                          `xorm:"version default 0"` // Status could be updated concomitantly, so an optimistic lock is needed
	Started           timeutil.TimeStamp
	Stopped           timeutil.TimeStamp
	Created           timeutil.TimeStamp `xorm:"created"`
	Updated           timeutil.TimeStamp `xorm:"updated"`
}

ActionRun represents a run of a workflow file

func GetRunByID

func GetRunByID(ctx context.Context, id int64) (*ActionRun, error)

func GetRunByIndex

func GetRunByIndex(ctx context.Context, repoID, index int64) (*ActionRun, error)

func (*ActionRun) Duration

func (run *ActionRun) Duration() time.Duration

func (*ActionRun) GetPullRequestEventPayload

func (run *ActionRun) GetPullRequestEventPayload() (*api.PullRequestPayload, error)

func (*ActionRun) GetPushEventPayload

func (run *ActionRun) GetPushEventPayload() (*api.PushPayload, error)

func (*ActionRun) HTMLURL

func (run *ActionRun) HTMLURL() string
func (run *ActionRun) Link() string

func (*ActionRun) LoadAttributes

func (run *ActionRun) LoadAttributes(ctx context.Context) error

LoadAttributes load Repo TriggerUser if not loaded

func (*ActionRun) PrettyRef

func (run *ActionRun) PrettyRef() string

PrettyRef return #id for pull ref or ShortName for others

func (run *ActionRun) RefLink() string

RefLink return the url of run's ref

type ActionRunIndex

type ActionRunIndex db.ResourceIndex

type ActionRunJob

type ActionRunJob struct {
	ID                int64
	RunID             int64      `xorm:"index"`
	Run               *ActionRun `xorm:"-"`
	RepoID            int64      `xorm:"index"`
	OwnerID           int64      `xorm:"index"`
	CommitSHA         string     `xorm:"index"`
	IsForkPullRequest bool
	Name              string `xorm:"VARCHAR(255)"`
	Attempt           int64
	WorkflowPayload   []byte
	JobID             string   `xorm:"VARCHAR(255)"` // job id in workflow, not job's id
	Needs             []string `xorm:"JSON TEXT"`
	RunsOn            []string `xorm:"JSON TEXT"`
	TaskID            int64    // the latest task of the job
	Status            Status   `xorm:"index"`
	Started           timeutil.TimeStamp
	Stopped           timeutil.TimeStamp
	Created           timeutil.TimeStamp `xorm:"created"`
	Updated           timeutil.TimeStamp `xorm:"updated index"`
}

ActionRunJob represents a job of a run

func GetRunJobByID

func GetRunJobByID(ctx context.Context, id int64) (*ActionRunJob, error)

func GetRunJobsByRunID

func GetRunJobsByRunID(ctx context.Context, runID int64) ([]*ActionRunJob, error)

func (*ActionRunJob) Duration

func (job *ActionRunJob) Duration() time.Duration

func (*ActionRunJob) LoadAttributes

func (job *ActionRunJob) LoadAttributes(ctx context.Context) error

LoadAttributes load Run if not loaded

func (*ActionRunJob) LoadRun

func (job *ActionRunJob) LoadRun(ctx context.Context) error

type ActionRunner

type ActionRunner struct {
	ID          int64
	UUID        string                 `xorm:"CHAR(36) UNIQUE"`
	Name        string                 `xorm:"VARCHAR(255)"`
	Version     string                 `xorm:"VARCHAR(64)"`
	OwnerID     int64                  `xorm:"index"` // org level runner, 0 means system
	Owner       *user_model.User       `xorm:"-"`
	RepoID      int64                  `xorm:"index"` // repo level runner, if OwnerID also is zero, then it's a global
	Repo        *repo_model.Repository `xorm:"-"`
	Description string                 `xorm:"TEXT"`
	Base        int                    // 0 native 1 docker 2 virtual machine
	RepoRange   string                 // glob match which repositories could use this runner

	Token     string `xorm:"-"`
	TokenHash string `xorm:"UNIQUE"` // sha256 of token
	TokenSalt string

	LastOnline timeutil.TimeStamp `xorm:"index"`
	LastActive timeutil.TimeStamp `xorm:"index"`

	// Store labels defined in state file (default: .runner file) of `act_runner`
	AgentLabels []string `xorm:"TEXT"`

	Created timeutil.TimeStamp `xorm:"created"`
	Updated timeutil.TimeStamp `xorm:"updated"`
	Deleted timeutil.TimeStamp `xorm:"deleted"`
}

ActionRunner represents runner machines

func GetRunnerByID

func GetRunnerByID(ctx context.Context, id int64) (*ActionRunner, error)

GetRunnerByID returns a runner via id

func GetRunnerByUUID

func GetRunnerByUUID(ctx context.Context, uuid string) (*ActionRunner, error)

GetRunnerByUUID returns a runner via uuid

func (*ActionRunner) BelongsToOwnerName added in v1.20.0

func (r *ActionRunner) BelongsToOwnerName() string

BelongsToOwnerName before calling, should guarantee that all attributes are loaded

func (*ActionRunner) BelongsToOwnerType added in v1.20.0

func (r *ActionRunner) BelongsToOwnerType() types.OwnerType

func (*ActionRunner) Editable

func (r *ActionRunner) Editable(ownerID, repoID int64) bool

Editable checks if the runner is editable by the user

func (*ActionRunner) GenerateToken

func (r *ActionRunner) GenerateToken() (err error)

func (*ActionRunner) IsOnline

func (r *ActionRunner) IsOnline() bool

func (*ActionRunner) LoadAttributes

func (r *ActionRunner) LoadAttributes(ctx context.Context) error

LoadAttributes loads the attributes of the runner

func (*ActionRunner) Status

func (r *ActionRunner) Status() runnerv1.RunnerStatus

if the logic here changed, you should also modify FindRunnerOptions.ToCond

func (*ActionRunner) StatusLocaleName

func (r *ActionRunner) StatusLocaleName(lang translation.Locale) string

func (*ActionRunner) StatusName

func (r *ActionRunner) StatusName() string

type ActionRunnerToken

type ActionRunnerToken struct {
	ID       int64
	Token    string                 `xorm:"UNIQUE"`
	OwnerID  int64                  `xorm:"index"` // org level runner, 0 means system
	Owner    *user_model.User       `xorm:"-"`
	RepoID   int64                  `xorm:"index"` // repo level runner, if orgid also is zero, then it's a global
	Repo     *repo_model.Repository `xorm:"-"`
	IsActive bool                   // true means it can be used

	Created timeutil.TimeStamp `xorm:"created"`
	Updated timeutil.TimeStamp `xorm:"updated"`
	Deleted timeutil.TimeStamp `xorm:"deleted"`
}

ActionRunnerToken represents runner tokens

func GetLastestRunnerToken added in v1.21.0

func GetLastestRunnerToken(ctx context.Context, ownerID, repoID int64) (*ActionRunnerToken, error)

GetLastestRunnerToken returns the latest runner token

func GetRunnerToken

func GetRunnerToken(ctx context.Context, token string) (*ActionRunnerToken, error)

GetRunnerToken returns a action runner via token

func NewRunnerToken

func NewRunnerToken(ctx context.Context, ownerID, repoID int64) (*ActionRunnerToken, error)

NewRunnerToken creates a new active runner token and invalidate all old tokens

type ActionSchedule added in v1.21.0

type ActionSchedule struct {
	ID            int64
	Title         string
	Specs         []string
	RepoID        int64                  `xorm:"index"`
	Repo          *repo_model.Repository `xorm:"-"`
	OwnerID       int64                  `xorm:"index"`
	WorkflowID    string
	TriggerUserID int64
	TriggerUser   *user_model.User `xorm:"-"`
	Ref           string
	CommitSHA     string
	Event         webhook_module.HookEventType
	EventPayload  string `xorm:"LONGTEXT"`
	Content       []byte
	Created       timeutil.TimeStamp `xorm:"created"`
	Updated       timeutil.TimeStamp `xorm:"updated"`
}

ActionSchedule represents a schedule of a workflow file

type ActionScheduleSpec added in v1.21.0

type ActionScheduleSpec struct {
	ID         int64
	RepoID     int64                  `xorm:"index"`
	Repo       *repo_model.Repository `xorm:"-"`
	ScheduleID int64                  `xorm:"index"`
	Schedule   *ActionSchedule        `xorm:"-"`

	// Next time the job will run, or the zero time if Cron has not been
	// started or this entry's schedule is unsatisfiable
	Next timeutil.TimeStamp `xorm:"index"`
	// Prev is the last time this job was run, or the zero time if never.
	Prev timeutil.TimeStamp
	Spec string

	Created timeutil.TimeStamp `xorm:"created"`
	Updated timeutil.TimeStamp `xorm:"updated"`
}

ActionScheduleSpec represents a schedule spec of a workflow file

func (*ActionScheduleSpec) Parse added in v1.21.0

func (s *ActionScheduleSpec) Parse() (cron.Schedule, error)

type ActionTask

type ActionTask struct {
	ID       int64
	JobID    int64
	Job      *ActionRunJob     `xorm:"-"`
	Steps    []*ActionTaskStep `xorm:"-"`
	Attempt  int64
	RunnerID int64              `xorm:"index"`
	Status   Status             `xorm:"index"`
	Started  timeutil.TimeStamp `xorm:"index"`
	Stopped  timeutil.TimeStamp

	RepoID            int64  `xorm:"index"`
	OwnerID           int64  `xorm:"index"`
	CommitSHA         string `xorm:"index"`
	IsForkPullRequest bool

	Token          string `xorm:"-"`
	TokenHash      string `xorm:"UNIQUE"` // sha256 of token
	TokenSalt      string
	TokenLastEight string `xorm:"index token_last_eight"`

	LogFilename  string     // file name of log
	LogInStorage bool       // read log from database or from storage
	LogLength    int64      // lines count
	LogSize      int64      // blob size
	LogIndexes   LogIndexes `xorm:"LONGBLOB"` // line number to offset
	LogExpired   bool       // files that are too old will be deleted

	Created timeutil.TimeStamp `xorm:"created"`
	Updated timeutil.TimeStamp `xorm:"updated index"`
}

ActionTask represents a distribution of job

func CreateTaskForRunner

func CreateTaskForRunner(ctx context.Context, runner *ActionRunner) (*ActionTask, bool, error)

func GetRunningTaskByToken

func GetRunningTaskByToken(ctx context.Context, token string) (*ActionTask, error)

func GetTaskByID

func GetTaskByID(ctx context.Context, id int64) (*ActionTask, error)

func UpdateTaskByState

func UpdateTaskByState(ctx context.Context, state *runnerv1.TaskState) (*ActionTask, error)

UpdateTaskByState updates the task by the state. It will always update the task if the state is not final, even there is no change. So it will update ActionTask.Updated to avoid the task being judged as a zombie task.

func (*ActionTask) Duration

func (task *ActionTask) Duration() time.Duration

func (*ActionTask) GenerateToken

func (task *ActionTask) GenerateToken() (err error)
func (task *ActionTask) GetCommitLink() string
func (task *ActionTask) GetRepoLink() string

func (*ActionTask) GetRepoName

func (task *ActionTask) GetRepoName() string
func (task *ActionTask) GetRunLink() string

func (*ActionTask) IsStopped

func (task *ActionTask) IsStopped() bool

func (*ActionTask) LoadAttributes

func (task *ActionTask) LoadAttributes(ctx context.Context) error

LoadAttributes load Job Steps if not loaded

func (*ActionTask) LoadJob

func (task *ActionTask) LoadJob(ctx context.Context) error

type ActionTaskOutput added in v1.20.0

type ActionTaskOutput struct {
	ID          int64
	TaskID      int64  `xorm:"INDEX UNIQUE(task_id_output_key)"`
	OutputKey   string `xorm:"VARCHAR(255) UNIQUE(task_id_output_key)"`
	OutputValue string `xorm:"MEDIUMTEXT"`
}

ActionTaskOutput represents an output of ActionTask. So the outputs are bound to a task, that means when a completed job has been rerun, the outputs of the job will be reset because the task is new. It's by design, to avoid the outputs of the old task to be mixed with the new task.

func FindTaskOutputByTaskID added in v1.20.0

func FindTaskOutputByTaskID(ctx context.Context, taskID int64) ([]*ActionTaskOutput, error)

FindTaskOutputByTaskID returns the outputs of the task.

type ActionTaskStep

type ActionTaskStep struct {
	ID        int64
	Name      string `xorm:"VARCHAR(255)"`
	TaskID    int64  `xorm:"index unique(task_index)"`
	Index     int64  `xorm:"index unique(task_index)"`
	RepoID    int64  `xorm:"index"`
	Status    Status `xorm:"index"`
	LogIndex  int64
	LogLength int64
	Started   timeutil.TimeStamp
	Stopped   timeutil.TimeStamp
	Created   timeutil.TimeStamp `xorm:"created"`
	Updated   timeutil.TimeStamp `xorm:"updated"`
}

ActionTaskStep represents a step of ActionTask

func GetTaskStepsByTaskID

func GetTaskStepsByTaskID(ctx context.Context, taskID int64) ([]*ActionTaskStep, error)

func (*ActionTaskStep) Duration

func (step *ActionTaskStep) Duration() time.Duration

type ActionTasksVersion added in v1.21.0

type ActionTasksVersion struct {
	ID          int64 `xorm:"pk autoincr"`
	OwnerID     int64 `xorm:"UNIQUE(owner_repo)"`
	RepoID      int64 `xorm:"INDEX UNIQUE(owner_repo)"`
	Version     int64
	CreatedUnix timeutil.TimeStamp `xorm:"created"`
	UpdatedUnix timeutil.TimeStamp `xorm:"updated"`
}

ActionTasksVersion If both ownerID and repoID is zero, its scope is global. If ownerID is not zero and repoID is zero, its scope is org (there is no user-level runner currrently). If ownerID is zero and repoID is not zero, its scope is repo.

type ActionVariable added in v1.21.0

type ActionVariable struct {
	ID          int64              `xorm:"pk autoincr"`
	OwnerID     int64              `xorm:"UNIQUE(owner_repo_name)"`
	RepoID      int64              `xorm:"INDEX UNIQUE(owner_repo_name)"`
	Name        string             `xorm:"UNIQUE(owner_repo_name) NOT NULL"`
	Data        string             `xorm:"LONGTEXT NOT NULL"`
	CreatedUnix timeutil.TimeStamp `xorm:"created NOT NULL"`
	UpdatedUnix timeutil.TimeStamp `xorm:"updated"`
}

func FindVariables added in v1.21.0

func FindVariables(ctx context.Context, opts FindVariablesOpts) ([]*ActionVariable, error)

func GetVariableByID added in v1.21.0

func GetVariableByID(ctx context.Context, variableID int64) (*ActionVariable, error)

func InsertVariable added in v1.21.0

func InsertVariable(ctx context.Context, ownerID, repoID int64, name, data string) (*ActionVariable, error)

func (*ActionVariable) Validate added in v1.21.0

func (v *ActionVariable) Validate() error

type ArtifactStatus added in v1.21.0

type ArtifactStatus int64

ArtifactStatus is the status of an artifact, uploading, expired or need-delete

const (
	ArtifactStatusUploadPending   ArtifactStatus = iota + 1 // 1, ArtifactStatusUploadPending is the status of an artifact upload that is pending
	ArtifactStatusUploadConfirmed                           // 2, ArtifactStatusUploadConfirmed is the status of an artifact upload that is confirmed
	ArtifactStatusUploadError                               // 3, ArtifactStatusUploadError is the status of an artifact upload that is errored
	ArtifactStatusExpired                                   // 4, ArtifactStatusExpired is the status of an artifact that is expired
)

type FindRunJobOptions

type FindRunJobOptions struct {
	db.ListOptions
	RunID         int64
	RepoID        int64
	OwnerID       int64
	CommitSHA     string
	Statuses      []Status
	UpdatedBefore timeutil.TimeStamp
}

type FindRunOptions

type FindRunOptions struct {
	db.ListOptions
	RepoID        int64
	OwnerID       int64
	WorkflowID    string
	Ref           string // the commit/tag/… that caused this workflow
	TriggerUserID int64
	TriggerEvent  webhook_module.HookEventType
	Approved      bool // not util.OptionalBool, it works only when it's true
	Status        []Status
}

type FindRunnerOptions

type FindRunnerOptions struct {
	db.ListOptions
	RepoID        int64
	OwnerID       int64
	Sort          string
	Filter        string
	IsOnline      util.OptionalBool
	WithAvailable bool // not only runners belong to, but also runners can be used
}

type FindScheduleOptions added in v1.21.0

type FindScheduleOptions struct {
	db.ListOptions
	RepoID  int64
	OwnerID int64
}

type FindSpecOptions added in v1.21.0

type FindSpecOptions struct {
	db.ListOptions
	RepoID int64
	Next   int64
}

type FindTaskOptions

type FindTaskOptions struct {
	db.ListOptions
	RepoID        int64
	OwnerID       int64
	CommitSHA     string
	Status        Status
	UpdatedBefore timeutil.TimeStamp
	StartedBefore timeutil.TimeStamp
	RunnerID      int64
	IDOrderDesc   bool
}

type FindVariablesOpts added in v1.21.0

type FindVariablesOpts struct {
	db.ListOptions
	OwnerID int64
	RepoID  int64
}

type LogIndexes

type LogIndexes []int64

LogIndexes is the index for mapping log line number to buffer offset. Because it uses varint encoding, it is impossible to predict its size. But we can make a simple estimate with an assumption that each log line has 200 byte, then: | lines | file size | index size | |-----------|---------------------|--------------------| | 100 | 20 KiB(20000) | 258 B(258) | | 1000 | 195 KiB(200000) | 2.9 KiB(2958) | | 10000 | 1.9 MiB(2000000) | 34 KiB(34715) | | 100000 | 19 MiB(20000000) | 386 KiB(394715) | | 1000000 | 191 MiB(200000000) | 4.1 MiB(4323626) | | 10000000 | 1.9 GiB(2000000000) | 47 MiB(49323626) | | 100000000 | 19 GiB(20000000000) | 490 MiB(513424280) |

func (*LogIndexes) FromDB

func (indexes *LogIndexes) FromDB(b []byte) error

func (*LogIndexes) ToDB

func (indexes *LogIndexes) ToDB() ([]byte, error)

type RunList

type RunList []*ActionRun

func FindRuns

func FindRuns(ctx context.Context, opts FindRunOptions) (RunList, int64, error)

func (RunList) GetRepoIDs

func (runs RunList) GetRepoIDs() []int64

func (RunList) GetUserIDs

func (runs RunList) GetUserIDs() []int64

GetUserIDs returns a slice of user's id

func (RunList) LoadRepos

func (runs RunList) LoadRepos() error

func (RunList) LoadTriggerUser

func (runs RunList) LoadTriggerUser(ctx context.Context) error

type RunnerList

type RunnerList []*ActionRunner

func FindRunners

func FindRunners(ctx context.Context, opts FindRunnerOptions) (runners RunnerList, err error)

func (RunnerList) GetUserIDs

func (runners RunnerList) GetUserIDs() []int64

GetUserIDs returns a slice of user's id

func (RunnerList) LoadAttributes

func (runners RunnerList) LoadAttributes(ctx context.Context) error

func (RunnerList) LoadOwners

func (runners RunnerList) LoadOwners(ctx context.Context) error

func (RunnerList) LoadRepos

func (runners RunnerList) LoadRepos(ctx context.Context) error

type ScheduleList added in v1.21.0

type ScheduleList []*ActionSchedule

func FindSchedules added in v1.21.0

func FindSchedules(ctx context.Context, opts FindScheduleOptions) (ScheduleList, int64, error)

func (ScheduleList) GetRepoIDs added in v1.21.0

func (schedules ScheduleList) GetRepoIDs() []int64

func (ScheduleList) GetUserIDs added in v1.21.0

func (schedules ScheduleList) GetUserIDs() []int64

GetUserIDs returns a slice of user's id

func (ScheduleList) LoadRepos added in v1.21.0

func (schedules ScheduleList) LoadRepos() error

func (ScheduleList) LoadTriggerUser added in v1.21.0

func (schedules ScheduleList) LoadTriggerUser(ctx context.Context) error

type SpecList added in v1.21.0

type SpecList []*ActionScheduleSpec

func FindSpecs added in v1.21.0

func FindSpecs(ctx context.Context, opts FindSpecOptions) (SpecList, int64, error)

func (SpecList) GetRepoIDs added in v1.21.0

func (specs SpecList) GetRepoIDs() []int64

func (SpecList) GetScheduleIDs added in v1.21.0

func (specs SpecList) GetScheduleIDs() []int64

func (SpecList) LoadRepos added in v1.21.0

func (specs SpecList) LoadRepos() error

func (SpecList) LoadSchedules added in v1.21.0

func (specs SpecList) LoadSchedules(ctx context.Context) error

type Status

type Status int

Status represents the status of ActionRun, ActionRunJob, ActionTask, or ActionTaskStep

const (
	StatusUnknown   Status = iota // 0, consistent with runnerv1.Result_RESULT_UNSPECIFIED
	StatusSuccess                 // 1, consistent with runnerv1.Result_RESULT_SUCCESS
	StatusFailure                 // 2, consistent with runnerv1.Result_RESULT_FAILURE
	StatusCancelled               // 3, consistent with runnerv1.Result_RESULT_CANCELLED
	StatusSkipped                 // 4, consistent with runnerv1.Result_RESULT_SKIPPED
	StatusWaiting                 // 5, isn't a runnerv1.Result
	StatusRunning                 // 6, isn't a runnerv1.Result
	StatusBlocked                 // 7, isn't a runnerv1.Result
)

func (Status) AsResult

func (s Status) AsResult() runnerv1.Result

func (Status) HasRun

func (s Status) HasRun() bool

HasRun returns whether the Status is a result of running

func (Status) In

func (s Status) In(statuses ...Status) bool

In returns whether s is one of the given statuses

func (Status) IsBlocked added in v1.20.0

func (s Status) IsBlocked() bool

func (Status) IsCancelled

func (s Status) IsCancelled() bool

func (Status) IsDone

func (s Status) IsDone() bool

IsDone returns whether the Status is final

func (Status) IsFailure

func (s Status) IsFailure() bool

func (Status) IsRunning

func (s Status) IsRunning() bool

func (Status) IsSkipped

func (s Status) IsSkipped() bool

func (Status) IsSuccess

func (s Status) IsSuccess() bool

func (Status) IsUnknown

func (s Status) IsUnknown() bool

func (Status) IsWaiting

func (s Status) IsWaiting() bool

func (Status) LocaleString

func (s Status) LocaleString(lang translation.Locale) string

LocaleString returns the locale string name of the Status

func (Status) String

func (s Status) String() string

String returns the string name of the Status

type StatusInfo added in v1.21.0

type StatusInfo struct {
	Status          int
	DisplayedStatus string
}

func GetStatusInfoList added in v1.21.0

func GetStatusInfoList(ctx context.Context) []StatusInfo

GetStatusInfoList returns a slice of StatusInfo

type TaskList

type TaskList []*ActionTask

func FindTasks

func FindTasks(ctx context.Context, opts FindTaskOptions) (TaskList, error)

func (TaskList) GetJobIDs

func (tasks TaskList) GetJobIDs() []int64

func (TaskList) LoadAttributes

func (tasks TaskList) LoadAttributes(ctx context.Context) error

func (TaskList) LoadJobs

func (tasks TaskList) LoadJobs(ctx context.Context) error

Jump to

Keyboard shortcuts

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