actions

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetArtifactsDir

func GetArtifactsDir(ctx context.Context) string

GetArtifactsDir retrieves the host artifacts directory from context, defaulting to ".gacils-artifacts".

func GetCacheDir

func GetCacheDir(ctx context.Context) string

GetCacheDir retrieves the host cache directory from context, defaulting to ".gacils-cache".

func GetJobID

func GetJobID(ctx context.Context) string

GetJobID retrieves the job ID from context.

func WithHostDirs

func WithHostDirs(ctx context.Context, cacheDir, artifactsDir string) context.Context

WithHostDirs returns a context with host cache and artifacts directories.

func WithJobID

func WithJobID(ctx context.Context, jobID string) context.Context

WithJobID returns a context with job ID.

Types

type ActionHandler

type ActionHandler func(ctx context.Context, cli *client.Client, containerID, workingDir string, with map[string]any) (*ActionResult, error)

ActionHandler defines the signature for an action simulation handler.

type ActionRef

type ActionRef struct {
	Raw   string
	Owner string
	Repo  string
	Ref   string
}

ActionRef represents a parsed action reference (e.g. actions/checkout@v4).

func ParseActionRef

func ParseActionRef(uses string) (ActionRef, error)

ParseActionRef parses a step's uses string into an ActionRef.

func (ActionRef) ActionName

func (a ActionRef) ActionName() string

ActionName returns the "owner/repo" format of the action.

type ActionResult

type ActionResult struct {
	Stdout string
	Stderr string
	Env    map[string]string
}

ActionResult holds output logs and environment changes from an action simulation.

func ExecuteCache

func ExecuteCache(ctx context.Context, cli *client.Client, containerID, workingDir string, with map[string]any) (*ActionResult, error)

ExecuteCache simulates actions/cache.

func ExecuteCheckout

func ExecuteCheckout(ctx context.Context, cli *client.Client, containerID, workingDir string, with map[string]any) (*ActionResult, error)

ExecuteCheckout simulates actions/checkout. Workspace copy is already performed, so this verifies the workspace container path exists.

func ExecuteDownloadArtifact

func ExecuteDownloadArtifact(ctx context.Context, cli *client.Client, containerID, workingDir string, with map[string]any) (*ActionResult, error)

ExecuteDownloadArtifact simulates actions/download-artifact.

func ExecuteSetupPython

func ExecuteSetupPython(ctx context.Context, cli *client.Client, containerID, workingDir string, with map[string]any) (*ActionResult, error)

ExecuteSetupPython simulates actions/setup-python. Requires 'python-version' input in 'with'.

func ExecuteUploadArtifact

func ExecuteUploadArtifact(ctx context.Context, cli *client.Client, containerID, workingDir string, with map[string]any) (*ActionResult, error)

ExecuteUploadArtifact simulates actions/upload-artifact.

type ActionValidationError

type ActionValidationError struct {
	Message string
}

ActionValidationError represents a validation error for action inputs. Exit code 2.

func NewActionValidationError

func NewActionValidationError(msg string) *ActionValidationError

NewActionValidationError creates a new ActionValidationError.

func (*ActionValidationError) Code

func (e *ActionValidationError) Code() int

func (*ActionValidationError) Error

func (e *ActionValidationError) Error() string

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry manages supported GitHub actions.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates and initializes an Action Registry with default supported actions.

func (*Registry) Execute

func (r *Registry) Execute(ctx context.Context, cli *client.Client, containerID, workingDir string, ref ActionRef, with map[string]any) (*ActionResult, error)

Execute runs the handler for the given ActionRef or returns an UnsupportedActionError.

func (*Registry) IsSupported

func (r *Registry) IsSupported(ref ActionRef) bool

IsSupported checks whether an ActionRef is registered.

func (*Registry) Register

func (r *Registry) Register(name string, handler ActionHandler)

Register registers a handler for a given action name (e.g. "actions/checkout").

type UnsupportedActionError

type UnsupportedActionError struct {
	Action string
}

UnsupportedActionError represents an error when an action is not supported. Exit code 3.

func NewUnsupportedActionError

func NewUnsupportedActionError(action string) *UnsupportedActionError

NewUnsupportedActionError creates a new UnsupportedActionError.

func (*UnsupportedActionError) Code

func (e *UnsupportedActionError) Code() int

func (*UnsupportedActionError) Error

func (e *UnsupportedActionError) Error() string

Jump to

Keyboard shortcuts

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