Documentation ¶
Index ¶
- func CountRunJobs(ctx context.Context, opts FindRunJobOptions) (int64, error)
- func CountRunners(ctx context.Context, opts FindRunnerOptions) (int64, error)
- func CountRuns(ctx context.Context, opts FindRunOptions) (int64, error)
- func CountTasks(ctx context.Context, opts FindTaskOptions) (int64, error)
- func CreateRunner(ctx context.Context, t *ActionRunner) error
- func DeleteRunner(ctx context.Context, id int64) error
- func InsertRun(ctx context.Context, run *ActionRun, jobs []*jobparser.SingleWorkflow) error
- func StopTask(ctx context.Context, taskID int64, status Status) error
- func UpdateRun(ctx context.Context, run *ActionRun, cols ...string) error
- func UpdateRunJob(ctx context.Context, job *ActionRunJob, cond builder.Cond, cols ...string) (int64, error)
- func UpdateRunner(ctx context.Context, r *ActionRunner, cols ...string) error
- func UpdateRunnerToken(ctx context.Context, r *ActionRunnerToken, cols ...string) (err error)
- func UpdateTask(ctx context.Context, task *ActionTask, cols ...string) error
- type ActionJobList
- type ActionRun
- func (run *ActionRun) Duration() time.Duration
- func (run *ActionRun) GetPushEventPayload() (*api.PushPayload, error)
- func (run *ActionRun) HTMLURL() string
- func (run *ActionRun) Link() string
- func (run *ActionRun) LoadAttributes(ctx context.Context) error
- func (run *ActionRun) PrettyRef() string
- func (run *ActionRun) RefLink() string
- type ActionRunIndex
- type ActionRunJob
- type ActionRunner
- func (r *ActionRunner) AllLabels() []string
- func (r *ActionRunner) Editable(ownerID, repoID int64) bool
- func (r *ActionRunner) GenerateToken() (err error)
- func (r *ActionRunner) IsOnline() bool
- func (r *ActionRunner) LoadAttributes(ctx context.Context) error
- func (r *ActionRunner) OwnType() string
- func (r *ActionRunner) Status() runnerv1.RunnerStatus
- func (r *ActionRunner) StatusLocaleName(lang translation.Locale) string
- func (r *ActionRunner) StatusName() string
- type ActionRunnerToken
- type ActionTask
- func CreateTaskForRunner(ctx context.Context, runner *ActionRunner) (*ActionTask, bool, error)
- func GetRunningTaskByToken(ctx context.Context, token string) (*ActionTask, error)
- func GetTaskByID(ctx context.Context, id int64) (*ActionTask, error)
- func UpdateTaskByState(ctx context.Context, state *runnerv1.TaskState) (*ActionTask, error)
- func (task *ActionTask) Duration() time.Duration
- func (task *ActionTask) GenerateToken() (err error)
- func (task *ActionTask) GetCommitLink() string
- func (task *ActionTask) GetRepoLink() string
- func (task *ActionTask) GetRepoName() string
- func (task *ActionTask) GetRunLink() string
- func (task *ActionTask) IsStopped() bool
- func (task *ActionTask) LoadAttributes(ctx context.Context) error
- func (task *ActionTask) LoadJob(ctx context.Context) error
- type ActionTaskStep
- type FindRunJobOptions
- type FindRunOptions
- type FindRunnerOptions
- type FindTaskOptions
- type LogIndexes
- type RunList
- type RunnerList
- type Status
- func (s Status) AsResult() runnerv1.Result
- func (s Status) HasRun() bool
- func (s Status) In(statuses ...Status) bool
- func (s Status) IsCancelled() bool
- func (s Status) IsDone() bool
- func (s Status) IsFailure() bool
- func (s Status) IsRunning() bool
- func (s Status) IsSkipped() bool
- func (s Status) IsSuccess() bool
- func (s Status) IsUnknown() bool
- func (s Status) IsWaiting() bool
- func (s Status) LocaleString(lang translation.Locale) string
- func (s Status) String() string
- type TaskList
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CountRunJobs ¶
func CountRunJobs(ctx context.Context, opts FindRunJobOptions) (int64, error)
func CountRunners ¶
func CountRunners(ctx context.Context, opts FindRunnerOptions) (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 DeleteRunner ¶
DeleteRunner deletes a runner by given ID.
func UpdateRunJob ¶
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 UpdateTask ¶
func UpdateTask(ctx context.Context, task *ActionTask, cols ...string) error
Types ¶
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
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 TriggerUser *user_model.User `xorm:"-"` Ref string CommitSHA string IsForkPullRequest bool Event webhook_module.HookEventType EventPayload string `xorm:"LONGTEXT"` Status Status `xorm:"index"` 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 GetRunByIndex ¶
func (*ActionRun) GetPushEventPayload ¶
func (run *ActionRun) GetPushEventPayload() (*api.PushPayload, error)
func (*ActionRun) LoadAttributes ¶
LoadAttributes load Repo TriggerUser if not loaded
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
type ActionRunner ¶
type ActionRunner struct { ID int64 UUID string `xorm:"CHAR(36) UNIQUE"` Name string `xorm:"VARCHAR(255)"` 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:"-"` 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 OS and Artch. AgentLabels []string // Store custom labes use defined. CustomLabels []string 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) AllLabels ¶
func (r *ActionRunner) AllLabels() []string
AllLabels returns agent and custom labels
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) OwnType ¶
func (r *ActionRunner) OwnType() string
func (*ActionRunner) Status ¶
func (r *ActionRunner) Status() runnerv1.RunnerStatus
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 Created timeutil.TimeStamp `xorm:"created"` Updated timeutil.TimeStamp `xorm:"updated"` Deleted timeutil.TimeStamp `xorm:"deleted"` }
ActionRunnerToken represents runner tokens
func GetRunnerToken ¶
func GetRunnerToken(ctx context.Context, token string) (*ActionRunnerToken, error)
GetRunnerToken returns a action runner via token
func GetUnactivatedRunnerToken ¶
func GetUnactivatedRunnerToken(ctx context.Context, ownerID, repoID int64) (*ActionRunnerToken, error)
GetUnactivatedRunnerToken returns a unactivated runner token
func NewRunnerToken ¶
func NewRunnerToken(ctx context.Context, ownerID, repoID int64) (*ActionRunnerToken, error)
NewRunnerToken creates a new runner token
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 (*ActionTask) Duration ¶
func (task *ActionTask) Duration() time.Duration
func (*ActionTask) GenerateToken ¶
func (task *ActionTask) GenerateToken() (err error)
func (*ActionTask) GetCommitLink ¶
func (task *ActionTask) GetCommitLink() string
func (*ActionTask) GetRepoLink ¶
func (task *ActionTask) GetRepoLink() string
func (*ActionTask) GetRepoName ¶
func (task *ActionTask) GetRepoName() string
func (*ActionTask) GetRunLink ¶
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
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 FindRunJobOptions ¶
type FindRunOptions ¶
type FindRunOptions struct { db.ListOptions RepoID int64 OwnerID int64 IsClosed util.OptionalBool WorkflowFileName string }
type FindRunnerOptions ¶
type FindTaskOptions ¶
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 (RunList) GetRepoIDs ¶
func (RunList) GetUserIDs ¶
GetUserIDs returns a slice of user's id
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
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) IsCancelled ¶
func (Status) LocaleString ¶
func (s Status) LocaleString(lang translation.Locale) string
LocaleString returns the locale string name of the Status
type TaskList ¶
type TaskList []*ActionTask