Documentation
¶
Index ¶
- Constants
- func BuildSignature(tag tagType, vals ...string) []byte
- func FormatLog(timestamp time.Time, content string) string
- func FullSteps(task *actions_model.ActionTask) []*actions_model.ActionTaskStep
- func GetContentFromEntry(entry *git.TreeEntry) ([]byte, error)
- func GetEventsFromContent(content []byte) ([]*jobparser.Event, error)
- func IsDefaultBranchWorkflow(triggedEvent webhook_module.HookEventType) bool
- func IsWorkflow(path string) bool
- func IsWorkflowOrScopedWorkflow(path string) bool
- func ListScopedWorkflows(commit *git.Commit) (string, git.Entries, error)
- func ListWorkflows(commit *git.Commit) (string, git.Entries, error)
- func OpenLogs(ctx context.Context, inStorage bool, filename string) (io.ReadSeekCloser, error)
- func ParseLog(in string) (time.Time, string, error)
- func ReadLogs(ctx context.Context, inStorage bool, filename string, offset, limit int64) ([]*runnerv1.LogRow, error)
- func RemoveLogs(ctx context.Context, inStorage bool, filename string) error
- func ScopedWorkflowStatusContextName(prefix, displayName, jobName, event string) string
- func ShouldEventCreateCommitStatus(event string) bool
- func TransferLogs(ctx context.Context, filename string) (func(), error)
- func ValidateWorkflowContent(content []byte) error
- func WorkflowDisplayName(file string, content []byte) string
- func WorkflowStatusContextName(displayName, jobName, event string) string
- func WriteLogs(ctx context.Context, filename string, offset int64, rows []*runnerv1.LogRow) ([]int, error)
- type CommitActionsStatusMap
- type DetectedWorkflow
- func DetectScheduledWorkflows(gitRepo *git.Repository, commit *git.Commit) ([]*DetectedWorkflow, error)
- func DetectWorkflows(gitRepo *git.Repository, commit *git.Commit, ...) (workflows, schedules, filtered []*DetectedWorkflow, err error)
- func MatchScopedWorkflows(parsed []*ParsedScopedWorkflow, consumerGitRepo *git.Repository, ...) (matched, filtered []*DetectedWorkflow)
- type ParsedScopedWorkflow
Constants ¶
const ( GithubEventPullRequest = "pull_request" GithubEventPullRequestTarget = "pull_request_target" GithubEventPullRequestReviewComment = "pull_request_review_comment" GithubEventPullRequestReview = "pull_request_review" GithubEventRegistryPackage = "registry_package" GithubEventCreate = "create" GithubEventDelete = "delete" GithubEventFork = "fork" GithubEventPush = "push" GithubEventIssues = "issues" GithubEventIssueComment = "issue_comment" GithubEventRelease = "release" GithubEventPullRequestComment = "pull_request_comment" GithubEventGollum = "gollum" GithubEventSchedule = "schedule" )
const ( MaxLineSize = 64 * 1024 DBFSPrefix = "actions_log/" )
Variables ¶
This section is empty.
Functions ¶
func BuildSignature ¶
BuildSignature builds a hmac signature for the input values. "tag" is an internal pre-defined static string to distinguish the signatures for different purpose.
func FullSteps ¶
func FullSteps(task *actions_model.ActionTask) []*actions_model.ActionTaskStep
FullSteps returns steps with "Set up job" and "Complete job"
func IsDefaultBranchWorkflow ¶
func IsDefaultBranchWorkflow(triggedEvent webhook_module.HookEventType) bool
IsDefaultBranchWorkflow returns true if the event only triggers workflows on the default branch
func IsWorkflow ¶
func IsWorkflowOrScopedWorkflow ¶
IsWorkflowOrScopedWorkflow reports whether path is a workflow file under WORKFLOW_DIRS or SCOPED_WORKFLOW_DIRS.
func ListScopedWorkflows ¶
ListScopedWorkflows lists scoped workflow files (under SCOPED_WORKFLOW_DIRS) at the given commit.
func ScopedWorkflowStatusContextName ¶
ScopedWorkflowStatusContextName prefixes a scoped run's status-check context with its source repo, set off by a colon: "<prefix>: <display> / <job> (<event>)".
func ShouldEventCreateCommitStatus ¶
ShouldEventCreateCommitStatus reports whether a run triggered by the given workflow `on:` event posts a commit status, so its context can serve as a required status check. TODO: this allowlist duplicates the truth in services/actions.getCommitStatusEventNameAndCommitID, which decides the actual event string and whether a status is posted. The two are kept in sync by hand and can drift; unify them into a single source so adding a status-producing event in one place automatically updates the other.
func TransferLogs ¶
TransferLogs transfers logs from DBFS to object storage. It happens when the file is complete and no more logs will be appended. It respects the file format in the filename like ".zst", and compresses the content if needed. The task log file must be marked as "log_in_storage=true" after the transfer.
func ValidateWorkflowContent ¶
ValidateWorkflowContent catches structural errors (e.g. blank lines in run: | blocks) that model.ReadWorkflow alone does not detect.
func WorkflowDisplayName ¶
WorkflowDisplayName returns a workflow's display name: its `name:` if non-blank, otherwise the base file name. This is the value used as the workflow segment of its commit-status context.
func WorkflowStatusContextName ¶
WorkflowStatusContextName builds a workflow job's commit-status context name: "<display> / <job> (<event>)".
func WriteLogs ¶
func WriteLogs(ctx context.Context, filename string, offset int64, rows []*runnerv1.LogRow) ([]int, error)
WriteLogs appends logs to DBFS file for temporary storage. It doesn't respect the file format in the filename like ".zst", since it's difficult to reopen a closed compressed file and append new content. Why doesn't it store logs in object storage directly? Because it's not efficient to append content to object storage.
Types ¶
type CommitActionsStatusMap ¶
type CommitActionsStatusMap map[int64]actions_model.Status
CommitActionsStatusMap maps CommitStatus.ID to the live ActionRunJob status for Gitea Actions rows.
func GetCommitActionsStatusMap ¶
func GetCommitActionsStatusMap(ctx context.Context, statuses []*git_model.CommitStatus) CommitActionsStatusMap
GetCommitActionsStatusMap resolves the live ActionRunJob.Status for every CommitStatus row backed by Gitea Actions. Rows from other sources (external CIs, API) are left untouched and rendered from their stored State.
func (CommitActionsStatusMap) IconStatus ¶
func (m CommitActionsStatusMap) IconStatus(s *git_model.CommitStatus) string
IconStatus returns the action status name to route the icon through repo/icons/action_status, or "" when the row isn't from Gitea Actions.
type DetectedWorkflow ¶
func DetectScheduledWorkflows ¶
func DetectScheduledWorkflows(gitRepo *git.Repository, commit *git.Commit) ([]*DetectedWorkflow, error)
func DetectWorkflows ¶
func DetectWorkflows( gitRepo *git.Repository, commit *git.Commit, triggedEvent webhook_module.HookEventType, payload api.Payloader, detectSchedule bool, ) (workflows, schedules, filtered []*DetectedWorkflow, err error)
func MatchScopedWorkflows ¶
func MatchScopedWorkflows( parsed []*ParsedScopedWorkflow, consumerGitRepo *git.Repository, consumerCommit *git.Commit, triggedEvent webhook_module.HookEventType, payload api.Payloader, ) (matched, filtered []*DetectedWorkflow)
MatchScopedWorkflows evaluates already-parsed scoped workflows against one consuming event. It returns the workflows whose `on:` matches, and those that matched the event but were excluded by a branch/paths filter (filtered).
type ParsedScopedWorkflow ¶
type ParsedScopedWorkflow struct {
EntryName string
DisplayName string // the workflow `name:` or base file name
Content []byte // raw content of the workflow file
Events []*jobparser.Event // decoded `on:` events
}
ParsedScopedWorkflow is one scoped workflow's source-side parse result
func ParseScopedWorkflows ¶
func ParseScopedWorkflows(sourceCommit *git.Commit) ([]*ParsedScopedWorkflow, error)
ParseScopedWorkflows lists and parses the scoped workflow files at sourceCommit (under SCOPED_WORKFLOW_DIRS).