Documentation
¶
Index ¶
- func CancelAbandonedJobs(ctx context.Context) error
- func CancelPreviousJobs(ctx context.Context, repoID int64, ref, workflowID string, ...) error
- func CleanRepoScheduleTasks(ctx context.Context, repo *repo_model.Repository) error
- func Cleanup(ctx context.Context) error
- func CleanupArtifacts(taskCtx context.Context) error
- func CleanupEphemeralRunners(ctx context.Context) error
- func CleanupEphemeralRunnersByPickedTaskOfRepo(ctx context.Context, repoID int64) error
- func CleanupExpiredLogs(ctx context.Context) error
- func ClearRunnerAlert(runnerID int64)
- func CreateAuthorizationToken(taskID, runID, jobID int64) (string, error)
- func CreateCommitStatusForRunJobs(ctx context.Context, run *actions_model.ActionRun, ...)
- func CreateScheduleTask(ctx context.Context, cron *actions_model.ActionSchedule) error
- func CreateVariable(ctx context.Context, ownerID, repoID int64, name, data, description string) (*actions_model.ActionVariable, error)
- func DeleteRun(ctx context.Context, run *actions_model.ActionRun) error
- func DeleteRunForce(ctx context.Context, run *actions_model.ActionRun) error
- func DeleteRunsByStatus(ctx context.Context, repoID int64, status actions_model.Status, ...) (int, error)
- func DeleteStuckRunningRuns(ctx context.Context, repoID int64, workflow string) (int, error)
- func DeleteSuccessRunsOlderThan(ctx context.Context, repoID int64, days int, workflow string) (int, error)
- func DeleteVariableByID(ctx context.Context, variableID int64) error
- func DeleteVariableByName(ctx context.Context, ownerID, repoID int64, name string) error
- func DetectAndHandleSchedules(ctx context.Context, repo *repo_model.Repository) error
- func DispatchActionWorkflow(ctx reqctx.RequestContext, doer *user_model.User, repo *repo_model.Repository, ...) error
- func EmitJobsIfReadyByJobs(jobs []*actions_model.ActionRunJob)
- func EmitJobsIfReadyByRun(runID int64) error
- func EnableOrDisableWorkflow(ctx *context.APIContext, workflowID string, isEnable bool) error
- func EvaluateJobConcurrencyFillModel(ctx context.Context, run *actions_model.ActionRun, ...) error
- func EvaluateRunConcurrencyFillModel(ctx context.Context, run *actions_model.ActionRun, ...) error
- func FindTaskNeeds(ctx context.Context, job *actions_model.ActionRunJob) (map[string]*TaskNeed, error)
- func GetAllRerunJobs(job *actions_model.ActionRunJob, allJobs []*actions_model.ActionRunJob) []*actions_model.ActionRunJob
- func GetPendingCleanupRequests(ctx context.Context) ([]*actions_model.RunnerCleanupRequest, error)
- func GetRunsFromCommitStatuses(ctx context.Context, statuses []*git_model.CommitStatus) ([]*actions_model.ActionRun, error)
- func GetVariable(ctx context.Context, opts actions_model.FindVariablesOpts) (*actions_model.ActionVariable, error)
- func Init(ctx context.Context) error
- func InsertRun(ctx context.Context, run *actions_model.ActionRun, ...) error
- func NewNotifier() notify_service.Notifier
- func NotifyWorkflowRunStatusUpdateWithReload(ctx context.Context, job *actions_model.ActionRunJob)
- func ParseAuthorizationToken(req *http.Request) (int64, error)
- func PickTask(ctx context.Context, runner *actions_model.ActionRunner) (*runnerv1.Task, bool, error)
- func PrepareRunAndInsert(ctx context.Context, content []byte, run *actions_model.ActionRun, ...) error
- func PrepareToStartJobWithConcurrency(ctx context.Context, job *actions_model.ActionRunJob) (actions_model.Status, error)
- func PrepareToStartRunWithConcurrency(ctx context.Context, run *actions_model.ActionRun) (actions_model.Status, error)
- func StartRunnerHealthMonitor(ctx context.Context)
- func StartScheduleTasks(ctx context.Context) error
- func StopEndlessTasks(ctx context.Context) error
- func StopZombieTasks(ctx context.Context) error
- func TokenToTaskID(token string) (int64, error)
- func UpdateVariableNameData(ctx context.Context, variable *actions_model.ActionVariable) (bool, error)
- type API
- type GiteaContext
- type TaskNeed
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CancelAbandonedJobs ¶
CancelAbandonedJobs cancels jobs that have not been picked by any runner for a long time
func CancelPreviousJobs ¶
func CancelPreviousJobs(ctx context.Context, repoID int64, ref, workflowID string, event webhook_module.HookEventType) error
func CleanRepoScheduleTasks ¶
func CleanRepoScheduleTasks(ctx context.Context, repo *repo_model.Repository) error
func Cleanup ¶
Cleanup removes expired actions logs, data, artifacts and used ephemeral runners
func CleanupArtifacts ¶
CleanupArtifacts removes expired add need-deleted artifacts and set records expired status
func CleanupEphemeralRunners ¶
CleanupEphemeralRunners removes used ephemeral runners which are no longer able to process jobs
func CleanupEphemeralRunnersByPickedTaskOfRepo ¶
CleanupEphemeralRunnersByPickedTaskOfRepo removes all ephemeral runners that have active/finished tasks on the given repository
func CleanupExpiredLogs ¶
CleanupExpiredLogs removes logs which are older than the configured retention time
func ClearRunnerAlert ¶
func ClearRunnerAlert(runnerID int64)
ClearRunnerAlert clears the alert status for a runner (call when runner becomes healthy)
func CreateAuthorizationToken ¶
func CreateCommitStatusForRunJobs ¶
func CreateCommitStatusForRunJobs(ctx context.Context, run *actions_model.ActionRun, jobs ...*actions_model.ActionRunJob)
CreateCommitStatusForRunJobs creates a commit status for the given job if it has a supported event and related commit. It won't return an error failed, but will log it, because it's not critical.
func CreateScheduleTask ¶
func CreateScheduleTask(ctx context.Context, cron *actions_model.ActionSchedule) error
CreateScheduleTask creates a scheduled task from a cron action schedule. It creates an action run based on the schedule, inserts it into the database, and creates commit statuses for each job.
func CreateVariable ¶
func CreateVariable(ctx context.Context, ownerID, repoID int64, name, data, description string) (*actions_model.ActionVariable, error)
func DeleteRun ¶
func DeleteRun(ctx context.Context, run *actions_model.ActionRun) error
DeleteRun deletes workflow run, including all logs and artifacts.
func DeleteRunForce ¶
func DeleteRunForce(ctx context.Context, run *actions_model.ActionRun) error
DeleteRunForce deletes a run regardless of its status (for stuck runs)
func DeleteRunsByStatus ¶
func DeleteRunsByStatus(ctx context.Context, repoID int64, status actions_model.Status, workflow string) (int, error)
DeleteRunsByStatus deletes all workflow runs for a repository with the given status Returns the number of runs deleted
func DeleteStuckRunningRuns ¶
DeleteStuckRunningRuns deletes running workflow runs (for stuck jobs) regardless of IsDone status
func DeleteSuccessRunsOlderThan ¶
func DeleteSuccessRunsOlderThan(ctx context.Context, repoID int64, days int, workflow string) (int, error)
DeleteSuccessRunsOlderThan deletes successful workflow runs older than the specified number of days
func DeleteVariableByName ¶
func DetectAndHandleSchedules ¶
func DetectAndHandleSchedules(ctx context.Context, repo *repo_model.Repository) error
DetectAndHandleSchedules detects the schedule workflows on the default branch and create schedule tasks
func DispatchActionWorkflow ¶
func DispatchActionWorkflow(ctx reqctx.RequestContext, doer *user_model.User, repo *repo_model.Repository, gitRepo *git.Repository, workflowID, ref string, processInputs func(model *model.WorkflowDispatch, inputs map[string]any) error) error
func EmitJobsIfReadyByJobs ¶
func EmitJobsIfReadyByJobs(jobs []*actions_model.ActionRunJob)
func EnableOrDisableWorkflow ¶
func EnableOrDisableWorkflow(ctx *context.APIContext, workflowID string, isEnable bool) error
func EvaluateJobConcurrencyFillModel ¶
func EvaluateJobConcurrencyFillModel(ctx context.Context, run *actions_model.ActionRun, actionRunJob *actions_model.ActionRunJob, vars map[string]string) error
EvaluateJobConcurrencyFillModel evaluates the expressions in a job-level concurrency, and fills the job's model fields with `concurrency.group` and `concurrency.cancel-in-progress`. Job-level concurrency may depend on other job's outputs (via `needs`): `concurrency.group: my-group-${{ needs.job1.outputs.out1 }}` If the needed jobs haven't been executed yet, this evaluation will also fail. See https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idconcurrency
func EvaluateRunConcurrencyFillModel ¶
func EvaluateRunConcurrencyFillModel(ctx context.Context, run *actions_model.ActionRun, wfRawConcurrency *act_model.RawConcurrency, vars map[string]string) error
EvaluateRunConcurrencyFillModel evaluates the expressions in a run-level (workflow) concurrency, and fills the run's model fields with `concurrency.group` and `concurrency.cancel-in-progress`. Workflow-level concurrency doesn't depend on the job outputs, so it can always be evaluated if there is no syntax error. See https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#concurrency
func FindTaskNeeds ¶
func FindTaskNeeds(ctx context.Context, job *actions_model.ActionRunJob) (map[string]*TaskNeed, error)
FindTaskNeeds finds the `needs` for the task by the task's job
func GetAllRerunJobs ¶
func GetAllRerunJobs(job *actions_model.ActionRunJob, allJobs []*actions_model.ActionRunJob) []*actions_model.ActionRunJob
GetAllRerunJobs get all jobs that need to be rerun when job should be rerun
func GetPendingCleanupRequests ¶
func GetPendingCleanupRequests(ctx context.Context) ([]*actions_model.RunnerCleanupRequest, error)
GetPendingCleanupRequests returns cleanup requests that haven't been completed
func GetRunsFromCommitStatuses ¶
func GetRunsFromCommitStatuses(ctx context.Context, statuses []*git_model.CommitStatus) ([]*actions_model.ActionRun, error)
func GetVariable ¶
func GetVariable(ctx context.Context, opts actions_model.FindVariablesOpts) (*actions_model.ActionVariable, error)
func InsertRun ¶
func InsertRun(ctx context.Context, run *actions_model.ActionRun, jobs []*jobparser.SingleWorkflow, vars map[string]string) error
InsertRun inserts a run The title will be cut off at 255 characters if it's longer than 255 characters.
func NewNotifier ¶
func NewNotifier() notify_service.Notifier
NewNotifier create a new actionsNotifier notifier
func NotifyWorkflowRunStatusUpdateWithReload ¶
func NotifyWorkflowRunStatusUpdateWithReload(ctx context.Context, job *actions_model.ActionRunJob)
func PickTask ¶
func PickTask(ctx context.Context, runner *actions_model.ActionRunner) (*runnerv1.Task, bool, error)
func PrepareRunAndInsert ¶
func PrepareRunAndInsert(ctx context.Context, content []byte, run *actions_model.ActionRun, inputsWithDefaults map[string]any) error
PrepareRunAndInsert prepares a run and inserts it into the database It parses the workflow content, evaluates concurrency if needed, and inserts the run and its jobs into the database. The title will be cut off at 255 characters if it's longer than 255 characters.
func PrepareToStartJobWithConcurrency ¶
func PrepareToStartJobWithConcurrency(ctx context.Context, job *actions_model.ActionRunJob) (actions_model.Status, error)
PrepareToStartJobWithConcurrency prepares a job to start by its evaluated concurrency group and cancelling previous jobs if necessary. It returns the new status of the job (either StatusBlocked or StatusWaiting) and any error encountered during the process.
func PrepareToStartRunWithConcurrency ¶
func PrepareToStartRunWithConcurrency(ctx context.Context, run *actions_model.ActionRun) (actions_model.Status, error)
PrepareToStartRunWithConcurrency prepares a run to start by its evaluated concurrency group and cancelling previous jobs if necessary. It returns the new status of the run (either StatusBlocked or StatusWaiting) and any error encountered during the process.
func StartRunnerHealthMonitor ¶
StartRunnerHealthMonitor starts a background goroutine that monitors runner health
func StartScheduleTasks ¶
StartScheduleTasks start the task
func StopEndlessTasks ¶
StopEndlessTasks stops the tasks which have running status and continuous updates, but don't end for a long time
func StopZombieTasks ¶
StopZombieTasks stops the task which have running status, but haven't been updated for a long time
func TokenToTaskID ¶
TokenToTaskID returns the TaskID associated with the provided JWT token
func UpdateVariableNameData ¶
func UpdateVariableNameData(ctx context.Context, variable *actions_model.ActionVariable) (bool, error)
Types ¶
type API ¶
type API interface {
// ListActionsSecrets list secrets
ListActionsSecrets(*context.APIContext)
// CreateOrUpdateSecret create or update a secret
CreateOrUpdateSecret(*context.APIContext)
// DeleteSecret delete a secret
DeleteSecret(*context.APIContext)
// ListVariables list variables
ListVariables(*context.APIContext)
// GetVariable get a variable
GetVariable(*context.APIContext)
// DeleteVariable delete a variable
DeleteVariable(*context.APIContext)
// CreateVariable create a variable
CreateVariable(*context.APIContext)
// UpdateVariable update a variable
UpdateVariable(*context.APIContext)
// GetRegistrationToken get registration token
GetRegistrationToken(*context.APIContext)
// CreateRegistrationToken get registration token
CreateRegistrationToken(*context.APIContext)
// ListRunners list runners
ListRunners(*context.APIContext)
// GetRunner get a runner
GetRunner(*context.APIContext)
// DeleteRunner delete runner
DeleteRunner(*context.APIContext)
// ListWorkflowJobs list jobs
ListWorkflowJobs(*context.APIContext)
// ListWorkflowRuns list runs
ListWorkflowRuns(*context.APIContext)
}
API for actions of a repository or organization
type GiteaContext ¶
func GenerateGiteaContext ¶
func GenerateGiteaContext(run *actions_model.ActionRun, job *actions_model.ActionRunJob) GiteaContext
GenerateGiteaContext generate the gitea context without token and gitea_runtime_token job can be nil when generating a context for parsing workflow-level expressions
func (*GiteaContext) ToGitHubContext ¶
func (g *GiteaContext) ToGitHubContext() *model.GithubContext
type TaskNeed ¶
type TaskNeed struct {
Result actions_model.Status
Outputs map[string]string
}
Source Files
¶
- auth.go
- cleanup.go
- clear_tasks.go
- commit_status.go
- concurrency.go
- context.go
- init.go
- interface.go
- job_emitter.go
- notifier.go
- notifier_helper.go
- rerun.go
- run.go
- runner_health.go
- schedule_tasks.go
- task.go
- variables.go
- workflow.go